Revision 1358

View differences:

org.gvsig.wfs.app/tags/org.gvsig.wfs.app-2.0.248/org.gvsig.wfs.app.mainplugin/buildNumber.properties
1
#Sun Jun 16 22:23:14 CEST 2024
2
buildNumber=2332
org.gvsig.wfs.app/tags/org.gvsig.wfs.app-2.0.248/org.gvsig.wfs.app.mainplugin/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.fmap.dal.store.wfs.WFSLibrary
org.gvsig.wfs.app/tags/org.gvsig.wfs.app-2.0.248/org.gvsig.wfs.app.mainplugin/src/main/assembly/gvsig-plugin-package.xml
1
<assembly>
2
  <id>gvsig-plugin-package</id>
3
  <formats>
4
    <format>zip</format>
5
  </formats>
6
  <baseDirectory>${project.artifactId}</baseDirectory>
7
  <includeBaseDirectory>true</includeBaseDirectory>
8
  <files>
9
    <file>
10
      <source>target/${project.artifactId}-${project.version}.jar</source>
11
      <outputDirectory>lib</outputDirectory>
12
    </file>
13
    <file>
14
      <source>target/package.info</source>
15
    </file>
16
  </files>
17

  
18
  <fileSets>
19
    <fileSet>
20
      <directory>src/main/resources-plugin</directory>
21
      <outputDirectory>.</outputDirectory>
22
    </fileSet>
23
  </fileSets>
24

  
25
<!--
26
  <dependencySets>
27
    <dependencySet>
28
      <useProjectArtifact>false</useProjectArtifact>
29
      <useTransitiveDependencies>false</useTransitiveDependencies>
30
      <outputDirectory>lib</outputDirectory>
31
      <includes>
32
        <include>org.gvsig:org.gvsig.wfs.app.mainplugin</include>
33
      </includes>
34
    </dependencySet>
35
  </dependencySets>
36
-->
37

  
38
</assembly>
org.gvsig.wfs.app/tags/org.gvsig.wfs.app-2.0.248/org.gvsig.wfs.app.mainplugin/src/main/java/org/gvsig/fmap/dal/serverexplorer/wfs/WFSServerExplorerParameters.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 * 
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 * 
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 * 
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
 * MA  02110-1301, USA.
20
 * 
21
 */
22

  
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2009 {Iver T.I.}   {Task}
26
 */
27
package org.gvsig.fmap.dal.serverexplorer.wfs;
28

  
29
import org.apache.commons.lang3.BooleanUtils;
30
import org.apache.commons.lang3.StringUtils;
31
import org.gvsig.fmap.dal.DataServerExplorerParameters;
32
import org.gvsig.fmap.dal.DataTypes;
33
import org.gvsig.fmap.dal.spi.AbstractDataParameters;
34
import org.gvsig.fmap.dal.spi.AbstractDataServerExplorerParameters;
35
import org.gvsig.tools.ToolsLocator;
36
import org.gvsig.tools.dynobject.DelegatedDynObject;
37
import org.gvsig.tools.dynobject.DynClass;
38
import org.gvsig.tools.dynobject.DynField;
39
import org.gvsig.tools.dynobject.DynObjectManager;
40

  
41
/**
42
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
43
 */
44
public class WFSServerExplorerParameters extends AbstractDataServerExplorerParameters
45
        implements DataServerExplorerParameters {
46

  
47
    public static final String DYNCLASS_NAME = "WFSServerExplorerParameters";
48
    public static final String DYNFIELDNAME_URL = "url";
49
    public static final String DYNFIELDNAME_VERSION = "version";
50
    public static final String DYNFIELDNAME_IGNORE_CACHE = "ignoreCache";
51
    private DelegatedDynObject delegatedDynObject;
52

  
53
    public WFSServerExplorerParameters() {
54
        super();
55
        this.delegatedDynObject = (DelegatedDynObject) ToolsLocator
56
                .getDynObjectManager()
57
                .createDynObject(this.registerDynClass());
58
    }
59

  
60
    @Override
61
    protected DelegatedDynObject getDelegatedDynObject() {
62
        return delegatedDynObject;
63
    }
64

  
65
    private DynClass registerDynClass() {
66
        DynObjectManager dynman = ToolsLocator.getDynObjectManager();
67
        DynClass dynClass = dynman.get(DYNCLASS_NAME);
68
        DynField field;
69
        if (dynClass == null) {
70
            dynClass = dynman.add(DYNCLASS_NAME);
71

  
72
            field = dynClass.addDynFieldString(DYNFIELDNAME_URL);
73
            field.setDescription("Path of the remote service");
74
            field.setMandatory(true);
75

  
76
            field = dynClass.addDynFieldString(DYNFIELDNAME_VERSION);
77
            field.setDescription("Version of the remote service");
78
            field.setMandatory(false);
79

  
80
            field = dynClass.addDynFieldBoolean(DYNFIELDNAME_IGNORE_CACHE);
81
            field.setDescription("If this is true download al files in the next access.");
82
            field.setMandatory(false);
83
            field.setDefaultFieldValue(Boolean.FALSE);
84
        }
85
        return dynClass;
86
    }
87

  
88
    /* (non-Javadoc)
89
     * @see org.gvsig.fmap.dal.DataServerExplorerParameters#getExplorerName()
90
     */
91
    public String getExplorerName() {
92
        return WFSServerExplorer.NAME;
93
    }
94

  
95
    public String getUrl() {
96
        return (String) this.getDynValue(DYNFIELDNAME_URL);
97
    }
98

  
99
    public void setUrl(String url) {
100
        this.setDynValue(DYNFIELDNAME_URL, url);
101
    }
102

  
103
    public String getVersion() {
104
        return (String) this.getDynValue(DYNFIELDNAME_VERSION);
105
    }
106

  
107
    public void setVersion(String version) {
108
        this.setDynValue(DYNFIELDNAME_VERSION, version);
109
    }
110

  
111
    public boolean getIgnoreChace() {
112
        return BooleanUtils.isTrue((Boolean) this.getDynValue(DYNFIELDNAME_IGNORE_CACHE));
113
    }
114

  
115
    public void setIgnoreCache(Boolean ignoreCache) {
116
        this.setDynValue(DYNFIELDNAME_IGNORE_CACHE, new Boolean(ignoreCache));
117
    }
118

  
119
    @Override
120
    public boolean isTheSameServerExplorer(DataServerExplorerParameters params) {
121
        if(!(params instanceof WFSServerExplorerParameters)){
122
            return false;
123
        }
124
        return StringUtils.equals(this.getUrl(), ((WFSServerExplorerParameters)params).getUrl());
125
    }
126

  
127
}
org.gvsig.wfs.app/tags/org.gvsig.wfs.app-2.0.248/org.gvsig.wfs.app.mainplugin/src/main/java/org/gvsig/fmap/dal/serverexplorer/wfs/WFSServerExplorerFactory.java
1

  
2
package org.gvsig.fmap.dal.serverexplorer.wfs;
3

  
4
import org.gvsig.fmap.dal.DataServerExplorer;
5
import org.gvsig.fmap.dal.DataServerExplorerParameters;
6
import org.gvsig.fmap.dal.exception.InitializeException;
7
import org.gvsig.fmap.dal.spi.AbstractDataServerExplorerFactory;
8
import org.gvsig.fmap.dal.spi.DataServerExplorerProviderServices;
9
import org.gvsig.fmap.dal.store.wfs.WFSStoreProvider;
10
import org.gvsig.tools.dynobject.DynObject;
11

  
12
public class WFSServerExplorerFactory extends AbstractDataServerExplorerFactory {
13

  
14
    public WFSServerExplorerFactory() {
15
        super(WFSServerExplorer.NAME, WFSStoreProvider.DESCRIPTION);
16
    }
17
    
18
    @Override
19
    public DynObject createParameters() {
20
        return new WFSServerExplorerParameters();
21
    }
22

  
23
    @Override
24
    public DataServerExplorer create(DataServerExplorerParameters parameters, DataServerExplorerProviderServices explorer) throws InitializeException {
25
        return new WFSServerExplorer((WFSServerExplorerParameters) parameters, explorer);
26
    }
27
    
28
}
org.gvsig.wfs.app/tags/org.gvsig.wfs.app-2.0.248/org.gvsig.wfs.app.mainplugin/src/main/java/org/gvsig/fmap/dal/serverexplorer/wfs/WFSServerExplorer.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22

  
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2009 {Iver T.I.}   {Task}
26
 */
