aboutsummaryrefslogtreecommitdiff
path: root/node_modules/montage/data/restaccess/reststore.js
blob: 9df05c2fd6957dffc3010f0a9de21530bedd03ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
/* <copyright>
This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
(c) Copyright 2011 Motorola Mobility, Inc.  All Rights Reserved.
</copyright> */
/**
	@module montage/data/restaccess/reststore
    @requires montage/core/core
    @requires montage/data/store
    @requires montage/core/logger
*/
var Montage = require("montage").Montage;
var Store = require("data/store").Store;
var Promise = require("core/promise").Promise;
var logger = require("core/logger").logger("reststore");

/**
    @class module:montage/data/restaccess/reststore.RestStore
    @extends module:montage/data/store.Store
*/
var RestStore = exports.RestStore = Montage.create(Store,/** @lends module:montage/data/restaccess/reststore.RestStore# */ {

/**
    Description TODO
    @function
    @param {Property} binder
    @returns {Boolean} true or false
    */
    canServiceBlueprintBinder: {
        value: function(binder) {
            if ((binder !== null) && (binder.storePrototypeName === "RestStore")) {
                // TODO [PJYF Apr 19 2011] We need to check that the connection url points to the same DB
                return true;
            }
            return false;
        }
    },

/**
    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)
    */
    pledgeForSourceObjectRelationship$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().init();
            }
            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.<br>
    Upon receiving this message the store should take steps to prepare the commit and insure it will succeed.<br>
    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.<br>
    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.<br>
    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([]);
        }
    }


});