~mortenoh/+junk/dhis2-detailed-import-export

« back to all changes in this revision

Viewing changes to gis/dhis-gis-geostat/mfbase/openlayers/lib/OpenLayers/Protocol.js

  • Committer: larshelge at gmail
  • Date: 2009-03-03 16:46:36 UTC
  • Revision ID: larshelge@gmail.com-20090303164636-2sjlrquo7ib1gf7r
Initial check-in

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD
 
2
 * license.  See http://svn.openlayers.org/trunk/openlayers/license.txt for the
 
3
 * full text of the license. */
 
4
 
 
5
/**
 
6
 * Class: OpenLayers.Protocol
 
7
 * Abstract vector layer protocol class.  Not to be instantiated directly.  Use
 
8
 *     one of the protocol subclasses instead.
 
9
 */
 
10
OpenLayers.Protocol = OpenLayers.Class({
 
11
    
 
12
    /**
 
13
     * Property: format
 
14
     * {<OpenLayers.Format>} The format used by this protocol.
 
15
     */
 
16
    format: null,
 
17
    
 
18
    /**
 
19
     * Property: options
 
20
     * {Object} Any options sent to the constructor.
 
21
     */
 
22
    options: null,
 
23
 
 
24
    /**
 
25
     * Property: autoDestroy
 
26
     * {Boolean} The creator of the protocol can set autoDestroy to false
 
27
     *      to fully control when the protocol is destroyed. Defaults to
 
28
     *      true.
 
29
     */
 
30
    autoDestroy: true,
 
31
   
 
32
    /**
 
33
     * Constructor: OpenLayers.Protocol
 
34
     * Abstract class for vector protocols.  Create instances of a subclass.
 
35
     *
 
36
     * Parameters:
 
37
     * options - {Object} Optional object whose properties will be set on the
 
38
     *     instance.
 
39
     */
 
40
    initialize: function(options) {
 
41
        options = options || {};
 
42
        OpenLayers.Util.extend(this, options);
 
43
        this.options = options;
 
44
    },
 
45
 
 
46
    /**
 
47
     * APIMethod: destroy
 
48
     * Clean up the protocol.
 
49
     */
 
50
    destroy: function() {
 
51
        this.options = null;
 
52
        this.format = null;
 
53
    },
 
54
    
 
55
    /**
 
56
     * Method: read
 
57
     * Construct a request for reading new features.
 
58
     *
 
59
     * Parameters:
 
60
     * options - {Object} Optional object for configuring the request.
 
61
     *
 
62
     * Returns:
 
63
     * {<OpenLayers.Protocol.Response>} An <OpenLayers.Protocol.Response>
 
64
     * object, the same object will be passed to the callback function passed
 
65
     * if one exists in the options object.
 
66
     */
 
67
    read: function() {
 
68
    },
 
69
    
 
70
    
 
71
    /**
 
72
     * Method: create
 
73
     * Construct a request for writing newly created features.
 
74
     *
 
75
     * Parameters:
 
76
     * features - {Array({<OpenLayers.Feature.Vector>})} or
 
77
     *            {<OpenLayers.Feature.Vector>}
 
78
     * options - {Object} Optional object for configuring the request.
 
79
     *
 
80
     * Returns:
 
81
     * {<OpenLayers.Protocol.Response>} An <OpenLayers.Protocol.Response>
 
82
     * object, the same object will be passed to the callback function passed
 
83
     * if one exists in the options object.
 
84
     */
 
85
    create: function() {
 
86
    },
 
87
    
 
88
    /**
 
89
     * Method: update
 
90
     * Construct a request updating modified features.
 
91
     *
 
92
     * Parameters:
 
93
     * features - {Array({<OpenLayers.Feature.Vector>})} or
 
94
     *            {<OpenLayers.Feature.Vector>}
 
95
     * options - {Object} Optional object for configuring the request.
 
96
     *
 
97
     * Returns:
 
98
     * {<OpenLayers.Protocol.Response>} An <OpenLayers.Protocol.Response>
 
99
     * object, the same object will be passed to the callback function passed
 
100
     * if one exists in the options object.
 
101
     */
 
102
    update: function() {
 
103
    },
 
104
    
 
105
    /**
 
106
     * Method: delete
 
107
     * Construct a request deleting a removed feature.
 
108
     *
 
109
     * Parameters:
 
110
     * feature - {<OpenLayers.Feature.Vector>}
 
111
     * options - {Object} Optional object for configuring the request.
 
112
     *
 
113
     * Returns:
 
114
     * {<OpenLayers.Protocol.Response>} An <OpenLayers.Protocol.Response>
 
115
     * object, the same object will be passed to the callback function passed
 
116
     * if one exists in the options object.
 
117
     */
 
118
    "delete": function() {
 
119
    },
 
120
 
 
121
    /**
 
122
     * Method: commit
 
123
     * Go over the features and for each take action
 
124
     * based on the feature state. Possible actions are create,
 
125
     * update and delete.
 
126
     *
 
127
     * Parameters:
 
128
     * features - {Array({<OpenLayers.Feature.Vector>})}
 
129
     * options - {Object} Object whose possible keys are "create", "update",
 
130
     *      "delete", "callback" and "scope", the values referenced by the
 
131
     *      first three are objects as passed to the "create", "update", and
 
132
     *      "delete" methods, the value referenced by the "callback" key is
 
133
     *      a function which is called when the commit operation is complete
 
134
     *      using the scope referenced by the "scope" key.
 
135
     *
 
136
     * Returns:
 
137
     * {Array({<OpenLayers.Protocol.Response>})} An array of
 
138
     * <OpenLayers.Protocol.Response> objects.
 
139
     */
 
140
    commit: function() {
 
141
    },
 
142
   
 
143
    CLASS_NAME: "OpenLayers.Protocol" 
 
144
});
 