27

  
28
package org.gvsig.fmap.dal.serverexplorer.wfs;
29

  
30
import java.io.File;
31
import java.io.FileNotFoundException;
32
import java.io.IOException;
33
import java.net.ConnectException;
34
import java.util.ArrayList;
35
import java.util.Hashtable;
36
import java.util.Iterator;
37
import java.util.List;
38

  
39
import org.gvsig.fmap.dal.DALLocator;
40
import org.gvsig.fmap.dal.DataManager;
41
import org.gvsig.fmap.dal.DataServerExplorerParameters;
42
import org.gvsig.fmap.dal.DataStoreParameters;
43
import org.gvsig.fmap.dal.NewDataStoreParameters;
44
import org.gvsig.fmap.dal.exception.DataException;
45
import org.gvsig.fmap.dal.exception.InitializeException;
46
import org.gvsig.fmap.dal.spi.AbstractDataServerExplorer;
47
import org.gvsig.fmap.dal.spi.DataServerExplorerProvider;
48
import org.gvsig.fmap.dal.spi.DataServerExplorerProviderServices;
49
import org.gvsig.fmap.dal.store.wfs.WFSFeatureFiller;
50
import org.gvsig.fmap.dal.store.wfs.WFSOpenStoreParameters;
51
import org.gvsig.fmap.dal.store.wfs.WFSStoreProvider;
52
import org.gvsig.remoteclient.wfs.WFSClient;
53
import org.gvsig.remoteclient.wfs.WFSFeature;
54
import org.gvsig.remoteclient.wfs.WFSStatus;
55
import org.gvsig.remoteclient.wfs.exceptions.WFSException;
56
import org.gvsig.tools.exception.BaseException;
57
import org.gvsig.xmlschema.lib.api.exceptions.SchemaCreationException;
58

  
59
/**
60
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
61
 */
