Statistics
| Revision:

svn-gvsig-desktop / import / extWFS2 / src / com / iver / cit / gvsig / fmap / drivers / wfs / FMapWFSDriver.java @ 18320

History | View | Annotate | Download (18.5 KB)

1 4886 jorpiell
package com.iver.cit.gvsig.fmap.drivers.wfs;
2
3 5293 jorpiell
import java.awt.geom.Rectangle2D;
4 5824 jorpiell
import java.io.File;
5 4886 jorpiell
import java.io.IOException;
6
import java.net.ConnectException;
7
import java.net.URL;
8 18320 jpiera
import java.text.Collator;
9 5293 jorpiell
import java.util.ArrayList;
10 18320 jpiera
import java.util.Collections;
11 4886 jorpiell
import java.util.Hashtable;
12
import java.util.Iterator;
13 18320 jpiera
import java.util.Locale;
14 4886 jorpiell
15 6289 jorpiell
import org.apache.log4j.Logger;
16 4886 jorpiell
import org.gvsig.remoteClient.wfs.WFSClient;
17 4911 jorpiell
import org.gvsig.remoteClient.wfs.WFSFeature;
18 18320 jpiera
import org.gvsig.remoteClient.wfs.WFSOperation;
19
import org.gvsig.remoteClient.wfs.WFSServiceInformation;
20 5293 jorpiell
import org.gvsig.remoteClient.wfs.WFSStatus;
21 18320 jpiera
import org.gvsig.remoteClient.wfs.exceptions.WFSException;
22 5830 jorpiell
import org.gvsig.remoteClient.wms.ICancellable;
23 4886 jorpiell
24 5293 jorpiell
import com.hardcode.gdbms.engine.data.DataSourceFactory;
25
import com.hardcode.gdbms.engine.data.driver.ObjectDriver;
26
import com.hardcode.gdbms.engine.data.edition.DataWare;
27
import com.hardcode.gdbms.engine.values.Value;
28 4886 jorpiell
import com.iver.cit.gvsig.fmap.DriverException;
29 5293 jorpiell
import com.iver.cit.gvsig.fmap.core.FShape;
30
import com.iver.cit.gvsig.fmap.core.IGeometry;
31 5673 caballero
import com.iver.cit.gvsig.fmap.drivers.BoundedShapes;
32 5293 jorpiell
import com.iver.cit.gvsig.fmap.drivers.DriverAttributes;
33 4886 jorpiell
import com.iver.cit.gvsig.fmap.drivers.UnsupportedVersionException;
34
import com.iver.cit.gvsig.fmap.drivers.WFSDriver;
35 18320 jpiera
import com.iver.cit.gvsig.fmap.drivers.WFSDriverException;
36 7355 jorpiell
import com.iver.cit.gvsig.fmap.drivers.gml.GMLDriver;
37 18320 jpiera
import com.iver.cit.gvsig.fmap.drivers.gml.IGMLDriver;
38
import com.iver.cit.gvsig.fmap.edition.IWriteable;
39
import com.iver.cit.gvsig.fmap.edition.IWriter;
40
import com.iver.cit.gvsig.fmap.edition.wfs.FmapWFSWriter;
41
import com.iver.cit.gvsig.fmap.edition.wfs.WFSTLockFeaturesException;
42 4886 jorpiell
import com.iver.cit.gvsig.fmap.layers.WFSLayerNode;
43 18320 jpiera
import com.iver.utiles.StringComparator;
44
import com.iver.utiles.StringComparator.LocaleRules;
45
import com.iver.utiles.extensionPoints.ExtensionPoint;
46
import com.iver.utiles.extensionPoints.ExtensionPointsSingleton;
47 4886 jorpiell
48
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
49
 *
50
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
51
 *
52
 * This program is free software; you can redistribute it and/or
53
 * modify it under the terms of the GNU General Public License
54
 * as published by the Free Software Foundation; either version 2
55
 * of the License, or (at your option) any later version.
56
 *
57
 * This program is distributed in the hope that it will be useful,
58
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
59
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
60
 * GNU General Public License for more details.
61
 *
62
 * You should have received a copy of the GNU General Public License
63
 * along with this program; if not, write to the Free Software
64
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
65
 *
66
 * For more information, contact:
67
 *
68
 *  Generalitat Valenciana
69
 *   Conselleria d'Infraestructures i Transport
70
 *   Av. Blasco Ib??ez, 50
