on 10-08-2019 5:00 PM
Hello,
I need help to setup Relationships between Entitys on a mockup server. With my ODATA Service (v2.0 Olingo) the application works well.
I have already tried the following patterns, but it does not work. I got with all my solution a reference to "DocumenTypes T1".
"uri": "/odatademo/xxxxxx.svc/DocumentTypes('T2')"
"uri": "DocumentTypes ('T2')"
Document.JSON
{
"Id": 1,
"Subject": "TEST",
"DocumentTypeDetails": {
"Id": "T2",
"Name": "DEF"
}
}
Furthermore I tried to follow the FAQ without success.
"Mock data in JSON format can be generated from an OData service by adding the $format=json"
https://sapui5.hana.ondemand.com/1.32.4/docs/guide/c9a91ddaef47461c9c44bfc2198ea3f0.html
{
"__metadata": {
"id": "https://odataXXX.hana.ondemand.com:443/odata/XXX.svc/Documents(1L)",
"uri": "https://odataXXX.hana.ondemand.com:443/odata/XXX.svc/Documents(1L)",
"type": "XXX.Document"
},
"Subject": "Test",
"DocumentTypeDetails": {
"__deferred": {
"uri": "https://odataXXX.hana.ondemand.com:443/odata/XXX.svc/Documents(1L)/DocumentTypeDetails"
}
}
}
A part of my Code:
localService/mockdata/Documents.JSON
[{
"Id": 1,
"Subject": "TEST",
"DocumentTypeDetails": {
"__deferred": {
"uri": "/odata/xxxxxx.svc/DocumentTypes('T2')"
}
}
}]<br>
localService/mockdata/DocumentTypes.JSON
[{
"Id": "T1",
"Name": "ABC"
},
{
"Id": "T2",
"Name": "DEF"
}]
localService/metadata.xml (C&P from OData $metadata)
<EntityType Name="DocumentType">
<Key>
<PropertyRef Name="Id"/>
</Key>
<Property Name="Id" Type="Edm.String" Nullable="false"/>
<Property Name="Name" Type="Edm.String" Nullable="true" MaxLength="255"/>
</EntityType>
<EntityType Name="Document">
<Key>
<PropertyRef Name="Id"/>
</Key>
<Property Name="Id" Type="Edm.Int64" Nullable="false"/>
<Property Name="Subject" Type="Edm.String" Nullable="true" MaxLength="255"/>
<NavigationProperty Name="DocumentTypeDetails" Relationship="XXX.Document_DocumentType_Many_ZeroToOne0" FromRole="Document"
ToRole="DocumentType"/>
</EntityType>
<Association Name="Document_DocumentType_Many_ZeroToOne0">
<End Type="XXX.Document" Multiplicity="*" Role="Document"/>
<End Type="XXX.DocumentType" Multiplicity="0..1" Role="DocumentType"/>
</Association>
<EntitySet Name="Documents" EntityType="XXX.Document"/>
<EntitySet Name="DocumentTypes" EntityType="XXX.DocumentType"/>
<AssociationSet Name="Document_DocumentType_Many_ZeroToOne0Set" Association="XXX.Document_DocumentType_Many_ZeroToOne0">
<End EntitySet="Documents" Role="Document"/>
<End EntitySet="DocumentTypes" Role="DocumentType"/>
</AssociationSet
XML View (short version)
<Table items="{path : 'MyODATA>/Documents', expand : 'DocumentTypeDetails'}">
....
<Texttext="{MyODATA>Subject}"/>
<Texttext="{MyODATA>DocumentTypeDetails/Name}"/>
....
</Table>
Thanks for your Help!
I found a "dirty" solution.
Now i hold all the data in one file. There is only one Data.json containing the complete entries with metadata.
For this i copied the structure of the OData service. For my example you get the data via the following request:
ODataService.svc/Documents?$expand=DocumentTypeDetails&$format=json
If you had more relationships, you can reach them via the NavigationPropertys.
For example:
ODataService.svc/Documents?$expand=DocumentTypeDetails/DocumentXXX,DocumentTypeDetails/PersonXXX/PersonTypeDetails&$format=json
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.