62
public class WFSServerExplorer extends AbstractDataServerExplorer implements
63
DataServerExplorerProvider {
64
    public static final String NAME = "WFSServerExplorer";
65
//    private WFSServerExplorerParameters parameters = null;
66
    private DataManager dataManager = DALLocator.getDataManager();
67
    private String url = null;
68

  
69
    //WFS Parameters
70
    private WFSStatus status = null;
71
    private WFSClient wfsClient = null;
72

  
73
    /**
74
     * @param parameters
75
     */
76
    public WFSServerExplorer(WFSServerExplorerParameters parameters, DataServerExplorerProviderServices services) throws InitializeException{
77
        super(parameters, services);
78
//        this.parameters = parameters;
79
        this.url = parameters.getUrl();
80
        if (wfsClient == null){
81
            try {
82
                wfsClient = new WFSClient(url, parameters.getIgnoreChace());
83
                if (status == null){
84
                    status = new WFSStatus(null);
85
                }
86

  
87
                wfsClient.getCapabilities(status, parameters.getIgnoreChace(), null);
88
            } catch (ConnectException e) {
89
                throw new InitializeException("Not possible to connect with " + url, e);
90
            } catch (IOException e) {
91
                throw new InitializeException("Not possible to connect with " + url, e);
92
            } catch (WFSException e) {
93
                throw new InitializeException("Not possible to connect with " + url, e);
94
            }
95
        }
96
    }
97

  
98
    /**
99
     * Returns all the feature information retrieved using a
100
     * describeFeatureTypeOpearion
101
     * @param nameSpace
102
     * @param layerName
103
     * Feature name
104
     * @return
105
     * @throws WFSException
106
     */
107
    public WFSFeature getFeatureInfo(String nameSpace, String layerName) throws WFSException{
108
        status = new WFSStatus(layerName, nameSpace);
109
        WFSFeature feature = (WFSFeature) wfsClient.getFeature(nameSpace, layerName);
110
        if (!feature.isCompleted()){
111
            File describeFeatureTypeFile = wfsClient.describeFeatureType(status, getParameters().getIgnoreChace(), null);
112

  
113
            WFSFeatureFiller featureFiller = new WFSFeatureFiller(feature);
114
            try {
115
                featureFiller.fill(describeFeatureTypeFile);
116
            } catch (SchemaCreationException e) {
117
                throw new WFSException(e);
118
            } catch (FileNotFoundException e) {
119
                throw new WFSException(e);
120
            }
121
        }
122

  
123
        return 	feature;
124
    }
125

  
126

  
127

  
128
    /**
129
     * Returns an array of WFSLayerNode's with the descriptors of
130
     * all features (retrieved using the getCapabilities operation)
131
     * @return WFSLayerNode[]
132
     */
133
    public Hashtable getFeatures(){
134
        return wfsClient.getFeatures();
135
    }
136

  
137
    /* (non-Javadoc)
138
     * @see org.gvsig.fmap.dal.DataServerExplorer#add(org.gvsig.fmap.dal.NewDataStoreParameters, boolean)
139
     */
140
    public boolean add(String providerName, NewDataStoreParameters parameters, boolean overwrite)
141
    throws DataException {
142
        // TODO Auto-generated method stub
143
        return false;
144
    }
145

  
146
    /* (non-Javadoc)
147
     * @see org.gvsig.fmap.dal.DataServerExplorer#canAdd()
148
     */
149
    public boolean canAdd() {
150
        // TODO Auto-generated method stub
151
        return false;
152
    }
153

  
154
    /* (non-Javadoc)
155
     * @see org.gvsig.fmap.dal.DataServerExplorer#canAdd(java.lang.String)
156
     */
157
    public boolean canAdd(String storeName) throws DataException {
158
        // TODO Auto-generated method stub
159
        return false;
160
    }
161

  
162
    @Override
163
    protected void doDispose() throws BaseException {
164
        // Nothing to do
165
    }
166

  
167
    /* (non-Javadoc)
168
     * @see org.gvsig.fmap.dal.DataServerExplorer#getAddParameters(java.lang.String)
169
     */
170
    public NewDataStoreParameters getAddParameters(String storeName)
171
    throws DataException {
172
        // TODO Auto-generated method stub
173
        return null;
174
    }
175

  
176
    /* (non-Javadoc)
177
     * @see org.gvsig.fmap.dal.DataServerExplorer#getName()
178
     */
179
    public String getProviderName() {
180
        return NAME;
181
    }
182

  
183
    /* (non-Javadoc)
184
     * @see org.gvsig.fmap.dal.DataServerExplorer#getParameters()
185
     */
186
    @Override
187
    public WFSServerExplorerParameters getParameters() {
188
        return (WFSServerExplorerParameters) super.getParameters();
189
    }
190

  
191
    /* (non-Javadoc)
192
     * @see org.gvsig.fmap.dal.DataServerExplorer#list()
193
     */
194
    public List list() throws DataException {
195
        ArrayList list = new ArrayList();
196
        Hashtable features = wfsClient.getFeatures();
197
        Iterator it = features.keySet().iterator();
198
        DataStoreParameters dsp = null;
199
        while (it.hasNext()){
200
            String key = (String)it.next();
201
            WFSFeature feature = (WFSFeature)features.get(key);
202
            list.add(getParametersFor(feature));
203
        }
204
        return list;
205
    }
206

  
207
    public DataStoreParameters getParametersFor(WFSFeature feature)
208
    throws DataException {
209
        WFSOpenStoreParameters params = (WFSOpenStoreParameters)dataManager
210
        .createStoreParameters(WFSStoreProvider.NAME);
211
        params.setUrl(url);
212
        params.setFeatureType(feature.getNamespace().getPrefix(),
213
            feature.getNamespace().getLocation(),
214
            feature.getName());
215
        return params;
216
    }
217

  
218
    /* (non-Javadoc)
219
     * @see org.gvsig.fmap.dal.DataServerExplorer#list(int)
220
     */
221
    public List list(int mode) throws DataException {
222
        return list();
223
    }
224

  
225
    /* (non-Javadoc)
226
     * @see org.gvsig.fmap.dal.DataServerExplorer#remove(org.gvsig.fmap.dal.DataStoreParameters)
227
     */
228
    public void remove(DataStoreParameters parameters) throws DataException {
229
        // TODO Auto-generated method stub
230

  
231
    }
232

  
233
    /* (non-Javadoc)
234
     * @see org.gvsig.fmap.dal.spi.DataServerExplorerProvider#getServerExplorerProviderServices()
235
     */
236
    public DataServerExplorerProviderServices getServerExplorerProviderServices() {
237
        // TODO Auto-generated method stub
238
        return null;
239
    }
240

  
241
    /* (non-Javadoc)
242
     * @see org.gvsig.fmap.dal.spi.DataServerExplorerProvider#initialize(org.gvsig.fmap.dal.spi.DataServerExplorerProviderServices)
243
     */
244
    public void initialize(
245
        DataServerExplorerProviderServices dataServerExplorerProviderServices) {
246
        // TODO Auto-generated method stub
247

  
248
    }
249

  
250
    /**
251
     * @return
252
     */
253
    public String getTitle() {
254
        String title = wfsClient.getServiceInformation().title;
255
        if (title == null){
256
            return "None";
257
        }
258
        return title;
259
    }
260

  
261
    /**
262
     * @return
263
     */
264
    public String getAbstract() {
265
        String _abstract = wfsClient.getServiceInformation().abstr;
266
        if (_abstract == null){
267
            return "None";
268
        }
269
        return _abstract;
270
    }
271

  
272
    /**
273
     * @return
274
     */
275
    public String getServerType() {
276
        String serverVersion = wfsClient.getVersion();
277
        if (serverVersion == null) {
278
            return "WFS";
279
        }
280
        return "WFS "+ serverVersion;
281
    }
282

  
283
    /**
284
     * @return
285
     */
286
    public String getUrl() {
287
        return wfsClient.getHost();
288
    }
289

  
290
    /**
291
     * @return
292
     */
293
    public int getMaxFeatures() {
294
        return status.getMaxFeatures();
295
    }
296

  
297
    /**
298
     * @return
299
     */
300
    public int getTimeOut() {
301
        return status.getTimeout();
302
    }
303

  
304
    /**
305
     * @param userName
306
     */
307
    public void setUserName(String userName) {
308
        status.setUserName(userName);
309
    }
310

  
311
    /**
312
     * @param buffer
313
     */
314
    public void setMaxFeatures(int buffer) {
315
        status.setMaxFeatures(buffer);
316
    }
317

  
318
    /**
319
     * @param timeout
320
     */
321
    public void setTimeOut(int timeout) {
322
        status.setTimeout(timeout);
323
    }
324

  
325
    /**
326
     * @return
327
     */
328
    public String getVersion() {
329
        return wfsClient.getVersion();
330
    }
331

  
332
    public List getDataStoreProviderNames() {
333
        List x = new ArrayList();
334
        x.add(WFSStoreProvider.NAME);
335
        return x;
336
    }
337
}
org.gvsig.wfs.app/tags/org.gvsig.wfs.app-2.0.248/org.gvsig.wfs.app.mainplugin/src/main/java/org/gvsig/fmap/dal/store/wfs/WFSNewStoreParameters.java
1
package org.gvsig.fmap.dal.store.wfs;
2

  
3
import org.gvsig.fmap.dal.DataParameters;
4
import org.gvsig.fmap.dal.exception.InitializeException;
5
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException;
6
import org.gvsig.fmap.dal.feature.OpenFeatureStoreParameters;
7

  
8

  
9
public class WFSNewStoreParameters 
10
    extends WFSBaseStoreParameters
11
    implements OpenFeatureStoreParameters
12
    {
13

  
14
    private static String PARAMETERS_NAME = "WFSNewStoreParameters";
15
    
16
    public WFSNewStoreParameters() {
17
        super();
18
    }
19
    
20
	public WFSNewStoreParameters(DataParameters dataParameters) throws InitializeException, ProviderNotRegisteredException{
21
		super(dataParameters);
22
    }
23

  
24
    @Override
25
    protected String getStoreParametersName() {
26
        return PARAMETERS_NAME;
27
    }
28
    
29
    public static void registerParameterClass() {
30
        WFSBaseStoreParameters.registerParameterClass(WFSOpenStoreParameters.class, PARAMETERS_NAME);
31
    }
32
}
org.gvsig.wfs.app/tags/org.gvsig.wfs.app-2.0.248/org.gvsig.wfs.app.mainplugin/src/main/java/org/gvsig/fmap/dal/store/wfs/WFSBaseStoreParameters.java
1

  
2
package org.gvsig.fmap.dal.store.wfs;
3

  
4
import org.apache.commons.lang3.BooleanUtils;
5
import org.cresques.cts.IProjection;
6
import org.gvsig.fmap.dal.DataParameters;
7
import org.gvsig.fmap.dal.DataStoreParameters;
8
import org.gvsig.fmap.dal.DataTypes;
9
import org.gvsig.fmap.dal.exception.InitializeException;
10
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException;
11
import org.gvsig.fmap.dal.spi.AbstractDataParameters;
12
import org.gvsig.fmap.dal.spi.AbstractDataStoreParameters;
13
import org.gvsig.fmap.geom.Geometry;
14
import org.gvsig.fmap.geom.primitive.Envelope;
15
import org.gvsig.tools.ToolsLocator;
16
import org.gvsig.tools.dynobject.DelegatedDynObject;
17
import org.gvsig.tools.dynobject.DynClass;
18
import org.gvsig.tools.dynobject.DynStruct;
19
import org.gvsig.tools.persistence.PersistenceManager;
20

  
21

  
22
public abstract class WFSBaseStoreParameters 
23
    extends AbstractDataStoreParameters 
