Revision 47642
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.csv/src/main/java/org/gvsig/fmap/dal/store/csv/CSVStoreParameters.java | ||
---|---|---|
96 | 96 |
super(parametersDefinitionName, CSVStoreProvider.NAME); |
97 | 97 |
} |
98 | 98 |
|
99 |
private FeatureType getFeatureType() {
|
|
99 |
protected FeatureType getFeatureType() {
|
|
100 | 100 |
if( this.featureType==null ) { |
101 | 101 |
try { |
102 | 102 |
EditableFeatureType ftype = DALLocator.getDataManager().createFeatureType(); |
... | ... | |
113 | 113 |
return this.featureType; |
114 | 114 |
} |
115 | 115 |
|
116 |
// @Override |
|
117 |
// protected DelegatedDynObject getDelegatedDynObject() { |
|
118 |
// return parameters; |
|
119 |
// } |
|
120 |
// |
|
121 |
// @Override |
|
122 |
// public void setDynValue(String name, Object value) { |
|
123 |
// super.setDynValue(name, value); |
|
124 |
// this.featureType = null; |
|
125 |
// } |
|
126 |
|
|
127 | 116 |
@Override |
128 | 117 |
public void validate() throws ValidateDataParametersException { |
129 |
File f = this.getFile(); |
|
130 |
if( f!=null ) { |
|
131 |
IProjection proj = null; |
|
132 |
FeatureType ftype = this.getFeatureType(); |
|
133 |
if( ftype!=null ) { |
|
134 |
this.setDynValue(AUTOMATICTYPESDETECTION, defaultValueOfAutomaticTypesDetection); |
|
135 |
proj = ftype.getDefaultSRS(); |
|
136 |
if( proj!=null ) { |
|
137 |
this.setDynValue(CRS_PARAMTER_NAME, proj); |
|
138 |
} |
|
139 |
FeatureAttributeDescriptor attrgeom = ftype.getDefaultGeometryAttribute(); |
|
140 |
if( attrgeom!=null ) { |
|
141 |
this.setDynValue(GEOMETRY_COLUMN, attrgeom.getName()); |
|
142 |
this.setDynValue(GEOMETRY_TYPE, attrgeom.getGeomType().getType()); |
|
143 |
this.setDynValue(GEOMETRY_SUBTYPE, attrgeom.getGeomType().getSubType()); |
|
144 |
} else { |
|
145 |
this.setDynValue(GEOMETRY_COLUMN, null); |
|
146 |
this.setDynValue(GEOMETRY_TYPE, Geometry.TYPES.UNKNOWN); |
|
147 |
this.setDynValue(GEOMETRY_SUBTYPE, Geometry.SUBTYPES.UNKNOWN); |
|
148 |
} |
|
149 |
Tags ftypeTags = ftype.getTags(); |
|
150 |
for (String tagname : ftypeTags) { |
|
151 |
if( StringUtils.startsWithIgnoreCase(tagname, "csvparameters.") ) { |
|
152 |
String paramname = tagname.substring(14); |
|
153 |
String paramvalue = ftypeTags.getString(tagname,null); |
|
154 |
if( paramvalue!=null ) { |
|
155 |
this.setDynValue(paramname, paramvalue); |
|
156 |
} |
|
157 |
} |
|
158 |
} |
|
118 |
super.validate(); |
|
119 |
FeatureType ftype = this.getFeatureType(); |
|
120 |
if( ftype!=null ) { |
|
121 |
FeatureAttributeDescriptor attrgeom = ftype.getDefaultGeometryAttribute(); |
|
122 |
if( attrgeom!=null ) { |
|
123 |
this.setDynValue(GEOMETRY_COLUMN, attrgeom.getName()); |
|
124 |
this.setDynValue(GEOMETRY_TYPE, attrgeom.getGeomType().getType()); |
|
125 |
this.setDynValue(GEOMETRY_SUBTYPE, attrgeom.getGeomType().getSubType()); |
|
126 |
} else { |
|
127 |
this.setDynValue(GEOMETRY_COLUMN, null); |
|
128 |
this.setDynValue(GEOMETRY_TYPE, Geometry.TYPES.UNKNOWN); |
|
129 |
this.setDynValue(GEOMETRY_SUBTYPE, Geometry.SUBTYPES.UNKNOWN); |
|
159 | 130 |
} |
160 |
if( proj==null ) { |
|
161 |
PRJFile prjfile = FormatsFile.getPRJFile(f); |
|
162 |
if( prjfile!= null ) { |
|
163 |
this.setDynValue(CRS_PARAMTER_NAME, prjfile.getCRS()); |
|
164 |
} |
|
165 |
} |
|
166 |
String charsetName = getCharset(this); |
|
167 |
if( StringUtils.isBlank(charsetName) ) { |
|
168 |
CPGFile cpgfile = FormatsFile.getCPGFile(f); |
|
169 |
if( cpgfile!=null ) { |
|
170 |
this.setDynValue(CHARSET, cpgfile.getCharsetName()); |
|
171 |
} |
|
172 |
} |
|
173 | 131 |
} |
174 |
super.validate(); |
|
175 | 132 |
} |
176 | 133 |
|
177 | 134 |
public static CsvPreference getPredefinedCSVPreferences(DynObject dynobj) { |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.csv/src/main/java/org/gvsig/fmap/dal/store/csv/CSVStoreProvider.java | ||
---|---|---|
30 | 30 |
import java.util.List; |
31 | 31 |
import org.apache.commons.io.FileUtils; |
32 | 32 |
import org.apache.commons.io.FilenameUtils; |
33 |
import org.apache.commons.lang3.StringUtils; |
|
33 | 34 |
import org.gvsig.fmap.dal.DataStore; |
35 |
import org.gvsig.fmap.dal.DataTypes; |
|
34 | 36 |
import org.gvsig.fmap.dal.FileHelper; |
35 | 37 |
import org.gvsig.fmap.dal.exception.DataException; |
36 | 38 |
import org.gvsig.fmap.dal.exception.InitializeException; |
39 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
37 | 40 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
38 | 41 |
import org.gvsig.fmap.dal.feature.FeatureType; |
39 | 42 |
import org.gvsig.fmap.dal.feature.exception.PerformEditingException; |
... | ... | |
284 | 287 |
LOGGER.warn("Not been able to end append '" + this.getFullName() + "'.", ex); |
285 | 288 |
} |
286 | 289 |
} |
290 |
|
|
291 |
@Override |
|
292 |
protected boolean mustFixFeatureType() { |
|
293 |
try { |
|
294 |
String param_types_def = CSVStoreParameters.getRawFieldTypes(this.getParameters()); |
|
295 |
String[] pointDimensionNames = CSVStoreParameters.getPointDimensionNames(this.getParameters()); |
|
296 |
String geometry_column = CSVStoreParameters.getGeometryColumn(this.getParameters()); |
|
297 |
|
|
298 |
|
|
299 |
FeatureType dalFeatureType = this.getStoreServices().getDefaultFeatureType(); |
|
300 |
if (StringUtils.isNotBlank(geometry_column)){ |
|
301 |
FeatureAttributeDescriptor attr = dalFeatureType.getAttributeDescriptor(geometry_column); |
|
302 |
if(attr == null || attr.getType() != DataTypes.GEOMETRY){ |
|
303 |
return true; |
|
304 |
} |
|
305 |
} |
|
306 |
if (StringUtils.isNotBlank(param_types_def) |
|
307 |
|| pointDimensionNames != null) { |
|
308 |
for (FeatureAttributeDescriptor dalAttr : dalFeatureType) { |
|
309 |
if(dalAttr.isComputed()){ |
|
310 |
continue; |
|
311 |
} |
|
312 |
FeatureAttributeDescriptor csvAttr = featureType.getAttributeDescriptor(dalAttr.getName()); |
|
313 |
if(csvAttr == null){ |
|
314 |
return true; |
|
315 |
} |
|
316 |
if(!dalAttr.get("all").equals(csvAttr.get("all"))){ |
|
317 |
return true; |
|
318 |
} |
|
319 |
} |
|
320 |
} |
|
321 |
} catch (DataException ex) { |
|
322 |
LOGGER.warn("Can't check if should fix the feature type", ex); |
|
323 |
} |
|
324 |
return false; |
|
325 |
} |
|
287 | 326 |
|
288 | 327 |
@Override |
289 | 328 |
protected SimpleReader getSimpleReader(SimpleReaderStoreParameters parameters, Reader in) throws IOException { |
... | ... | |
303 | 342 |
|
304 | 343 |
@Override |
305 | 344 |
public List<String> getRowByIndex(long index) { |
306 |
try { |
|
307 |
this.open(); |
|
308 |
} catch(Exception ex) { |
|
309 |
throw new RuntimeException("Can't get row by index", ex); |
|
310 |
} |
|
311 |
if (this.virtualrows == null) { |
|
312 |
return null; |
|
313 |
} |
|
314 |
List<String> line = this.virtualrows.get64(index); |
|
345 |
List<String> line = super.getRowByIndex(index); |
|
315 | 346 |
if( line!=null ) { |
316 | 347 |
for (int i = 0; i < line.size(); i++) { |
317 | 348 |
String s = line.get(i); |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.csv/src/main/java/org/gvsig/fmap/dal/store/simplereader/SimpleReaderStoreParameters.java | ||
---|---|---|
29 | 29 |
import org.apache.commons.lang3.StringEscapeUtils; |
30 | 30 |
import org.apache.commons.lang3.StringUtils; |
31 | 31 |
import org.cresques.cts.IProjection; |
32 |
import org.gvsig.basicformats.CPGFile; |
|
33 |
import org.gvsig.basicformats.FormatsFile; |
|
34 |
import org.gvsig.basicformats.PRJFile; |
|
35 |
import static org.gvsig.fmap.dal.DataParameters.CRS_PARAMTER_NAME; |
|
32 | 36 |
import org.gvsig.fmap.dal.FileHelper; |
37 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
|
33 | 38 |
import org.gvsig.fmap.dal.feature.FeatureType; |
34 | 39 |
import org.gvsig.fmap.dal.feature.OpenFeatureStoreParameters; |
35 | 40 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters; |
... | ... | |
37 | 42 |
import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
38 | 43 |
import org.gvsig.tools.dynobject.DelegatedDynObject; |
39 | 44 |
import org.gvsig.tools.dynobject.DynObject; |
45 |
import org.gvsig.tools.dynobject.Tags; |
|
40 | 46 |
import org.slf4j.Logger; |
41 | 47 |
import org.slf4j.LoggerFactory; |
42 | 48 |
|
... | ... | |
68 | 74 |
this.parameters = (DelegatedDynObject) FileHelper.newParameters(parametersDefinitionName); |
69 | 75 |
this.setDynValue(DataStoreProviderServices.PROVIDER_PARAMTER_NAME, name); |
70 | 76 |
} |
77 |
|
|
78 |
protected FeatureType getFeatureType() { |
|
79 |
return null; |
|
80 |
} |
|
71 | 81 |
|
72 | 82 |
@Override |
73 | 83 |
protected DelegatedDynObject getDelegatedDynObject() { |
... | ... | |
290 | 300 |
throw new IllegalArgumentException("Can't recognize the format field definition '"+definition+"' ("+i+")."); |
291 | 301 |
} |
292 | 302 |
} |
303 |
|
|
304 |
@Override |
|
305 |
public void validate() throws ValidateDataParametersException { |
|
306 |
File f = this.getFile(); |
|
307 |
if( f!=null ) { |
|
308 |
IProjection proj = null; |
|
309 |
FeatureType ftype = this.getFeatureType(); |
|
310 |
if( ftype!=null ) { |
|
311 |
this.setDynValue(AUTOMATICTYPESDETECTION, defaultValueOfAutomaticTypesDetection); |
|
312 |
proj = ftype.getDefaultSRS(); |
|
313 |
if( proj!=null ) { |
|
314 |
this.setDynValue(CRS_PARAMTER_NAME, proj); |
|
315 |
} |
|
316 |
Tags ftypeTags = ftype.getTags(); |
|
317 |
for (String tagname : ftypeTags) { |
|
318 |
if( StringUtils.startsWithIgnoreCase(tagname, "storeparameters.") || |
|
319 |
StringUtils.startsWithIgnoreCase(tagname, "csvparameters.") /*por compativilidad*/ ) { |
|
320 |
String paramname = tagname.substring(14); |
|
321 |
String paramvalue = ftypeTags.getString(tagname,null); |
|
322 |
if( paramvalue!=null ) { |
|
323 |
this.setDynValue(paramname, paramvalue); |
|
324 |
} |
|
325 |
} |
|
326 |
} |
|
327 |
} |
|
328 |
if( proj==null ) { |
|
329 |
PRJFile prjfile = FormatsFile.getPRJFile(f); |
|
330 |
if( prjfile!= null ) { |
|
331 |
this.setDynValue(CRS_PARAMTER_NAME, prjfile.getCRS()); |
|
332 |
} |
|
333 |
} |
|
334 |
String charsetName = getCharset(this); |
|
335 |
if( StringUtils.isBlank(charsetName) ) { |
|
336 |
CPGFile cpgfile = FormatsFile.getCPGFile(f); |
|
337 |
if( cpgfile!=null ) { |
|
338 |
this.setDynValue(CHARSET, cpgfile.getCharsetName()); |
|
339 |
} |
|
340 |
} |
|
341 |
} |
|
342 |
super.validate(); |
|
343 |
} |
|
293 | 344 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.csv/src/main/java/org/gvsig/fmap/dal/store/simplereader/SimpleReaderStoreProvider.java | ||
---|---|---|
637 | 637 |
} |
638 | 638 |
|
639 | 639 |
protected boolean mustFixFeatureType() { |
640 |
//Este m?todo lo debe sobreescribir el CSV |
|
641 |
// try { |
|
642 |
// String param_types_def = CSVStoreParameters.getRawFieldTypes(this.getParameters()); |
|
643 |
// String[] pointDimensionNames = CSVStoreParameters.getPointDimensionNames(this.getParameters()); |
|
644 |
// String geometry_column = CSVStoreParameters.getGeometryColumn(this.getParameters()); |
|
645 |
// |
|
646 |
// |
|
647 |
// FeatureType dalFeatureType = this.getStoreServices().getDefaultFeatureType(); |
|
648 |
// if (StringUtils.isNotBlank(geometry_column)){ |
|
649 |
// FeatureAttributeDescriptor attr = dalFeatureType.getAttributeDescriptor(geometry_column); |
|
650 |
// if(attr == null || attr.getType() != DataTypes.GEOMETRY){ |
|
651 |
// return true; |
|
652 |
// } |
|
653 |
// } |
|
654 |
// if (StringUtils.isNotBlank(param_types_def) |
|
655 |
// || pointDimensionNames != null) { |
|
656 |
// for (FeatureAttributeDescriptor dalAttr : dalFeatureType) { |
|
657 |
// if(dalAttr.isComputed()){ |
|
658 |
// continue; |
|
659 |
// } |
|
660 |
// FeatureAttributeDescriptor csvAttr = featureType.getAttributeDescriptor(dalAttr.getName()); |
|
661 |
// if(csvAttr == null){ |
|
662 |
// return true; |
|
663 |
// } |
|
664 |
// if(!dalAttr.get("all").equals(csvAttr.get("all"))){ |
|
665 |
// return true; |
|
666 |
// } |
|
667 |
// } |
|
668 |
// } |
|
669 |
// } catch (DataException ex) { |
|
670 |
// LOGGER.warn("Can't check if should fix the feature type", ex); |
|
671 |
// } |
|
672 | 640 |
return false; |
673 | 641 |
} |
674 | 642 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.csv/src/main/java/org/gvsig/fmap/dal/store/gml/GMLStoreParameters.java | ||
---|---|---|
23 | 23 |
*/ |
24 | 24 |
package org.gvsig.fmap.dal.store.gml; |
25 | 25 |
|
26 |
import java.io.File; |
|
27 |
import org.apache.commons.lang3.StringUtils; |
|
28 |
import org.cresques.cts.IProjection; |
|
29 |
import org.gvsig.basicformats.CPGFile; |
|
30 |
import org.gvsig.basicformats.FormatsFile; |
|
31 |
import org.gvsig.basicformats.PRJFile; |
|
26 | 32 |
import org.gvsig.fmap.dal.DALLocator; |
33 |
import static org.gvsig.fmap.dal.DataParameters.CRS_PARAMTER_NAME; |
|
34 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
|
27 | 35 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
36 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
28 | 37 |
import org.gvsig.fmap.dal.feature.FeatureType; |
29 | 38 |
import org.gvsig.fmap.dal.feature.OpenFeatureStoreParameters; |
30 | 39 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters; |
31 | 40 |
import org.gvsig.fmap.dal.store.simplereader.SimpleReaderFeatureTypeLoader; |
32 | 41 |
import org.gvsig.fmap.dal.store.simplereader.SimpleReaderStoreParameters; |
42 |
import static org.gvsig.fmap.dal.store.simplereader.SimpleReaderStoreParameters.getCharset; |
|
43 |
import org.gvsig.fmap.geom.Geometry; |
|
44 |
import org.gvsig.tools.dynobject.Tags; |
|
33 | 45 |
import org.slf4j.Logger; |
34 | 46 |
import org.slf4j.LoggerFactory; |
35 | 47 |
|
... | ... | |
50 | 62 |
super(parametersDefinitionName, GMLStoreProvider.NAME); |
51 | 63 |
} |
52 | 64 |
|
53 |
private FeatureType getFeatureType() {
|
|
65 |
protected FeatureType getFeatureType() {
|
|
54 | 66 |
if( this.featureType==null ) { |
55 | 67 |
try { |
56 | 68 |
EditableFeatureType ftype = DALLocator.getDataManager().createFeatureType(); |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.csv/src/main/java/org/gvsig/fmap/dal/store/gml/GMLFilesystemServerProvider.java | ||
---|---|---|
88 | 88 |
} |
89 | 89 |
|
90 | 90 |
@Override |
91 |
public boolean canCreate(NewDataStoreParameters parameters) { |
|
92 |
return false; |
|
93 |
} |
|
94 |
|
|
95 |
public void create(NewDataStoreParameters parameters, boolean overwrite) { |
|
96 |
throw new UnsupportedOperationException(); |
|
97 |
} |
|
98 |
|
|
99 |
protected NewDataStoreParameters createInstanceNewDataStoreParameters() { |
|
100 |
throw new UnsupportedOperationException(); |
|
101 |
} |
|
102 |
|
|
103 |
@Override |
|
104 |
public NewDataStoreParameters getCreateParameters() { |
|
105 |
throw new UnsupportedOperationException(); |
|
106 |
} |
|
107 |
|
|
108 |
@Override |
|
109 | 91 |
public void initialize(FilesystemServerExplorerProviderServices serverExplorer) { |
110 | 92 |
this.serverExplorer = serverExplorer; |
111 | 93 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.csv/src/main/java/org/gvsig/fmap/dal/store/gml/GMLStoreProvider.java | ||
---|---|---|
59 | 59 |
); |
60 | 60 |
} |
61 | 61 |
|
62 |
private GMLStoreParameters getCSVParameters() {
|
|
62 |
private GMLStoreParameters getGMLParameters() {
|
|
63 | 63 |
return (GMLStoreParameters) this.getParameters(); |
64 | 64 |
} |
65 | 65 |
|
... | ... | |
76 | 76 |
|
77 | 77 |
@Override |
78 | 78 |
protected SimpleReaderFeatureTypeLoader getFeatureTypeLoader() { |
79 |
return new GMLFeatureTypeLoader(getCSVParameters());
|
|
79 |
return new GMLFeatureTypeLoader(getGMLParameters());
|
|
80 | 80 |
} |
81 | 81 |
|
82 | 82 |
} |
Also available in: Unified diff