既存のoDataモデルと作業中のoDataモデルに基づいていくつかのデータをモックしようとしています。モックサーバーは機能しますが、私は$expand
に仕事をさせるのに苦労しています。私はと思っています。 JSONをどこに保存するかを理解していないのは、ほとんど私の問題です。UI5、JSONファイルでモックデータを展開する
メタデータファイルは、サービスサービスからそのままコピーされ、すべてのエンティティ、エンティティセット、アソシエーションなどが含まれます。
ここにいくつかの関連するビットがあります。
<NavigationProperty Name="Dealers" Relationship="Y_DP_CORE_SRV.User_Dealer" FromRole="FromRole_User_Dealer" ToRole="ToRole_User_Dealer" />
協会:Users
エンティティから
<Association Name="User_Dealer" sap:content-version="1">
<End Type="Y_DP_CORE_SRV.User" Multiplicity="1" Role="FromRole_User_Dealer" />
<End Type="Y_DP_CORE_SRV.Dealer" Multiplicity="*" Role="ToRole_User_Dealer" />
<ReferentialConstraint>
<Principal Role="FromRole_User_Dealer">
<PropertyRef Name="Id" />
</Principal>
<Dependent Role="ToRole_User_Dealer">
<PropertyRef Name="Id" />
</Dependent>
</ReferentialConstraint>
</Association>
私はUsers('PRX-00015')
を得ることができます。私はUsers('PRX-00015')/Dealers
またはUsers('PRX-00015')?$expand=Dealers
を得ることができません。エラーはなく、データもありません。
がここにUsers.JSON
です:
[{
"__metadata": {
"id": "http://localhost/sap/opu/odata/sap/Y_DP_CORE_SRV/Users('PRX-00015')",
"uri": "http://localhost/sap/opu/odata/sap/Y_DP_CORE_SRV/Users('PRX-00015')",
"type": "Y_DP_CORE_SRV.User"
},
"Id": "PRX-00015",
"FullName": "Jorg",
"Email": "",
"Telephone": "",
"InternalUser": false,
"Enabled": true,
"Dealers": {
"results": [{
"__metadata": {
"id": "http://localhost/sap/opu/odata/sap/Y_DP_CORE_SRV/Dealers('AA2002')",
"uri": "http://localhost/sap/opu/odata/sap/Y_DP_CORE_SRV/Dealers('AA2002')",
"type": "Y_DP_CORE_SRV.Dealer"
},
"Id": "AA2002"
}, {
"__metadata": {
"id": "http://localhost/sap/opu/odata/sap/Y_DP_CORE_SRV/Dealers('AA1046')",
"uri": "http://localhost/sap/opu/odata/sap/Y_DP_CORE_SRV/Dealers('AA1046')",
"type": "Y_DP_CORE_SRV.Dealer"
},
"Id": "AA1046"
}]
},
}]
私もDealers
の拡張されていないバージョンを使用し、ラインが見え、その場合には、それ自身のDealers.json
ファイルに配列を移動することができますよう
"Dealers": {
"__deferred": {
"uri": "http://localhost/sap/opu/odata/sap/Y_DP_CORE_SRV/Users('PRX-00015')/Dealers"
}
}
そして、 Dealers.json
これらのすべてが空のDealers
配列(Dealers.length
が0)になります。誰でもこの仕組みが分かりますか?
ありがとうございます。展開の例は良いでしょう。 JSONファイルが見つかりました、私は個々のユーザーと個々のディーラーを得ることができますが、私は$ expandを使用して接続を行うように見えません。 – Jorg
@Jorg、例を追加しました。あなたの質問に答えますか? – Skay