24
    implements DataStoreParameters
25
    {
26
	protected static DynClass DYNCLASS = null;
27

  
28
	public static final String FIELD_URL = "url";
29
	public static final String FIELD_VERSION = "version";
30
	public static final String FIELD_TYPENAME = "typeName";
31
	public static final String FIELD_NAMESPACE = "namespace";
32
	public static final String DYNFIELDNAME_NAMESPACEPREFIX = "namespacePrefix";
33
	public static final String DYNFIELDNAME_FIELDS = "fields";
34
	public static final String FIELD_FILTER_ENCODING_BY_ATTRIBUTE = "filterEncodingByAttribute";
35
	public static final String DYNFIELDNAME_MAXFEATURES = "maxFeatures";
36
	public static final String DYNFIELDNAME_TIMEOUT = "timeOut";
37
	public static final String DYNFIELDNAME_USER = "user";
38
	public static final String DYNFIELDNAME_PASSWORD = "password";
39
	public static final String DYNFIELDNAME_FILTER_BY_AREA_GEOMETRY = "filterByAreaGeometry";
40
	public static final String DYNFIELDNAME_FILTER_BY_AREA_ENVELOPE = "filterByAreaEnvelope";
41
	public static final String DYNFIELDNAME_FILTER_BY_AREA_OPERATION = "filterByAreaOperation";
42
	public static final String DYNFIELDNAME_FILTER_BY_AREA_ATTRIBUTE = "filterByAreaAttribute";
43
	public static final String DYNFIELDNAME_FILTER_BY_AREA_CRS = "filterByAreaCrs";
44
	public static final String DYNFIELDNAME_CRS = "Crs";
45

  
46
	private DelegatedDynObject delegatedDynObject;
47

  
48
	public WFSBaseStoreParameters() {
49
		super();
50
		this.delegatedDynObject = (DelegatedDynObject) ToolsLocator
51
            .getDynObjectManager().createDynObject(DYNCLASS);
52
	}
53

  
54
	@Override
55
	protected DelegatedDynObject getDelegatedDynObject() {
56
		return delegatedDynObject;
57
	}
58
    
59
    protected abstract String getStoreParametersName();
60

  
61
	public WFSBaseStoreParameters(DataParameters dataParameters) throws InitializeException, ProviderNotRegisteredException{
62
		this();
63
		setUrl((String)dataParameters.getDynValue(FIELD_URL));
64
		String namespace = null;
65
		String namespacePrefix = null;
66
		if (dataParameters.hasDynValue(FIELD_NAMESPACE)){
67
			namespace = (String)dataParameters.getDynValue(FIELD_NAMESPACE);
68
		}
69
		if (dataParameters.hasDynValue(DYNFIELDNAME_NAMESPACEPREFIX)){
70
			namespacePrefix = (String)dataParameters.getDynValue(DYNFIELDNAME_NAMESPACEPREFIX);
71
		}
72
		setFeatureType(namespacePrefix, namespace,
73
				(String)dataParameters.getDynValue(FIELD_TYPENAME));
74
		if (dataParameters.hasDynValue(DYNFIELDNAME_MAXFEATURES)){
75
			setMaxFeatures((Integer)dataParameters.getDynValue(DYNFIELDNAME_MAXFEATURES));
76
		}else{
77
			setMaxFeatures(1000);
78
		}
79
		if (dataParameters.hasDynValue(DYNFIELDNAME_TIMEOUT)){
80
			setTimeOut((Integer)dataParameters.getDynValue(DYNFIELDNAME_TIMEOUT));
81
		}else{
82
			setTimeOut(10000);
83
		}
84
		if (dataParameters.hasDynValue(DYNFIELDNAME_FILTER_BY_AREA_GEOMETRY)){
85
			setFilterByAreaGeometry((Geometry)dataParameters.getDynValue(DYNFIELDNAME_FILTER_BY_AREA_GEOMETRY));
86
			setFilterByAreaAttribute((String)dataParameters.getDynValue(DYNFIELDNAME_FILTER_BY_AREA_ATTRIBUTE));
87
			setFilterByAreaCrs((IProjection)dataParameters.getDynValue(DYNFIELDNAME_FILTER_BY_AREA_CRS));
88
			setFilterByAreaOperation((Integer)dataParameters.getDynValue(DYNFIELDNAME_FILTER_BY_AREA_OPERATION));
89
		}
90
		if (dataParameters.hasDynValue(DYNFIELDNAME_FILTER_BY_AREA_ENVELOPE)){
91
			setFilterByAreaEnvelope((Envelope)dataParameters.getDynValue(DYNFIELDNAME_FILTER_BY_AREA_ENVELOPE));
92
			setFilterByAreaAttribute((String)dataParameters.getDynValue(DYNFIELDNAME_FILTER_BY_AREA_ATTRIBUTE));
93
			setFilterByAreaCrs((IProjection)dataParameters.getDynValue(DYNFIELDNAME_FILTER_BY_AREA_CRS));
94
			setFilterByAreaOperation((Integer)dataParameters.getDynValue(DYNFIELDNAME_FILTER_BY_AREA_OPERATION));
95
		}
96
		if (dataParameters.hasDynValue(FIELD_VERSION)){
97
			setVersion((String)dataParameters.getDynValue(FIELD_VERSION));
98
		}
99
		if (dataParameters.hasDynValue(FIELD_FILTER_ENCODING_BY_ATTRIBUTE)){
100
			setFilterEncodingByAttribute((String)dataParameters.getDynValue(FIELD_FILTER_ENCODING_BY_ATTRIBUTE));
101
		}
102
		if (dataParameters.hasDynValue(DYNFIELDNAME_USER)){
103
			setUser((String)dataParameters.getDynValue(DYNFIELDNAME_USER));
104
		}
105
		if (dataParameters.hasDynValue(DYNFIELDNAME_PASSWORD)){
106
			setPassword((String)dataParameters.getDynValue(DYNFIELDNAME_PASSWORD));
107
		}
108
		if (dataParameters.hasDynValue(DYNFIELDNAME_CRS)){
109
			setCrs((String)dataParameters.getDynValue(DYNFIELDNAME_CRS));
110
		}
111
	}
112

  
113
	protected static void registerParameterClass(Class parametersClass, String parametersName) {
114
		if (DYNCLASS == null) {
115
			PersistenceManager manager = ToolsLocator.getPersistenceManager();
116
			DynStruct definition = manager.addDefinition(
117
					parametersClass,
118
					parametersName,
119
					parametersName + " Persistence definition",
120
					null,
121
					null
122
			);
123
			definition.addDynFieldString(FIELD_URL)
124
				.setDescription("URL of the WFS server")
125
				.setMandatory(true);
126

  
127
			definition.addDynFieldString(FIELD_VERSION)
128
				.setDescription("Version of the WFS server")
129
				.setMandatory(false);
130

  
131
			definition.addDynFieldString(FIELD_TYPENAME)
132
				.setDescription("Feature type to retrieve")
133
				.setMandatory(true);
134

  
135
			definition.addDynFieldString(FIELD_NAMESPACE)
136
				.setDescription("Namespace of the feature type to retrieve")
137
				.setMandatory(false);
138

  
139
			definition.addDynFieldString(DYNFIELDNAME_NAMESPACEPREFIX)
140
				.setDescription("Prefix of the namespace of the feature type to retrieve")
141
				.setMandatory(false);
142

  
143
			definition.addDynFieldString(DYNFIELDNAME_FIELDS)
144
				.setDescription("Fields to retrieve separated by ','")
145
				.setMandatory(false);
146

  
147
			definition.addDynFieldString(FIELD_FILTER_ENCODING_BY_ATTRIBUTE)
148
				.setDescription("Filter encoding request")
149
				.setMandatory(false);
150

  
151
			definition.addDynFieldInt(DYNFIELDNAME_MAXFEATURES)
152
				.setDescription("Number of features to retrieve")
153
				.setMandatory(false);
154

  
155
			definition.addDynFieldInt(DYNFIELDNAME_TIMEOUT)
156
				.setDescription("Timeout")
157
				.setMandatory(false);
158

  
159
			definition.addDynFieldString(DYNFIELDNAME_USER)
160
				.setDescription("User name (not used at this moment)")
161
				.setMandatory(false);
162

  
163
			definition.addDynFieldString(DYNFIELDNAME_PASSWORD)
164
				.setDescription("Password (not used at this moment")
165
				.setMandatory(false);
166

  
167
			definition.addDynFieldObject(DYNFIELDNAME_FILTER_BY_AREA_GEOMETRY)
168
				.setType(DataTypes.GEOMETRY)
169
				.setDescription("Geometry used to do the filter")
170
				.setMandatory(false);
171

  
172
			definition.addDynFieldObject(DYNFIELDNAME_FILTER_BY_AREA_ENVELOPE)
173
			.setType(DataTypes.ENVELOPE)
174
			.setDescription("Envelope used to do the filter")
175
			.setMandatory(false);
176

  
177
			definition.addDynFieldInt(DYNFIELDNAME_FILTER_BY_AREA_OPERATION)
178
				.setDescription("Geometry operation used to do the filter")
179
				.setMandatory(false);
180

  
181
			definition.addDynFieldString(DYNFIELDNAME_FILTER_BY_AREA_ATTRIBUTE)
182
				.setDescription("Attribute that contains the geometry")
183
				.setMandatory(false);
184

  
185
			definition.addDynFieldObject(DYNFIELDNAME_FILTER_BY_AREA_CRS)
186
			.setType(DataTypes.CRS)
187
			.setDescription("CRS to do the spatial filter of the query")
188
			.setMandatory(false);
189

  
190
			definition.addDynFieldString(DYNFIELDNAME_CRS)
191
			.setDescription("CRS")
192
			.setMandatory(false);
193

  
194
			definition.addDynFieldBoolean("useAxisOrderYX")
195
                                .setDefaultFieldValue("false")
196
				.setMandatory(false);
197

  
198
			definition.addDynFieldBoolean("ignoreCache")
199
                                .setDefaultFieldValue("false")
200
				.setMandatory(false);
201

  
202
			DYNCLASS = (DynClass) definition;
203
		}
204
	}
205
    
206
    @Override
207
	public String getDataStoreName() {
208
		return WFSStoreProvider.NAME;
209
	}
210

  
211
    @Override
212
	public String getDescription() {
213
		return WFSStoreProvider.DESCRIPTION;
214
	}
215

  
216
    @Override
217
	public boolean isValid() {
218
		// TODO Auto-generated method stub
219
		return false;
220
	}
221

  
222
	public String getUrl(){
223
		return (String) this.getDynValue(FIELD_URL);
224
	}
225

  
226
	public void setUrl(String url){
227
		this.setDynValue(FIELD_URL, url);
228
	}
229

  
230
	public String getVersion(){
231
		return (String) this.getDynValue(FIELD_VERSION);
232
	}
233

  
234
	public void setVersion(String version){
235
		this.setDynValue(FIELD_VERSION, version);
236
	}
237

  
238
	public String getFeatureType(){
239
		return (String) this.getDynValue(FIELD_TYPENAME);
240
	}
241

  
242
	public void setFeatureType(String featureType){
243
		this.setDynValue(FIELD_TYPENAME, featureType);
244
	}
245

  
246
	public void setFeatureType(String namespace, String featureType){
247
		this.setDynValue(FIELD_NAMESPACE, namespace);
248
		this.setDynValue(FIELD_TYPENAME, featureType);
249
	}
250

  
251
	public void setFeatureType(String prefix, String namespace, String featureType){
252
		this.setDynValue(DYNFIELDNAME_NAMESPACEPREFIX, prefix);
253
		this.setDynValue(FIELD_NAMESPACE, namespace);
254
		this.setDynValue(FIELD_TYPENAME, featureType);
255
	}
256

  
257
	public String getFeatureNamespace(){
258
		return (String) this.getDynValue(FIELD_NAMESPACE);
259
	}
260

  
261
	public String getFeaturePrefix(){
262
		return (String) this.getDynValue(DYNFIELDNAME_NAMESPACEPREFIX);
263
	}
264

  
265
	public String getFields(){
266
		return (String) this.getDynValue(DYNFIELDNAME_FIELDS);
267
	}
268

  
269
	public void setFields(String fields){
270
		this.setDynValue(DYNFIELDNAME_FIELDS, fields);
271
	}
272

  
273
	public String getFilterEncodingByAttribute(){
274
		return (String) this.getDynValue(FIELD_FILTER_ENCODING_BY_ATTRIBUTE);
275
	}
276

  
277
	public void setFilterEncodingByAttribute(String filter){
278
		this.setDynValue(FIELD_FILTER_ENCODING_BY_ATTRIBUTE, filter);
279
	}
280

  
281
	public Integer getMaxFeatures(){
282
		return (Integer) this.getDynValue(DYNFIELDNAME_MAXFEATURES);
283
	}
284

  
285
	public void setMaxFeatures(Integer maxFeatures){
286
		this.setDynValue(DYNFIELDNAME_MAXFEATURES, maxFeatures);
287
	}
288

  
289
	public Integer getTimeOut(){
290
		return (Integer) this.getDynValue(DYNFIELDNAME_TIMEOUT);
291
	}
292

  
293
	public void setTimeOut(Integer timeOut){
294
		this.setDynValue(DYNFIELDNAME_TIMEOUT, timeOut);
295
	}
296

  
297
	public String getUser(){
298
		return (String) this.getDynValue(DYNFIELDNAME_USER);
299
	}
300

  
301
	public void setUser(String user){
302
		this.setDynValue(DYNFIELDNAME_USER, user);
303
	}
304

  
305
	public String getPassword(){
306
		return (String) this.getDynValue(DYNFIELDNAME_PASSWORD);
307
	}
308

  
309
	public void setPassword(String password){
310
		this.setDynValue(DYNFIELDNAME_PASSWORD, password);
311
	}
312

  
313
	public Geometry getFilterByAreaGeometry(){
314
		return (Geometry) this.getDynValue(DYNFIELDNAME_FILTER_BY_AREA_GEOMETRY);
315
	}
316

  
317
	public void setFilterByAreaGeometry(Geometry area){
318
		this.setDynValue(DYNFIELDNAME_FILTER_BY_AREA_GEOMETRY, area);
319
	}
320

  
321
	public Envelope getFilterByAreaEnvelope(){
322
		return (Envelope) this.getDynValue(DYNFIELDNAME_FILTER_BY_AREA_ENVELOPE);
323
	}
324

  
325
	public void setFilterByAreaEnvelope(Envelope area){
326
		this.setDynValue(DYNFIELDNAME_FILTER_BY_AREA_ENVELOPE, area);
327
	}
328

  
329
	public Integer getFilterByAreaOperation(){
330
		return (Integer) this.getDynValue(DYNFIELDNAME_FILTER_BY_AREA_OPERATION);
331
	}
332

  
333
	public void setFilterByAreaOperation(Integer operation){
334
		this.setDynValue(DYNFIELDNAME_FILTER_BY_AREA_OPERATION, operation);
335
	}
336

  
337
	public IProjection getFilterByAreaCrs(){
338
		return (IProjection) this.getDynValue(DYNFIELDNAME_FILTER_BY_AREA_CRS);
339
	}
340

  
341
	public void setFilterByAreaCrs(IProjection crs){
342
		this.setDynValue(DYNFIELDNAME_FILTER_BY_AREA_CRS, crs);
343
	}
344

  
345
	public String getCrs(){
346
		return (String) this.getDynValue(DYNFIELDNAME_CRS);
347
	}
348

  
349
	public void setCrs(String crs){
350
		this.setDynValue(DYNFIELDNAME_CRS, crs);
351
	}
352

  
353
	public String getFilterByAreaAttribute(){
354
		return (String) this.getDynValue(DYNFIELDNAME_FILTER_BY_AREA_ATTRIBUTE);
355
	}
356

  
357
	public void setFilterByAreaAttribute(String attribute){
358
		this.setDynValue(DYNFIELDNAME_FILTER_BY_AREA_ATTRIBUTE, attribute);
359
	}
360

  
361
	public boolean getUseAxisOrderYX() {
362
            Boolean x = (Boolean) this.getDynValue("useAxisOrderYX");
363
            return BooleanUtils.isTrue(x);
364
	}
365

  
366
	public void setUseAxisOrderYX(boolean useAxisOrderYX){
367
            this.setDynValue("useAxisOrderYX", useAxisOrderYX);
368
	}
369

  
370
        public boolean getIgnoreCache() {
371
            Boolean x = (Boolean) this.getDynValue("ignoreCache");
372
            return BooleanUtils.isTrue(x);
373
	}
374

  
375
	public void setIgnoreCache(boolean ignoreCache){
376
            this.setDynValue("ignoreCache", ignoreCache);
377
	}
378
    
379
}
org.gvsig.wfs.app/tags/org.gvsig.wfs.app-2.0.248/org.gvsig.wfs.app.mainplugin/src/main/java/org/gvsig/fmap/dal/store/wfs/WFSStoreProviderFactory.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.fmap.dal.store.wfs;
25

  
26

  
27
import org.slf4j.Logger;
28
import org.slf4j.LoggerFactory;
29

  
30
import org.gvsig.fmap.dal.DataParameters;
31
import org.gvsig.fmap.dal.DataStoreProvider;
32
import org.gvsig.fmap.dal.exception.InitializeException;
33
import org.gvsig.fmap.dal.feature.spi.AbstractFeatureStoreProviderFactory;
34
import org.gvsig.fmap.dal.spi.DataStoreProviderServices;
35
import org.gvsig.tools.dynobject.DynObject;
36

  
37
public class WFSStoreProviderFactory extends AbstractFeatureStoreProviderFactory {
38

  
39
    private static final Logger logger = LoggerFactory.getLogger(WFSStoreProviderFactory.class);
40

  
41
	protected WFSStoreProviderFactory(String name, String description) {
42
		super(name, description);
43
	}
44

  
45
    @Override
46
	public DataStoreProvider createProvider(DataParameters parameters,
47
			DataStoreProviderServices providerServices)
48
			throws InitializeException {
49
		return new WFSStoreProvider((WFSOpenStoreParameters) parameters, providerServices);
50
	}
51

  
52
    @Override
53
	public DynObject createParameters() {
54
		return new WFSOpenStoreParameters();
55
	}
56

  
57
    @Override
58
	public int allowCreate() {
59
		return NO;
60
	}
61

  
62
    @Override
63
	public int allowWrite() {
64
		return NO;
65
	}
66

  
67
    @Override
68
	public int allowRead() {
69
		return YES;
70
	}
71

  
72
    @Override
73
	public int hasRasterSupport() {
74
		return NO;
75
	}
76

  
77
    @Override
78
	public int hasTabularSupport() {
79
		return YES;
80
	}
81

  
82
    @Override
83
	public int hasVectorialSupport() {
84
		return YES;
85
	}
86

  
87
	public int allowMultipleGeometryTypes() {
88
		return YES;
89
	}
90

  
91

  
92
    @Override
93
    public int allowEditableFeatureType() {
94
        return NO;
95
    }
96

  
97
    @Override
98
    public int useLocalIndexesCanImprovePerformance() {
99
        return NO;
100
    }
101

  
102
}
org.gvsig.wfs.app/tags/org.gvsig.wfs.app-2.0.248/org.gvsig.wfs.app.mainplugin/src/main/java/org/gvsig/fmap/dal/store/wfs/WFSTTransactionBuilder.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.fmap.dal.store.wfs;
23

  
24
import java.io.ByteArrayOutputStream;
25
import java.io.OutputStream;
26

  
27
import org.gvsig.fmap.dal.DataTypes;
28
import org.gvsig.fmap.dal.exception.DataException;
29
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
30
import org.gvsig.fmap.dal.feature.spi.FeatureProvider;
31
import org.gvsig.fmap.geom.Geometry;
32
import org.gvsig.fmap.geom.operation.GeometryOperationContext;
33
import org.gvsig.fmap.geom.operation.GeometryOperationException;
34
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException;
35
import org.gvsig.gpe.lib.api.GPELocator;
36
import org.gvsig.gpe.lib.api.GPEManager;
37
import org.gvsig.gpe.lib.api.exceptions.WriterHandlerCreationException;
38
import org.gvsig.gpe.lib.api.writer.IGPEWriterHandler;
39
import org.gvsig.remoteclient.wfs.WFSClient;
40
import org.gvsig.remoteclient.wfs.WFSStatus;
41
import org.gvsig.remoteclient.wfs.edition.WFSTAttributesOperation;
42
import org.gvsig.remoteclient.wfs.edition.WFSTInsertOperation;
43
import org.gvsig.remoteclient.wfs.edition.WFSTTransaction;
44
import org.gvsig.remoteclient.wfs.edition.WFSTUpdateOperation;
45

  
46

  
47
/**
48
 * @author gvSIG Team
49
 * @version $Id$
50
 *
51
 */
