Revision 8765 branches/v10/extensions/extWFS2/src/com/iver/cit/gvsig/fmap/layers/FLyrWFS.java
FLyrWFS.java | ||
---|---|---|
7 | 7 |
import java.net.URL; |
8 | 8 |
import java.util.HashMap; |
9 | 9 |
import java.util.Map; |
10 |
import java.util.Vector; |
|
10 | 11 |
|
11 | 12 |
import javax.swing.ImageIcon; |
12 | 13 |
|
13 |
import org.cresques.cts.ProjectionPool; |
|
14 |
import org.gvsig.remoteClient.wfs.WFSAttribute; |
|
14 |
import org.gvsig.remoteClient.gml.schemas.IXMLType; |
|
15 |
import org.gvsig.remoteClient.gml.schemas.XMLComplexType; |
|
16 |
import org.gvsig.remoteClient.gml.schemas.XMLElement; |
|
15 | 17 |
import org.gvsig.remoteClient.wfs.WFSStatus; |
18 |
import org.gvsig.remoteClient.wfs.filters.FilterEncoding; |
|
16 | 19 |
|
17 | 20 |
import com.iver.andami.PluginServices; |
18 | 21 |
import com.iver.cit.gvsig.fmap.DriverException; |
... | ... | |
22 | 25 |
import com.iver.cit.gvsig.fmap.drivers.WFSException; |
23 | 26 |
import com.iver.cit.gvsig.fmap.drivers.wfs.FMapWFSDriver; |
24 | 27 |
import com.iver.cit.gvsig.fmap.drivers.wfs.FMapWFSDriverFactory; |
28 |
import com.iver.cit.gvsig.fmap.drivers.wfs.filters.SQLExpressionFormat; |
|
25 | 29 |
import com.iver.cit.gvsig.fmap.rendering.LegendFactory; |
26 | 30 |
import com.iver.utiles.StringUtilities; |
27 | 31 |
import com.iver.utiles.XMLEntity; |
... | ... | |
70 | 74 |
* |
71 | 75 |
* $Id$ |
72 | 76 |
* $Log$ |
73 |
* Revision 1.10.2.4 2006-10-02 12:46:17 jorpiell
|
|
74 |
* A?adidos los m?todos para escribirse y recuperarse del XMLEntity
|
|
77 |
* Revision 1.10.2.5 2006-11-15 00:08:20 jjdelcerro
|
|
78 |
* *** empty log message ***
|
|
75 | 79 |
* |
80 |
* Revision 1.18 2006/10/31 12:24:04 jorpiell |
|
81 |
* Comprobado el caso en el que los atributos no tienen tipo |
|
82 |
* |
|
83 |
* Revision 1.17 2006/10/31 09:55:28 jorpiell |
|
84 |
* Se ha modificado el constructor del WFS desde cat?logo |
|
85 |
* |
|
86 |
* Revision 1.16 2006/10/31 09:38:15 jorpiell |
|
87 |
* Se ha creado una factoria para crear la capa. De ese modo no se repite c?digo desde le panel de propiedades y desde el panel de la capa |
|
88 |
* |
|
89 |
* Revision 1.15 2006/10/23 07:37:04 jorpiell |
|
90 |
* Ya funciona el filterEncoding |
|
91 |
* |
|
92 |
* Revision 1.14 2006/10/10 12:55:06 jorpiell |
|
93 |
* Se ha a?adido el soporte de features complejas |
|
94 |
* |
|
95 |
* Revision 1.13 2006/10/02 12:54:35 jorpiell |
|
96 |
* No se pod?a crear un mapa que tubiera la opci?n enlace vivo habilitada |
|
97 |
* |
|
98 |
* Revision 1.12 2006/10/02 09:09:45 jorpiell |
|
99 |
* Cambios del 10 copiados al head |
|
100 |
* |
|
101 |
* Revision 1.10.2.3 2006/09/29 14:12:53 luisw2 |
|
102 |
* CRSFactory.getCRS substitutes ProjectionPool.get |
|
103 |
* |
|
76 | 104 |
* Revision 1.10.2.2 2006/09/28 08:54:01 jorpiell |
77 | 105 |
* Ya se puede reproyectar |
78 | 106 |
* |
... | ... | |
123 | 151 |
private String layerName = null; |
124 | 152 |
private String userName = null; |
125 | 153 |
private String password = null; |
126 |
private WFSAttribute[] fields = null; |
|
154 |
private String AttributesQuery = null; |
|
155 |
private String CoordinatesQuery = null; |
|
156 |
private XMLElement[] fields = null; |
|
127 | 157 |
private int numfeatures = 100; |
128 | 158 |
private int timeout = 10000; |
129 | 159 |
private String srs = null; |
... | ... | |
162 | 192 |
|
163 | 193 |
layer.setSelectedFields(layer.getFields()); |
164 | 194 |
|
165 |
WFSAttribute[] atts = new WFSAttribute[layer.getFields().size()]; |
|
166 |
for (int i=0 ; i<atts.length ; i++){ |
|
167 |
atts[i] = (WFSAttribute)layer.getFields().get(i); |
|
195 |
Vector vAtts = new Vector(); |
|
196 |
if (layer.getFields().size() == 1){ |
|
197 |
XMLElement element = (XMLElement)layer.getFields().get(0); |
|
198 |
if (element.getEntityType().getType() != IXMLType.COMPLEX){ |
|
199 |
vAtts.add(element); |
|
200 |
}else{ |
|
201 |
vAtts = ((XMLComplexType)element.getEntityType()).getAttributes(); |
|
202 |
} |
|
168 | 203 |
} |
204 |
for (int i=0 ; i<layer.getFields().size() ; i++){ |
|
205 |
XMLElement element = (XMLElement)layer.getFields().get(i); |
|
206 |
if (element.getEntityType().getType() != IXMLType.COMPLEX){ |
|
207 |
vAtts.add((XMLElement)layer.getFields().get(i)); |
|
208 |
}else{ |
|
209 |
|
|
210 |
} |
|
211 |
} |
|
212 |
|
|
213 |
XMLElement[] atts = new XMLElement[vAtts.size()]; |
|
214 |
for (int i=0 ; i<vAtts.size() ; i++){ |
|
215 |
atts[i] = (XMLElement)vAtts.get(i); |
|
216 |
} |
|
169 | 217 |
|
170 | 218 |
setHost(host); |
171 | 219 |
setName(sLayer[0]); |
... | ... | |
194 | 242 |
adapter.setDriver((VectorialDriver) wfsDriver); |
195 | 243 |
setSource(adapter); |
196 | 244 |
|
245 |
|
|
197 | 246 |
setLegend(LegendFactory.createSingleSymbolLegend( |
198 | 247 |
getShapeType())); |
199 | 248 |
} catch (Exception e){ |
... | ... | |
215 | 264 |
status.setFields(getFieldNames()); |
216 | 265 |
status.setOnlineResource(getOnlineResource()); |
217 | 266 |
status.setSrs(getSrs()); |
218 |
return status; |
|
267 |
//Filter Encoding transformation |
|
268 |
FilterEncoding fe = SQLExpressionFormat.createFilter(); |
|
269 |
fe.setQuery(getAttributesQuery()); |
|
270 |
status.setFilterQuery(fe.toString()); |
|
271 |
return status; |
|
219 | 272 |
} |
220 | 273 |
|
221 | 274 |
/** |
... | ... | |
291 | 344 |
/** |
292 | 345 |
* @return Returns the fields. |
293 | 346 |
*/ |
294 |
public WFSAttribute[] getFields() {
|
|
347 |
public XMLElement[] getFields() {
|
|
295 | 348 |
if (fields == null){ |
296 |
return new WFSAttribute[0];
|
|
349 |
return new XMLElement[0];
|
|
297 | 350 |
} |
298 | 351 |
return fields; |
299 | 352 |
} |
... | ... | |
303 | 356 |
* @return |
304 | 357 |
*/ |
305 | 358 |
public String[] getFieldNames(){ |
306 |
String[] attributes = new String[getFields().length];
|
|
359 |
Vector vAttributes = new Vector();
|
|
307 | 360 |
for (int i=0 ; i<getFields().length ; i++){ |
308 |
attributes[i] = getFields()[i].getName(); |
|
361 |
if ((getFields()[i].getEntityType() == null) || |
|
362 |
(getFields()[i].getEntityType().getType() != IXMLType.COMPLEX)){ |
|
363 |
vAttributes.add(getFields()[i].getName()); |
|
364 |
} |
|
309 | 365 |
} |
366 |
String[] attributes = new String[vAttributes.size()]; |
|
367 |
for (int i=0 ; i<vAttributes.size() ; i++){ |
|
368 |
attributes[i] = (String)vAttributes.get(i); |
|
369 |
} |
|
310 | 370 |
return attributes; |
311 | 371 |
} |
312 | 372 |
|
313 | 373 |
/** |
314 | 374 |
* @param fields The fields to set. |
315 | 375 |
*/ |
316 |
public void setFields(WFSAttribute[] fields) {
|
|
376 |
public void setFields(XMLElement[] fields) {
|
|
317 | 377 |
this.fields = fields; |
318 | 378 |
} |
319 | 379 |
/** |
... | ... | |
481 | 541 |
|
482 | 542 |
//Layer fields |
483 | 543 |
String strFields = ""; |
484 |
WFSAttribute[] fields = getFields();
|
|
544 |
XMLElement[] fields = getFields();
|
|
485 | 545 |
for (int i=0 ; i<fields.length ; i++){ |
486 | 546 |
strFields = strFields + fields[i].getName(); |
487 | 547 |
if (i < fields.length - 1){ |
... | ... | |
571 | 631 |
WFSLayerNode[] layers = driver.getLayerList(); |
572 | 632 |
WFSLayerNode layer = driver.getLayerInfo(getLayerName()); |
573 | 633 |
layer.setSelectedFields(layer.getFields()); |
574 |
WFSAttribute[] atts = null;
|
|
634 |
XMLElement[] atts = null;
|
|
575 | 635 |
|
576 | 636 |
if (xml.contains("fields")) { |
577 | 637 |
String[] fields = xml.getStringProperty("fields").split("~##SEP1##~"); |
578 |
atts = new WFSAttribute[fields.length];
|
|
638 |
atts = new XMLElement[fields.length];
|
|
579 | 639 |
for (int i=0 ; i<fields.length ; i++){ |
580 | 640 |
for (int j=0 ; j<layer.getFields().size() ; j++){ |
581 |
WFSAttribute attribute = (WFSAttribute)layer.getFields().get(j);
|
|
641 |
XMLElement attribute = (XMLElement)layer.getFields().get(j);
|
|
582 | 642 |
if (attribute.getName().equals(fields[i])){ |
583 | 643 |
atts[i] = attribute; |
584 | 644 |
break; |
... | ... | |
586 | 646 |
} |
587 | 647 |
} |
588 | 648 |
}else{ |
589 |
atts = new WFSAttribute[0];
|
|
649 |
atts = new XMLElement[0];
|
|
590 | 650 |
} |
591 | 651 |
layer.setSelectedFields(atts); |
592 | 652 |
setWfsDriver(driver); |
... | ... | |
594 | 654 |
setFields(atts); |
595 | 655 |
setAvailable(true); |
596 | 656 |
} |
657 |
|
|
658 |
/** |
|
659 |
* @return Returns the attributesQuery. |
|
660 |
*/ |
|
661 |
public String getAttributesQuery() { |
|
662 |
return AttributesQuery; |
|
663 |
} |
|
664 |
|
|
665 |
/** |
|
666 |
* @param attributesQuery The attributesQuery to set. |
|
667 |
*/ |
|
668 |
public void setAttributesQuery(String attributesQuery) { |
|
669 |
AttributesQuery = attributesQuery; |
|
670 |
} |
|
671 |
|
|
672 |
/** |
|
673 |
* @return Returns the coordinatesQuery. |
|
674 |
*/ |
|
675 |
public String getCoordinatesQuery() { |
|
676 |
return CoordinatesQuery; |
|
677 |
} |
|
678 |
|
|
679 |
/** |
|
680 |
* @param coordinatesQuery The coordinatesQuery to set. |
|
681 |
*/ |
|
682 |
public void setCoordinatesQuery(String coordinatesQuery) { |
|
683 |
CoordinatesQuery = coordinatesQuery; |
|
684 |
} |
|
597 | 685 |
} |
Also available in: Unified diff