aboutsummaryrefslogtreecommitdiff
path: root/node_modules/montage/data/blueprint.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/montage/data/blueprint.js')
-rwxr-xr-xnode_modules/montage/data/blueprint.js1831
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 */
17var Montage = require("montage").Montage; 17var Montage = require("montage").Montage;
18var Store = require("data/store").Store; 18var MappingFolder = require("data/mapping").MappingFolder;
19var TemporaryObjectId = require("data/objectid").TemporaryObjectId; 19var TemporaryObjectId = require("data/object-id").TemporaryObjectId;
20var Query = require("data/query").Query; 20var Query = require("data/query").Query;
21var Exception = require("core/exception").Exception; 21var ObjectProperty = require("data/object-property").ObjectProperty;
22var ObjectProperty = require("data/objectproperty").ObjectProperty;
23var Promise = require("core/promise").Promise; 22var Promise = require("core/promise").Promise;
23var Exception = require("core/exception").Exception;
24var logger = require("core/logger").logger("blueprint"); 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 25
32/** 26/**
33 Description TODO 27 @private
34 @private 28 */
35*/ 29var _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: { 35var 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
117var 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 if (index < 0) {
191 if (mapping.owner !== this) {
192 throw new Error(
193 "Mapping already owned: " + JSON.stringify(mapping));
194 }
195 this.mappings.push(mapping);
196 //
197 this._addMappingForName(mapping);