52
public class WFSTTransactionBuilder {
53
    private WFSStatus wfsStatus;
54
    private WFSClient wfsClient;
55
    private static final GPEManager gpeManager = GPELocator.getGPEManager();
56
    private WFSTTransaction transaction = null;
57
    
58
    public WFSTTransactionBuilder(WFSStatus wfsStatus, WFSClient wfsClient) {
59
        super();
60
        this.wfsStatus = wfsStatus;
61
        this.wfsClient = wfsClient;
62
        transaction = wfsStatus.createNewTransaction();
63
    }  
64
    
65
    private void addFeatureAttributes(WFSTAttributesOperation attributesOperation, FeatureProvider featureProvider) throws WriterHandlerCreationException, GeometryOperationNotSupportedException, GeometryOperationException{
66
        for (int i=0 ; i<featureProvider.getType().size() ; i++){
67
            FeatureAttributeDescriptor featureAttributeDescriptor = featureProvider.getType().getAttributeDescriptor(i);
68
            String attributeValue = "";
69
            if (featureAttributeDescriptor.getType() != DataTypes.GEOMETRY){
70
                if (featureProvider.get(i) != null){
71
                    attributeValue = featureProvider.get(i).toString();
72
                }
73
            }else{
74
                Geometry geometry = (Geometry)featureProvider.get(i);
75
                attributeValue = toGML(geometry, featureAttributeDescriptor.getSRS().getAbrev());               
76
            }  
77
            attributesOperation.addAttribute(featureAttributeDescriptor.getName(), attributeValue);
78
        }
79
    }
80
    
81
    private String toGML(Geometry geometry, String srs) throws GeometryOperationNotSupportedException, GeometryOperationException, WriterHandlerCreationException{
82
        OutputStream os = new ByteArrayOutputStream();
83
        IGPEWriterHandler writerHandler = gpeManager.createWriterByMimeType("text/xml; subtype=gml/3.1.2");  
84
        writerHandler.setOutputStream(os);
85
        writerHandler.initialize();       
86
        GeometryOperationContext geometryOperationContext = new GeometryOperationContext();
87
        geometryOperationContext.setAttribute("writerHandler", writerHandler);
88
        geometryOperationContext.setAttribute("srs", srs);
89
        geometryOperationContext.setAttribute("id", null);
90
        geometry.invokeOperation("writeGml2", geometryOperationContext);
91
        writerHandler.close(); 
92
        //Remove the xml header
93
        String gml = os.toString();
94
        return gml.substring(38, gml.length());
95
    }
96
    
97
    public void addInsertFeature(FeatureProvider featureProvider) throws WriterHandlerCreationException, GeometryOperationNotSupportedException, GeometryOperationException{
98
        WFSTInsertOperation insertOperation = transaction.createInsertOperation();
99
        addFeatureAttributes(insertOperation, featureProvider);
100
    } 
101

  
102
    public void addUpdateFeature(FeatureProvider featureProvider) throws WriterHandlerCreationException, GeometryOperationNotSupportedException, GeometryOperationException{
103
        WFSTUpdateOperation updateOperation = transaction.createUpdateOperation(featureProvider.getOID().toString());
104
        addFeatureAttributes(updateOperation, featureProvider);
105
    }
106
    
107
    public void addDeleteFeature(String id) throws DataException{
108
        transaction.createDeleteOperation(id);      
109
    }
110
}
org.gvsig.wfs.app/tags/org.gvsig.wfs.app-2.0.248/org.gvsig.wfs.app.mainplugin/src/main/java/org/gvsig/fmap/dal/store/wfs/WFSOpenStoreParameters.java
1
package org.gvsig.fmap.dal.store.wfs;
2

  
3
import org.gvsig.fmap.dal.DataParameters;
4
import org.gvsig.fmap.dal.exception.InitializeException;
5
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException;
6
import org.gvsig.fmap.dal.feature.OpenFeatureStoreParameters;
7

  
8

  
9
public class WFSOpenStoreParameters 
10
    extends WFSBaseStoreParameters
