Statistics
| Revision:

svn-gvsig-desktop / branches / v10 / extensions / extWFS2 / src / com / iver / cit / gvsig / fmap / layers / FLyrWFS.java @ 9230

History | View | Annotate | Download (19.7 KB)

1
package com.iver.cit.gvsig.fmap.layers;
2

    
3
import java.awt.geom.Rectangle2D;
4
import java.io.IOException;
5
import java.net.ConnectException;
6
import java.net.MalformedURLException;
7
import java.net.URL;
8
import java.util.ArrayList;
9
import java.util.HashMap;
10
import java.util.Map;
11
import java.util.Vector;
12

    
13
import javax.swing.ImageIcon;
14

    
15
import org.gvsig.remoteClient.gml.schemas.IXMLType;
16
import org.gvsig.remoteClient.gml.schemas.XMLComplexType;
17
import org.gvsig.remoteClient.gml.schemas.XMLElement;
18
import org.gvsig.remoteClient.wfs.WFSStatus;
19
import org.gvsig.remoteClient.wfs.filters.FilterEncoding;
20

    
21
import com.hardcode.gdbms.engine.instruction.FieldNotFoundException;
22
import com.iver.andami.PluginServices;
23
import com.iver.cit.gvsig.fmap.DriverException;
24
import com.iver.cit.gvsig.fmap.crs.CRSFactory;
25
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
26
import com.iver.cit.gvsig.fmap.drivers.VectorialDriver;
27
import com.iver.cit.gvsig.fmap.drivers.WFSException;
28
import com.iver.cit.gvsig.fmap.drivers.wfs.FMapWFSDriver;
29
import com.iver.cit.gvsig.fmap.drivers.wfs.FMapWFSDriverFactory;
30
import com.iver.cit.gvsig.fmap.drivers.wfs.WFSUtils;
31
import com.iver.cit.gvsig.fmap.drivers.wfs.filters.SQLExpressionFormat;
32
import com.iver.cit.gvsig.fmap.rendering.LegendFactory;
33
import com.iver.cit.gvsig.fmap.rendering.VectorialLegend;
34
import com.iver.utiles.StringUtilities;
35
import com.iver.utiles.XMLEntity;
36

    
37
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
38
 *
39
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
40
 *
41
 * This program is free software; you can redistribute it and/or
42
 * modify it under the terms of the GNU General Public License
43
 * as published by the Free Software Foundation; either version 2
44
 * of the License, or (at your option) any later version.
45
 *
46
 * This program is distributed in the hope that it will be useful,
47
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
48
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
49
 * GNU General Public License for more details.
50
 *
51
 * You should have received a copy of the GNU General Public License
52
 * along with this program; if not, write to the Free Software
53
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
54
 *
55
 * For more information, contact:
56
 *
57
 *  Generalitat Valenciana
58
 *   Conselleria d'Infraestructures i Transport
59
 *   Av. Blasco Ib??ez, 50
60
 *   46010 VALENCIA
61
 *   SPAIN
62
 *
63
 *      +34 963862235
64
 *   gvsig@gva.es
65
 *      www.gvsig.gva.es
66
 *
67
 *    or
68
 *
69
 *   IVER T.I. S.A
70
 *   Salamanca 50
71
 *   46005 Valencia
72
 *   Spain
73
 *
74
 *   +34 963163400
75
 *   dac@iver.es
76
 */
