From 8fe92b94ce5e1e2857d088752d94e19db7e3d8a8 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Sun, 17 Jun 2012 22:31:44 -0700 Subject: montage v11 merge into ninja Signed-off-by: Valerio Virgillito --- .../montage/data/rest-access/rest-store.js | 221 +++++++++++++++++++++ 1 file changed, 221 insertions(+) create mode 100755 node_modules/montage/data/rest-access/rest-store.js (limited to 'node_modules/montage/data/rest-access/rest-store.js') diff --git a/node_modules/montage/data/rest-access/rest-store.js b/node_modules/montage/data/rest-access/rest-store.js new file mode 100755 index 00000000..28dbd650 --- /dev/null +++ b/node_modules/montage/data/rest-access/rest-store.js @@ -0,0 +1,221 @@ +/* + This file contains proprietary software owned by Motorola Mobility, Inc.
+ No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
+ (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. +
*/ +/** + @module montage/data/rest-access/rest-store + @requires montage/core/core + @requires montage/data/store + @requires montage/core/logger + @requires montage/core/promise + @requires data/rest-access/rest-mapping + */ +var Montage = require("montage").Montage; +var Store = require("data/store").Store; +var Promise = require("core/promise").Promise; +var RestBinderMapping = require("data/rest-access/rest-mapping").RestBinderMapping; +var RestBlueprintMapping = require("data/rest-access/rest-mapping").RestBlueprintMapping; +var RestAttributeMapping = require("data/rest-access/rest-mapping").RestAttributeMapping; +var RestAssociationMapping = require("data/rest-access/rest-mapping").RestAssociationMapping; + +var logger = require("core/logger").logger("rest-store"); + +/** + @class module:montage/data/rest-access/rest-store.RestStore + @extends module:montage/data/store.Store + */ +var RestStore = exports.RestStore = Montage.create(Store, /** @lends module:montage/data/rest-access/rest-store.RestStore# */ { + + /** + Create a new binder mapping. + @function + @returns binder mapping + */ + createBinderMapping:{ + get:function () { + return RestBinderMapping.create(); + } + }, + + /** + Create a new blueprint mapping. + @function + @returns blueprint mapping + */ + createBlueprintMapping:{ + get:function () { + return RestBlueprintMapping.create(); + } + }, + + /** + Create a new attribute mapping. + @function + @returns attribute mapping + */ + createAttributeMapping:{ + get:function () { + return RestAttributeMapping.create(); + } + }, + + /** + Create a new association mapping. + @function + @returns association mapping + */ + createAssociationMapping:{ + get:function () { + return RestAssociationMapping.create(); + } + }, + + /** + Description TODO + @function + @param {Object} object TODO + @param {Property} context TODO + @param {Property} transactionId TODO + @returns {Function} Promise.ref(object.objectId) or Promise.ref(null) + */ + permanentIdForObjectId$Implementation:{ + value:function (object, context, transactionId) { + // TODO [PJYF Apr 28 2011] We need to implement it. + if (typeof object.objectId !== "undefined") { + return Promise.ref(object.objectId); + } + return Promise.ref(null); + } + }, + + /** + Description TODO + @function + @param {Object} objectId TODO + @param {Property} context TODO + @param {Property} transactionId TODO + @returns {Function} Promise.ref(null) + */ + pledgeForObjectId$Implementation:{ + value:function (objectId, context, transactionId) { + // TODO [PJYF Apr 28 2011] We need to implement it. + return Promise.ref(null); + } + }, + + /** + Description TODO + @function + @param {Object} sourceObject TODO + @param {Property} relationship TODO + @param {Property} context TODO + @param {Property} transactionId TODO + @returns {Function} Promise.ref(null) + */ + pledgeForSourceObjectAssociation$Implementation:{ + value:function (sourceObject, relationship, context, transactionId) { + // TODO [PJYF Apr 28 2011] We need to implement it. + return Promise.ref(null); + } + }, + + /** + Description TODO + @function + @param {Object} object TODO + @param {Property} context TODO + @param {Property} transactionId TODO + @returns {Function} Promise.ref(object) + */ + initializeObject$Implementation:{ + value:function (object, context, transactionId) { + if (typeof object.objectId === "undefined") { + // TODO [PJYF June 17 2011] This will need to be revisited. + object.objectId = TemporaryObjectId.create().initWithBlueprint(object.blueprint); + } + return Promise.ref(object); + } + }, + + /** + Description TODO + @function + @param {Object} object TODO + @param {Property} context TODO + @param {Property} transactionId TODO + @returns {Function} this.pledgeForObjectId(object.objectId, context, transactionId) or Promise.ref(object) + */ + repledgeObject$Implementation:{ + value:function (object, context, transactionId) { + if (typeof object.objectId !== "undefined") { + return this.pledgeForObjectId(object.objectId, context, transactionId); + } + return Promise.ref(object); + } + + }, + + /** + Called on each store before a save.
+ Upon receiving this message the store should take steps to prepare the commit and insure it will succeed.
+ If the commit cannot succeed it should return a rejected promise. + @function + @param {Property} context TODO + @param {Property} transactionId TODO + @returns {Function} Promise.ref(true) + */ + prepareToSaveChangesInContext$Implementation:{ + value:function (context, transactionId) { + // TODO [PJYF Sep 27 2011] This needs to be reimplemented + return Promise.ref(true); + } + }, + + /** + Called on each store before a revert to prepare a save.
+ Any step taken to prepare the save should be rolled back. + @function + @param {Property} context TODO + @param {Property} transactionId TODO + @returns {Function} Promise.ref(true) + */ + cancelSaveChangesInContext$Implementation:{ + value:function (context, transactionId) { + // TODO [PJYF Sep 27 2011] This needs to be reimplemented + return Promise.ref(true); + } + }, + + /** + Commits the transaction.
+ Any failure during this step will cause the store to be left an inconsistent state. + @function + @param {Property} context TODO + @param {Property} transactionId TODO + @returns {Function} Promise.ref(true) + */ + commitChangesInContext$Implementation:{ + value:function (context, transactionId) { + // TODO [PJYF Sep 27 2011] This needs to be reimplemented + return Promise.ref(true); + } + }, + + /** + Description TODO + @function + @param {Property} query TODO + @param {Property} context TODO + @param {Property} transactionId TODO + @returns {Function} Promise.ref([]) + */ + queryInContext$Implementation:{ + value:function (query, context, transactionID) { + // TODO [PJYF Sept 4 2011] This needs to be implemented + return Promise.ref([]); + } + } + + +}); -- cgit v1.2.3