Datajs: How to modify rel-attribute? - post

I'm trying to post linked entries in atom-format to Odata service. Only thing missing from my payload is that rel-attribute should be: "http://schemas.microsoft.com/ado/2007/08/dataservices/related/SOItems". Currently it's automatically generated to "http://schemas.microsoft.com/ado/2007/08/dataservices/related/links"
Heres my current linked entries:
<a:link href="SOItems" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/links" type="application/atom+xml;type=entry"><m:inline><a:feed><a:entry><a:author><a:name></a:name></a:author><a:content type="application/xml"><m:properties><d:OrderId>0</d:OrderId><d:Item>000020</d:Item><d:Material>M-06</d:Material><d:Plant>1200</d:Plant><d:Quantity>200.000</d:Quantity><d:Description m:null="true"></d:Description><d:UoM m:null="true"></d:UoM><d:Value m:null="true"></d:Value></m:properties></a:content></a:entry><a:entry><a:author><a:name></a:name></a:author><a:content type="application/xml"><m:properties><d:OrderId>0</d:OrderId><d:Item>000020</d:Item><d:Material>M-06</d:Material><d:Plant>1200</d:Plant><d:Quantity>200.000</d:Quantity><d:Description m:null="true"></d:Description><d:UoM m:null="true"></d:UoM><d:Value m:null="true"></d:Value></m:properties></a:content></a:entry></a:feed></m:inline></a:link>
How can I set rel-attribute for linked entry with datajs.
Thanks,
Br,
RP

the namespace of links "http://schemas.microsoft.com/ado/2007/08/dataservices/related/links" is hard code on datajs code. Currently there is no public API that the application could use to change it. However, since the datajs is open source, there are still some methods to work around this issue by modifying the datajs code:
a) Change the value of local property “odataRelatedLinksPrefix” in data.js
b) Expose the local variable “odataRelatedLinksPrefix” to be public by adding odata.odataRelatedLinksPrefix = odataRelatedLinksPrefix in data.js code. After doing this, the application could change the namespace value by calling OData.odataRelatedLinksPrefix whenever and wherever.

Related

Jena read hook not invoked upon duplicate import read

My problem will probably be explained better with code.
Consider the snippet below:
// First read
OntModel m1 = ModelFactory.createOntologyModel();
RDFDataMgr.read(m1,uri0);
m1.loadImports();
// Second read (from the same URI)
OntModel m2 = ModelFactory.createOntologyModel();
RDFDataMgr.read(m2,uri0);
m2.loadImports();
where uri0 points to a valid RDF file describing an ontology model with n imports.
and the following custom ReadHook (which has been set in advance):
#Override
public String beforeRead(Model model, String source, OntDocumentManager odm) {
System.out.println("BEFORE READ CALLED: " + source);
}
Global FileManager and OntDocumentManager are used with the following settings:
processImports = true;
caching = true;
If I run the snippet above, the model will be read from uri0 and beforeRead will be invoked exactly n times (once for each import).
However, in the second read, beforeRead won't be invoked even once.
How, and what should I reset in order for Jena to invoke beforeRead in the second read as well?
What I have tried so far:
At first I thought it was due to caching being on, but turning it off or clearing it between the first and second read didn't do anything.
I have also tried removing all ignoredImport records from m1. Nothing changed.
Finally got to solve this. The problem was in ModelFactory.createOntologyModel(). Ultimately, this gets translated to ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_RDFS_INF,null).
All ontology models created with the static OntModelSpec.OWL_MEM_RDFS_INF will have their ImportsModelMaker and some of its other objects shared, which results in a shared state. Apparently, this state has blocked the reading hook to be invoked twice for the same imports.
This can be prevented by creating a custom, independent and non-static OntModelSpec instance and using it when creating an OntModel, for example:
new OntModelSpec( ModelFactory.createMemModelMaker(), new OntDocumentManager(), RDFSRuleReasonerFactory.theInstance(), ProfileRegistry.OWL_LANG );

Localize blazor with IStringLocalizer using a unique resource file per language

I'm trying to localize my Blazor app (.NET 5.0) using IStringLocalizer and user UI selection based on cookies. Following the documentation, it seems to work if I create a .resx file for each page in my Resources/Pages folder.
I'd like to group all key-value pairs within a single file as follows :
MyApp
|-- Resources
| MyResources.resx <--- set to public modifiers to generate class!!!
| MyResources.es.resx
| MyResources.fr.resx
...
|-- Resources
| Index.razor
So in Startup.cs I register the Resources folder:
services.AddControllers();
services.AddLocalization(options => options.ResourcesPath = "Resources");
I also added MapControllers in the configure method, as well as registering supported cultures. I also added the controller:
[Route("[controller]/[action]")]
public class CultureController : Controller {
public IActionResult SetCulture(string culture, string redirectUri) {
if (culture != null) {
HttpContext.Response.Cookies.Append(
CookieRequestCultureProvider.DefaultCookieName,
CookieRequestCultureProvider.MakeCookieValue(new RequestCulture(culture)));
}
return LocalRedirect(redirectUri);
}
}
Now, on my main "index.razor" page I inject the IStringLocalizer<MyResources> as follows:
#page "/index"
#inject IStringLocalizer<Language> _localizer
<h2>#_localizer["hello_world"]</h2>
<h2>#DateTime.Now.ToShortDateString()</h2>
<h2>#DateTime.Now.ToLongDateString()</h2>
I make sure that all resx files actually contain the "hello_world" key with some values and added a language selector.
When I run the app, changing the language does change the displayed dates, however, the hello_world key is not found so the app displays the key instead. When exploring the _localizer variable, I see that the container is empty - none of the key-value pairs of the .resx are actually loaded.
Is it possible to get this to work? If so, what am I doing wrong here?
The mistake is because of naming here:
#inject IStringLocalizer<Language> _localizer
should be
#inject IStringLocalizer<MyResources> _localizer
And important is to add an empty file MyResources.razor at the root of the project.
Edit:
Another mistake I made is to add the myApp.Resources to _Imports.razor
...
#using myApp.Resources <==== do NOT add this
#neggenbe
Adding an empty razor(AppLang.razor) component at the root of my project with same name with my resource(AppLang.resx) file solved the challenge. I stumbled accross #neggenbe after over 48 hours trying to figure out what was wrong with my code.
If your project is purely blazor, you wont come accross this challenge but if its a mix of MVC and razor(blazor) components, then you'll definately need to do this.