11
    implements OpenFeatureStoreParameters
12
    {
13

  
14
    private static String PARAMETERS_NAME = "WFSStoreParameters";
15
    
16
    public WFSOpenStoreParameters() {
17
        super();
18
    }
19
    
20
	public WFSOpenStoreParameters(DataParameters dataParameters) throws InitializeException, ProviderNotRegisteredException{
21
		super(dataParameters);
22
    }
23

  
24
    @Override
25
    protected String getStoreParametersName() {
26
        return PARAMETERS_NAME;
27
    }
28
    
29
    public static void registerParameterClass() {
30
        WFSBaseStoreParameters.registerParameterClass(WFSOpenStoreParameters.class, PARAMETERS_NAME);
31
    }
32
}
org.gvsig.wfs.app/tags/org.gvsig.wfs.app-2.0.248/org.gvsig.wfs.app.mainplugin/src/main/java/org/gvsig/fmap/dal/store/wfs/WFSLibrary.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
* 
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
* 
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
* 
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
* MA  02110-1301, USA.
20
* 
21
*/
22

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2009 {Iver T.I.}   {Task}
26
*/
27
 
28
package org.gvsig.fmap.dal.store.wfs;
29

  
30
import org.gvsig.fmap.dal.DALFileLocator;
31
import org.gvsig.fmap.dal.DALLibrary;
32
import org.gvsig.fmap.dal.DALLocator;
33
import org.gvsig.fmap.dal.serverexplorer.wfs.WFSServerExplorer;
34
import org.gvsig.fmap.dal.serverexplorer.wfs.WFSServerExplorerFactory;
35
import org.gvsig.fmap.dal.serverexplorer.wfs.WFSServerExplorerParameters;
36
import org.gvsig.fmap.dal.spi.DataManagerProviderServices;
37
import org.gvsig.fmap.mapcontext.MapContextLibrary;
38
import org.gvsig.metadata.exceptions.MetadataException;
39
import org.gvsig.tools.ToolsLocator;
40
import org.gvsig.tools.extensionpoint.ExtensionPoint;
41
import org.gvsig.tools.extensionpoint.ExtensionPointManager;
42
import org.gvsig.tools.library.AbstractLibrary;
43
import org.gvsig.tools.library.LibraryException;
44

  
45
/**
46
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
47
 */
