root / org.gvsig.wfs.app / trunk / org.gvsig.wfs.app / org.gvsig.wfs.app.mainplugin / src / main / java / org / gvsig / fmap / dal / store / wfs / WFSBaseStoreParameters.java @ 416
History | View | Annotate | Download (12.5 KB)
1 |
|
---|---|
2 |
package org.gvsig.fmap.dal.store.wfs; |
3 |
|
4 |
import org.apache.commons.lang3.BooleanUtils; |
5 |
import org.cresques.cts.IProjection; |
6 |
import org.gvsig.fmap.dal.DataParameters; |
7 |
import org.gvsig.fmap.dal.DataStoreParameters; |
8 |
import org.gvsig.fmap.dal.DataTypes; |
9 |
import org.gvsig.fmap.dal.exception.InitializeException; |
10 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
11 |
import org.gvsig.fmap.dal.spi.AbstractDataParameters; |
12 |
import org.gvsig.fmap.geom.Geometry; |
13 |
import org.gvsig.fmap.geom.primitive.Envelope; |
14 |
import org.gvsig.tools.ToolsLocator; |
15 |
import org.gvsig.tools.dynobject.DelegatedDynObject; |
16 |
import org.gvsig.tools.dynobject.DynClass; |
17 |
import org.gvsig.tools.dynobject.DynStruct; |
18 |
import org.gvsig.tools.persistence.PersistenceManager; |
19 |
|
20 |
|
21 |
public abstract class WFSBaseStoreParameters |
22 |
extends AbstractDataParameters
|
23 |
implements DataStoreParameters
|
24 |
{ |
25 |
protected static DynClass DYNCLASS = null; |
26 |
|
27 |
public static final String FIELD_URL = "url"; |
28 |
public static final String FIELD_VERSION = "version"; |
29 |
public static final String FIELD_TYPENAME = "typeName"; |
30 |
public static final String FIELD_NAMESPACE = "namespace"; |
31 |
public static final String DYNFIELDNAME_NAMESPACEPREFIX = "namespacePrefix"; |
32 |
public static final String DYNFIELDNAME_FIELDS = "fields"; |
33 |
public static final String FIELD_FILTER_ENCODING_BY_ATTRIBUTE = "filterEncodingByAttribute"; |
34 |
public static final String DYNFIELDNAME_MAXFEATURES = "maxFeatures"; |
35 |
public static final String DYNFIELDNAME_TIMEOUT = "timeOut"; |
36 |
public static final String DYNFIELDNAME_USER = "user"; |
37 |
public static final String DYNFIELDNAME_PASSWORD = "password"; |
38 |
public static final String DYNFIELDNAME_FILTER_BY_AREA_GEOMETRY = "filterByAreaGeometry"; |
39 |
public static final String DYNFIELDNAME_FILTER_BY_AREA_ENVELOPE = "filterByAreaEnvelope"; |
40 |
public static final String DYNFIELDNAME_FILTER_BY_AREA_OPERATION = "filterByAreaOperation"; |
41 |
public static final String DYNFIELDNAME_FILTER_BY_AREA_ATTRIBUTE = "filterByAreaAttribute"; |
42 |
public static final String DYNFIELDNAME_FILTER_BY_AREA_CRS = "filterByAreaCrs"; |
43 |
public static final String DYNFIELDNAME_CRS = "Crs"; |
44 |
|
45 |
private DelegatedDynObject delegatedDynObject;
|
46 |
|
47 |
public WFSBaseStoreParameters() {
|
48 |
super();
|
49 |
this.delegatedDynObject = (DelegatedDynObject) ToolsLocator
|
50 |
.getDynObjectManager().createDynObject(DYNCLASS); |
51 |
} |
52 |
|
53 |
@Override
|
54 |
protected DelegatedDynObject getDelegatedDynObject() {
|
55 |
return delegatedDynObject;
|
56 |
} |
57 |
|
58 |
protected abstract String getStoreParametersName(); |
59 |
|
60 |
public WFSBaseStoreParameters(DataParameters dataParameters) throws InitializeException, ProviderNotRegisteredException{ |
61 |
this();
|
62 |
setUrl((String)dataParameters.getDynValue(FIELD_URL));
|
63 |
String namespace = null; |
64 |
String namespacePrefix = null; |
65 |
if (dataParameters.hasDynValue(FIELD_NAMESPACE)){
|
66 |
namespace = (String)dataParameters.getDynValue(FIELD_NAMESPACE);
|
67 |
} |
68 |
if (dataParameters.hasDynValue(DYNFIELDNAME_NAMESPACEPREFIX)){
|
69 |
namespacePrefix = (String)dataParameters.getDynValue(DYNFIELDNAME_NAMESPACEPREFIX);
|
70 |
} |
71 |
setFeatureType(namespacePrefix, namespace, |
72 |
(String)dataParameters.getDynValue(FIELD_TYPENAME));
|
73 |
if (dataParameters.hasDynValue(DYNFIELDNAME_MAXFEATURES)){
|
74 |
setMaxFeatures((Integer)dataParameters.getDynValue(DYNFIELDNAME_MAXFEATURES));
|
75 |
}else{
|
76 |
setMaxFeatures(1000);
|
77 |
} |
78 |
if (dataParameters.hasDynValue(DYNFIELDNAME_TIMEOUT)){
|
79 |
setTimeOut((Integer)dataParameters.getDynValue(DYNFIELDNAME_TIMEOUT));
|
80 |
}else{
|
81 |
setTimeOut(10000);
|
82 |
} |
83 |
if (dataParameters.hasDynValue(DYNFIELDNAME_FILTER_BY_AREA_GEOMETRY)){
|
84 |
setFilterByAreaGeometry((Geometry)dataParameters.getDynValue(DYNFIELDNAME_FILTER_BY_AREA_GEOMETRY)); |
85 |
setFilterByAreaAttribute((String)dataParameters.getDynValue(DYNFIELDNAME_FILTER_BY_AREA_ATTRIBUTE));
|
86 |
setFilterByAreaCrs((IProjection)dataParameters.getDynValue(DYNFIELDNAME_FILTER_BY_AREA_CRS)); |
87 |
setFilterByAreaOperation((Integer)dataParameters.getDynValue(DYNFIELDNAME_FILTER_BY_AREA_OPERATION));
|
88 |
} |
89 |
if (dataParameters.hasDynValue(DYNFIELDNAME_FILTER_BY_AREA_ENVELOPE)){
|
90 |
setFilterByAreaEnvelope((Envelope)dataParameters.getDynValue(DYNFIELDNAME_FILTER_BY_AREA_ENVELOPE)); |
91 |
setFilterByAreaAttribute((String)dataParameters.getDynValue(DYNFIELDNAME_FILTER_BY_AREA_ATTRIBUTE));
|
92 |
setFilterByAreaCrs((IProjection)dataParameters.getDynValue(DYNFIELDNAME_FILTER_BY_AREA_CRS)); |
93 |
setFilterByAreaOperation((Integer)dataParameters.getDynValue(DYNFIELDNAME_FILTER_BY_AREA_OPERATION));
|
94 |
} |
95 |
if (dataParameters.hasDynValue(FIELD_VERSION)){
|
96 |
setVersion((String)dataParameters.getDynValue(FIELD_VERSION));
|
97 |
} |
98 |
if (dataParameters.hasDynValue(FIELD_FILTER_ENCODING_BY_ATTRIBUTE)){
|
99 |
setFilterEncodingByAttribute((String)dataParameters.getDynValue(FIELD_FILTER_ENCODING_BY_ATTRIBUTE));
|
100 |
} |
101 |
if (dataParameters.hasDynValue(DYNFIELDNAME_USER)){
|
102 |
setUser((String)dataParameters.getDynValue(DYNFIELDNAME_USER));
|
103 |
} |
104 |
if (dataParameters.hasDynValue(DYNFIELDNAME_PASSWORD)){
|
105 |
setPassword((String)dataParameters.getDynValue(DYNFIELDNAME_PASSWORD));
|
106 |
} |
107 |
if (dataParameters.hasDynValue(DYNFIELDNAME_CRS)){
|
108 |
setCrs((String)dataParameters.getDynValue(DYNFIELDNAME_CRS));
|
109 |
} |
110 |
} |
111 |
|
112 |
protected static void registerParameterClass(Class parametersClass, String parametersName) { |
113 |
if (DYNCLASS == null) { |
114 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
115 |
DynStruct definition = manager.addDefinition( |
116 |
parametersClass, |
117 |
parametersName, |
118 |
parametersName + " Persistence definition",
|
119 |
null,
|
120 |
null
|
121 |
); |
122 |
definition.addDynFieldString(FIELD_URL) |
123 |
.setDescription("URL of the WFS server")
|
124 |
.setMandatory(true);
|
125 |
|
126 |
definition.addDynFieldString(FIELD_VERSION) |
127 |
.setDescription("Version of the WFS server")
|
128 |
.setMandatory(false);
|
129 |
|
130 |
definition.addDynFieldString(FIELD_TYPENAME) |
131 |
.setDescription("Feature type to retrieve")
|
132 |
.setMandatory(true);
|
133 |
|
134 |
definition.addDynFieldString(FIELD_NAMESPACE) |
135 |
.setDescription("Namespace of the feature type to retrieve")
|
136 |
.setMandatory(false);
|
137 |
|
138 |
definition.addDynFieldString(DYNFIELDNAME_NAMESPACEPREFIX) |
139 |
.setDescription("Prefix of the namespace of the feature type to retrieve")
|
140 |
.setMandatory(false);
|
141 |
|
142 |
definition.addDynFieldString(DYNFIELDNAME_FIELDS) |
143 |
.setDescription("Fields to retrieve separated by ','")
|
144 |
.setMandatory(false);
|
145 |
|
146 |
definition.addDynFieldString(FIELD_FILTER_ENCODING_BY_ATTRIBUTE) |
147 |
.setDescription("Filter encoding request")
|
148 |
.setMandatory(false);
|
149 |
|
150 |
definition.addDynFieldInt(DYNFIELDNAME_MAXFEATURES) |
151 |
.setDescription("Number of features to retrieve")
|
152 |
.setMandatory(false);
|
153 |
|
154 |
definition.addDynFieldInt(DYNFIELDNAME_TIMEOUT) |
155 |
.setDescription("Timeout")
|
156 |
.setMandatory(false);
|
157 |
|
158 |
definition.addDynFieldString(DYNFIELDNAME_USER) |
159 |
.setDescription("User name (not used at this moment)")
|
160 |
.setMandatory(false);
|
161 |
|
162 |
definition.addDynFieldString(DYNFIELDNAME_PASSWORD) |
163 |
.setDescription("Password (not used at this moment")
|
164 |
.setMandatory(false);
|
165 |
|
166 |
definition.addDynFieldObject(DYNFIELDNAME_FILTER_BY_AREA_GEOMETRY) |
167 |
.setType(DataTypes.GEOMETRY) |
168 |
.setDescription("Geometry used to do the filter")
|
169 |
.setMandatory(false);
|
170 |
|
171 |
definition.addDynFieldObject(DYNFIELDNAME_FILTER_BY_AREA_ENVELOPE) |
172 |
.setType(DataTypes.ENVELOPE) |
173 |
.setDescription("Envelope used to do the filter")
|
174 |
.setMandatory(false);
|
175 |
|
176 |
definition.addDynFieldInt(DYNFIELDNAME_FILTER_BY_AREA_OPERATION) |
177 |
.setDescription("Geometry operation used to do the filter")
|
178 |
.setMandatory(false);
|
179 |
|
180 |
definition.addDynFieldString(DYNFIELDNAME_FILTER_BY_AREA_ATTRIBUTE) |
181 |
.setDescription("Attribute that contains the geometry")
|
182 |
.setMandatory(false);
|
183 |
|
184 |
definition.addDynFieldObject(DYNFIELDNAME_FILTER_BY_AREA_CRS) |
185 |
.setType(DataTypes.CRS) |
186 |
.setDescription("CRS to do the spatial filter of the query")
|
187 |
.setMandatory(false);
|
188 |
|
189 |
definition.addDynFieldString(DYNFIELDNAME_CRS) |
190 |
.setDescription("CRS")
|
191 |
.setMandatory(false);
|
192 |
|
193 |
definition.addDynFieldBoolean("useAxisOrderYX")
|
194 |
.setDefaultFieldValue("false")
|
195 |
.setMandatory(false);
|
196 |
|
197 |
definition.addDynFieldBoolean("ignoreCache")
|
198 |
.setDefaultFieldValue("false")
|
199 |
.setMandatory(false);
|
200 |
|
201 |
DYNCLASS = (DynClass) definition; |
202 |
} |
203 |
} |
204 |
|
205 |
@Override
|
206 |
public String getDataStoreName() { |
207 |
return WFSStoreProvider.NAME;
|
208 |
} |
209 |
|
210 |
@Override
|
211 |
public String getDescription() { |
212 |
return WFSStoreProvider.DESCRIPTION;
|
213 |
} |
214 |
|
215 |
@Override
|
216 |
public boolean isValid() { |
217 |
// TODO Auto-generated method stub
|
218 |
return false; |
219 |
} |
220 |
|
221 |
public String getUrl(){ |
222 |
return (String) this.getDynValue(FIELD_URL); |
223 |
} |
224 |
|
225 |
public void setUrl(String url){ |
226 |
this.setDynValue(FIELD_URL, url);
|
227 |
} |
228 |
|
229 |
public String getVersion(){ |
230 |
return (String) this.getDynValue(FIELD_VERSION); |
231 |
} |
232 |
|
233 |
public void setVersion(String version){ |
234 |
this.setDynValue(FIELD_VERSION, version);
|
235 |
} |
236 |
|
237 |
public String getFeatureType(){ |
238 |
return (String) this.getDynValue(FIELD_TYPENAME); |
239 |
} |
240 |
|
241 |
public void setFeatureType(String featureType){ |
242 |
this.setDynValue(FIELD_TYPENAME, featureType);
|
243 |
} |
244 |
|
245 |
public void setFeatureType(String namespace, String featureType){ |
246 |
this.setDynValue(FIELD_NAMESPACE, namespace);
|
247 |
this.setDynValue(FIELD_TYPENAME, featureType);
|
248 |
} |
249 |
|
250 |
public void setFeatureType(String prefix, String namespace, String featureType){ |
251 |
this.setDynValue(DYNFIELDNAME_NAMESPACEPREFIX, prefix);
|
252 |
this.setDynValue(FIELD_NAMESPACE, namespace);
|
253 |
this.setDynValue(FIELD_TYPENAME, featureType);
|
254 |
} |
255 |
|
256 |
public String getFeatureNamespace(){ |
257 |
return (String) this.getDynValue(FIELD_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(FIELD_FILTER_ENCODING_BY_ATTRIBUTE); |
274 |
} |
275 |
|
276 |
public void setFilterEncodingByAttribute(String filter){ |
277 |
this.setDynValue(FIELD_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 Envelope getFilterByAreaEnvelope(){
|
321 |
return (Envelope) this.getDynValue(DYNFIELDNAME_FILTER_BY_AREA_ENVELOPE); |
322 |
} |
323 |
|
324 |
public void setFilterByAreaEnvelope(Envelope area){ |
325 |
this.setDynValue(DYNFIELDNAME_FILTER_BY_AREA_ENVELOPE, area);
|
326 |
} |
327 |
|
328 |
public Integer getFilterByAreaOperation(){ |
329 |
return (Integer) this.getDynValue(DYNFIELDNAME_FILTER_BY_AREA_OPERATION); |
330 |
} |
331 |
|
332 |
public void setFilterByAreaOperation(Integer operation){ |
333 |
this.setDynValue(DYNFIELDNAME_FILTER_BY_AREA_OPERATION, operation);
|
334 |
} |
335 |
|
336 |
public IProjection getFilterByAreaCrs(){
|
337 |
return (IProjection) this.getDynValue(DYNFIELDNAME_FILTER_BY_AREA_CRS); |
338 |
} |
339 |
|
340 |
public void setFilterByAreaCrs(IProjection crs){ |
341 |
this.setDynValue(DYNFIELDNAME_FILTER_BY_AREA_CRS, crs);
|
342 |
} |
343 |
|
344 |
public String getCrs(){ |
345 |
return (String) this.getDynValue(DYNFIELDNAME_CRS); |
346 |
} |
347 |
|
348 |
public void setCrs(String crs){ |
349 |
this.setDynValue(DYNFIELDNAME_CRS, crs);
|
350 |
} |
351 |
|
352 |
public String getFilterByAreaAttribute(){ |
353 |
return (String) this.getDynValue(DYNFIELDNAME_FILTER_BY_AREA_ATTRIBUTE); |
354 |
} |
355 |
|
356 |
public void setFilterByAreaAttribute(String attribute){ |
357 |
this.setDynValue(DYNFIELDNAME_FILTER_BY_AREA_ATTRIBUTE, attribute);
|
358 |
} |
359 |
|
360 |
public boolean getUseAxisOrderYX() { |
361 |
Boolean x = (Boolean) this.getDynValue("useAxisOrderYX"); |
362 |
return BooleanUtils.isTrue(x);
|
363 |
} |
364 |
|
365 |
public void setUseAxisOrderYX(boolean useAxisOrderYX){ |
366 |
this.setDynValue("useAxisOrderYX", useAxisOrderYX); |
367 |
} |
368 |
|
369 |
public boolean getIgnoreCache() { |
370 |
Boolean x = (Boolean) this.getDynValue("ignoreCache"); |
371 |
return BooleanUtils.isTrue(x);
|
372 |
} |
373 |
|
374 |
public void setIgnoreCache(boolean ignoreCache){ |
375 |
this.setDynValue("ignoreCache", ignoreCache); |
376 |
} |
377 |
|
378 |
} |