Statistics
| Revision:

gvsig-gdal / trunk / org.gvsig.gdal / org.gvsig.gdal.prov / org.gvsig.gdal.prov.ogr / src / main / java / org / gvsig / gdal / prov / ogr / OGRDataStoreParameters.java @ 274

History | View | Annotate | Download (5.02 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright ? 2007-2016 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 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
 * 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.gdal.prov.ogr;
25

    
26
import java.io.File;
27

    
28
import org.apache.commons.lang3.StringUtils;
29
import org.cresques.cts.IProjection;
30
import org.gvsig.fmap.dal.DataStoreParameters;
31
import org.gvsig.fmap.dal.feature.OpenFeatureStoreParameters;
32
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters;
33
import org.gvsig.fmap.dal.spi.AbstractDataParameters;
34
import org.gvsig.fmap.dal.spi.DataStoreProviderServices;
35
import org.gvsig.tools.ToolsLocator;
36
import org.gvsig.tools.dynobject.DelegatedDynObject;
37

    
38
/**
39
 *
40
 * @author <a href="mailto:lmarques@disid.com">Lluis Marques</a>
41
 *
42
 */
43
public class OGRDataStoreParameters extends AbstractDataParameters implements OpenFeatureStoreParameters,
44
    FilesystemStoreParameters {
45

    
46
    /**
47
     *
48
     */
49
    public static final String PARAMETERS_DEFINITION_NAME = "OGRDataStoreParameters";
50

    
51
    /**
52
     *
53
     */
54
    public static final String FILE_PARAMTER_NAME = "file";
55

    
56
    /**
57
     *
58
     */
59
    public static final String LAYER_NAME_PARAMTER_NAME = "layerName";
60

    
61
    /**
62
     *
63
     */
64
    public static final String CONNECTION_STRING_PARAMETER_NAME = "connectionString";
65

    
66
    /**
67
     *
68
     */
69
    public static final String DEFAULT_GEOMETRY_PARAMETER_NAME = "defaultGeometryField";
70

    
71
    /**
72
     *
73
     */
74
    public static final String CRS_PARAMETER_NAME = "crs";
75

    
76
    /**
77
     *
78
     */
79
    public static final String IGNORE_SPATIAL_FILTER = "ignoreSpatialFilter";
80

    
81

    
82
    protected DelegatedDynObject parameters;
83

    
84
    /**
85
     *
86
     */
87
    public OGRDataStoreParameters() {
88
        this.parameters =
89
            (DelegatedDynObject) ToolsLocator.getDynObjectManager().createDynObject(
90
                ToolsLocator.getPersistenceManager().getDefinition(PARAMETERS_DEFINITION_NAME));
91
        this.setDynValue(DataStoreProviderServices.PROVIDER_PARAMTER_NAME,
92
            OGRDataStoreProvider.NAME);
93
    }
94

    
95
    @Override
96
    public String getDataStoreName() {
97
        return OGRDataStoreProvider.NAME;
98
    }
99

    
100
    @Override
101
    public String getDescription() {
102
        return OGRDataStoreProvider.DESCRIPTION;
103
    }
104

    
105
    /**
106
     * @return File
107
     */
108
    public File getFile() {
109
        return (File) this.getDynValue(FILE_PARAMTER_NAME);
110
    }
111

    
112
    /**
113
     * @return String
114
     */
115
    public String getLayerName() {
116
        return (String) this.getDynValue(LAYER_NAME_PARAMTER_NAME);
117
    }
118

    
119
    /**
120
     * @return String
121
     */
122
    public String getConnectionString() {
123
        return (String) this.getDynValue(CONNECTION_STRING_PARAMETER_NAME);
124
    }
125

    
126
    /**
127
     * @return String
128
     */
129
    public String getDefaultGeometryField() {
130
        return (String) this.getDynValue(DEFAULT_GEOMETRY_PARAMETER_NAME);
131
    }
132

    
133
    /**
134
     *
135
     * @return String
136
     */
137
    public IProjection getCRS() {
138
        return (IProjection) this.getDynValue(CRS_PARAMETER_NAME);
139
    }
140

    
141
    /**
142
     * @param file
143
     *            File
144
     */
145
    public void setFile(File file) {
146
        this.setDynValue(FILE_PARAMTER_NAME, file);
147
    }
148

    
149
    /**
150
     * @param layerName
151
     *            Name of layer
152
     */
153
    public void setLayerName(String layerName) {
154
        this.setDynValue(LAYER_NAME_PARAMTER_NAME, layerName);
155
    }
156

    
157
    /**
158
     * @param connectionString
159
     *            Connection string
160
     */
161
    public void setConnectionString(String connectionString) {
162
        this.setDynValue(CONNECTION_STRING_PARAMETER_NAME, connectionString);
163
    }
164

    
165
    /**
166
     * @param defaultGeoemtryField
167
     *            Name of defualt geometry field.
168
     */
169
    public void setDefaultGeometryField(String defaultGeoemtryField) {
170
        this.setDynValue(DEFAULT_GEOMETRY_PARAMETER_NAME, defaultGeoemtryField);
171
    }
172

    
173
    /**
174
     *
175
     * @param crs
176
     */
177
    public void setCRS(IProjection crs) {
178
        this.setDynValue(CRS_PARAMETER_NAME, crs);
179
    }
180

    
181
    @Override
182
    public boolean isValid() {
183
        if ((this.getFile() != null && this.getFile().exists())
184
            || StringUtils.isNotBlank(this.getConnectionString())) {
185
            return true;
186
        }
187
        return false;
188
    }
189

    
190
    @Override
191
    protected DelegatedDynObject getDelegatedDynObject() {
192
        return parameters;
193
    }
194

    
195
}