77
/* CVS MESSAGES:
78
 *
79
 * $Id: FLyrWFS.java 9230 2006-12-11 10:01:09Z ppiqueras $
80
 * $Log$
81
 * Revision 1.10.2.10  2006-12-11 10:01:09  ppiqueras
82
 * Corregido un bug
83
 *
84
 * Revision 1.22  2006/11/28 08:04:51  jorpiell
85
 * Se guarda la query para que pueda ser recuperada desde la ventana de propiedades
86
 *
87
 * Revision 1.21  2006/11/16 17:17:48  jorpiell
88
 * Se guarda el filtro en el gvp
89
 *
90
 * Revision 1.20  2006/11/16 13:29:47  jorpiell
91
 * Se ha reescrito losl m?todo para  guardar y recuperar gvps
92
 *
93
 * Revision 1.19  2006/11/15 17:38:08  jorpiell
94
 * Ya se puede guardar una capa en WFS.
95
 *
96
 * Revision 1.18  2006/10/31 12:24:04  jorpiell
97
 * Comprobado el caso en el que los atributos no tienen tipo
98
 *
99
 * Revision 1.17  2006/10/31 09:55:28  jorpiell
100
 * Se ha modificado el constructor del WFS desde cat?logo
101
 *
102
 * Revision 1.16  2006/10/31 09:38:15  jorpiell
103
 * 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
104
 *
105
 * Revision 1.15  2006/10/23 07:37:04  jorpiell
106
 * Ya funciona el filterEncoding
107
 *
108
 * Revision 1.14  2006/10/10 12:55:06  jorpiell
109
 * Se ha a?adido el soporte de features complejas
110
 *
111
 * Revision 1.13  2006/10/02 12:54:35  jorpiell
112
 * No se pod?a crear un mapa que tubiera la opci?n enlace vivo habilitada
113
 *
114
 * Revision 1.12  2006/10/02 09:09:45  jorpiell
115
 * Cambios del 10 copiados al head
116
 *
117
 * Revision 1.10.2.3  2006/09/29 14:12:53  luisw2
118
 * CRSFactory.getCRS substitutes ProjectionPool.get
119
 *
120
 * Revision 1.10.2.2  2006/09/28 08:54:01  jorpiell
121
 * Ya se puede reproyectar
122
 *
123
 * Revision 1.10.2.1  2006/09/26 07:36:24  jorpiell
124
 * El WFS no reproyectaba porque no se le asignaba a la capa un sistema de referencia. Ahora ya se hace.
125
 *
126
 * Revision 1.10  2006/09/05 15:41:52  jorpiell
127
 * A?adida la funcionalidad de cargar WFS desde el cat?logo
128
 *
129
 * Revision 1.9  2006/07/05 12:05:41  jorpiell
130
 * Se ha modificado para que avise si se han recuperado las mismas features que marca el campo buffer
131
 *
132
 * Revision 1.8  2006/06/21 12:52:10  jorpiell
133
 * A?adido un icono para la capa WFS
134
 *
135
 * Revision 1.7  2006/06/21 12:35:45  jorpiell
136
 * 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
137
 *
138
 * Revision 1.6  2006/06/15 11:17:06  jorpiell
139
 * Se ha encontrado la forma de comprobar cuando se prodicia un error de parseo al hacer un hasnext (en la feature). Se atrapa y se lanza la excepci?n hacia arriba
140
 *
141
 * Revision 1.5  2006/06/14 07:57:19  jorpiell
142
 * Ya no se usa la estrategia ni se usa geotools para hacer el getFeature. Ahora se usa ?nicamente para el parseo de GML
143
 *
144
 * Revision 1.4  2006/06/05 16:49:31  caballero
145
 * poder editar y exportar
146
 *
147
 * Revision 1.3  2006/05/25 10:31:55  jorpiell
148
 * Se ha renombrado la clase WFSFields por WFSAttributes porque era algo confusa
149
 *
150
 * Revision 1.2  2006/05/23 13:21:59  jorpiell
151
 * Si hay alg?n problema en la carga se muestra un mensaje de error
152
 *
153
 * Revision 1.1  2006/05/19 12:54:11  jorpiell
154
 * Creada la capa WFS
155
 *
156
 *
157
 */
158
/**
159
 *  FMap's WFS Layer class.
160
 *
161
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
162
 */