71
 *   46010 VALENCIA
72
 *   SPAIN
73
 *
74
 *      +34 963862235
75
 *   gvsig@gva.es
76
 *      www.gvsig.gva.es
77
 *
78
 *    or
79
 *
80
 *   IVER T.I. S.A
81
 *   Salamanca 50
82
 *   46005 Valencia
83
 *   Spain
84
 *
85
 *   +34 963163400
86
 *   dac@iver.es
87
 */
88
/* CVS MESSAGES:
89
 *
90
 * $Id$
91
 * $Log$
92 8847 ppiqueras
 * Revision 1.18.2.5  2006-11-17 11:28:45  ppiqueras
93
 * Corregidos bugs y a?adida nueva funcionalidad.
94 8824 jorpiell
 *
95 8847 ppiqueras
 * Revision 1.22  2006/11/16 13:31:10  jorpiell
96
 * Se ha eliminado la visivilidad del constructor
97 7500 caballero
 *
98 8847 ppiqueras
 * Revision 1.21  2006/11/15 17:38:08  jorpiell
99
 * Ya se puede guardar una capa en WFS.
100
 *
101 8765 jjdelcerro
 * Revision 1.20  2006/09/25 10:23:03  caballero
102
 * no multiType
103 7355 jorpiell
 *
104
 * Revision 1.19  2006/09/18 12:07:31  jorpiell
105
 * Se ha sustituido geotools por el driver de remoteservices
106
 *
107
 * Revision 1.18  2006/07/24 08:27:35  jorpiell
108 6508 jorpiell
 * Implementado el m?todo getFieldType que permite la exportaci?n a los diferentes tipos de ficheros (como shp,....)
109
 *
110
 * Revision 1.17  2006/07/21 10:02:43  caballero
111 6493 caballero
 * soluci?n provisional a WFS
112
 *
113
 * Revision 1.16  2006/07/12 11:55:22  jmvivo
114 6324 jmvivo
 * *** empty log message ***
115
 *
116
 * Revision 1.15  2006/07/12 10:58:10  jmvivo
117 6318 jmvivo
 * A?adido el metodo 'reload' del ObjectDriver (falta implementar)
118
 *
119
 * Revision 1.14  2006/07/11 11:55:41  jorpiell
120 6289 jorpiell
 * Se ha a?adido el fallo de tipo de dato en el log
121
 *
122
 * Revision 1.13  2006/06/15 10:34:12  jorpiell
123 5863 jorpiell
 * Ya se pueden ver los atributos de las tablas
124
 *
125
 * Revision 1.12  2006/06/15 07:50:58  jorpiell
126 5856 jorpiell
 * A?adida la funcionalidad de reproyectar y hechos algunos cambios en la interfaz
127
 *
128
 * Revision 1.11  2006/06/14 08:46:24  jorpiell
129 5830 jorpiell
 * Se tiene en cuanta la opcion para refrescar las capabilities
130
 *
131
 * Revision 1.10  2006/06/14 07:57:19  jorpiell
132 5824 jorpiell
 * Ya no se usa la estrategia ni se usa geotools para hacer el getFeature. Ahora se usa ?nicamente para el parseo de GML
133
 *
134
 * Revision 1.9  2006/06/05 16:49:42  caballero
135 5673 caballero
 * poder editar y exportar
136
 *
137
 * Revision 1.8  2006/05/30 05:26:38  jorpiell
138 5528 jorpiell
 * isWritable ha sido a?adido a la interfaz, y hay que implementarlo
139
 *
140
 * Revision 1.7  2006/05/25 10:32:11  jorpiell
141 5440 jorpiell
 * Se ha renombrado la clase WFSFields por WFSAttributes porque era algo confusa
142
 *
143
 * Revision 1.6  2006/05/23 13:21:28  jorpiell
144 5365 jorpiell
 * Se tiene en cuanta el online resource
145
 *
146
 * Revision 1.5  2006/05/22 10:31:35  jorpiell
147 5315 jorpiell
 * Cambio producido al cambiar una interfaz del geotools driver
148
 *
149
 * Revision 1.4  2006/05/22 10:11:10  jorpiell
150 5308 jorpiell
 * Eliminadas algunas lineas innecesarias
151
 *
152
 * Revision 1.3  2006/05/19 12:53:54  jorpiell
153 5293 jorpiell
 * Se le ha a?adido un driver de geottols, por lo que tiene dos drivers. Para hacer el getFeatureInfo y el capablities utilizar? elremoteServices y para hacer el getFeature usar? el de geotools.
154
 *
155
 * Revision 1.2  2006/04/20 16:38:24  jorpiell
156 4911 jorpiell
 * Ahora mismo ya se puede hacer un getCapabilities y un getDescribeType de la capa seleccionada para ver los atributos a dibujar. Queda implementar el panel de opciones y hacer el getFeature().
157
 *
158
 * Revision 1.1  2006/04/19 12:50:16  jorpiell
159 4886 jorpiell
 * Primer commit de la aplicaci?n. Se puede hacer un getCapabilities y ver el mensaje de vienvenida del servidor
160
 *
161
 *
162
 */