Properties of Entity sent from iOS are set to null when objectify is used to store the entity into datastore

I send an entity from an iOS client and it is processed by the following backendAPI method:
#ApiMethod(name="dataInserter.insertData",path="insertData",httpMethod="post")
public Entity insertData(customEntity userInput){
ofy().save().entity(userInput).now();
return userInput;
}
customEntity is defined within customEntity.java as follows:
//Import Statements here
#Entity
public class customEntity {
#Id public String someID;
#Index String providedData;
}
After the above code runs, datastore contains the following entry:
ID/Name providedData
id=5034... <null>
If I add the following lines to my method:
customEntity badSoup=new customEntity();
badSoup.providedData="I am exhausted";
ofy().save().entity(badSoup).now();
I see the following in the datastore after I run the code:
ID/Name providedData
id=5034... I am exhausted
In a post almost similar to this one, the poster -- Drux -- concludes "...assignments to #Indexed properties only have actual effects on indices (and hence queries) if they are carried out directly with Objectify on the server (not indirectly on iOS clients and then passed to the server with Google Cloud Endpoints)." stickfigure then responds, "It sounds like what you're saying is 'cloud endpoints is not reconstituting your SomeEntity object correctly'. Objectify is not involved; it just saves whatever you give it."
It's hard to tell whether stickfigure is correct most especially given the fact that when I explore my API using Google's APIs Explorer, the same problem described above still occurs.
Is anyone able to explain what's causing this or is Drux's conclusion correct?

How to start another Activity with android-annotation?

I'm just trying to use android-annotation. When I start another Activity, an empty activity showed up.
I check this to find that the #EActivity generate the subclass of XXActivity named XXActivity_. So I try to code
mIntent = new Intent(this, XXActivity_.class);
But eclipse shows error that XXActivity_ cannot be resolved to a type. I don't know when the XX_ is generated.
I have add the jar, declare the XX_ in the AndroidManifest.xml. How to make eclipse generate the XX_ class?
you could start activity using annotations like this
first you should write your activities on the manifest file with '_' after that you have two activities you want to go from one to another you could use this :
CarDetailActivity_.intent(CarSaleListActivity.this).start();
with this you will go the CarDetailActivity on the other hand if you want to pass message to the other activity you will use this
CarDetailActivity_.intent(CarSaleListActivity.this).myMessage("arrived with android annotations").start();
and in this case you should define this on the CarDetailActivity
#Extra
String myMessage;
and you could use this message on CarDetailActivity like this on
#AfterViews
public void showMessage(){
Toast.makeText(this,myMessage,Toast.LENGTH_SHORT).show();
}
Note : CarDetailActivity should be #EActivity to make this work
Blockquote

StructureMap 202 - Why?

OK, I'm trying to set a property on a type I'm registering with SM.
Here's the code from the registry in one of my components. This
registry is being added during the configuration from a console app.
When I try to access the EndorsementSpecs property of the instance
AutoMandatoryEndorsementAggregator object, I get the 202. What's
interesting is that I can call
GetAllInstances>() from my
console app and it resolves just fine. Is there something about
accessing this code from within OnCreation that is causing the 202? I
can see everything I expect in WhatDoIHave(). I've also tried a TypeInterceptor with the same results.
//register all open generics
cfg.ConnectImplementationsToTypesClosing(typeof
(MandatoryEndorsementSpecBase<>));
ForSingletonOf<IMandatoryEndorsementAggregator<AutoPolicy>>()
.Use<AutoMandatoryEndorsementAggregator>()
.OnCreation((context, x) =>
{
var specs =
context.GetAllInstances<MandatoryEndorsementSpecBase<AutoPolicy>>();
x.EndorsementSpecs = specs;
})
;
Sorry to deflect your real questions, but are you just trying to inject all instances of MandatoryEndorsementSpecBase into AutoMandatoryEndorsementAggregatory?
If so, you can probably get away with just making it a constructor parameter so that they are all automatically injected.
public AutoMandatoryEndorsementAggregatory(MandatoryEndorsementSpecBase<AutoPolicy>[] endorsementSpecs){
EndorsementSpecs = endorsementSpecs;
}

Resources