aboutsummaryrefslogtreecommitdiff
path: root/node_modules/montage/data/rest-access/rest-store.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/montage/data/rest-access/rest-store.js')
-rwxr-xr-xnode_modules/montage/data/rest-access/rest-store.js221
1 files changed, 221 insertions, 0 deletions
diff --git a/node_modules/montage/data/rest-access/rest-store.js b/node_modules/montage/data/rest-access/rest-store.js
new file mode 100755
index 00000000..28dbd650
--- /dev/null
+++ b/node_modules/montage/data/rest-access/rest-store.js
@@ -0,0 +1,221 @@
1/* <copyright>
2 This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3 No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
4 (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5 </copyright> */
6/**
7 @module montage/data/rest-access/rest-store
8 @requires montage/core/core
9 @requires montage/data/store
10 @requires montage/core/logger
11 @requires montage/core/promise
12 @requires data/rest-access/rest-mapping
13 */
14var Montage = require("montage").Montage;
15var Store = require("data/store").Store;
16var Promise = require("core/promise").Promise;
17var RestBinderMapping = require("data/rest-access/rest-mapping").RestBinderMapping;
18var RestBlueprintMapping = require("data/rest-access/rest-mapping").RestBlueprintMapping;
19var RestAttributeMapping = require("data/rest-access/rest-mapping").RestAttributeMapping;
20var RestAssociationMapping = require("data/rest-access/rest-mapping").RestAssociationMapping;
21
22var logger = require("core/logger").logger("rest-store");
23
24/**
25 @class module:montage/data/rest-access/rest-store.RestStore
26 @extends module:montage/data/store.Store
27 */
28var RestStore = exports.RestStore = Montage.create(Store, /** @lends module:montage/data/rest-access/rest-store.RestStore# */ {
29
30 /**
31 Create a new binder mapping.
32 @function
33 @returns binder mapping
34 */
35 createBinderMapping:{
36 get:function () {
37 return RestBinderMapping.create();
38 }
39 },
40
41 /**
42 Create a new blueprint mapping.
43 @function
44 @returns blueprint mapping
45 */
46 createBlueprintMapping:{
47 get:function () {
48 return RestBlueprintMapping.create();
49 }
50 },
51
52 /**
53 Create a new attribute mapping.
54 @function
55 @returns attribute mapping
56 */
57 createAttributeMapping:{
58 get:function () {
59 return RestAttributeMapping.create();
60 }
61 },
62
63 /**
64 Create a new association mapping.
65 @function
66 @returns association mapping
67 */
68 createAssociationMapping:{
69 get:function () {
70 return RestAssociationMapping.create();
71 }
72 },
73
74 /**
75 Description TODO
76 @function
77 @param {Object} object TODO
78 @param {Property} context TODO
79 @param {Property} transactionId TODO
80 @returns {Function} Promise.ref(object.objectId) or Promise.ref(null)
81 */
82 permanentIdForObjectId$Implementation:{
83 value:function (object, context, transactionId) {
84 // TODO [PJYF Apr 28 2011] We need to implement it.
85 if (typeof object.objectId !== "undefined") {
86 return Promise.ref(object.objectId);
87 }
88 return Promise.ref(null);
89 }
90 },
91
92 /**
93 Description TODO
94 @function
95 @param {Object} objectId TODO
96 @param {Property} context TODO
97 @param {Property} transactionId TODO
98 @returns {Function} Promise.ref(null)
99 */
100 pledgeForObjectId$Implementation:{
101 value:function (objectId, context, transactionId) {
102 // TODO [PJYF Apr 28 2011] We need to implement it.
103 return Promise.ref(null);
104 }
105 },
106
107 /**
108 Description TODO
109 @function
110 @param {Object} sourceObject TODO
111 @param {Property} relationship TODO
112 @param {Property} context TODO
113 @param {Property} transactionId TODO
114 @returns {Function} Promise.ref(null)
115 */
116 pledgeForSourceObjectAssociation$Implementation:{
117 value:function (sourceObject, relationship, context, transactionId) {
118 // TODO [PJYF Apr 28 2011] We need to implement it.
119 return Promise.ref(null);
120 }
121 },
122
123 /**
124 Description TODO
125 @function
126 @param {Object} object TODO
127 @param {Property} context TODO
128 @param {Property} transactionId TODO
129 @returns {Function} Promise.ref(object)
130 */
131 initializeObject$Implementation:{
132 value:function (object, context, transactionId) {
133 if (typeof object.objectId === "undefined") {
134 // TODO [PJYF June 17 2011] This will need to be revisited.
135 object.objectId = TemporaryObjectId.create().initWithBlueprint(object.blueprint);
136 }
137 return Promise.ref(object);
138 }
139 },
140
141 /**
142 Description TODO
143 @function
144 @param {Object} object TODO
145 @param {Property} context TODO
146 @param {Property} transactionId TODO
147 @returns {Function} this.pledgeForObjectId(object.objectId, context, transactionId) or Promise.ref(object)
148 */
149 repledgeObject$Implementation:{
150 value:function (object, context, transactionId) {
151 if (typeof object.objectId !== "undefined") {
152 return this.pledgeForObjectId(object.objectId, context, transactionId);
153 }
154 return Promise.ref(object);
155 }
156
157 },
158
159 /**
160 Called on each store before a save.<br>
161 Upon receiving this message the store should take steps to prepare the commit and insure it will succeed.<br>
162 If the commit cannot succeed it should return a rejected promise.
163 @function
164 @param {Property} context TODO
165 @param {Property} transactionId TODO
166 @returns {Function} Promise.ref(true)
167 */
168 prepareToSaveChangesInContext$Implementation:{
169 value:function (context, transactionId) {
170 // TODO [PJYF Sep 27 2011] This needs to be reimplemented
171 return Promise.ref(true);
172 }
173 },
174
175 /**
176 Called on each store before a revert to prepare a save.<br>
177 Any step taken to prepare the save should be rolled back.
178 @function
179 @param {Property} context TODO
180 @param {Property} transactionId TODO
181 @returns {Function} Promise.ref(true)
182 */
183 cancelSaveChangesInContext$Implementation:{
184 value:function (context, transactionId) {
185 // TODO [PJYF Sep 27 2011] This needs to be reimplemented
186 return Promise.ref(true);
187 }
188 },
189
190 /**
191 Commits the transaction.<br>
192 Any failure during this step will cause the store to be left an inconsistent state.
193 @function
194 @param {Property} context TODO
195 @param {Property} transactionId TODO
196 @returns {Function} Promise.ref(true)
197 */
198 commitChangesInContext$Implementation:{
199 value:function (context, transactionId) {
200 // TODO [PJYF Sep 27 2011] This needs to be reimplemented
201 return Promise.ref(true);
202 }
203 },
204
205 /**
206 Description TODO
207 @function
208 @param {Property} query TODO
209 @param {Property} context TODO
210 @param {Property} transactionId TODO
211 @returns {Function} Promise.ref([])
212 */
213 queryInContext$Implementation:{
214 value:function (query, context, transactionID) {
215 // TODO [PJYF Sept 4 2011] This needs to be implemented
216 return Promise.ref([]);
217 }
218 }
219
220
221});