145
 
 
146
/**
 
147
 * Class: OpenLayers.Protocol.Response
 
148
 * Protocols return Response objects to their users.
 
149
 */
 
150
OpenLayers.Protocol.Response = OpenLayers.Class({
 
151
    /**
 
152
     * Property: code
 
153
     * {Number} - OpenLayers.Protocol.Response.SUCCESS or
 
154
     *            OpenLayers.Protocol.Response.FAILURE
 
155
     */
 
156
    code: null,
 
157
 
 
158
    /**
 
159
     * Property: requestType
 
160
     * {String} The type of request this response corresponds to. Either
 
161
     *      "create", "read", "update" or "delete".
 
162
     */
 
163
    requestType: null,
 
164
 
 
165
    /**
 
166
     * Property: last
 
167
     * {Boolean} - true if this is the last response expected in a commit,
 
168
     * false otherwise, defaults to true.
 
169
     */
 
170
    last: true,
 
171
 
 
172
    /**
 
173
     * Property: features
 
174
     * {Array({<OpenLayers.Feature.Vector>})} or {<OpenLayers.Feature.Vector>}
 
175
     * The features returned in the response by the server.
 
176
     */
 
177
    features: null,
 
178
 
 
179
    /**
 
180
     * Property: reqFeatures
 
181
     * {Array({<OpenLayers.Feature.Vector>})} or {<OpenLayers.Feature.Vector>}
 
182
     * The features provided by the user and placed in the request by the
 
183
     *      protocol.
 
184
     */
 
185
    reqFeatures: null,
 
186
 
 
187
    /**
 
188
     * Property: priv
 
189
     */
 
190
    priv: null,
 
191
 
 
192
    /**
 
193
     * Constructor: OpenLayers.Protocol.Response
 
194
     *
 
195
     * Parameters:
 
196
     * options - {Object} Optional object whose properties will be set on the
 
197
     *     instance.
 
198
     */
 
199
    initialize: function(options) {
 
200
        OpenLayers.Util.extend(this, options);
 
201
    },
 
202
 
 
203
    /**
 
204
     * Method: success
 
205
     *
 
206
     * Returns:
 
207
     * {Boolean} - true on success, false otherwise
 
208
     */
 
209
    success: function() {
 
210
        return this.code > 0;
 
211
    },
 
212
 
 
213
    CLASS_NAME: "OpenLayers.Protocol.Response"
 
214
});
 
215
 
 
216
OpenLayers.Protocol.Response.SUCCESS = 1;
 
217
OpenLayers.Protocol.Response.FAILURE = 0;