I'm new in UI5 and I'd like to read an EntitySet without implemention of Get EntitySet
oModel1.read("/LinesSet?$expand=ToCells&$filter=IdQuery%20eq%20%27ZSMKPI_QM_TOTAL_USERS%27", {
success: function(oData) {
console.log(" expand");
},
error: function(oError) {
console.log("errooooooor expand");
}
});
Error message :
errordetails":[{"code":"/IWBEP/CX_MGW_NOT_IMPL_EXC","message":"Method
'LINESSET_GET_ENTITYSET' not implemented in data provider
class.","propertyref":"","severity":"error"}]}}} -
It's not implemented. I want to skip this method and consume $expand directly.
It is possible by creating Association and Navigation between the entity sets.
Related
In Odata create entity i am having one to many relationship, with below request json am getting,
{
"parentProperty1":"",
"parentProperty2":"",
"parentProperty3":"",
"NavigationProperty":[
{
"childProperty1":""
}
]
}
Error
org.apache.olingo.odata2.jpa.processor.api.exception.ODataJPARuntimeException: "OData - JPA Runtime: JPA create request is not correct"
at org.apache.olingo.odata2.jpa.processor.api.exception.ODataJPARuntimeException.throwException(ODataJPARuntimeException.java:100 undefined) ~[olingo-odata2-jpa-processor-api-2.0.12.jar:2.0.12]
at org.apache.olingo.odata2.jpa.processor.core.access.data.JPALink.linkJPAEntities(JPALink.java:242 undefined) ~[olingo-odata2-jpa-processor-core-2.0.12.jar:2.0.12
im trying to use Successfactors' ODATA API to update an entity.
This entity has got a one to many relationship to another entity.
The Model looks like:
Candidate
- custAnrede (PicklistOption (1:*)
I try to call
PUT <server>/odata/v2/Candidate('myId')
data:
{"custAnrede" : {"id":"555"}}
}
This call fails with:
Inline entity are not supported for property custAnrede in non insert request.
When calling with data:
{"custAnrede": {
"__metadata": {
"uri": "PicklistOption('HRUser')"
}
}}
it suceeds, but the value of custAnrede has not been changed.
Does anybody know how a one to many relationship with ODATA can be modified ?
Thanks,
Detlef
I've done something similar but with different objects (Parent - Child)
{
"__metadata":{
"uri":"cust_Overeenkomst(cust_ParentOvereenkomst_effectiveStartDate=datetime'2017-01-12T00:00:00',cust_ParentOvereenkomst_externalCode='1109',externalCode=2502L)"
},
"cust_event": "SO",
"cust_eventreason":"SO-01",
"cust_to_childsalarisgegevens":{
"__metadata":{
"uri":"cust_ChildSalarisgegevens(cust_Overeenkomst_externalCode=2502L,cust_ParentOvereenkomst_effectiveStartDate=datetime'2017-01-12T00:00:00',cust_ParentOvereenkomst_externalCode='1109',externalCode='SalComp_26')"
},
"cust_opmerking":"TEST Vincent",
"cust_paycomponent":"BRUTOMAAND",
"cust_paycompvalue":"1000"
}
}
I have a situation, where I am saving multiple types of entities during a single SaveChanges. In some cases, this save will include my "target entity", in some cases not. In those cases where the save does include a "target entity", i need to be able to trap the entity's id as returned from the server using saveChanges() saveResult.
I have been trying to figure out how to use the Breeze EntityType to see if my "target entity" in the the saveResult, but I keep on getting undefined in the approach below. Clearly I'm not understanding how to use this feature?
function trapTargetEntityId(saveResult) {
saveResult.entities.forEach(function(entity) {
if (entity.EntityType === 'targetEntity') {
targetEntitId = entity.id;
}
return;
});
}
Not sure I understand. But if you are looking for a specific entity by key after the save
// make sure that targetType is NOT null
var targetType = myEntityManager.metadataStore.getEntityType("Customer");
var targetId = 23452; // arbitrary id
function trapTargetEntityId(saveResult) {
saveResult.entities.forEach(function(entity) {
// assumes that you have a data property called 'id' on the 'Customer' entityType
if (entity.entityType === targetType && entity.id === targetId) {
targetEntity = entity;
// do something with 'targetEntity'
}
});
}
... and be careful with your casing - in your example it should have been 'entity.entityType' not 'entity.EntityType'
How can I also fetch navigation property of an entity while using fetchEntityByKey method in breeze ? Is it even possible ?
If you want to "fetch" the value of a navigation property use the EntityAspect.loadNavigationPrperty method
myEntity.entityAspect.loadNavigationProperty("Orders").then(function (data) {
var orders = data.results;
}).fail(function (exception) {
// handle exception here;
});
I have a SPA application (durandaljs), and I have a specific route where I map the "id" of the entity that I want to fetch.
The template is "/#/todoDetail/:id".
For example, "/#/todoDetail/232" or "/#/todoDetail/19".
On the activate function of viewmodel, I get the route info so I can grab the id. Then I create a new instance of breezejs EntityManager to get the entity with the given id.
The problem is when I call manager.fetchEntityByKey("Todos", id), the EntityManager doesn't have yet the metadata from the server, so it throwing exception "Unable to locate an 'Type' by the name: Todos".
It only works if first I execute a query against the store (manager.executeQuery), prior to calling fetchEntityByKey.
Is this an expected behavior or a bug ? Is there any way to auto-fecth the metadata during instantiation of EntityManager ?
note: I believe it's hard to use a shared EntityManager in my case, because I want to allow the user directly type the route on the browser.
EDIT: As a temporary workaround, I'm doing this:
BreezeService.prototype.get = function (id, callback) {
var self = this;
function queryFailed(error) {
app.showMessage(error.message);
callback({});
}
/* first checking if metadatastore was already loaded */
if (self.manager.metadataStore.isEmpty()) {
return self.manager.fetchMetadata()
.then(function (rawMetadata) {
return executeQuery();
}).fail(queryFailed);
} else {
return executeQuery();
}
/* Now I can fetch */
function executeQuery() {
return self.manager.fetchEntityByKey(self.entityType, id, true)
.then(callback)
.fail(queryFailed);
}
};
You've learned about fetchMetadata. That's important. If you application can begin without issuing a query, you have to use fetchMetadata and wait for it to return before you can perform any operations directly on the cache (e.g., checking for an entity by key in the cache before falling back to a database query).
But I sense something else going on because you mentioned multiple managers. By default a new manager doesn't know the metadata from any other manager. But did you know that you can share a single metadataStore among managers? You can.
What I often do (and you'll see it in the metadata tests in the DocCode sample), is get a metadataStore for the application, write an EntityManager factory function that creates new managers with that metadataStore, and then use the factory whenever I'm making new managers ... as you seem to be doing when you spin up a ViewModel to review the TodoDetail.
Coming from a Silverlight background where I used a lot of WCF RIA Services combined with Caliburn Micro, I used this approach for integrating Breeze with Durandal.
I created a sub folder called services in the App folder of the application. In that folder I created a javascript file called datacontext.js. Here is a subset of my datacontext:
define(function (require) {
var breeze = require('lib/breeze'); // path to breeze
var app = require('durandal/app'); // path to durandal
breeze.NamingConvention.camelCase.setAsDefault();
// service name is route to the Web API controller
var serviceName = 'api/TeamData',
// manager is the service gateway and cache holder
manager = new breeze.EntityManager(serviceName),
store = manager.metadataStore;
function queryFailed(error) {
app.showMessage("Query failed: " + error.message);
}
// constructor overrides here
// included one example query here
return datacontext = {
getSponsors: function (queryCompleted) {
var query = breeze.EntityQuery.from("Sponsors");
return manager
.executeQuery(query)
.then(queryCompleted)
.fail(queryFailed)
}
};
}
Then in your durandal view models you can just require the services/datacontext. For example, here is part of a sample view model from my app:
define(function (require) {
var datacontext = require('services/datacontext');
var ctor = function () {
this.displayName = 'Sponsors',
this.sponsors = ko.observable(false)
};
ctor.prototype.activate = function () {
var that = this;
return datacontext.getSponsors(function (data) { that.sponsors(data.results) });
}
return ctor;
});
This will allow you to not worry about initializing the metadata store in every view model since it is all done in one place.