163
/**
164
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
165
 */
166 18320 jpiera
public class FMapWFSDriver implements WFSDriver, BoundedShapes,ObjectDriver,IWriteable{
167 5293 jorpiell
        private WFSClient remoteServicesClient;
168 5824 jorpiell
        private WFSLayerNode[] featuresList;
169 18320 jpiera
        private Hashtable hashFeatures;
170
        private DriverAttributes attr = new DriverAttributes();
171
        private IGMLDriver driver = null;
172
        private boolean hasGeometry = false;
173
        //The GML driver to use
174
        private static Class gmlDriverClass = null;
175
        //WFSTDriver
176
        private FmapWFSWriter writer = null;
177
        private WFSStatus status = null;
178
        private boolean isWfstEditing = false;
179
        private boolean isWfstGeometriesUpdated = true;
180
181 8824 jorpiell
        FMapWFSDriver() {
182 18320 jpiera
                super();
183 5293 jorpiell
        }
184
185 18320 jpiera
        //Method used to register the GML parser
186
        public static void registerGmlDriver(Class clazz){
187
                gmlDriverClass = clazz;
188
        }
189
190 4886 jorpiell
        /*
191
         *  (non-Javadoc)
192
         * @see com.iver.cit.gvsig.fmap.drivers.WFSDriver#getCapabilities(java.net.URL)
193
         */
194 5673 caballero
        public void getCapabilities(URL server)
195 18320 jpiera
        throws WFSDriverException {
196
                try {
197
                        getClient(server).connect(null);
198
                } catch (Exception e) {
199
                        throw new WFSDriverException(e);
200
                }
201 5673 caballero
        }
202
203 18320 jpiera
        /*
204
         *  (non-Javadoc)
205
         * @see com.iver.cit.gvsig.fmap.drivers.WFSDriver#describeFeatureType(java.lang.String)
206
         */
207
        public void describeFeatureType(String featureType,String nameSpace) throws WFSException {
208
                status = new WFSStatus(featureType,nameSpace);
209
                remoteServicesClient.describeFeatureType(status);
210 5293 jorpiell
        }
211 5673 caballero
212 5293 jorpiell
        /*
213
         *  (non-Javadoc)
214
         * @see com.iver.cit.gvsig.fmap.drivers.WFSDriver#getFeature(org.gvsig.remoteClient.wfs.WFSStatus)
215
         */
216
        public void getFeature(WFSStatus wfsStatus) throws WFSException {
217 18320 jpiera
                //Retrieve the file
218 5824 jorpiell
                File file = remoteServicesClient.getFeature(wfsStatus);
219
                try {
220 18320 jpiera
                        //Creates the driver
221
                        if (gmlDriverClass == null){
222
                                ExtensionPoint extensionPoint = (ExtensionPoint)ExtensionPointsSingleton.getInstance().get("FMAPWFSDriver");
223
                                if (extensionPoint != null){
224
                                        driver = (IGMLDriver)extensionPoint.create("FMAPWFSDriver");
225
                                }
226
                        }
227
                } catch (Exception e1) {
228 7355 jorpiell
                        driver = new GMLDriver();
229 18320 jpiera
                }
230
                //Reads the GML file
231
                try {
232 7355 jorpiell
                        driver.open(file);
233 8765 jjdelcerro
                        driver.initialize();
234 7355 jorpiell
                        hasGeometry = WFSUtils.getHasGeometry(featuresList,wfsStatus);
235 5824 jorpiell
                } catch (Exception e) {
236 6289 jorpiell
                        Logger.getLogger(getClass().getName()).error(e.getMessage());
237 18320 jpiera
                        throw new WFSDriverException(e);
238 5293 jorpiell
                }
239 5673 caballero
        }
240
241 5293 jorpiell
        /*
242
         *  (non-Javadoc)
243
         * @see com.iver.cit.gvsig.fmap.drivers.VectorialDriver#getShapeType()
244
         */
245
        public int getShapeType() {
246 18320 jpiera
                //return driver.getShapeType();
247
                try {
248
                        if (getShapeCount() > 0){
249
                                return getShapeType(0);
250
                        }
251
                } catch (IOException e) {
252
                        // TODO Auto-generated catch block
253
                        e.printStackTrace();
254
                }
255
                return FShape.MULTI;
256 5293 jorpiell
        }
257
258
        /*
259
         *  (non-Javadoc)
260
         * @see com.iver.cit.gvsig.fmap.drivers.VectorialDriver#getShapeCount()
261
         */
262
        public int getShapeCount() throws IOException {
263 18320 jpiera
                return driver.getShapeCount();
264 5293 jorpiell
        }
265
266
        /*
267
         *  (non-Javadoc)
268
         * @see com.iver.cit.gvsig.fmap.drivers.VectorialDriver#getDriverAttributes()
269
         */
270
        public DriverAttributes getDriverAttributes() {
271 18320 jpiera
                return attr;
272 5293 jorpiell
        }
273
274
        /*
275
         *  (non-Javadoc)
276
         * @see com.iver.cit.gvsig.fmap.drivers.VectorialDriver#getFullExtent()
277
         */
278
        public Rectangle2D getFullExtent() throws IOException {
279 7355 jorpiell
                return driver.getFullExtent();
280 5293 jorpiell
        }
281
282
        /*
283
         *  (non-Javadoc)
284
         * @see com.iver.cit.gvsig.fmap.drivers.VectorialDriver#getShape(int)
285
         */
286
        public IGeometry getShape(int index) throws IOException {
287 18320 jpiera
                return driver.getShape(index);
288 5293 jorpiell
        }
289
290
        /*
291
         *  (non-Javadoc)
292
         * @see com.hardcode.driverManager.Driver#getName()
293
         */
294
        public String getName() {
295
                return "WFS Driver";
296
        }
297 5673 caballero
298
299
300 4886 jorpiell
        /**
301
         * Devuelve WFSClient a partir de su URL.
302
         *
303
         * @param url URL.
304
         *
305
         * @return WMSClient.
306 5673 caballero
         * @throws IOException
307
         * @throws ConnectException
308 4886 jorpiell
         *
309
         * @throws UnsupportedVersionException
310
         * @throws IOException
311
         */
312
        public WFSClient getClient(URL url) throws ConnectException, IOException {
313 5293 jorpiell
                if (remoteServicesClient == null) {
314
                        remoteServicesClient = new WFSClient(url.toString());
315 4886 jorpiell
                }
316 5293 jorpiell
                return remoteServicesClient;
317 4886 jorpiell
        }
318 5673 caballero
319 4886 jorpiell
        /**
320 18320 jpiera
         * Creates a new instance of a WFSClient.
321
         * @param
322
         * host
323 5673 caballero
         * @throws IOException
324
         * @throws ConnectException
325 18320 jpiera
         */
326
        public void createClient(URL host) throws ConnectException, IOException {
327
                remoteServicesClient = new WFSClient(host.toString());
328
        }
329 5673 caballero
330 18320 jpiera
        /**
331 4886 jorpiell
         * Establishes the connection to the WfS server. Connecting to a WFS is
332
         * an abstraction.<br>
333
         * <p>
334 5673 caballero
         * Actually, it sends a GetCapabilities request to read the necessary
335 4886 jorpiell
         * data for building further DescribeFeatureType requests.
336
         * </p>
337
         * @throws IOException, DriverException.
338
         */
339 5830 jorpiell
        public boolean connect(boolean override,ICancellable cancel) throws IOException, DriverException {
340
                return remoteServicesClient.connect(override,cancel);
341 4886 jorpiell
        }
342 6493 caballero
343 5830 jorpiell
        public boolean connect(ICancellable cancel) {
344 18320 jpiera
                return remoteServicesClient.connect(false, cancel);
345 5830 jorpiell
        }
346 5673 caballero
347 4886 jorpiell
        /**
348 5673 caballero
         * Returns an array of WFSLayerNode's with the descriptors of
349 4911 jorpiell
         * all features (retrieved using the getCapabilities operation)
350
         * @return WFSLayerNode[]
351
         */
352
        public WFSLayerNode[] getLayerList(){
353 5293 jorpiell
                if (hashFeatures == null) {
354
                        hashFeatures = new Hashtable();
355
                        Hashtable wfsFeatures  = remoteServicesClient.getFeatures();
356 5673 caballero
357 18320 jpiera
                        StringComparator stringComparator = new StringComparator();
358
                    // Set spanish rules and with case sensitive
359
                        Collator collator = Collator.getInstance(new Locale("es_ES"));
360
                        stringComparator.setLocaleRules(stringComparator.new LocaleRules(true, collator));
361
                        stringComparator.setCaseSensitive(false);
362
363
                        ArrayList keysList = new ArrayList(wfsFeatures.keySet());
364
                        Collections.sort(keysList, stringComparator);
365
366
                        Iterator keys = keysList.iterator();
367 4911 jorpiell
                        featuresList = new WFSLayerNode[wfsFeatures.size()];
368 5673 caballero
369 4911 jorpiell
                        for (int i=0 ; i<wfsFeatures.size() ; i++){
370
                                WFSLayerNode lyr = new WFSLayerNode();
371
                                WFSFeature feature = (WFSFeature)wfsFeatures.get(keys.next());
372 5673 caballero
373 4911 jorpiell
                                lyr.setName(feature.getName());
374
                                lyr.setTitle(feature.getTitle());
375
                                lyr.setAbstract(feature.getAbstract());
376
                                lyr.setFields(feature.getFields());
377 5856 jorpiell
                                lyr.setSrs(feature.getSrs());
378
                                lyr.setLatLonBbox(feature.getLatLonBbox());
379 5673 caballero
380 4911 jorpiell
                                featuresList[i] = lyr;
381 5293 jorpiell
                                hashFeatures.put(lyr.getName(), lyr);
382 5673 caballero
                        }
383
                }
384 4911 jorpiell
                return featuresList;
385
        }
386 5673 caballero
387 4911 jorpiell
        /**
388 5673 caballero
         * Returns all the feature information retrieved using a
389 4911 jorpiell
         * describeFeatureTypeOpearion
390
         * @param layerName
391
         * Feature name
392
         * @return
393
         */
394
        public WFSLayerNode getLayerInfo(String layerName){
395 5293 jorpiell
                WFSLayerNode lyr = (WFSLayerNode)hashFeatures.get(layerName);
396 8847 ppiqueras
                try {
397 18320 jpiera
                        describeFeatureType(layerName, null);
398 8847 ppiqueras
                        WFSFeature feature = (WFSFeature) remoteServicesClient.getFeatures().get(layerName);
399
                        lyr.setFields(feature.getFields());
400
                } catch (WFSException e) {
401
                        // The feature doesn't has fields
402
                        e.printStackTrace();
403
                }
404 4911 jorpiell
                return lyr;
405
        }
406 5673 caballero
407
408 4911 jorpiell
        /**
409 18320 jpiera
         * @return The title of the service offered by the WMS server.
410
         */
411
        public String getServiceTitle() {
412
                return remoteServicesClient.getServiceInformation().title;
413
        }
414 5673 caballero
415 5293 jorpiell
        /**
416 18320 jpiera
         * @return The abstract of the service offered by the WMS server.
417 5293 jorpiell
         */
418 18320 jpiera
        public String getServiceAbstract() {
419
                return remoteServicesClient.getServiceInformation().abstr;
420 4911 jorpiell
        }
421 5293 jorpiell
422
        /**
423 18320 jpiera
         * @return the online resource
424 5293 jorpiell
         */
425 18320 jpiera
        public String getOnlineResource(){
426
                WFSServiceInformation si = remoteServicesClient.getServiceInformation();
427
                return si.getOnline_resource();
428 5293 jorpiell
        }
429 5673 caballero
430 18320 jpiera
        /**
431
         *
432
         * @return the host
433 5293 jorpiell
         */
434 18320 jpiera
        public String getHost(){
435
                return remoteServicesClient.getHost();
436 5293 jorpiell
        }
437 5673 caballero
438 18320 jpiera
        /**
439
         * @return the version of this client.
440 5293 jorpiell
         */
441 18320 jpiera
        public String getVersion() {
442
                return remoteServicesClient.getVersion();
443 5293 jorpiell
        }
444 5673 caballero
445 5293 jorpiell
        /*
446
         *  (non-Javadoc)
447
         * @see com.iver.cit.gvsig.fmap.drivers.WFSDriver#close()
448
         */
449
        public void close() {
450
                // TODO Auto-generated method stub
451 5673 caballero
452 5293 jorpiell
        }
453
454
        /*
455
         *  (non-Javadoc)
456
         * @see com.iver.cit.gvsig.fmap.drivers.WFSDriver#open()
457 5673 caballero
         */
458 5293 jorpiell
        public void open() throws DriverException {
459 5673 caballero
                attr.setLoadedInMemory(true);
460
461 5293 jorpiell
        }
462
463
        /*
464
         *  (non-Javadoc)
465
         * @see com.hardcode.gdbms.engine.data.driver.ObjectDriver#getPrimaryKeys()
466
         */
467
        public int[] getPrimaryKeys() throws com.hardcode.gdbms.engine.data.driver.DriverException {
468
                throw new UnsupportedOperationException();
469
        }
470
471
        /*
472
         *  (non-Javadoc)
473
         * @see com.hardcode.gdbms.engine.data.driver.ObjectDriver#write(com.hardcode.gdbms.engine.data.edition.DataWare)
474
         */
475
        public void write(DataWare dataWare) throws com.hardcode.gdbms.engine.data.driver.DriverException {
476 5673 caballero
477 5293 jorpiell
        }
478 5673 caballero
479 5293 jorpiell
        /*
480
         *  (non-Javadoc)
481
         * @see com.hardcode.gdbms.engine.data.driver.GDBMSDriver#setDataSourceFactory(com.hardcode.gdbms.engine.data.DataSourceFactory)
482
         */
483
        public void setDataSourceFactory(DataSourceFactory dsf) {
484
                // TODO Auto-generated method stub
485 5673 caballero
486 5293 jorpiell
        }
487
488
        /*
489
         *  (non-Javadoc)
490
         * @see com.hardcode.gdbms.engine.data.driver.ReadAccess#getFieldValue(long, int)
491
         */
492
        public Value getFieldValue(long rowIndex, int fieldId) throws com.hardcode.gdbms.engine.data.driver.DriverException {
493 18320 jpiera
                return driver.getFieldValue(rowIndex, fieldId);
494 5293 jorpiell
        }
495
496
        /*
497
         *  (non-Javadoc)
498
         * @see com.hardcode.gdbms.engine.data.driver.ReadAccess#getFieldCount()
499
         */
500
        public int getFieldCount() throws com.hardcode.gdbms.engine.data.driver.DriverException {
501 18320 jpiera
                return driver.getFieldCount();
502 5293 jorpiell
        }
503
504
        /*
505
         *  (non-Javadoc)
506
         * @see com.hardcode.gdbms.engine.data.driver.ReadAccess#getFieldName(int)
507
         */
508
        public String getFieldName(int fieldId) throws com.hardcode.gdbms.engine.data.driver.DriverException {
509 18320 jpiera
                return driver.getFieldName(fieldId);
510 5293 jorpiell
        }
511
512
        /*
513
         *  (non-Javadoc)
514
         * @see com.hardcode.gdbms.engine.data.driver.ReadAccess#getRowCount()
515
         */
516
        public long getRowCount() throws com.hardcode.gdbms.engine.data.driver.DriverException {
517 18320 jpiera
                return driver.getRowCount();
518 5293 jorpiell
        }
519
520
        /*
521
         *  (non-Javadoc)
522
         * @see com.hardcode.gdbms.engine.data.driver.ReadAccess#getFieldType(int)
523
         */
524
        public int getFieldType(int i) throws com.hardcode.gdbms.engine.data.driver.DriverException {
525 18320 jpiera
                return driver.getFieldType(i);
526 5293 jorpiell
        }
527
528
        /*
529
         *  (non-Javadoc)
530
         * @see com.hardcode.gdbms.engine.data.driver.ReadAccess#getFieldWidth(int)
531
         */
532
        public int getFieldWidth(int i) throws com.hardcode.gdbms.engine.data.driver.DriverException {
533
                // TODO Auto-generated method stub
534 6493 caballero
                return 100;
535 5293 jorpiell
        }
536
537
        /*
538
         *  (non-Javadoc)
539 5863 jorpiell
         * @see com.iver.cit.gvsig.fmap.drivers.VectorialDriver#isWritable()
540
         */
541 5528 jorpiell
        public boolean isWritable() {
542 18320 jpiera
                return true;
543 5528 jorpiell
        }
544 5673 caballero
545 5863 jorpiell
        /*
546
         *  (non-Javadoc)
547
         * @see com.iver.cit.gvsig.fmap.drivers.BoundedShapes#getShapeBounds(int)
548
         */
549 5673 caballero
        public Rectangle2D getShapeBounds(int index) throws IOException {
550
                return getShape(index).getBounds2D();
551
        }
552
553 5863 jorpiell
        /*
554
         *  (non-Javadoc)
555
         * @see com.iver.cit.gvsig.fmap.drivers.BoundedShapes#getShapeType(int)
556
         */
557 5673 caballero
        public int getShapeType(int index) {
558
                try {
559 5863 jorpiell
                        if (getShapeCount() > 0){
560 5673 caballero
                                return getShape(0).getGeometryType();
561 5863 jorpiell
                        }
562 5673 caballero
563
                } catch (IOException e) {
564
                        e.printStackTrace();
565
                }
566
                return FShape.MULTI;
567
        }
568
569 6508 jorpiell
        /*
570
         *  (non-Javadoc)
571
         * @see com.iver.cit.gvsig.fmap.drivers.VectorialDriver#reload()
572
         */
573 6324 jmvivo
        public void reload() throws IOException, com.hardcode.gdbms.engine.data.driver.DriverException {
574 18320 jpiera
                try {
575
                        getFeature(status);
576
                } catch (WFSException e) {
577
                        throw new com.hardcode.gdbms.engine.data.driver.DriverException(e);
578
                }
579 6318 jmvivo
        }
580
581 18320 jpiera
        /*
582
         * (non-Javadoc)
583
         * @see com.iver.cit.gvsig.fmap.edition.IWriteable#getWriter()
584
         */
585
        public IWriter getWriter() {
586
                if (writer == null){
587
                        writer = new FmapWFSWriter(this, isWfstEditing);
588
                }
589
                return writer;
590
        }
591 6324 jmvivo
592 18320 jpiera
        /**
593
         * @return the status
594
         */
595
        public WFSStatus getStatus() {
596
                return status;
597
        }
598
599
        /**
600
         * @return the isWfstEditing
601
         */
602
        public boolean isWfstEditing() {
603
                return isWfstEditing;
604
        }
605
606
        /**
607
         * @param isWfstEditing the isWfstEditing to set
608
         */
609
        public void setWfstEditing(boolean isWfstEditing) {
610
                this.isWfstEditing = isWfstEditing;
611
                if (writer != null){
612
                        writer.setWfstEditing(isWfstEditing);
613
                }
614
        }
615
616
        /**
617
         * @return the isWfstGeometriesUpdated
618
         */
619
        public boolean isWfstGeometriesUpdated() {
620
                return isWfstGeometriesUpdated;
621
        }
622
623
        /**
624
         * @param isWfstGeometriesUpdated the isWfstGeometriesUpdated to set
625
         */
626
        public void setWfstGeometriesUpdated(boolean isWfstGeometriesUpdated) {
627
                this.isWfstGeometriesUpdated = isWfstGeometriesUpdated;
628
        }
629
630
        /**
631
         * It locks all the features
632
         * @param expiryTime
633
         * The maximum time to edit
634
         * @throws WFSTLockFeaturesException
635
         */
636
        public void lockCurrentFeatures(int expiryTime) throws WFSTLockFeaturesException{
637
                ((FmapWFSWriter)getWriter()).lockCurrentFeatures(expiryTime);
638
        }
639
640
        /**
641
         * @return the remoteServicesClient
642
         */
643
        public WFSClient getRemoteServicesClient() {
644
                return remoteServicesClient;
645
        }
646
647
        /**
648
        * @return true if the server supports WFST
649
         */
650
        public boolean isTransactional(){
651
                String onlineResource = remoteServicesClient.getServiceInformation().getOnlineResource(WFSOperation.TRANSACTION);
652
                if (onlineResource == null){
653
                        onlineResource = remoteServicesClient.getServiceInformation().getOnlineResource(WFSOperation.TRANSACTION, WFSOperation.PROTOCOL_POST);
654
                        if (onlineResource == null){
655
                                return false;
656
                        }
657
                }
658
                return true;
659
        }
660 4886 jorpiell
}