48
public class WFSLibrary extends AbstractLibrary {
49

  
50
    @Override
51
    public void doRegistration() {
52
        registerAsServiceOf(DALLibrary.class);
53
        require(MapContextLibrary.class);
54
    }
55

  
56
	@Override
57
	protected void doInitialize() throws LibraryException {
58
	}
59

  
60
	@Override
61
	protected void doPostInitialize() throws LibraryException {
62
		WFSOpenStoreParameters.registerParameterClass();
63
		try {
64
			WFSStoreProvider.registerMetadataDefinition();
65
		} catch (MetadataException e) {
66
			throw new LibraryException(this.getClass(), e);
67
		}
68

  
69
		DataManagerProviderServices dataman = (DataManagerProviderServices) DALLocator
70
    		.getDataManager();
71

  
72
        if (!dataman.getStoreProviders().contains(WFSStoreProvider.NAME)) {
73
            dataman.registerStoreProviderFactory(new WFSStoreProviderFactory(WFSStoreProvider.NAME, WFSStoreProvider.DESCRIPTION));
74

  
75
        }
76
            
77
		if (!dataman.getExplorerProviders().contains(WFSServerExplorer.NAME)){
78
            dataman.registerServerExplorerFactory(new WFSServerExplorerFactory());
79
		}	
80
		
81
		//Register the WFSStroreParams to be loaded from the catalog extension
82
		ExtensionPointManager extensionPointManager = ToolsLocator.getExtensionPointManager();
83
		ExtensionPoint extensionPoint = extensionPointManager.add("CatalogDataStoreParameters");
84
		extensionPoint.append("OGC:WFS", "Data store parameters to load a WFS layer", WFSOpenStoreParameters.class);
85
	}
86
}
87

  
88

  
89

  
org.gvsig.wfs.app/tags/org.gvsig.wfs.app-2.0.248/org.gvsig.wfs.app.mainplugin/src/main/java/org/gvsig/fmap/dal/store/wfs/WFSStoreProvider.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22

  
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2009 {Iver T.I.}   {Task}
26
 */
