root / trunk / extensions / extWFS2 / src / com / iver / cit / gvsig / fmap / drivers / wfs / WFSUtils.java @ 9461
History | View | Annotate | Download (5.74 KB)
1 |
package com.iver.cit.gvsig.fmap.drivers.wfs; |
---|---|
2 |
|
3 |
import java.util.ArrayList; |
4 |
import java.util.Vector; |
5 |
|
6 |
import org.gvsig.remoteClient.gml.schemas.XMLElement; |
7 |
import org.gvsig.remoteClient.gml.types.IXMLType; |
8 |
import org.gvsig.remoteClient.wfs.WFSStatus; |
9 |
|
10 |
import com.iver.cit.gvsig.fmap.drivers.gml.GMLTypesConversor; |
11 |
import com.iver.cit.gvsig.fmap.drivers.gml.GMLUtils; |
12 |
import com.iver.cit.gvsig.fmap.layers.WFSLayerNode; |
13 |
|
14 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
15 |
*
|
16 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
17 |
*
|
18 |
* This program is free software; you can redistribute it and/or
|
19 |
* modify it under the terms of the GNU General Public License
|
20 |
* as published by the Free Software Foundation; either version 2
|
21 |
* of the License, or (at your option) any later version.
|
22 |
*
|
23 |
* This program is distributed in the hope that it will be useful,
|
24 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
25 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
26 |
* GNU General Public License for more details.
|
27 |
*
|
28 |
* You should have received a copy of the GNU General Public License
|
29 |
* along with this program; if not, write to the Free Software
|
30 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
31 |
*
|
32 |
* For more information, contact:
|
33 |
*
|
34 |
* Generalitat Valenciana
|
35 |
* Conselleria d'Infraestructures i Transport
|
36 |
* Av. Blasco Ib??ez, 50
|
37 |
* 46010 VALENCIA
|
38 |
* SPAIN
|
39 |
*
|
40 |
* +34 963862235
|
41 |
* gvsig@gva.es
|
42 |
* www.gvsig.gva.es
|
43 |
*
|
44 |
* or
|
45 |
*
|
46 |
* IVER T.I. S.A
|
47 |
* Salamanca 50
|
48 |
* 46005 Valencia
|
49 |
* Spain
|
50 |
*
|
51 |
* +34 963163400
|
52 |
* dac@iver.es
|
53 |
*/
|
54 |
/* CVS MESSAGES:
|
55 |
*
|
56 |
* $Id: WFSUtils.java 9461 2006-12-26 10:25:37Z ppiqueras $
|
57 |
* $Log$
|
58 |
* Revision 1.7 2006-12-26 10:25:37 ppiqueras
|
59 |
* Corregidas las dependencias con las nuevas ubicaciones de clases: IXMLType, XMLElement, IXMLComplexType, etc. (en libRemoteServices)
|
60 |
*
|
61 |
* Revision 1.6 2006/12/26 09:27:26 ppiqueras
|
62 |
* Cambiado "atttibutes" en todas las aparaciones en atributos, m?todos, clases, paquetes o comentarios por "fields". (S?lo a aquellas que afectan a clases dentro del proyecto extWFS2).
|
63 |
*
|
64 |
* Revision 1.4 2006/10/11 11:19:58 jorpiell
|
65 |
* Una nullPointerException que no se comprobaba
|
66 |
*
|
67 |
* Revision 1.3 2006/10/10 12:55:06 jorpiell
|
68 |
* Se ha a?adido el soporte de features complejas
|
69 |
*
|
70 |
* Revision 1.2 2006/10/02 09:09:45 jorpiell
|
71 |
* Cambios del 10 copiados al head
|
72 |
*
|
73 |
* Revision 1.1.2.1 2006/09/19 12:28:32 jorpiell
|
74 |
* Ya no se depende de geotools
|
75 |
*
|
76 |
* Revision 1.1 2006/09/18 12:07:31 jorpiell
|
77 |
* Se ha sustituido geotools por el driver de remoteservices
|
78 |
*
|
79 |
* Revision 1.1 2006/07/24 07:30:33 jorpiell
|
80 |
* Se han eliminado las partes duplicadas y se est? usando el parser de GML de FMAP.
|
81 |
*
|
82 |
* Revision 1.5 2006/06/21 12:35:45 jorpiell
|
83 |
* Se ha a?adido la ventana de propiedades. Esto implica a?adir listeners por todos los paneles. Adem?s no se muestra la geomatr?a en la lista de atributos y se muestran ?nicamnete los que se van a descargar
|
84 |
*
|
85 |
* Revision 1.4 2006/06/14 07:57:19 jorpiell
|
86 |
* Ya no se usa la estrategia ni se usa geotools para hacer el getFeature. Ahora se usa ?nicamente para el parseo de GML
|
87 |
*
|
88 |
* Revision 1.3 2006/05/25 15:32:01 jorpiell
|
89 |
* Se ha a?adido la funcionalidad para eliminar el namespace de los tipos de atributos
|
90 |
*
|
91 |
* Revision 1.2 2006/05/25 10:32:21 jorpiell
|
92 |
* Se ha renombrado la clase WFSFields por WFSAttributes porque era algo confusa
|
93 |
*
|
94 |
* Revision 1.1 2006/05/23 08:07:00 jorpiell
|
95 |
* A?adido un m?todo para detectar el tipo de geometr?a
|
96 |
*
|
97 |
*
|
98 |
*/
|
99 |
/**
|
100 |
* This class implements some utils to manage GML
|
101 |
* @author Jorge Piera Llodr? (piera_jor@gva.es)
|
102 |
*/
|
103 |
public class WFSUtils extends GMLUtils { |
104 |
|
105 |
|
106 |
/**
|
107 |
* Return the layer geometry
|
108 |
* @param layer
|
109 |
* Layer with a set of Fields
|
110 |
* @return
|
111 |
*/
|
112 |
public static String getGeometry(WFSLayerNode layer){ |
113 |
if (layer.getGeometry() != null){ |
114 |
return layer.getGeometry().getName().split(":")[1]; |
115 |
} |
116 |
return ""; |
117 |
|
118 |
} |
119 |
|
120 |
/**
|
121 |
* It returns the field type. It has to remove the
|
122 |
* namespace to can use the translation mechanism
|
123 |
* translations
|
124 |
* @param field
|
125 |
* Field to translate
|
126 |
*/
|
127 |
public static String getFieldType(IXMLType field){ |
128 |
if (field == null){ |
129 |
return ""; |
130 |
} |
131 |
|
132 |
if (field.getType() == IXMLType.GML_GEOMETRY){
|
133 |
return field.getName().split(":")[1]; |
134 |
} |
135 |
|
136 |
String sfield = ""; |
137 |
if (field.getName().split(":").length > 1){ |
138 |
sfield = field.getName().split(":")[1]; |
139 |
}else{
|
140 |
sfield = field.getName(); |
141 |
} |
142 |
return sfield;
|
143 |
} |
144 |
|
145 |
public static Class getFieldJavaType(IXMLType field){ |
146 |
String sType = getFieldType(field);
|
147 |
Class clazz = GMLTypesConversor.gmlToJavaTypes(sType);
|
148 |
if (clazz == null){ |
149 |
clazz = String.class;
|
150 |
} |
151 |
return clazz;
|
152 |
} |
153 |
|
154 |
public static ArrayList getFields(WFSLayerNode[] featuresList,WFSStatus status){ |
155 |
ArrayList fields = new ArrayList(); |
156 |
WFSLayerNode layer = null;
|
157 |
for (int i=0 ; i<featuresList.length ; i++){ |
158 |
if (featuresList[i].getName().equals(status.getFeatureName())){
|
159 |
layer = featuresList[i]; |
160 |
} |
161 |
} |
162 |
Vector selectedFileds = layer.getSelectedFields();
|
163 |
for (int i=0 ; i<selectedFileds.size() ; i++){ |
164 |
IXMLType field = (IXMLType)selectedFileds.get(i); |
165 |
if (!(field.getType() == IXMLType.GML_GEOMETRY)){
|
166 |
fields.add(field); |
167 |
} |
168 |
} |
169 |
return fields;
|
170 |
} |
171 |
|
172 |
public static boolean getHasGeometry(WFSLayerNode[] featuresList, WFSStatus wfsStatus) { |
173 |
WFSLayerNode layer = null;
|
174 |
for (int i=0 ; i<featuresList.length ; i++){ |
175 |
if (featuresList[i].getName().equals(wfsStatus.getFeatureName())){
|
176 |
layer = featuresList[i]; |
177 |
} |
178 |
} |
179 |
Vector selectedFileds = layer.getSelectedFields();
|
180 |
for (int i=0 ; i<selectedFileds.size() ; i++){ |
181 |
XMLElement field = (XMLElement)selectedFileds.get(i); |
182 |
if (!((field.getEntityType() != null) && (field.getEntityType().getType() == IXMLType.GML_GEOMETRY))){ |
183 |
return true; |
184 |
} |
185 |
} |
186 |
return false; |
187 |
} |
188 |
|
189 |
} |