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 @ 951
History | View | Annotate | Download (4.98 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.feature.OpenFeatureStoreParameters; |
31 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters; |
32 |
import org.gvsig.fmap.dal.spi.AbstractDataStoreParameters; |
33 |
import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
34 |
import org.gvsig.tools.ToolsLocator; |
35 |
import org.gvsig.tools.dynobject.DelegatedDynObject; |
36 |
|
37 |
/**
|
38 |
*
|
39 |
* @author <a href="mailto:lmarques@disid.com">Lluis Marques</a>
|
40 |
*
|
41 |
*/
|
42 |
public class OGRDataStoreParameters extends AbstractDataStoreParameters implements OpenFeatureStoreParameters, |
43 |
FilesystemStoreParameters { |
44 |
|
45 |
/**
|
46 |
*
|
47 |
*/
|
48 |
public static final String PARAMETERS_DEFINITION_NAME = "OGRDataStoreParameters"; |
49 |
|
50 |
/**
|
51 |
*
|
52 |
*/
|
53 |
public static final String FILE_PARAMTER_NAME = "file"; |
54 |
|
55 |
/**
|
56 |
*
|
57 |
*/
|
58 |
public static final String LAYER_NAME_PARAMTER_NAME = "layerName"; |
59 |
|
60 |
/**
|
61 |
*
|
62 |
*/
|
63 |
public static final String CONNECTION_STRING_PARAMETER_NAME = "connectionString"; |
64 |
|
65 |
/**
|
66 |
*
|
67 |
*/
|
68 |
public static final String DEFAULT_GEOMETRY_PARAMETER_NAME = "defaultGeometryField"; |
69 |
|
70 |
/**
|
71 |
*
|
72 |
*/
|
73 |
public static final String CRS_PARAMETER_NAME = "crs"; |
74 |
|
75 |
/**
|
76 |
*
|
77 |
*/
|
78 |
public static final String IGNORE_SPATIAL_FILTER = "ignoreSpatialFilter"; |
79 |
|
80 |
|
81 |
protected DelegatedDynObject parameters;
|
82 |
|
83 |
/**
|
84 |
*
|
85 |
*/
|
86 |
public OGRDataStoreParameters() {
|
87 |
this.parameters =
|
88 |
(DelegatedDynObject) ToolsLocator.getDynObjectManager().createDynObject( |
89 |
ToolsLocator.getPersistenceManager().getDefinition(PARAMETERS_DEFINITION_NAME)); |
90 |
this.setDynValue(DataStoreProviderServices.PROVIDER_PARAMTER_NAME,
|
91 |
OGRDataStoreProvider.NAME); |
92 |
} |
93 |
|
94 |
@Override
|
95 |
public String getDataStoreName() { |
96 |
return OGRDataStoreProvider.NAME;
|
97 |
} |
98 |
|
99 |
@Override
|
100 |
public String getDescription() { |
101 |
return OGRDataStoreProvider.DESCRIPTION;
|
102 |
} |
103 |
|
104 |
/**
|
105 |
* @return File
|
106 |
*/
|
107 |
public File getFile() { |
108 |
return (File) this.getDynValue(FILE_PARAMTER_NAME); |
109 |
} |
110 |
|
111 |
/**
|
112 |
* @return String
|
113 |
*/
|
114 |
public String getLayerName() { |
115 |
return (String) this.getDynValue(LAYER_NAME_PARAMTER_NAME); |
116 |
} |
117 |
|
118 |
/**
|
119 |
* @return String
|
120 |
*/
|
121 |
public String getConnectionString() { |
122 |
return (String) this.getDynValue(CONNECTION_STRING_PARAMETER_NAME); |
123 |
} |
124 |
|
125 |
/**
|
126 |
* @return String
|
127 |
*/
|
128 |
public String getDefaultGeometryField() { |
129 |
return (String) this.getDynValue(DEFAULT_GEOMETRY_PARAMETER_NAME); |
130 |
} |
131 |
|
132 |
/**
|
133 |
*
|
134 |
* @return String
|
135 |
*/
|
136 |
public IProjection getCRS() {
|
137 |
return (IProjection) this.getDynValue(CRS_PARAMETER_NAME); |
138 |
} |
139 |
|
140 |
/**
|
141 |
* @param file
|
142 |
* File
|
143 |
*/
|
144 |
public void setFile(File file) { |
145 |
this.setDynValue(FILE_PARAMTER_NAME, file);
|
146 |
} |
147 |
|
148 |
/**
|
149 |
* @param layerName
|
150 |
* Name of layer
|
151 |
*/
|
152 |
public void setLayerName(String layerName) { |
153 |
this.setDynValue(LAYER_NAME_PARAMTER_NAME, layerName);
|
154 |
} |
155 |
|
156 |
/**
|
157 |
* @param connectionString
|
158 |
* Connection string
|
159 |
*/
|
160 |
public void setConnectionString(String connectionString) { |
161 |
this.setDynValue(CONNECTION_STRING_PARAMETER_NAME, connectionString);
|
162 |
} |
163 |
|
164 |
/**
|
165 |
* @param defaultGeoemtryField
|
166 |
* Name of defualt geometry field.
|
167 |
*/
|
168 |
public void setDefaultGeometryField(String defaultGeoemtryField) { |
169 |
this.setDynValue(DEFAULT_GEOMETRY_PARAMETER_NAME, defaultGeoemtryField);
|
170 |
} |
171 |
|
172 |
/**
|
173 |
*
|
174 |
* @param crs
|
175 |
*/
|
176 |
public void setCRS(IProjection crs) { |
177 |
this.setDynValue(CRS_PARAMETER_NAME, crs);
|
178 |
} |
179 |
|
180 |
@Override
|
181 |
public boolean isValid() { |
182 |
if ((this.getFile() != null && this.getFile().exists()) |
183 |
|| StringUtils.isNotBlank(this.getConnectionString())) {
|
184 |
return true; |
185 |
} |
186 |
return false; |
187 |
} |
188 |
|
189 |
@Override
|
190 |
protected DelegatedDynObject getDelegatedDynObject() {
|
191 |
return parameters;
|
192 |
} |
193 |
|
194 |
} |