diff options
author | Ananya Sen | 2012-06-20 15:20:04 -0700 |
---|---|---|
committer | Ananya Sen | 2012-06-20 15:20:04 -0700 |
commit | caa9683fd259307658f96190a5c5bd771126fbb8 (patch) | |
tree | 83983a8819487ce8b33f65f5d20e34af2df8dd26 /node_modules/montage/data/blueprint.js | |
parent | d852ea28dad399e84e8d5e69c0293500c30b59f1 (diff) | |
parent | c9852665eadc1acb9c1c881d207c4bd9ef88805f (diff) | |
download | ninja-caa9683fd259307658f96190a5c5bd771126fbb8.tar.gz |
Merge branch 'refs/heads/ninja-internal-master' into cut-copy-paste
Diffstat (limited to 'node_modules/montage/data/blueprint.js')
-rwxr-xr-x | node_modules/montage/data/blueprint.js | 1831 |
1 files changed, 1123 insertions, 708 deletions
diff --git a/node_modules/montage/data/blueprint.js b/node_modules/montage/data/blueprint.js index b3a66167..86a99ee7 100755 --- a/node_modules/montage/data/blueprint.js +++ b/node_modules/montage/data/blueprint.js | |||
@@ -4,94 +4,338 @@ | |||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | 4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. |
5 | </copyright> */ | 5 | </copyright> */ |
6 | /** | 6 | /** |
7 | @module montage/data/blueprint | 7 | @module montage/data/blueprint |
8 | @requires montage/core/core | 8 | @requires montage/core/core |
9 | @requires montage/data/store | 9 | @requires montage/data/store |
10 | @requires montage/data/objectid | 10 | @requires montage/data/object-id |
11 | @requires data/query | 11 | @requires data/query |
12 | @requires core/exception | 12 | @requires core/exception |
13 | @requires data/objectproperty | 13 | @requires data/object-property |
14 | @requires core/promise | 14 | @requires core/promise |
15 | @requires core/logger | 15 | @requires core/logger |
16 | */ | 16 | */ |
17 | var Montage = require("montage").Montage; | 17 | var Montage = require("montage").Montage; |
18 | var Store = require("data/store").Store; | 18 | var MappingFolder = require("data/mapping").MappingFolder; |
19 | var TemporaryObjectId = require("data/objectid").TemporaryObjectId; | 19 | var TemporaryObjectId = require("data/object-id").TemporaryObjectId; |
20 | var Query = require("data/query").Query; | 20 | var Query = require("data/query").Query; |
21 | var Exception = require("core/exception").Exception; | 21 | var ObjectProperty = require("data/object-property").ObjectProperty; |
22 | var ObjectProperty = require("data/objectproperty").ObjectProperty; | ||
23 | var Promise = require("core/promise").Promise; | 22 | var Promise = require("core/promise").Promise; |
23 | var Exception = require("core/exception").Exception; | ||
24 | var logger = require("core/logger").logger("blueprint"); | 24 | var 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 | */ | ||
30 | var BlueprintBinder = exports.BlueprintBinder = Montage.create(Montage,/** @lends module:montage/data/blueprint.BlueprintBinder# */ { | ||
31 | 25 | ||
32 | /** | 26 | /** |
33 | Description TODO | 27 | @private |
34 | @private | 28 | */ |
35 | */ | 29 | var _binderManager = null; |
36 | _blueprintForPrototypeTable: { | ||
37 | value: {}, | ||
38 | serializable: false, | ||
39 | distinct: true, | ||
40 | enumerable: false, | ||
41 | writable: false | ||
42 | }, | ||
43 | /** | 30 | /** |
44 | Description TODO | 31 | @class module:montage/data/blueprint.BlueprintBinderManager |
45 | @type {Property} | 32 | @classdesc A blueprint binder manager is a singleton that is responsible for loading and dispaching binders and blueprints. |
46 | @default {Table} {} | 33 | @extends module:montage/core/core.Montage |
47 | */ | 34 | */ |
48 | restrictionsTable: { | 35 | var BlueprintBinderManager = exports.BlueprintBinderManager = Montage.create(Montage, /** @lends module:montage/data/blueprint.BlueprintBinderManager# */ { |
49 | value: {}, | 36 | |
50 | serializable: true, | 37 | /** |
51 | distinct: true, | 38 | Description TODO |
52 | enumerable: false, | 39 | @function |
53 | writable: false | 40 | @returns itself |
41 | */ | ||
42 | init:{ | ||
43 | serializable:false, | ||
44 | enumerable:false, | ||
45 | value:function () { | ||
46 | return this; | ||
47 | } | ||
54 | }, | 48 | }, |
55 | /** | 49 | |
56 | Description TODO | 50 | /** |
57 | @type {Property} | 51 | Description TODO |
58 | @default {String} null | 52 | @type {Property} Function |
59 | */ | 53 | @default {Array} new Array(10) |
60 | name: { | 54 | */ |
61 | value: null, | 55 | blueprintBinders:{ |
62 | serializable: true | 56 | serializable:true, |
57 | writable:false, | ||
58 | distinct:true, | ||
59 | value:new Array(10) | ||
60 | }, | ||
61 | |||
62 | /** | ||
63 | Add a new blueprint binder. | ||
64 | @function | ||
65 | @param {Property} binder TODO | ||
66 | */ | ||
67 | addBlueprintBinder:{ | ||
68 | value:function (binder) { | ||
69 | if (binder !== null) { | ||
70 | var index = this.blueprintBinders.indexOf(binder); | ||
71 | if (index >= 0) { | ||
72 | this.blueprintBinders.splice(index, 1); | ||
73 | } | ||
74 | this.blueprintBinders.push(binder); | ||
75 | } | ||
76 | } | ||
77 | }, | ||
78 | |||
79 | /** | ||
80 | Description TODO | ||
81 | @function | ||
82 | @param {Property} binder TODO | ||
83 | */ | ||
84 | removeBlueprintBinder:{ | ||
85 | value:function (binder) { | ||
86 | if (binder !== null) { | ||
87 | var index = this.blueprintBinders.indexOf(binder); | ||
88 | if (index >= 0) { | ||
89 | this.blueprintBinders.splice(index, 1); | ||
90 | } | ||
91 | } | ||
92 | } | ||
63 | }, | 93 | }, |
94 | |||
95 | /** | ||
96 | Search through the binders for a blueprint that extends that prototype. | ||
97 | @function | ||
98 | @param {Property} prototypeName TODO | ||
99 | @param {Property} moduleId TODO | ||
100 | @returns The requested blueprint or null if this prototype is not managed. | ||
101 | */ | ||
102 | blueprintForPrototype: { | ||
103 | value: function(prototypeName, moduleId) { | ||
104 | var binder, blueprint, index; | ||
105 | for (index = 0; typeof (binder = this.blueprintBinders[index]) !== "undefined"; index++) { | ||
106 | blueprint = binder.blueprintForPrototype(prototypeName, moduleId); | ||
107 | if (blueprint !== null) { | ||
108 | return blueprint; | ||
109 | } | ||
110 | } | ||
111 | return null; | ||
112 | } | ||
113 | } | ||
114 | |||
115 | }); | ||
116 | |||
117 | var BlueprintObject = exports.BlueprintObject = Montage.create(Montage, /** @lends module:montage/data/blueprint.BlueprintObject# */ { | ||
118 | |||
119 | /** | ||
120 | @private | ||
121 | */ | ||
122 | _name:{ | ||
123 | serializable:true, | ||
124 | enumerable:false, | ||
125 | value:null | ||
126 | }, | ||
127 | |||
128 | /** | ||
129 | Name of the object. The name is used to define the property on the object. | ||
130 | @function | ||
131 | @returns {String} this._name | ||
132 | */ | ||
133 | name:{ | ||
134 | get:function () { | ||
135 | return this._name; | ||
136 | } | ||
137 | }, | ||
138 | |||
139 | /** | ||
140 | @private | ||
141 | */ | ||
142 | _mappings:{ | ||
143 | serializable:true, | ||
144 | enumerable:false, | ||
145 | distinct:true, | ||
146 | value: new Array(5) | ||
147 | }, | ||
148 | |||
149 | /** | ||
150 | @private | ||
151 | */ | ||
152 | _mappingForName:{ | ||
153 | value:{}, | ||
154 | serializable:false, | ||
155 | distinct:true, | ||
156 | enumerable:false, | ||
157 | writable:false | ||
158 | }, | ||
159 | |||
160 | deserializedFromSerialization:{ | ||
161 | value:function () { | ||
162 | var aMapping, index; | ||
163 | for (index = 0; typeof (aMapping = this._mappings[index]) !== "undefined"; index++) { | ||
164 | this._mappingForName[aMapping.name] = aMapping; | ||
165 | } | ||
166 | } | ||
167 | }, | ||
168 | |||
169 | /** | ||
170 | List of mappings attached to this object. | ||
171 | @function | ||
172 | @returns mappings | ||
173 | */ | ||
174 | mappings:{ | ||
175 | get:function () { | ||
176 | return this._mappings; | ||
177 | } | ||
178 | }, | ||
179 | |||
180 | /** | ||
181 | Add a mapping to the list of mappings. | ||
182 | @function | ||
183 | @param {mapping} mapping to add. | ||
184 | @returns mapping | ||
185 | */ | ||
186 | addMapping:{ | ||
187 | value:function (mapping) { | ||
188 | if (mapping !== null) { | ||
189 | var index = this.mappings.indexOf(mapping); | ||
190 |