163
public class FLyrWFS extends FLyrVect{
164
        private URL host = null;
165
        private String onlineResource = null;
166
        private String name = null;
167
        private String layerName = null;
168
    private String userName = null;
169
    private String password = null;
170
    private String AttributesQuery = null;
171
    private String CoordinatesQuery = null;
172
    private String visualFilterQuery = null;
173
    private XMLElement[] fields = null;
174
    private int numfeatures = 100;
175
    private int timeout = 10000;
176
    private String srs = null;
177
    private FMapWFSDriver wfsDriver = null;
178
    private WFSLayerNode wfsLayerNode = null;
179
    
180
    /**
181
     * Constructor
182
     */
183
    public FLyrWFS(){
184
            super();
185
    }
186
    
187
    /**
188
     * Constructor to load a new layer from a catalog
189
     * search
190
     * @param args
191
     * Params to load a new layer
192
     * @throws WFSException 
193
     * @throws IOException 
194
     * @throws MalformedURLException 
195
     * @throws ConnectException 
196
     * @throws DriverIOException 
197
     */
198
    public FLyrWFS(Map args) throws WFSException, ConnectException, MalformedURLException, IOException, DriverIOException{
199
            String[] sLayer = (String[])args.get("layer");
200
                String user = (String)args.get("user");
201
                String pwd = (String)args.get("pwd");
202
                String host = (String)args.get("host");        
203
                String projection = (String)args.get("projection");
204
                
205
                FMapWFSDriver driver = FMapWFSDriverFactory.getFMapDriverForURL(new URL(host));
206
                WFSLayerNode[] layers = driver.getLayerList();
207
                WFSLayerNode layer = driver.getLayerInfo(sLayer[0]);
208
                
209
                layer.setSelectedFields(layer.getFields());
210
                
211
                Vector vAtts = new Vector();
212
                if (layer.getFields().size() == 1){
213
                        XMLElement element = (XMLElement)layer.getFields().get(0);
214
                        if (element.getEntityType().getType() != IXMLType.COMPLEX){
215
                                vAtts.add(element);
216
                        }else{
217
                                vAtts = ((XMLComplexType)element.getEntityType()).getAttributes();
218
                        }
219
                }
220
                for (int i=0 ; i<layer.getFields().size() ; i++){
221
                        XMLElement element = (XMLElement)layer.getFields().get(i);
222
                        if (element.getEntityType().getType() != IXMLType.COMPLEX){
223
                                vAtts.add((XMLElement)layer.getFields().get(i));
224
                        }else{
225
                                
226
                        }
227
                }
228
                
229
                XMLElement[] atts = new XMLElement[vAtts.size()];
230
                for (int i=0 ; i<vAtts.size() ; i++){
231
                        atts[i] = (XMLElement)vAtts.get(i);
232
                }
233
        
234
                setHost(host);
235
                setName(sLayer[0]);
236
                setLayerName(sLayer[0]);
237
                setWfsLayerNode(layer);
238
                setFields(atts);
239
                setUserName(user);
240
                setPassword(pwd);
241
                setNumfeatures(10000);
242
                setTimeout(10000);
243
                setWfsDriver(driver);                        
244
                setProjection(CRSFactory.getCRS(projection));
245
                
246
            load();            
247
    }
248
    
249

    
250
    /**
251
     * Loads the features from the server
252
     */
253
    public void load() throws DriverIOException{
254
            WFSAdapter adapter = new WFSAdapter();
255
            try {
256
                    wfsDriver.getFeature(getWFSStatus());
257

    
258
                    adapter.setDriver((VectorialDriver) wfsDriver);
259
                    setSource(adapter);
260

    
261
                    if (getLegend() == null){
262
                            setLegend(LegendFactory.createSingleSymbolLegend(
263
                                    getShapeType()));
264
                    }
265
            } catch (Exception e){
266
                    e.printStackTrace();
267
                    throw new DriverIOException(e.getMessage());
268
            }
269
    }
270

    
271
    /**
272
     * Gets the WFS Status
273
     * @return
274
     */
275
    private WFSStatus getWFSStatus(){
276
            WFSStatus status = new WFSStatus(getLayerName());
277
            status.setUserName(getUserName());
278
            status.setPassword(getPassword());
279
            status.setBuffer(getNumfeatures());
280
            status.setTimeout(getTimeout());
281
            status.setFields(getFieldNames());
282
            status.setOnlineResource(getOnlineResource());
283
            status.setSrs(getSrs());
284
            //Filter Encoding transformation
285
            FilterEncoding fe = SQLExpressionFormat.createFilter();                                
286
                fe.setQuery(getAttributesQuery());
287
                status.setFilterQuery(fe.toString());
288
                status.setFilterVisualText(getVisualFilterQuery());
289
            return status;
290
    }
291

    
292
        /**
293
         * @return Returns the layerName.
294
         */
295
        public String getLayerName() {
296
                return layerName;
297
        }
298
        /**
299
         * @param layerName The layerName to set.
300
         */
301
        public void setLayerName(String layerName) {
302
                this.layerName = layerName;
303
        }
304
        /**
305
         * @return Returns the numfeatures.
306
         */
307
        public int getNumfeatures() {
308
                return numfeatures;
309
        }
310
        /**
311
         * @param numfeatures The numfeatures to set.
312
         */
313
        public void setNumfeatures(int numfeatures) {
314
                this.numfeatures = numfeatures;
315
        }
316

    
317
        /**
318
         * @return Returns the pwd.
319
         */
320
        public String getPassword() {
321
                return password;
322
        }
323
        /**
324
         * @param pwd The pwd to set.
325
         */
326
        public void setPassword(String password) {
327
                this.password = password;
328
        }
329
        /**
330
         * @return Returns the timeout.
331
         */
332
        public int getTimeout() {
333
                return timeout;
334
        }
335
        /**
336
         * @param timeout The timeout to set.
337
         */
338
        public void setTimeout(int timeout) {
339
                this.timeout = timeout;
340
        }
341
        /**
342
         * @return Returns the user.
343
         */
344
        public String getUserName() {
345
                return userName;
346
        }
347
        /**
348
         * @param user The user to set.
349
         */
350
        public void setUserName(String userName) {
351
                this.userName = userName;
352
        }
353
        /**
354
         * @return The visual filtering text from "Where"
355
         */
356
        public String getVisualFilterQuery() {
357
                return visualFilterQuery;
358
        }
359
        /**
360
         * @param visualFilterQuery The visual filtering text from "Where"
361
         */
362
        public void setVisualFilterQueyr(String visualFilterQuery) {
363
                this.visualFilterQuery = visualFilterQuery;
364
        }
365
        /**
366
         * @return Returns the fields.
367
         */
368
        public XMLElement[] getFields() {
369
                if (fields == null){
370
                        return new XMLElement[0];
371
                }
372
                return fields;
373
        }
374

    
375
        /**
376
         * Return the attributes name
377
         * @return
378
         */
379
        public String[] getFieldNames(){
380
                Vector vAttributes = new Vector();
381
                for (int i=0 ; i<getFields().length ; i++){
382
                        if ((getFields()[i].getEntityType() == null) || 
383
                                        (getFields()[i].getEntityType().getType() != IXMLType.COMPLEX)){
384
                                vAttributes.add(getFields()[i].getName());
385
                        }
386
                }
387
                String[] attributes = new String[vAttributes.size()];
388
                for (int i=0 ; i<vAttributes.size() ; i++){
389
                        attributes[i] = (String)vAttributes.get(i);
390
                }
391
                return attributes;
392
        }
393

    
394
        /**
395
         * @param fields The fields to set.
396
         */
397
        public void setFields(XMLElement[] fields) {
398
                this.fields = fields;
399
        }
400
        /**
401
         * @return Returns the name.
402
         */
403
        public String getName() {
404
                return name;
405
        }
406
        /**
407
         * @param name The name to set.
408
         */
409
        public void setName(String name) {
410
                this.name = name;
411
        }
412
        /**
413
         * @return Returns the host.
414
         */
415
        public URL getHost() {
416
                return host;
417
        }
418
        /**
419
         * @param host The host to set.
420
         */
421
        public void setHost(URL host) {
422
                this.host = host;
423
        }
424

    
425
        /**
426
         * @return Returns the wfs.
427
         */
428
        public FMapWFSDriver getWfsDriver() {
429
                return wfsDriver;
430
        }
431

    
432
        /**
433
         * @param wfs The wfs to set.
434
         */
435
        public void setWfsDriver(FMapWFSDriver wfs) {
436
                this.wfsDriver = wfs;
437
        }
438

    
439

    
440
        /*
441
         *  (non-Javadoc)
442
         * @see com.iver.cit.gvsig.fmap.layers.FLyrDefault#getStrategy()
443
         */
444
//    public Strategy getStrategy() {
445
//        if (wfsStrategy == null){
446
//                wfsStrategy = new WFSStrategy(this);
447
//        }
448
//            return wfsStrategy;
449
//    }
450

    
451
    /*
452
     *  (non-Javadoc)
453
     * @see com.iver.cit.gvsig.fmap.layers.FLayer#getFullExtent()
454
     */
455
    public Rectangle2D getFullExtent() throws DriverException {
456
            try {
457
                    Rectangle2D extent = wfsDriver.getFullExtent();
458
                    if (getCoordTrans() != null){
459
                            return getCoordTrans().convert(extent);
460
                    }
461
                        return extent;
462
                } catch (IOException e) {
463
                        throw new DriverException(e.toString());
464
                }
465
        }
466

    
467
        /**
468
         * @return Returns the onlineResource.
469
         */
470
        public String getOnlineResource() {
471
                return onlineResource;
472
        }
473

    
474
        /**
475
         * @param onlineResource The onlineResource to set.
476
         */
477
        public void setOnlineResource(String onlineResource) {
478
                this.onlineResource = onlineResource;
479
        }
480

    
481
        public HashMap getProperties() {
482
                HashMap info = new HashMap();
483
                info.put("name", getName());
484
                info.put("layerName", getLayerName());
485
                info.put("layerText", getLayerText());
486
                info.put("attributes", getFields());
487
                info.put("host", getHost());        
488
                info.put("wfsLayerNode", getWfsLayerNode());        
489
                WFSStatus status = new WFSStatus(getLayerName());
490
                status.setBuffer(getNumfeatures());
491
                status.setTimeout(getTimeout());
492
                status.setUserName(getUserName());
493
                status.setPassword(getPassword());
494
                status.setFilterQuery(getAttributesQuery());
495
                status.setFilterVisualText(getVisualFilterQuery());
496
                info.put("status",status);                        
497
                return info;
498

    
499
        }
500

    
501
        /**
502
         * @return Returns the wfsLayerNode.
503
         */
504
        public WFSLayerNode getWfsLayerNode() {
505
                return wfsLayerNode;
506
        }
507

    
508
        /**
509
         * @param wfsLayerNode The wfsLayerNode to set.
510
         */
511
        public void setWfsLayerNode(WFSLayerNode wfsLayerNode) {
512
                this.wfsLayerNode = wfsLayerNode;
513
        }
514

    
515
        public void setHost(String host2) {
516
                try {
517
                        setHost(new URL(host2));
518
                } catch (MalformedURLException e) {
519
                        // TODO Auto-generated catch block
520
                        e.printStackTrace();
521
                }                
522
        }
523
        
524
        public ImageIcon getTocImageIcon() {                        
525
                return new ImageIcon(PluginServices.getPluginServices("com.iver.cit.gvsig.wfs2").getClassLoader().getResource("images/icoLayer.png"));
526
        }
527
        
528
        /*
529
         *  (non-Javadoc)
530
         * @see com.iver.cit.gvsig.fmap.layers.FLyrVect#isPropertiesMenuVisible()
531
         */
532
        public boolean isPropertiesMenuVisible(){
533
                return false;
534
        }
535

    
536
        public String getSrs() {
537
                return srs;
538
        }
539

    
540
        public void setSrs(String srs) {
541
                this.srs = srs;
542
        }
543
        
544
        /**
545
         * @return XMLEntity.
546
         * @throws XMLException
547
         */
548
        public XMLEntity getXMLEntity() throws XMLException {        
549
                XMLEntity xml = super.getXMLEntity();                
550
                
551
                // Full extent
552
                try {
553
                        xml.putProperty("fullExtent", StringUtilities.rect2String(getFullExtent()));
554
                } catch (DriverException e) {
555
                        // TODO Auto-generated catch block
556
                        e.printStackTrace();
557
                }
558

    
559
                // Host
560
                xml.putProperty("host", host.toExternalForm());
561
                
562
                // Layer name
563
                xml.putProperty("layerName", getLayerName());                
564
                xml.putProperty("name", getName());
565

    
566
                //Layer fields
567
                XMLElement[] fields = getFields();
568
                String strFields = "";
569
                for (int i=0 ; i<fields.length ; i++){
570
                        //If is not the root node
571
                        if (fields[i].getParentElement() != null){
572
                                strFields = strFields + fields[i].getFullName();
573
                                if (i < fields.length - 1){
574
                                        strFields = strFields + "~##SEP1##~";
575
                                }
576
                        }else{
577
                                xml.putProperty("rootNode", true);
578
                        }
579
                }
580
                xml.putProperty("fields", strFields);
581
                
582
                // User name
583
                xml.putProperty("user", getUserName());
584
        
585
                // SRS
586
                xml.putProperty("srs", getSrs());                
587

    
588
        // OnlineResources
589
        xml.putProperty("onlineResource", getOnlineResource());
590
      
591
            // TimeOut
592
                xml.putProperty("timeout", getTimeout());                
593

    
594
        // Buffer
595
        xml.putProperty("buffer", getNumfeatures());
596
        
597
        //Projection
598
        xml.putProperty("projection",getProjection().getAbrev());
599
        
600
        //Filter
601
        xml.putProperty("filterEncoding",getAttributesQuery());
602
        
603
        return xml;
604
        }
605
        
606
        /**
607
         * @param xml XMLEntity
608
         *
609
         * @throws XMLException
610
         * @throws DriverException
611
         * @throws DriverI OException
612
         */
613
        public void setXMLEntity(XMLEntity xml)throws XMLException {
614
                                                
615
                // Host
616
                try {
617
                        host = new URL(xml.getStringProperty("host"));
618
                } catch (MalformedURLException e) {
619
                        throw new XMLException(e);
620
                }
621
                
622
                // Layer name
623
                setLayerName(xml.getStringProperty("layerName"));                        
624
                setName(xml.getStringProperty("name"));                
625
                
626
                // User name
627
                if (xml.contains("user")){
628
                        setUserName(xml.getStringProperty("user"));
629
                }
630
                
631
                // SRS
632
                if (xml.contains("srs")){
633
                        setSrs(xml.getStringProperty("srs"));
634
                }
635
                
636
                // OnlineResources
637
                if (xml.contains("onlineResource")){
638
                        setOnlineResource(xml.getStringProperty("onlineResource"));
639
                }
640
                
641
                // TimeOut
642
                if (xml.contains("timeout")){
643
                        setTimeout(xml.getIntProperty("timeout"));
644
                }
645
                
646
                // Buffer
647
                if (xml.contains("buffer")){
648
                        setNumfeatures(xml.getIntProperty("buffer"));
649
                }
650
                
651
                 //Projection
652
                if (xml.contains("projection")){
653
                        setProjection(CRSFactory.getCRS(xml.getStringProperty("projection")));
654
                }       
655
                
656
                 //Filter
657
                if (xml.contains("filterEncoding")){
658
                        setAttributesQuery(xml.getStringProperty("filterEncoding"));
659
                }   
660
                
661
                // Layer fields
662
                FMapWFSDriver driver;
663
                try {
664
                        driver = FMapWFSDriverFactory.getFMapDriverForURL(host);
665
                        setWfsDriver(driver);        
666
                        WFSAdapter adapter = new WFSAdapter();
667
                    adapter.setDriver((VectorialDriver) wfsDriver);
668
                    setSource(adapter);
669
                    super.setXMLEntity(xml);
670
                    setLegend(LegendFactory.createFromXML(xml.getChild(0)));
671
                } catch (Exception e) {
672
                        throw new XMLException(e);        
673
                }
674
                driver.getLayerList();
675
                WFSLayerNode layer = driver.getLayerInfo(getLayerName());                        
676
                XMLElement[] atts = null;                
677
                
678
//                The root element always exists
679
                XMLElement rootElement = (XMLElement)layer.getFields().get(0);
680
                
681
                if (xml.contains("fields")) {
682
                        String[] fields = xml.getStringProperty("fields").split("~##SEP1##~");        
683
                        if ((fields.length == 1) && (fields[0].equals(""))){
684
                                fields = new String[0];
685
                        }
686
                        //The root element always is a complex type
687
                        Vector allFields = ((XMLComplexType)rootElement.getEntityType()).getAttributes();
688
                        //If the root node has been selected
689
                        if (xml.contains("rootNode")){
690
                                if (xml.getBooleanProperty("rootNode")==true){
691
                                        atts = new XMLElement[fields.length + 1];
692
                                        atts[fields.length] = rootElement;
693
                                }else{
694
                                        atts = new XMLElement[fields.length];
695
                                }
696
                        }else{
697
                                atts = new XMLElement[fields.length];
698
                        }
699
                        //Adding the other fields
700
                        for (int i=0 ; i<fields.length ; i++){
701
                                for (int j=0 ; j<allFields.size() ; j++){
702
                                        XMLElement attribute = (XMLElement)allFields.get(j);
703
                                        if (attribute != null){
704
                                                XMLElement found = attribute.searchAttribute(fields[i]);
705
                                                if (found != null){
706
                                                        atts[i] = found;
707
                                                        break;
708
                                                }
709
                                        }
710
                                }                                        
711
                        }                        
712
                }else{
713
                        if (xml.contains("rootNode")){
714
                                if (xml.getBooleanProperty("rootNode")==true){
715
                                        atts = new XMLElement[1];
716
                                        atts[0] = rootElement;
717
                                }
718
                        }
719
                }
720
                layer.setSelectedFields(atts);
721
                setWfsLayerNode(layer);
722
                setFields(atts);        
723
                setAvailable(true);
724
        }
725

    
726
        /**
727
         * @return Returns the attributesQuery.
728
         */
729
        public String getAttributesQuery() {
730
                return AttributesQuery;
731
        }
732

    
733
        /**
734
         * @param attributesQuery The attributesQuery to set.
735
         */
736
        public void setAttributesQuery(String attributesQuery) {
737
                AttributesQuery = attributesQuery;
738
        }
739

    
740
        /**
741
         * @return Returns the coordinatesQuery.
742
         */
743
        public String getCoordinatesQuery() {
744
                return CoordinatesQuery;
745
        }
746

    
747
        /**
748
         * @param coordinatesQuery The coordinatesQuery to set.
749
         */
750
        public void setCoordinatesQuery(String coordinatesQuery) {
751
                CoordinatesQuery = coordinatesQuery;
752
        }
753
}