Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / extensions / extWFS2 / src / org / gvsig / wfs / gui / panels / model / WFSUtils.java @ 34026

History | View | Annotate | Download (5.35 KB)

1
package org.gvsig.wfs.gui.panels.model;
2

    
3
import java.util.ArrayList;
4
import java.util.Vector;
5

    
6
import org.gvsig.remoteclient.wfs.WFSStatus;
7
import org.gvsig.xmlschema.lib.api.som.IXSElementDeclaration;
8
import org.gvsig.xmlschema.lib.api.som.IXSTypeDefinition;
9

    
10
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
11
 *
12
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
13
 *
14
 * This program is free software; you can redistribute it and/or
15
 * modify it under the terms of the GNU General Public License
16
 * as published by the Free Software Foundation; either version 2
17
 * of the License, or (at your option) any later version.
18
 *
19
 * This program is distributed in the hope that it will be useful,
20
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
 * GNU General Public License for more details.
23
 *
24
 * You should have received a copy of the GNU General Public License
25
 * along with this program; if not, write to the Free Software
26
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
27
 *
28
 * For more information, contact:
29
 *
30
 *  Generalitat Valenciana
31
 *   Conselleria d'Infraestructures i Transport
32
 *   Av. Blasco Ib??ez, 50
33
 *   46010 VALENCIA
34
 *   SPAIN
35
 *
36
 *      +34 963862235
37
 *   gvsig@gva.es
38
 *      www.gvsig.gva.es
39
 *
40
 *    or
41
 *
42
 *   IVER T.I. S.A
43
 *   Salamanca 50
44
 *   46005 Valencia
45
 *   Spain
46
 *
47
 *   +34 963163400
48
 *   dac@iver.es
49
 */
50
/* CVS MESSAGES:
51
 *
52
 * $Id: WFSUtils.java 9916 2007-01-25 16:11:35Z jorpiell $
53
 * $Log$
54
 * Revision 1.1.2.4  2007-01-25 16:11:15  jorpiell
55
 * Se han cambiado los imports que hac?an referencia a remoteServices. Esto es as?, porque se han renombrado las clases del driver de GML
56
 *
57
 * Revision 1.1.2.3  2006/11/17 11:28:45  ppiqueras
58
 * Corregidos bugs y a?adida nueva funcionalidad.
59
 *
60
 * Revision 1.4  2006/10/11 11:19:58  jorpiell
61
 * Una nullPointerException que no se comprobaba
62
 *
63
 * Revision 1.3  2006/10/10 12:55:06  jorpiell
64
 * Se ha a?adido el soporte de features complejas
65
 *
66
 * Revision 1.2  2006/10/02 09:09:45  jorpiell
67
 * Cambios del 10 copiados al head
68
 *
69
 * Revision 1.1.2.1  2006/09/19 12:28:32  jorpiell
70
 * Ya no se depende de geotools
71
 *
72
 * Revision 1.1  2006/09/18 12:07:31  jorpiell
73
 * Se ha sustituido geotools por el driver de remoteservices
74
 *
75
 * Revision 1.1  2006/07/24 07:30:33  jorpiell
76
 * Se han eliminado las partes duplicadas y se est? usando el parser de GML de FMAP.
77
 *
78
 * Revision 1.5  2006/06/21 12:35:45  jorpiell
79
 * 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
80
 *
81
 * Revision 1.4  2006/06/14 07:57:19  jorpiell
82
 * Ya no se usa la estrategia ni se usa geotools para hacer el getFeature. Ahora se usa ?nicamente para el parseo de GML
83
 *
84
 * Revision 1.3  2006/05/25 15:32:01  jorpiell
85
 * Se ha a?adido la funcionalidad para eliminar el namespace de los tipos de atributos
86
 *
87
 * Revision 1.2  2006/05/25 10:32:21  jorpiell
88
 * Se ha renombrado la clase WFSFields por WFSAttributes porque era algo confusa
89
 *
90
 * Revision 1.1  2006/05/23 08:07:00  jorpiell
91
 * A?adido un m?todo para detectar el tipo de geometr?a
92
 *
93
 *
94
 */
95
/**
96
 * This class implements some utils to manage GML
97
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
98
 */
99
public class WFSUtils {
100
        
101
        
102
        /**
103
         * Return the layer geometry
104
         * @param layer
105
         * Layer with a set of Fields
106
         * @return
107
         */
108
        public static String getGeometry(WFSSelectedFeature selectedFeature){
109
                   if (selectedFeature.getGeometryField() != null){
110
                           return selectedFeature.getGeometryField().getName().split(":")[1];
111
                   }
112
                   return "";
113
  
114
        }
115
        
116
        /**
117
         * It returns the field type. It has to remove the
118
         * namespace to can use the translation mechanism 
119
         * translations
120
         * @param field
121
         * Field to translate
122
         */
123
        public static String getFieldType(IXSTypeDefinition field){
124
                if (field == null){
125
                        return "";
126
                }
127
                
128
                if (field.isGeometry()){
129
                        return field.getNodeName().split(":")[1];
130
                }
131
                
132
                String sfield = "";
133
                if (field.getNodeName().split(":").length > 1){
134
                        sfield = field.getNodeName().split(":")[1];
135
                }else{
136
                        sfield = field.getNodeName();
137
                }                
138
                return sfield;
139
        }
140
        
141
        
142
        public static ArrayList getFields(WFSSelectedFeature[] featuresList,WFSStatus status){
143
                ArrayList fields = new ArrayList();
144
                WFSSelectedFeature layer = null;
145
                for (int i=0 ; i<featuresList.length ; i++){
146
                        if (featuresList[i].getName().equals(status.getFeatureName())){
147
                                layer = featuresList[i];
148
                        }
149
                }
150
                Vector selectedFileds = layer.getSelectedFields();
151
                for (int i=0 ; i<selectedFileds.size() ; i++){
152
                        IXSTypeDefinition field = (IXSTypeDefinition)selectedFileds.get(i);
153
                        if (!(field.isGeometry())){
154
                                fields.add(field);
155
                        }
156
                }
157
                return fields;
158
        }
159

    
160
        public static boolean getHasGeometry(WFSSelectedFeature[] featuresList, WFSStatus wfsStatus) {
161
                WFSSelectedFeature layer = null;
162
                for (int i=0 ; i<featuresList.length ; i++){
163
                        if (featuresList[i].getName().equals(wfsStatus.getFeatureName())){
164
                                layer = featuresList[i];
165
                        }
166
                }
167
                Vector selectedFileds = layer.getSelectedFields();
168
                for (int i=0 ; i<selectedFileds.size() ; i++){
169
                        IXSElementDeclaration field = (IXSElementDeclaration)selectedFileds.get(i);
170
                        if (!((field.getTypeDefinition() != null) && (field.getTypeDefinition().isGeometry()))){
171
                                return true;
172
                        }
173
                }
174
                return false;
175
        }
176
        
177
        
178
}