-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
SandboxModel.js
64 lines (62 loc) · 1.85 KB
/
SandboxModel.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*!
* ${copyright}
*/
// The SandboxModel is used in the manifest instead of OData V4 model for the following purposes:
// Certain constructor parameters are taken from URL parameters. For the "non-realOData" case, a
// mock server for the back-end requests is set up.
sap.ui.define([
"sap/ui/core/sample/common/SandboxModelHelper",
"sap/ui/model/odata/v4/ODataModel"
], function (SandboxModelHelper, ODataModel) {
"use strict";
var oMockData = {
mFixture : {
"$metadata?sap-language=EN" : {
source : "metadata.xml"
},
"GET Sticky?$count=true&$select=Content,Id&$skip=0&$top=5" : {
message : {
"@odata.count" : "1",
"value" : [{
"Id" : "10",
"Content" : "Test Data 10"
}]
}
},
"GET Sticky('10')?$select=Content,Id" : {
message : {
"Id" : "10",
"Content" : "Test Data 10"
}
},
"PATCH Sticky('10')" : [{
headers : {"SAP-ContextId" : "session1"},
ifMatch : function (oRequest) {
return oRequest.requestHeaders["SAP-ContextId"] === "session1";
},
message : {
"Id" : "10",
"Content" : "returned from server"
}
}, {
code : 400,
headers : {"Content-Type" : "text/plain"},
message : "PATCH request w/o SAP-ContextId header"
}],
"POST Sticky('10')/com.sap.gateway.srvd.zrc_rap_sticky.v0001.PrepareForEdit" : {
headers : {"SAP-ContextId" : "session1"},
message : {
"Id" : "10",
"Content" : "prepared for edit"
}
}
},
sFilterBase : "/sap/opu/odata4/sap/zrc_rap_sticky/srvd/sap/zrc_rap_sticky/0001/",
sSourceBase : "sap/ui/core/sample/odata/v4/Sticky/data"
};
return ODataModel.extend("sap.ui.core.sample.odata.v4.Sticky.SandboxModel", {
constructor : function (mParameters) {
return SandboxModelHelper.adaptModelParametersAndCreateModel(mParameters, oMockData);
}
});
});