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 @ 112

History | View | Annotate | Download (13.9 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.apache.commons.lang3.BooleanUtils;
31
import org.gvsig.fmap.dal.DataParameters;
32
import org.gvsig.fmap.dal.DataStoreParameters;
33
import org.gvsig.fmap.dal.DataTypes;
34
import org.gvsig.fmap.dal.exception.InitializeException;
35
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException;
36
import org.gvsig.fmap.dal.spi.AbstractDataParameters;
37
import org.gvsig.fmap.geom.Geometry;
38
import org.gvsig.fmap.geom.primitive.Envelope;
39
import org.gvsig.tools.ToolsLocator;
40
import org.gvsig.tools.dynobject.DelegatedDynObject;
41
import org.gvsig.tools.dynobject.DynClass;
42
import org.gvsig.tools.dynobject.DynStruct;
43
import org.gvsig.tools.persistence.PersistenceManager;
44

    
45
/**
46
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
47
 */
48
public class WFSStoreParameters extends AbstractDataParameters implements
49
 DataStoreParameters{
50
        protected static DynClass DYNCLASS = null;
51
        public static final String DYNCLASS_NAME = "WFSStoreParameters";
52

    
53
        public static final String DYNFIELDNAME_URL = "url";
54
        public static final String DYNFIELDNAME_VERSION = "version";
55
        public static final String DYNFIELDNAME_TYPENAME = "typeName";
56
        public static final String DYNFIELDNAME_NAMESPACE = "namespace";
57
        public static final String DYNFIELDNAME_NAMESPACEPREFIX = "namespacePrefix";
58
        public static final String DYNFIELDNAME_FIELDS = "fields";
59
        public static final String DYNFIELDNAME_FILTER_ENCODING_BY_ATTRIBUTE = "filterEncodingByAttribute";
60
        public static final String DYNFIELDNAME_MAXFEATURES = "maxFeatures";
61
        public static final String DYNFIELDNAME_TIMEOUT = "timeOut";
62
        public static final String DYNFIELDNAME_USER = "user";
63
        public static final String DYNFIELDNAME_PASSWORD = "password";
64
        public static final String DYNFIELDNAME_FILTER_BY_AREA_GEOMETRY = "filterByAreaGeometry";
65
        public static final String DYNFIELDNAME_FILTER_BY_AREA_ENVELOPE = "filterByAreaEnvelope";
66
        public static final String DYNFIELDNAME_FILTER_BY_AREA_OPERATION = "filterByAreaOperation";
67
        public static final String DYNFIELDNAME_FILTER_BY_AREA_ATTRIBUTE = "filterByAreaAttribute";
68
        public static final String DYNFIELDNAME_FILTER_BY_AREA_CRS = "filterByAreaCrs";
69

    
70
        private DelegatedDynObject delegatedDynObject;
71

    
72
        public WFSStoreParameters() {
73
                super();
74
                this.delegatedDynObject = (DelegatedDynObject) ToolsLocator
75
                .getDynObjectManager().createDynObject(
76
                        WFSStoreParameters.DYNCLASS);
77
        }
78

    
79
        @Override
80
        protected DelegatedDynObject getDelegatedDynObject() {
81
                return delegatedDynObject;
82
        }
83

    
84
        public WFSStoreParameters(DataParameters dataParameters) throws InitializeException, ProviderNotRegisteredException{
85
                this();
86
                setUrl((String)dataParameters.getDynValue(WFSStoreParameters.DYNFIELDNAME_URL));
87
                String namespace = null;
88
                String namespacePrefix = null;
89
                if (dataParameters.hasDynValue(WFSStoreParameters.DYNFIELDNAME_NAMESPACE)){
90
                        namespace = (String)dataParameters.getDynValue(WFSStoreParameters.DYNFIELDNAME_NAMESPACE);
91
                }
92
                if (dataParameters.hasDynValue(WFSStoreParameters.DYNFIELDNAME_NAMESPACEPREFIX)){
93
                        namespacePrefix = (String)dataParameters.getDynValue(WFSStoreParameters.DYNFIELDNAME_NAMESPACEPREFIX);
94
                }
95
                setFeatureType(namespacePrefix, namespace,
96
                                (String)dataParameters.getDynValue(WFSStoreParameters.DYNFIELDNAME_TYPENAME));
97
                if (dataParameters.hasDynValue(WFSStoreParameters.DYNFIELDNAME_MAXFEATURES)){
98
                        setMaxFeatures((Integer)dataParameters.getDynValue(WFSStoreParameters.DYNFIELDNAME_MAXFEATURES));
99
                }else{
100
                        setMaxFeatures(1000);
101
                }
102
                if (dataParameters.hasDynValue(WFSStoreParameters.DYNFIELDNAME_TIMEOUT)){
103
                        setTimeOut((Integer)dataParameters.getDynValue(WFSStoreParameters.DYNFIELDNAME_TIMEOUT));
104
                }else{
105
                        setTimeOut(10000);
106
                }
107
                if (dataParameters.hasDynValue(WFSStoreParameters.DYNFIELDNAME_FILTER_BY_AREA_GEOMETRY)){
108
                        setFilterByAreaGeometry((Geometry)dataParameters.getDynValue(WFSStoreParameters.DYNFIELDNAME_FILTER_BY_AREA_GEOMETRY));
109
                        setFilterByAreaAttribute((String)dataParameters.getDynValue(WFSStoreParameters.DYNFIELDNAME_FILTER_BY_AREA_ATTRIBUTE));
110
                        setFilterByAreaCrs((String)dataParameters.getDynValue(WFSStoreParameters.DYNFIELDNAME_FILTER_BY_AREA_CRS));
111
                        setFilterByAreaOperation((Integer)dataParameters.getDynValue(WFSStoreParameters.DYNFIELDNAME_FILTER_BY_AREA_OPERATION));
112
                }
113
                if (dataParameters.hasDynValue(WFSStoreParameters.DYNFIELDNAME_FILTER_BY_AREA_ENVELOPE)){
114
                        setFilterByAreaEnvelope((Envelope)dataParameters.getDynValue(WFSStoreParameters.DYNFIELDNAME_FILTER_BY_AREA_ENVELOPE));
115
                        setFilterByAreaAttribute((String)dataParameters.getDynValue(WFSStoreParameters.DYNFIELDNAME_FILTER_BY_AREA_ATTRIBUTE));
116
                        setFilterByAreaCrs((String)dataParameters.getDynValue(WFSStoreParameters.DYNFIELDNAME_FILTER_BY_AREA_CRS));
117
                        setFilterByAreaOperation((Integer)dataParameters.getDynValue(WFSStoreParameters.DYNFIELDNAME_FILTER_BY_AREA_OPERATION));
118
                }
119
                if (dataParameters.hasDynValue(WFSStoreParameters.DYNFIELDNAME_VERSION)){
120
                        setVersion((String)dataParameters.getDynValue(WFSStoreParameters.DYNFIELDNAME_VERSION));
121
                }
122
                if (dataParameters.hasDynValue(WFSStoreParameters.DYNFIELDNAME_FILTER_ENCODING_BY_ATTRIBUTE)){
123
                        setFilterEncodingByAttribute((String)dataParameters.getDynValue(WFSStoreParameters.DYNFIELDNAME_FILTER_ENCODING_BY_ATTRIBUTE));
124
                }
125
                if (dataParameters.hasDynValue(WFSStoreParameters.DYNFIELDNAME_USER)){
126
                        setUser((String)dataParameters.getDynValue(WFSStoreParameters.DYNFIELDNAME_USER));
127
                }
128
                if (dataParameters.hasDynValue(WFSStoreParameters.DYNFIELDNAME_PASSWORD)){
129
                        setPassword((String)dataParameters.getDynValue(WFSStoreParameters.DYNFIELDNAME_PASSWORD));
130
                }
131
        }
132

    
133
        protected static void registerDynClass() {
134
                if (DYNCLASS == null) {
135
                        PersistenceManager manager = ToolsLocator.getPersistenceManager();
136
                        DynStruct definition = manager.addDefinition(
137
                                        WFSStoreParameters.class,
138
                                        DYNCLASS_NAME,
139
                                        "WFSStoreParameters Persistence definition",
140
                                        null,
141
                                        null
142
                        );
143
                        definition.addDynFieldString(DYNFIELDNAME_URL)
144
                                .setDescription("URL of the WFS server")
145
                                .setMandatory(true);
146

    
147
                        definition.addDynFieldString(DYNFIELDNAME_VERSION)
148
                                .setDescription("Version of the WFS server")
149
                                .setMandatory(false);
150

    
151
                        definition.addDynFieldString(DYNFIELDNAME_TYPENAME)
152
                                .setDescription("Feature type to retrieve")
153
                                .setMandatory(true);
154

    
155
                        definition.addDynFieldString(DYNFIELDNAME_NAMESPACE)
156
                                .setDescription("Namespace of the feature type to retrieve")
157
                                .setMandatory(false);
158

    
159
                        definition.addDynFieldString(DYNFIELDNAME_NAMESPACEPREFIX)
160
                                .setDescription("Prefix of the namespace of the feature type to retrieve")
161
                                .setMandatory(false);
162

    
163
                        definition.addDynFieldString(DYNFIELDNAME_FIELDS)
164
                                .setDescription("Fields to retrieve separated by ','")
165
                                .setMandatory(false);
166

    
167
                        definition.addDynFieldString(DYNFIELDNAME_FILTER_ENCODING_BY_ATTRIBUTE)
168
                                .setDescription("Filter encoding request")
169
                                .setMandatory(false);
170

    
171
                        definition.addDynFieldInt(DYNFIELDNAME_MAXFEATURES)
172
                                .setDescription("Number of features to retrieve")
173
                                .setMandatory(false);
174

    
175
                        definition.addDynFieldInt(DYNFIELDNAME_TIMEOUT)
176
                                .setDescription("Timeout")
177
                                .setMandatory(false);
178

    
179
                        definition.addDynFieldString(DYNFIELDNAME_USER)
180
                                .setDescription("User name (not used at this moment)")
181
                                .setMandatory(false);
182

    
183
                        definition.addDynFieldString(DYNFIELDNAME_PASSWORD)
184
                                .setDescription("Password (not used at this moment")
185
                                .setMandatory(false);
186

    
187
                        definition.addDynFieldObject(DYNFIELDNAME_FILTER_BY_AREA_GEOMETRY)
188
                                .setType(DataTypes.GEOMETRY)
189
                                .setDescription("Geometry used to do the filter")
190
                                .setMandatory(false);
191

    
192
                        definition.addDynFieldObject(DYNFIELDNAME_FILTER_BY_AREA_ENVELOPE)
193
                        .setType(DataTypes.ENVELOPE)
194
                        .setDescription("Envelope used to do the filter")
195
                        .setMandatory(false);
196

    
197
                        definition.addDynFieldInt(DYNFIELDNAME_FILTER_BY_AREA_OPERATION)
198
                                .setDescription("Geometry operation used to do the filter")
199
                                .setMandatory(false);
200

    
201
                        definition.addDynFieldString(DYNFIELDNAME_FILTER_BY_AREA_ATTRIBUTE)
202
                                .setDescription("Attribute that contains the geometry")
203
                                .setMandatory(false);
204

    
205
                        definition.addDynFieldString(DYNFIELDNAME_FILTER_BY_AREA_CRS)
206
                                .setDescription("CRS to do the query")
207
                                .setMandatory(false);
208

    
209
                        definition.addDynFieldBoolean("useAxisOrderYX")
210
                                .setDefaultFieldValue("false")
211
                                .setMandatory(false);
212

    
213
                        definition.addDynFieldBoolean("ignoreCache")
214
                                .setDefaultFieldValue("false")
215
                                .setMandatory(false);
216

    
217
                        DYNCLASS = (DynClass) definition;
218
                }
219
        }
220

    
221
        /* (non-Javadoc)
222
         * @see org.gvsig.fmap.dal.DataStoreParameters#getDataStoreName()
223
         */
224
        public String getDataStoreName() {
225
                return WFSStoreProvider.NAME;
226
        }
227

    
228
        /* (non-Javadoc)
229
         * @see org.gvsig.fmap.dal.DataStoreParameters#getDescription()
230
         */
231
        public String getDescription() {
232
                return WFSStoreProvider.DESCRIPTION;
233
        }
234

    
235
        /* (non-Javadoc)
236
         * @see org.gvsig.fmap.dal.DataStoreParameters#isValid()
237
         */
238
        public boolean isValid() {
239
                // TODO Auto-generated method stub
240
                return false;
241
        }
242

    
243
        public String getUrl(){
244
                return (String) this.getDynValue(DYNFIELDNAME_URL);
245
        }
246

    
247
        public void setUrl(String url){
248
                this.setDynValue(DYNFIELDNAME_URL, url);
249
        }
250

    
251
        public String getVersion(){
252
                return (String) this.getDynValue(DYNFIELDNAME_VERSION);
253
        }
254

    
255
        public void setVersion(String version){
256
                this.setDynValue(DYNFIELDNAME_VERSION, version);
257
        }
258

    
259
        public String getFeatureType(){
260
                return (String) this.getDynValue(DYNFIELDNAME_TYPENAME);
261
        }
262

    
263
        public void setFeatureType(String featureType){
264
                this.setDynValue(DYNFIELDNAME_TYPENAME, featureType);
265
        }
266

    
267
        public void setFeatureType(String namespace, String featureType){
268
                this.setDynValue(DYNFIELDNAME_NAMESPACE, namespace);
269
                this.setDynValue(DYNFIELDNAME_TYPENAME, featureType);
270
        }
271

    
272
        public void setFeatureType(String prefix, String namespace, String featureType){
273
                this.setDynValue(DYNFIELDNAME_NAMESPACEPREFIX, prefix);
274
                this.setDynValue(DYNFIELDNAME_NAMESPACE, namespace);
275
                this.setDynValue(DYNFIELDNAME_TYPENAME, featureType);
276
        }
277

    
278
        public String getFeatureNamespace(){
279
                return (String) this.getDynValue(DYNFIELDNAME_NAMESPACE);
280
        }
281

    
282
        public String getFeaturePrefix(){
283
                return (String) this.getDynValue(DYNFIELDNAME_NAMESPACEPREFIX);
284
        }
285

    
286
        public String getFields(){
287
                return (String) this.getDynValue(DYNFIELDNAME_FIELDS);
288
        }
289

    
290
        public void setFields(String fields){
291
                this.setDynValue(DYNFIELDNAME_FIELDS, fields);
292
        }
293

    
294
        public String getFilterEncodingByAttribute(){
295
                return (String) this.getDynValue(DYNFIELDNAME_FILTER_ENCODING_BY_ATTRIBUTE);
296
        }
297

    
298
        public void setFilterEncodingByAttribute(String filter){
299
                this.setDynValue(DYNFIELDNAME_FILTER_ENCODING_BY_ATTRIBUTE, filter);
300
        }
301

    
302
        public Integer getMaxFeatures(){
303
                return (Integer) this.getDynValue(DYNFIELDNAME_MAXFEATURES);
304
        }
305

    
306
        public void setMaxFeatures(Integer maxFeatures){
307
                this.setDynValue(DYNFIELDNAME_MAXFEATURES, maxFeatures);
308
        }
309

    
310
        public Integer getTimeOut(){
311
                return (Integer) this.getDynValue(DYNFIELDNAME_TIMEOUT);
312
        }
313

    
314
        public void setTimeOut(Integer timeOut){
315
                this.setDynValue(DYNFIELDNAME_TIMEOUT, timeOut);
316
        }
317

    
318
        public String getUser(){
319
                return (String) this.getDynValue(DYNFIELDNAME_USER);
320
        }
321

    
322
        public void setUser(String user){
323
                this.setDynValue(DYNFIELDNAME_USER, user);
324
        }
325

    
326
        public String getPassword(){
327
                return (String) this.getDynValue(DYNFIELDNAME_PASSWORD);
328
        }
329

    
330
        public void setPassword(String password){
331
                this.setDynValue(DYNFIELDNAME_PASSWORD, password);
332
        }
333

    
334
        public Geometry getFilterByAreaGeometry(){
335
                return (Geometry) this.getDynValue(DYNFIELDNAME_FILTER_BY_AREA_GEOMETRY);
336
        }
337

    
338
        public void setFilterByAreaGeometry(Geometry area){
339
                this.setDynValue(DYNFIELDNAME_FILTER_BY_AREA_GEOMETRY, area);
340
        }
341

    
342
        public Envelope getFilterByAreaEnvelope(){
343
                return (Envelope) this.getDynValue(DYNFIELDNAME_FILTER_BY_AREA_ENVELOPE);
344
        }
345

    
346
        public void setFilterByAreaEnvelope(Envelope area){
347
                this.setDynValue(DYNFIELDNAME_FILTER_BY_AREA_ENVELOPE, area);
348
        }
349

    
350
        public Integer getFilterByAreaOperation(){
351
                return (Integer) this.getDynValue(DYNFIELDNAME_FILTER_BY_AREA_OPERATION);
352
        }
353

    
354
        public void setFilterByAreaOperation(Integer operation){
355
                this.setDynValue(DYNFIELDNAME_FILTER_BY_AREA_OPERATION, operation);
356
        }
357

    
358
        public String getFilterByAreaCrs(){
359
                return (String) this.getDynValue(DYNFIELDNAME_FILTER_BY_AREA_CRS);
360
        }
361

    
362
        public void setFilterByAreaCrs(String crs){
363
                this.setDynValue(DYNFIELDNAME_FILTER_BY_AREA_CRS, crs);
364
        }
365

    
366
        public String getFilterByAreaAttribute(){
367
                return (String) this.getDynValue(DYNFIELDNAME_FILTER_BY_AREA_ATTRIBUTE);
368
        }
369

    
370
        public void setFilterByAreaAttribute(String attribute){
371
                this.setDynValue(DYNFIELDNAME_FILTER_BY_AREA_ATTRIBUTE, attribute);
372
        }
373

    
374
        public boolean getUseAxisOrderYX() {
375
            Boolean x = (Boolean) this.getDynValue("useAxisOrderYX");
376
            return BooleanUtils.isTrue(x);
377
        }
378

    
379
        public void setUseAxisOrderYX(boolean useAxisOrderYX){
380
            this.setDynValue("useAxisOrderYX", new Boolean(useAxisOrderYX));
381
        }
382

    
383
        public boolean getIgnoreCache() {
384
            Boolean x = (Boolean) this.getDynValue("ignoreCache");
385
            return BooleanUtils.isTrue(x);
386
        }
387

    
388
        public void setIgnoreCache(boolean ignoreCache){
389
            this.setDynValue("ignoreCache", new Boolean(ignoreCache));
390
        }
391
}
392