27

  
28
package org.gvsig.fmap.dal.store.wfs;
29

  
30
import java.awt.geom.AffineTransform;
31
import java.io.File;
32
import java.io.IOException;
33
import java.util.ArrayList;
34
import java.util.Iterator;
35
import java.util.List;
36

  
37
import org.cresques.cts.ICoordTrans;
38
import org.cresques.cts.IProjection;
39
import org.gvsig.fmap.crs.CRSFactory;
40
import org.gvsig.fmap.dal.DALLocator;
41
import org.gvsig.fmap.dal.DataManager;
42
import org.gvsig.fmap.dal.DataServerExplorer;
43
import org.gvsig.fmap.dal.DataStoreParameters;
44
import org.gvsig.fmap.dal.DataTypes;
45
import org.gvsig.fmap.dal.exception.ConnectionServerException;
46
import org.gvsig.fmap.dal.exception.DataException;
47
import org.gvsig.fmap.dal.exception.InitializeException;
48
import org.gvsig.fmap.dal.exception.OpenException;
49
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException;
50
import org.gvsig.fmap.dal.exception.ReadException;
51
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor;
52
import org.gvsig.fmap.dal.feature.EditableFeatureType;
53
import org.gvsig.fmap.dal.feature.FeatureQuery;
54
import org.gvsig.fmap.dal.feature.FeatureStore;
55
import org.gvsig.fmap.dal.feature.FeatureType;
56
import org.gvsig.fmap.dal.feature.spi.AbstractFeatureStoreProvider;
57
import org.gvsig.fmap.dal.feature.spi.FeatureProvider;
58
import org.gvsig.fmap.dal.feature.spi.FeatureReferenceProviderServices;
59
import org.gvsig.fmap.dal.feature.spi.FeatureSetProvider;
60
import org.gvsig.fmap.dal.resource.spi.ResourceProvider;
61
import org.gvsig.fmap.dal.serverexplorer.wfs.WFSServerExplorer;
62
import org.gvsig.fmap.dal.serverexplorer.wfs.WFSServerExplorerParameters;
63
import org.gvsig.fmap.dal.spi.DataStoreProviderServices;
64
import org.gvsig.fmap.dal.store.gpe.GPEStoreProvider;
65
import org.gvsig.fmap.geom.Geometry;
66
import org.gvsig.fmap.geom.Geometry.SUBTYPES;
67
import org.gvsig.fmap.geom.GeometryLocator;
68
import org.gvsig.fmap.geom.GeometryManager;
69
import org.gvsig.fmap.geom.exception.CreateEnvelopeException;
70
import org.gvsig.fmap.geom.operation.GeometryOperationException;
71
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException;
72
import org.gvsig.fmap.geom.primitive.Envelope;
73
import org.gvsig.gpe.lib.api.exceptions.WriterHandlerCreationException;
74
import org.gvsig.metadata.MetadataLocator;
75
import org.gvsig.metadata.MetadataManager;
76
import org.gvsig.metadata.exceptions.MetadataException;
77
import org.gvsig.remoteclient.ogc.OGCClientOperation;
78
import org.gvsig.remoteclient.utils.BoundaryBox;
79
import org.gvsig.remoteclient.wfs.WFSClient;
80
import org.gvsig.remoteclient.wfs.WFSFeature;
81
import org.gvsig.remoteclient.wfs.WFSFeatureField;
82
import org.gvsig.remoteclient.wfs.WFSStatus;
83
import org.gvsig.remoteclient.wfs.exceptions.WFSException;
84
import org.gvsig.remoteclient.wfs.request.WFSGetFeatureRequestInformation;
85
import org.gvsig.remoteclient.wfs.request.WFSTransactionRequestInformation;
86
import org.gvsig.tools.ToolsLocator;
87
import org.gvsig.tools.dynobject.DynStruct;
88
import org.gvsig.xmlschema.lib.api.XMLSchemaLocator;
89
import org.gvsig.xmlschema.lib.api.XMLSchemaManager;
90
import org.gvsig.xmlschema.lib.api.som.IXSGeometryTypeDefinition;
91
import org.gvsig.xmlschema.lib.api.som.IXSTypeDefinition;
92
import org.slf4j.Logger;
93
import org.slf4j.LoggerFactory;
94

  
95
/**
96
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
97
 */
98
public class WFSStoreProvider extends AbstractFeatureStoreProvider {
99
	private static final Logger logger = LoggerFactory
100
			.getLogger(WFSStoreProvider.class);
101
	public static String NAME = "WFSStore";
102
	public static String DESCRIPTION = "WFS store to load WFS resources";
103

  
104
	private static final MetadataManager metadataManager = MetadataLocator
105
			.getMetadataManager();
106
	private static final String METADATA_DEFINITION_NAME = "WFSStore";
107
	private static final String METADATA_DEFINITION_DESCRIPTION = "WFSStore metadata definition";
108

  
109
	// private IProjection projection;
110
	private long featureCount = -1;
111
	private boolean isKnownEnvelope = false;
112

  
113
	/**
114
	 * If the user has selected the filter by area option
115
	 */
116
	private boolean hasFilterByArea = false;
117

  
118
	/**
119
	 * GML provider used by delegation to read the GML files
120
	 */
121
	private GPEStoreProvider storeProviderDelegate = null;
122

  
123
	private static final DataManager dataManager = DALLocator.getDataManager();
124
	private static final XMLSchemaManager xmlSchemaManager = XMLSchemaLocator
125
			.getXMLSchemaManager();
126

  
127
	boolean isFilterByAreaSupported = true;
128

  
129
	// WFS Parameters
130
	private WFSClient wfsClient;
131
	private WFSStatus wfsStatus;
132

  
133
	public WFSStoreProvider(DataStoreParameters params,
134
			DataStoreProviderServices storeServices) throws InitializeException {
135
		super(
136
				params,
137
				storeServices,
138
				ToolsLocator
139
						.getDynObjectManager()
140
						.createDynObject(
141
								metadataManager
142
										.getDefinition(METADATA_DEFINITION_NAME)));
143
		initParams();
144
		try {
145
			initFeatureType();
146
		} catch (WFSException e) {
147
			throw new InitializeException(e);
148
		} catch (ReadException e) {
149
			throw new InitializeException(e);
150
		}
151
	}
152

  
153
	private void initParams() throws InitializeException {
154
		try {
155
			WFSOpenStoreParameters wfsParameters = getWFSParameters();
156
			try {
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff