diff options
Diffstat (limited to 'node_modules/montage-user/data/store.js')
-rwxr-xr-x | node_modules/montage-user/data/store.js | 1211 |
1 files changed, 1211 insertions, 0 deletions
diff --git a/node_modules/montage-user/data/store.js b/node_modules/montage-user/data/store.js new file mode 100755 index 00000000..5057826d --- /dev/null +++ b/node_modules/montage-user/data/store.js | |||
@@ -0,0 +1,1211 @@ | |||
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/store | ||
8 | @requires montage/core/core | ||
9 | @requires montage/data/blueprint | ||
10 | @requires montage/data/query | ||
11 | @requires montage/data/restriction | ||
12 | @requires montage/data/transactionid | ||
13 | @requires montage/data/objectid | ||
14 | @requires montage/data/controllistener | ||
15 | @requires montage/core/serializer | ||
16 | @requires montage/core/deserializer | ||
17 | @requires montage/core/promise | ||
18 | @requires montage/core/logger | ||
19 | */ | ||
20 | var Montage = require("montage").Montage; | ||
21 | var Blueprint = require("data/blueprint").Blueprint; | ||
22 | var BlueprintBinder = require("data/blueprint").BlueprintBinder; | ||
23 | var Query = require("data/query").Query; | ||
24 | var Restriction = require("data/restriction").Restriction; | ||
25 | var TransactionId = require("data/transactionid").TransactionId; | ||
26 | var ObjectId = require("data/objectid").ObjectId; | ||
27 | var TemporaryObjectId = require("data/objectid").TemporaryObjectId; | ||
28 | var ControlListener = require("data/controllistener").ControlListener; | ||
29 | var Serializer = require("core/serializer").Serializer; | ||
30 | var Deserializer = require("core/deserializer").Deserializer; | ||
31 | var Promise = require("core/promise").Promise; | ||
32 | var logger = require("core/logger").logger("store"); | ||
33 | /** | ||
34 | Description TODO | ||
35 | @private | ||
36 | */ | ||
37 | var _defaultStoreManager = null; | ||
38 | /** | ||
39 | @class module:montage/data/store.Store | ||
40 | @extends module:montage/core/core.Montage | ||
41 | */ | ||
42 | var Store = exports.Store = Montage.create(Montage,/** @lends module:montage/data/store.Store# */ { | ||
43 | /** | ||
44 | Description TODO | ||
45 | @type {Property} Function | ||
46 | @default {Array} new Array(10) | ||
47 | */ | ||
48 | blueprintBinders: { | ||
49 | serializable: true, | ||
50 | writable: false, | ||
51 | distinct: true, | ||
52 | value: new Array(10) | ||
53 | }, | ||
54 | /** | ||
55 | Description TODO | ||
56 | @function | ||
57 | @param {Property} binder TODO | ||
58 | */ | ||
59 | addBlueprintBinder: { | ||
60 | value: function(binder) { | ||
61 | if (binder !== null) { | ||
62 | var index = this.blueprintBinders.indexOf(binder); | ||
63 | if (index < 0) { | ||
64 | this.blueprintBinders.push(binder); | ||
65 | } | ||
66 | } | ||
67 | } | ||
68 | }, | ||
69 | /** | ||
70 | Description TODO | ||
71 | @function | ||
72 | @param {Property} binder TODO | ||
73 | */ | ||
74 | removeBlueprintBinder: { | ||
75 | value: function(binder) { | ||
76 | if (binder !== null) { | ||
77 | var index = this.blueprintBinders.indexOf(binder); | ||
78 | if (index >= 0) { | ||
79 | this.blueprintBinders.splice(index, 1); | ||
80 | } | ||
81 | } | ||
82 | } | ||
83 | }, | ||
84 | /** | ||
85 | Description TODO | ||
86 | @function | ||
87 | @param {Property} name TODO | ||
88 | @returns null | ||
89 | */ | ||
90 | blueprintBinderForName: { | ||
91 | value: function(name) { | ||
92 | var binder, index; | ||
93 | for (index = 0; typeof (binder = this.blueprintBinders[index]) !== "undefined"; index++) { | ||
94 | if (binder.name === name) { | ||
95 | return binder; | ||
96 | } | ||
97 | } | ||
98 | return null; | ||
99 | } | ||
100 | }, | ||
101 | /** | ||
102 | Description TODO | ||
103 | @type {Property} | ||
104 | @default {Array} new Array(10) | ||
105 | */ | ||
106 | restrictions: { | ||
107 | serializable: true, | ||
108 | writable: false, | ||
109 | distinct: true, | ||
110 | value: new Array(10) | ||
111 | }, | ||
112 | /** | ||
113 | Description TODO | ||
114 | @private | ||
115 | */ | ||
116 | _parent: { | ||
117 | serializable: true, | ||
118 | enumerable: false, | ||
119 | value: null | ||
120 | }, | ||
121 | |||
122 | /** | ||
123 | Returns the parent store. | ||
124 | @function | ||
125 | @returns this._parent | ||
126 | */ | ||
127 | parent: { | ||
128 | get: function() { | ||
129 | return this._parent; | ||
130 | } | ||
131 | }, | ||
132 | |||
133 | |||
134 | /* | ||
135 | * | ||
136 | * | ||
137 | */ | ||
138 | |||
139 | /** | ||
140 | Returns the default store manager.<br> | ||
141 | If none is defined it will create one that will then be reused for subsequent calls. | ||
142 | @function | ||
143 | @returns _defaultStoreManager | ||
144 | */ | ||
145 | defaultManager: { | ||
146 | get: function() { | ||
147 | if (_defaultStoreManager === null) { | ||
148 | _defaultStoreManager = StoreManager.create().init(); | ||
149 | } | ||
150 | return _defaultStoreManager; | ||
151 | }, | ||
152 | // This is used only for testing. | ||
153 | set: function(storeManager) { | ||
154 | _defaultStoreManager = storeManager; | ||
155 | } | ||
156 | }, | ||
157 | /** | ||
158 | @function | ||
159 | @returns this.initWithParentAndRestrictions(null, null) | ||
160 | */ | ||
161 | init: { | ||
162 | serializable: false, | ||
163 | enumerable: false, | ||
164 | value: function() { | ||
165 | return this.initWithParentAndRestrictions(null, null); | ||
166 | } | ||
167 | }, | ||
168 | /** | ||
169 | @function | ||
170 | @param {Property} parent TODO | ||
171 | @returns this.initWithParentAndRestrictions(parent, null) | ||
172 | */ | ||
173 | initWithParent: { | ||
174 | serializable: false, | ||
175 | enumerable: false, | ||
176 | value: function(parent) { | ||
177 | return this.initWithParentAndRestrictions(parent, null); | ||
178 | } | ||
179 | }, | ||
180 | /** | ||
181 | Description TODO | ||
182 | @function | ||
183 | @param {Property} parent TODO | ||
184 | @param {Property} restrictions TODO | ||
185 | @returns itself | ||
186 | */ | ||
187 | initWithParentAndRestrictions: { | ||
188 | serializable: false, | ||
189 | value: function(parent, restrictions) { | ||
190 | if (this.parent !== null) { | ||
191 | this.parent.remove(this); | ||
192 | } | ||
193 | this._parent = (parent != null ? parent : Store.defaultManager); | ||
194 | this.parent.addStore(this); | ||
195 | |||
196 | if (restrictions != null) { | ||
197 | var restriction, index; | ||
198 | for (index = 0; typeof (restriction = restrictions[index]) !== "undefined"; index++) { | ||
199 | this.restrictions.push(Object.freeze(restriction)); | ||
200 | } | ||
201 | } | ||
202 | return this; | ||
203 | } | ||
204 | }, | ||
205 | /** | ||
206 | Description TODO | ||
207 | @function | ||
208 | @param {Prototyoe} prototypeName TODO | ||
209 | @param {Id} moduleId TODO | ||
210 | @returns null | ||
211 | */ | ||
212 | blueprintForPrototype$Implementation: { | ||
213 | serializable: false, | ||
214 | value: function(prototypeName, moduleId) { | ||
215 | var binder, blueprint, index; | ||
216 | for (index = 0; typeof (binder = this.blueprintBinders[index]) !== "undefined"; index++) { | ||
217 | blueprint = binder.blueprintForPrototype(prototypeName, moduleId); | ||
218 | if (blueprint !== null) { | ||
219 | return blueprint; | ||
220 | } | ||
221 | } | ||
222 | return null; | ||
223 | } | ||
224 | }, | ||
225 | /** | ||
226 | Description TODO | ||
227 | @function | ||
228 | @param {Prototyoe} prototypeName TODO | ||
229 | @param {Id} moduleId TODO | ||
230 | @returns null | ||
231 | */ | ||
232 | blueprintForPrototype: { | ||
233 | value: function(prototypeName, moduleId) { | ||
234 | if (this.parent !== null) { | ||
235 | return this.parent.blueprintForPrototype(prototypeName, moduleId); | ||
236 | } | ||
237 | return null; | ||