diff options
Diffstat (limited to 'node_modules/montage/data/restaccess/reststore.js')
-rwxr-xr-x | node_modules/montage/data/restaccess/reststore.js | 186 |
1 files changed, 186 insertions, 0 deletions
diff --git a/node_modules/montage/data/restaccess/reststore.js b/node_modules/montage/data/restaccess/reststore.js new file mode 100755 index 00000000..9df05c2f --- /dev/null +++ b/node_modules/montage/data/restaccess/reststore.js | |||
@@ -0,0 +1,186 @@ | |||
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/restaccess/reststore | ||
8 | @requires montage/core/core | ||
9 | @requires montage/data/store | ||
10 | @requires montage/core/logger | ||
11 | */ | ||
12 | var Montage = require("montage").Montage; | ||
13 | var Store = require("data/store").Store; | ||
14 | var Promise = require("core/promise").Promise; | ||
15 | var logger = require("core/logger").logger("reststore"); | ||
16 | |||
17 | /** | ||
18 | @class module:montage/data/restaccess/reststore.RestStore | ||
19 | @extends module:montage/data/store.Store | ||
20 | */ | ||
21 | var RestStore = exports.RestStore = Montage.create(Store,/** @lends module:montage/data/restaccess/reststore.RestStore# */ { | ||
22 | |||
23 | /** | ||
24 | Description TODO | ||
25 | @function | ||
26 | @param {Property} binder | ||
27 | @returns {Boolean} true or false | ||
28 | */ | ||
29 | canServiceBlueprintBinder: { | ||
30 | value: function(binder) { | ||
31 | if ((binder !== null) && (binder.storePrototypeName === "RestStore")) { | ||
32 | // TODO [PJYF Apr 19 2011] We need to check that the connection url points to the same DB | ||
33 | return true; | ||
34 | } | ||
35 | return false; | ||
36 | } | ||
37 | }, | ||
38 | |||
39 | /** | ||
40 | Description TODO | ||
41 | @function | ||
42 | @param {Object} object TODO | ||
43 | @param {Property} context TODO | ||
44 | @param {Property} transactionId TODO | ||
45 | @returns {Function} Promise.ref(object.objectId) or Promise.ref(null) | ||
46 | */ | ||
47 | permanentIdForObjectId$Implementation: { | ||
48 | value: function(object, context, transactionId) { | ||
49 | // TODO [PJYF Apr 28 2011] We need to implement it. | ||
50 | if (typeof object.objectId !== "undefined") { | ||
51 | return Promise.ref(object.objectId); | ||
52 | } | ||
53 | return Promise.ref(null); | ||
54 | } | ||
55 | }, | ||
56 | |||
57 | /** | ||
58 | Description TODO | ||
59 | @function | ||
60 | @param {Object} objectId TODO | ||
61 | @param {Property} context TODO | ||
62 | @param {Property} transactionId TODO | ||
63 | @returns {Function} Promise.ref(null) | ||
64 | */ | ||
65 | pledgeForObjectId$Implementation: { | ||
66 | value: function(objectId, context, transactionId) { | ||
67 | // TODO [PJYF Apr 28 2011] We need to implement it. | ||
68 | return Promise.ref(null); | ||
69 | } | ||
70 | }, | ||
71 | |||
72 | /** | ||
73 | Description TODO | ||
74 | @function | ||
75 | @param {Object} sourceObject TODO | ||
76 | @param {Property} relationship TODO | ||
77 | @param {Property} context TODO | ||
78 | @param {Property} transactionId TODO | ||
79 | @returns {Function} Promise.ref(null) | ||
80 | */ | ||
81 | pledgeForSourceObjectRelationship$Implementation: { | ||
82 | value: function(sourceObject, relationship, context, transactionId) { | ||
83 | // TODO [PJYF Apr 28 2011] We need to implement it. | ||
84 | return Promise.ref(null); | ||
85 | } | ||
86 | }, | ||
87 | |||
88 | /** | ||
89 | Description TODO | ||
90 | @function | ||
91 | @param {Object} object TODO | ||
92 | @param {Property} context TODO | ||
93 | @param {Property} transactionId TODO | ||
94 | @returns {Function} Promise.ref(object) | ||
95 | */ | ||
96 | initializeObject$Implementation: { | ||
97 | value: function(object, context, transactionId) { | ||
98 | if (typeof object.objectId === "undefined") { | ||
99 | // TODO [PJYF June 17 2011] This will need to be revisited. | ||
100 | object.objectId = TemporaryObjectId.create().init(); | ||
101 | } | ||
102 | return Promise.ref(object); | ||
103 | } | ||
104 | }, | ||
105 | |||
106 | /** | ||
107 | Description TODO | ||
108 | @function | ||
109 | @param {Object} object TODO | ||
110 | @param {Property} context TODO | ||
111 | @param {Property} transactionId TODO | ||
112 | @returns {Function} this.pledgeForObjectId(object.objectId, context, transactionId) or Promise.ref(object) | ||
113 | */ | ||
114 | repledgeObject$Implementation: { | ||
115 | value: function(object, context, transactionId) { | ||
116 | if (typeof object.objectId !== "undefined") { | ||
117 | return this.pledgeForObjectId(object.objectId, context, transactionId); | ||
118 | } | ||
119 | return Promise.ref(object); | ||
120 | } | ||
121 | |||
122 | }, | ||
123 | |||
124 | /** | ||
125 | Called on each store before a save.<br> | ||
126 | Upon receiving this message the store should take steps to prepare the commit and insure it will succeed.<br> | ||
127 | If the commit cannot succeed it should return a rejected promise. | ||
128 | @function | ||
129 | @param {Property} context TODO | ||
130 | @param {Property} transactionId TODO | ||
131 | @returns {Function} Promise.ref(true) | ||
132 | */ | ||
133 | prepareToSaveChangesInContext$Implementation: { | ||
134 | value: function(context, transactionId) { | ||
135 | // TODO [PJYF Sep 27 2011] This needs to be reimplemented | ||
136 | return Promise.ref(true); | ||
137 | } | ||
138 | }, | ||
139 | |||
140 | /** | ||
141 | Called on each store before a revert to prepare a save.<br> | ||
142 | Any step taken to prepare the save should be rolled back. | ||
143 | @function | ||
144 | @param {Property} context TODO | ||
145 | @param {Property} transactionId TODO | ||
146 | @returns {Function} Promise.ref(true) | ||
147 | */ | ||
148 | cancelSaveChangesInContext$Implementation: { | ||
149 | value: function(context, transactionId) { | ||
150 | // TODO [PJYF Sep 27 2011] This needs to be reimplemented | ||
151 | return Promise.ref(true); | ||
152 | } | ||
153 | }, | ||
154 | |||
155 | /** | ||
156 | Commits the transaction.<br> | ||
157 | Any failure during this step will cause the store to be left an inconsistent state. | ||
158 | @function | ||
159 | @param {Property} context TODO | ||
160 | @param {Property} transactionId TODO | ||
161 | @returns {Function} Promise.ref(true) | ||
162 | */ | ||
163 | commitChangesInContext$Implementation: { | ||
164 | value: function(context, transactionId) { | ||
165 | // TODO [PJYF Sep 27 2011] This needs to be reimplemented | ||
166 | return Promise.ref(true); | ||
167 | } | ||
168 | }, | ||
169 | |||
170 | /** | ||
171 | Description TODO | ||
172 | @function | ||
173 | @param {Property} query TODO | ||
174 | @param {Property} context TODO | ||
175 | @param {Property} transactionId TODO | ||
176 | @returns {Function} Promise.ref([]) | ||
177 | */ | ||
178 | queryInContext$Implementation: { | ||
179 | value: function(query, context, transactionID) { | ||
180 | // TODO [PJYF Sept 4 2011] This needs to be implemented | ||
181 | return Promise.ref([]); | ||
182 | } | ||
183 | } | ||
184 | |||
185 | |||
186 | }); | ||