summaryrefslogtreecommitdiff
path: root/includes/js/dojox/wire/ml/DataStore.js
blob: e366d05600e2babe097b43ed6d8d7edfb1bfe307 (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
if(!dojo._hasResource["dojox.wire.ml.DataStore"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.wire.ml.DataStore"] = true;
dojo.provide("dojox.wire.ml.DataStore");

dojo.require("dijit._Widget");
dojo.require("dojox.wire._base");

dojo.declare("dojox.wire.ml.DataStore", dijit._Widget, {
	//	summary:
	//		A widget for a data store
	//	description:
	//		This widget represents a data store of 'storeClass' attribute.
	//	storeClass:
	//		A class name of a data store
	storeClass: "",

	postCreate: function(){
		//	summary:
		//		Call _createStore()
		//	description:
		//		See _createStore().
		this.store = this._createStore();
	},

	_createStore: function(){
		//	summary:
		//		Create a data store
		//	desription:
		//		A data store of 'storeClass' is created with arguments
		//		specified with attributes.
		//	returns:
		//		A data store
		if(!this.storeClass){
			return null; //null
		}
		var storeClass = dojox.wire._getClass(this.storeClass);
		if(!storeClass){
			return null; //null
		}
		var args = {};
		var attributes = this.domNode.attributes;
		for(var i = 0; i < attributes.length; i++){
			var a = attributes.item(i);
			if(a.specified && !this[a.nodeName]){
				args[a.nodeName] = a.nodeValue;
			}
		}
		return new storeClass(args); //Object
	},

	getFeatures: function(){
		//	summary:
		//		Call getFeatures() method of a data store
		//	description:
		//		See dojo.data.api.Read.getFeatures().
		//	returns:
		//		A features object
		return this.store.getFeatures(); //Object
	},

	fetch: function(/*Object*/request){
		//	summary:
		//		Call fetch() method of a data store
		//	description:
		//		See dojo.data.api.Read.fetch().
		//	request:
		//		A request object
		//	returns:
		//		A request object
		return this.store.fetch(request); //Object
	},

	save: function(/*Object*/args){
		//	summary:
		//		Call save() method of a data store
		//	description:
		//		See dojo.data.api.Write.save().
		//	args:
		//		A save arguments object
		this.store.save(args);
	},

	newItem: function(/*Object*/args){
		//	summary:
		//		Call newItem() method of a data store
		//	description:
		//		See dojo.data.api.Write.newItem().
		//	args:
		//		A new item arguments object
		//	returns:
		//		A new item
		return this.store.newItem(args); //Object
	},

	deleteItem: function(/*Object*/item){
		//	summary:
		//		Call deleteItem() method of a data store
		//	description:
		//		See dojo.data.api.Write.deleteItem().
		//	returns:
		//		A boolean
		return this.store.deleteItem(item); //Boolean
	},

	revert: function(){
		//	summary:
		//		Call revert() method of a data store
		//	description:
		//		See dojo.data.api.Write.revert().
		//	returns:
		//		A boolean
		return this.store.revert(); //Boolean
	}
});

}