Statistics
| Revision:

root / org.gvsig.wfs.app / trunk / org.gvsig.wfs.app / org.gvsig.wfs.app.mainplugin / src / main / java / org / gvsig / fmap / dal / store / wfs / WFSStoreParameters.java @ 10

History | View | Annotate | Download (12 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
* 
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
* 
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
* 
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
* MA  02110-1301, USA.
20
* 
21
*/
22

    
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2009 {Iver T.I.}   {Task}
26
*/
27
 
28
package org.gvsig.fmap.dal.store.wfs;
29

    
30
import org.gvsig.fmap.dal.DataParameters;
31
import org.gvsig.fmap.dal.DataStoreParameters;
32
import org.gvsig.fmap.dal.DataTypes;
33
import org.gvsig.fmap.dal.exception.InitializeException;
34
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException;
35
import org.gvsig.fmap.dal.spi.AbstractDataParameters;
36
import org.gvsig.fmap.geom.Geometry;
37
import org.gvsig.tools.ToolsLocator;
38
import org.gvsig.tools.dynobject.DelegatedDynObject;
39
import org.gvsig.tools.dynobject.DynClass;
40
import org.gvsig.tools.dynobject.DynStruct;
41
import org.gvsig.tools.persistence.PersistenceManager;
42

    
43
/**
44
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
45
 */
46
public class WFSStoreParameters extends AbstractDataParameters implements
47
 DataStoreParameters{
48
        protected static DynClass DYNCLASS = null;
49
        public static final String DYNCLASS_NAME = "WFSStoreParameters";
50
        
51
        public static final String DYNFIELDNAME_URL = "url";
52
        public static final String DYNFIELDNAME_VERSION = "version";
53
        public static final String DYNFIELDNAME_TYPENAME = "typeName";
54
        public static final String DYNFIELDNAME_NAMESPACE = "namespace";
55
        public static final String DYNFIELDNAME_NAMESPACEPREFIX = "namespacePrefix";
56
        public static final String DYNFIELDNAME_FIELDS = "fields";
57
        public static final String DYNFIELDNAME_FILTER_ENCODING_BY_ATTRIBUTE = "filterEncodingByAttribute";
58
        public static final String DYNFIELDNAME_MAXFEATURES = "maxFeatures";
59
        public static final String DYNFIELDNAME_TIMEOUT = "timeOut";
60
        public static final String DYNFIELDNAME_USER = "user";
61
        public static final String DYNFIELDNAME_PASSWORD = "password";
62
        public static final String DYNFIELDNAME_FILTER_BY_AREA_GEOMETRY = "filterByAreaGeometry";
63
        public static final String DYNFIELDNAME_FILTER_BY_AREA_OPERATION = "filterByAreaOperation";
64
        public static final String DYNFIELDNAME_FILTER_BY_AREA_ATTRIBUTE = "filterByAreaAttribute";
65
        public static final String DYNFIELDNAME_FILTER_BY_AREA_CRS = "filterByAreaCrs";
66

    
67
        private DelegatedDynObject delegatedDynObject;
68
                
69
        public WFSStoreParameters() {
70
                super();
71
                this.delegatedDynObject = (DelegatedDynObject) ToolsLocator
72
                .getDynObjectManager().createDynObject(
73
                        WFSStoreParameters.DYNCLASS);
74
        }                
75
        
76
        @Override
77
        protected DelegatedDynObject getDelegatedDynObject() {
78
                return delegatedDynObject;
79
        }
80

    
81
        public WFSStoreParameters(DataParameters dataParameters) throws InitializeException, ProviderNotRegisteredException{
82
                this();                        
83
                setUrl((String)dataParameters.getDynValue(WFSStoreParameters.DYNFIELDNAME_URL));
84
                String namespace = null;
85
                String namespacePrefix = null;
86
                if (dataParameters.hasDynValue(WFSStoreParameters.DYNFIELDNAME_NAMESPACE)){
87
                        namespace = (String)dataParameters.getDynValue(WFSStoreParameters.DYNFIELDNAME_NAMESPACE);
88
                }
89
                if (dataParameters.hasDynValue(WFSStoreParameters.DYNFIELDNAME_NAMESPACEPREFIX)){
90
                        namespacePrefix = (String)dataParameters.getDynValue(WFSStoreParameters.DYNFIELDNAME_NAMESPACEPREFIX);
91
                }
92
                setFeatureType(namespacePrefix, namespace,
93
                                (String)dataParameters.getDynValue(WFSStoreParameters.DYNFIELDNAME_TYPENAME));
94
                if (dataParameters.hasDynValue(WFSStoreParameters.DYNFIELDNAME_MAXFEATURES)){
95
                        setMaxFeatures((Integer)dataParameters.getDynValue(WFSStoreParameters.DYNFIELDNAME_MAXFEATURES));
96
                }else{
97
                        setMaxFeatures(1000);
98
                }
99
                if (dataParameters.hasDynValue(WFSStoreParameters.DYNFIELDNAME_TIMEOUT)){
100
                        setTimeOut((Integer)dataParameters.getDynValue(WFSStoreParameters.DYNFIELDNAME_TIMEOUT));
101
                }else{
102
                        setTimeOut(10000);
103
                }
104
                if (dataParameters.hasDynValue(WFSStoreParameters.DYNFIELDNAME_FILTER_BY_AREA_GEOMETRY)){
105
                        setFilterByAreaGeometry((Geometry)dataParameters.getDynValue(WFSStoreParameters.DYNFIELDNAME_FILTER_BY_AREA_GEOMETRY));
106
                        setFilterByAreaAttribute((String)dataParameters.getDynValue(WFSStoreParameters.DYNFIELDNAME_FILTER_BY_AREA_ATTRIBUTE));
107
                        setFilterByAreaCrs((String)dataParameters.getDynValue(WFSStoreParameters.DYNFIELDNAME_FILTER_BY_AREA_CRS));
108
                        setFilterByAreaOperation((Integer)dataParameters.getDynValue(WFSStoreParameters.DYNFIELDNAME_FILTER_BY_AREA_OPERATION));
109
                }
110
                if (dataParameters.hasDynValue(WFSStoreParameters.DYNFIELDNAME_VERSION)){
111
                        setVersion((String)dataParameters.getDynValue(WFSStoreParameters.DYNFIELDNAME_VERSION));
112
                }
113
                if (dataParameters.hasDynValue(WFSStoreParameters.DYNFIELDNAME_FILTER_ENCODING_BY_ATTRIBUTE)){
114
                        setFilterEncodingByAttribute((String)dataParameters.getDynValue(WFSStoreParameters.DYNFIELDNAME_FILTER_ENCODING_BY_ATTRIBUTE));
115
                }
116
                if (dataParameters.hasDynValue(WFSStoreParameters.DYNFIELDNAME_USER)){
117
                        setUser((String)dataParameters.getDynValue(WFSStoreParameters.DYNFIELDNAME_USER));
118
                }
119
                if (dataParameters.hasDynValue(WFSStoreParameters.DYNFIELDNAME_PASSWORD)){
120
                        setPassword((String)dataParameters.getDynValue(WFSStoreParameters.DYNFIELDNAME_PASSWORD));
121
                }
122
        }
123
        
124
        protected static void registerDynClass() {
125
                if (DYNCLASS == null) {
126
                        PersistenceManager manager = ToolsLocator.getPersistenceManager();
127
                        DynStruct definition = manager.addDefinition(
128
                                        WFSStoreParameters.class,
129
                                        DYNCLASS_NAME,
130
                                        "WFSStoreParameters Persistence definition",
131
                                        null, 
132
                                        null
133
                        );
134
                        definition.addDynFieldString(DYNFIELDNAME_URL)
135
                                .setDescription("URL of the WFS server")
136
                                .setMandatory(true);
137
                        
138
                        definition.addDynFieldString(DYNFIELDNAME_VERSION)
139
                                .setDescription("Version of the WFS server")
140
                                .setMandatory(false);
141
                        
142
                        definition.addDynFieldString(DYNFIELDNAME_TYPENAME)
143
                                .setDescription("Feature type to retrieve")
144
                                .setMandatory(true);
145
                        
146
                        definition.addDynFieldString(DYNFIELDNAME_NAMESPACE)
147
                                .setDescription("Namespace of the feature type to retrieve")
148
                                .setMandatory(false);
149
                        
150
                        definition.addDynFieldString(DYNFIELDNAME_NAMESPACEPREFIX)
151
                                .setDescription("Prefix of the namespace of the feature type to retrieve")
152
                                .setMandatory(false);
153
                        
154
                        definition.addDynFieldString(DYNFIELDNAME_FIELDS)
155
                                .setDescription("Fields to retrieve separated by ','")
156
                                .setMandatory(false);
157
                        
158
                        definition.addDynFieldString(DYNFIELDNAME_FILTER_ENCODING_BY_ATTRIBUTE)
159
                                .setDescription("Filter encoding request")
160
                                .setMandatory(false);
161
                        
162
                        definition.addDynFieldInt(DYNFIELDNAME_MAXFEATURES)
163
                                .setDescription("Number of features to retrieve")
164
                                .setMandatory(false);
165
                        
166
                        definition.addDynFieldInt(DYNFIELDNAME_TIMEOUT)
167
                                .setDescription("Timeout")
168
                                .setMandatory(false);
169
                        
170
                        definition.addDynFieldString(DYNFIELDNAME_USER)
171
                                .setDescription("User name (not used at this moment)")
172
                                .setMandatory(false);
173
                        
174
                        definition.addDynFieldString(DYNFIELDNAME_PASSWORD)
175
                                .setDescription("Passwrod (not used at this moment")
176
                                .setMandatory(false);                
177
                        
178
                        definition.addDynFieldObject(DYNFIELDNAME_FILTER_BY_AREA_GEOMETRY)
179
                                .setType(DataTypes.GEOMETRY)
180
                                .setDescription("Geometry used to do the filter")
181
                                .setMandatory(false);
182
                        
183
                        definition.addDynFieldInt(DYNFIELDNAME_FILTER_BY_AREA_OPERATION)
184
                                .setDescription("Geometry operation used to do the filter")
185
                                .setMandatory(false);
186
                        
187
                        definition.addDynFieldString(DYNFIELDNAME_FILTER_BY_AREA_ATTRIBUTE)
188
                                .setDescription("Attribute that contains the geometry")
189
                                .setMandatory(false);
190
                        
191
                        definition.addDynFieldString(DYNFIELDNAME_FILTER_BY_AREA_CRS)
192
                                .setDescription("CRS to do the query")
193
                                .setMandatory(false);
194
                        
195
                        DYNCLASS = (DynClass) definition;
196
                }
197
        }        
198

    
199
        /* (non-Javadoc)
200
         * @see org.gvsig.fmap.dal.DataStoreParameters#getDataStoreName()
201
         */
202
        public String getDataStoreName() {
203
                return WFSStoreProvider.NAME;
204
        }
205

    
206
        /* (non-Javadoc)
207
         * @see org.gvsig.fmap.dal.DataStoreParameters#getDescription()
208
         */
209
        public String getDescription() {
210
                return WFSStoreProvider.DESCRIPTION;
211
        }        
212

    
213
        /* (non-Javadoc)
214
         * @see org.gvsig.fmap.dal.DataStoreParameters#isValid()
215
         */
216
        public boolean isValid() {
217
                // TODO Auto-generated method stub
218
                return false;
219
        }
220
        
221
        public String getUrl(){
222
                return (String) this.getDynValue(DYNFIELDNAME_URL);
223
        }
224
        
225
        public void setUrl(String url){
226
                this.setDynValue(DYNFIELDNAME_URL, url);
227
        }
228
        
229
        public String getVersion(){
230
                return (String) this.getDynValue(DYNFIELDNAME_VERSION);
231
        }
232
        
233
        public void setVersion(String version){
234
                this.setDynValue(DYNFIELDNAME_VERSION, version);
235
        }
236
        
237
        public String getFeatureType(){
238
                return (String) this.getDynValue(DYNFIELDNAME_TYPENAME);
239
        }
240
        
241
        public void setFeatureType(String featureType){
242
                this.setDynValue(DYNFIELDNAME_TYPENAME, featureType);
243
        }
244
        
245
        public void setFeatureType(String namespace, String featureType){
246
                this.setDynValue(DYNFIELDNAME_NAMESPACE, namespace);
247
                this.setDynValue(DYNFIELDNAME_TYPENAME, featureType);
248
        }
249
        
250
        public void setFeatureType(String prefix, String namespace, String featureType){
251
                this.setDynValue(DYNFIELDNAME_NAMESPACEPREFIX, prefix);
252
                this.setDynValue(DYNFIELDNAME_NAMESPACE, namespace);
253
                this.setDynValue(DYNFIELDNAME_TYPENAME, featureType);
254
        }
255
        
256
        public String getFeatureNamespace(){
257
                return (String) this.getDynValue(DYNFIELDNAME_NAMESPACE);
258
        }
259
        
260
        public String getFeaturePrefix(){
261
                return (String) this.getDynValue(DYNFIELDNAME_NAMESPACEPREFIX);
262
        }
263
        
264
        public String getFields(){
265
                return (String) this.getDynValue(DYNFIELDNAME_FIELDS);
266
        }
267
        
268
        public void setFields(String fields){
269
                this.setDynValue(DYNFIELDNAME_FIELDS, fields);
270
        }
271
        
272
        public String getFilterEncodingByAttribute(){
273
                return (String) this.getDynValue(DYNFIELDNAME_FILTER_ENCODING_BY_ATTRIBUTE);
274
        }
275
        
276
        public void setFilterEncodingByAttribute(String filter){
277
                this.setDynValue(DYNFIELDNAME_FILTER_ENCODING_BY_ATTRIBUTE, filter);
278
        }
279
        
280
        public Integer getMaxFeatures(){
281
                return (Integer) this.getDynValue(DYNFIELDNAME_MAXFEATURES);
282
        }
283
        
284
        public void setMaxFeatures(Integer maxFeatures){
285
                this.setDynValue(DYNFIELDNAME_MAXFEATURES, maxFeatures);
286
        }
287
        
288
        public Integer getTimeOut(){
289
                return (Integer) this.getDynValue(DYNFIELDNAME_TIMEOUT);
290
        }
291
        
292
        public void setTimeOut(Integer timeOut){
293
                this.setDynValue(DYNFIELDNAME_TIMEOUT, timeOut);
294
        }        
295
        
296
        public String getUser(){
297
                return (String) this.getDynValue(DYNFIELDNAME_USER);
298
        }
299
        
300
        public void setUser(String user){
301
                this.setDynValue(DYNFIELDNAME_USER, user);
302
        }
303
        
304
        public String getPassword(){
305
                return (String) this.getDynValue(DYNFIELDNAME_PASSWORD);
306
        }
307
        
308
        public void setPassword(String password){
309
                this.setDynValue(DYNFIELDNAME_PASSWORD, password);
310
        }
311
        
312
        public Geometry getFilterByAreaGeometry(){
313
                return (Geometry) this.getDynValue(DYNFIELDNAME_FILTER_BY_AREA_GEOMETRY);
314
        }
315
        
316
        public void setFilterByAreaGeometry(Geometry area){
317
                this.setDynValue(DYNFIELDNAME_FILTER_BY_AREA_GEOMETRY, area);
318
        }
319
        
320
        public Integer getFilterByAreaOperation(){
321
                return (Integer) this.getDynValue(DYNFIELDNAME_FILTER_BY_AREA_OPERATION);
322
        }
323
        
324
        public void setFilterByAreaOperation(Integer operation){
325
                this.setDynValue(DYNFIELDNAME_FILTER_BY_AREA_OPERATION, operation);
326
        }
327
        
328
        public String getFilterByAreaCrs(){
329
                return (String) this.getDynValue(DYNFIELDNAME_FILTER_BY_AREA_CRS);
330
        }
331
        
332
        public void setFilterByAreaCrs(String crs){
333
                this.setDynValue(DYNFIELDNAME_FILTER_BY_AREA_CRS, crs);
334
        }
335
        
336
        public String getFilterByAreaAttribute(){
337
                return (String) this.getDynValue(DYNFIELDNAME_FILTER_BY_AREA_ATTRIBUTE);
338
        }
339
        
340
        public void setFilterByAreaAttribute(String attribute){
341
                this.setDynValue(DYNFIELDNAME_FILTER_BY_AREA_ATTRIBUTE, attribute);
342
        }
343
}
344