aboutsummaryrefslogtreecommitdiff
path: root/node_modules/montage/data/blueprint.js
diff options
context:
space:
mode:
authorPierre Frisch2011-12-22 07:25:50 -0800
committerValerio Virgillito2012-01-27 11:18:17 -0800
commitb89a7ee8b956c96a1dcee995ea840feddc5d4b27 (patch)
tree0f3136ab0ecdbbbed6a83576581af0a53124d6f1 /node_modules/montage/data/blueprint.js
parent2401f05d1f4b94d45e4568b81fc73e67b969d980 (diff)
downloadninja-b89a7ee8b956c96a1dcee995ea840feddc5d4b27.tar.gz
First commit of Ninja to ninja-internal
Signed-off-by: Valerio Virgillito <rmwh84@motorola.com>
Diffstat (limited to 'node_modules/montage/data/blueprint.js')
-rwxr-xr-xnode_modules/montage/data/blueprint.js1062
1 files changed, 1062 insertions, 0 deletions
diff --git a/node_modules/montage/data/blueprint.js b/node_modules/montage/data/blueprint.js
new file mode 100755
index 00000000..b3a66167
--- /dev/null
+++ b/node_modules/montage/data/blueprint.js
@@ -0,0 +1,1062 @@
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/blueprint
8 @requires montage/core/core
9 @requires montage/data/store
10 @requires montage/data/objectid
11 @requires data/query
12 @requires core/exception
13 @requires data/objectproperty
14 @requires core/promise
15 @requires core/logger
16*/
17var Montage = require("montage").Montage;
18var Store = require("data/store").Store;
19var TemporaryObjectId = require("data/objectid").TemporaryObjectId;
20var Query = require("data/query").Query;
21var Exception = require("core/exception").Exception;
22var ObjectProperty = require("data/objectproperty").ObjectProperty;
23var Promise = require("core/promise").Promise;
24var logger = require("core/logger").logger("blueprint");
25/**
26 @class module:montage/data/blueprint.BlueprintBinder
27 @classdesc A blueprint binder is a collection of of blueprints for a specific access type. It also includes the connection information.
28 @extends module:montage/core/core.Montage
29*/
30var BlueprintBinder = exports.BlueprintBinder = Montage.create(Montage,/** @lends module:montage/data/blueprint.BlueprintBinder# */ {
31
32/**
33 Description TODO
34 @private
35*/
36 _blueprintForPrototypeTable: {
37 value: {},
38 serializable: false,
39 distinct: true,
40 enumerable: false,
41 writable: false
42 },
43/**
44 Description TODO
45 @type {Property}
46 @default {Table} {}
47 */
48 restrictionsTable: {
49 value: {},
50 serializable: true,
51 distinct: true,
52 enumerable: false,
53 writable: false
54 },
55/**
56 Description TODO
57 @type {Property}
58 @default {String} null
59 */
60 name: {
61 value: null,
62 serializable: true
63 },
64/**
65 Description TODO
66 @function
67 @param {String} name TODO
68 @returns itself
69 */
70 initWithName: {
71 value: function(name) {
72 this.name = (name !== null ? name : "default");
73 return this;
74 }
75 },
76/**
77 Description TODO
78 @type {Property}
79 @default {Array} new Array(30)
80 */
81 blueprints: {
82 serializable: true,
83 distinct: true,
84 writable: false,
85 value: new Array(30)
86 },
87/**
88 Description TODO
89 @function
90 @param {Array} blueprint TODO
91 @returns blueprint
92 */
93 addBlueprint: {
94 value: function(blueprint) {
95 if (blueprint !== null) {
96 var index = this.blueprints.indexOf(blueprint);
97 if (index < 0) {
98 if (blueprint.binder !== null) {
99 blueprint.binder.removeBlueprint(blueprint);
100 }
101 this.blueprints.push(blueprint);
102 blueprint.binder = this;
103 //
104 var key = blueprint.moduleId + "." + blueprint.prototypeName;
105 this._blueprintForPrototypeTable[key] = blueprint;
106 }
107 }
108 return blueprint;
109 }
110 },
111/**
112 Description TODO
113 @function
114 @param {Array} blueprint TODO
115 @returns blueprint
116 */
117 removeBlueprint: {
118 value: function(blueprint) {
119 if (blueprint !== null) {
120 var index = this.blueprints.indexOf(blueprint);
121 if (index >= 0) {
122 this.blueprints.splice(index, 1);
123 blueprint.binder = null;
124 // Remove the cached entry
125 var key = blueprint.moduleId + "." + blueprint.prototypeName;
126 delete this._blueprintForPrototypeTable[key];
127 }
128 }
129 return blueprint;
130 }
131 },
132/**
133 Description TODO
134 @function
135 @param {String} name TODO
136 @param {String} moduleID TODO
137 @returns this.addBlueprint(this.createBlueprint().initWithNameAndModuleId(name, moduleId))
138 */
139 addBlueprintNamed : {
140 value: function(name, moduleId) {
141 return this.addBlueprint(this.createBlueprint().initWithNameAndModuleId(name, moduleId));
142 }
143 },
144/**
145 Description TODO
146 @function
147 @returns Blueprint.create()
148 */
149 createBlueprint: {
150 value: function() {
151 return Blueprint.create();
152 }
153 },
154/**
155 Description TODO
156 @function
157 @param {String} name TODO
158 @param {Selector} defaultSelector TODO
159 @returns restriction
160 */
161 addRestriction: {
162 value: function(name, defaultSelector) {
163 var restriction = null;
164 if (name != null && defaultSelector != null) {
165 restriction = this.restrictionsTable[name] = defaultSelector;
166 }
167 return restriction;
168 }
169 },
170/**
171 Description TODO
172 @function
173 @param {String} name TODO
174 @returns restriction
175 */
176 removeRestriction: {
177 value: function(name) {
178 if (name !== null) {
179 var restriction = this.restrictionsTable[name]
180 if (restriction != null) {
181 delete restriction;
182 }
183 }
184 return restriction;
185 }
186 },
187
188/**
189 Description TODO
190 @function
191 @param {String} restriction TODO
192 @returns selector
193 */
194 defaultSelectorForRestriction: {
195 value: function(restriction) {
196 var selector = null;
197 if (restriction != null) {
198 selector = this.restrictionsTable[restriction.name];
199 if (typeof selector === 'undefined') {
200 selector = null;
201 }
202 }
203 return selector;
204 }
205 },
206 /**
207 Description TODO
208 @type {Property}
209 @default {ID} montage/data/store
210 */
211 storeModuleId: {
212 value: "data/store"
213 },
214 /**
215 Description TODO
216 @type {Property}
217 @default {String} "Store"
218 */
219 storePrototypeName: {
220 value: "Store"
221 },
222 /**
223 Return the blueprint associated with this prototype.
224 @function
225 @param {String} prototypeName TODO
226 @param {ID} moduleId TODO
227 @returns blueprint
228 */
229 blueprintForPrototype: {
230 value: function(prototypeName, moduleId) {
231 var key = moduleId + "." + prototypeName;
232 var blueprint = this._blueprintForPrototypeTable[key];
233 if (typeof blueprint =