csvdumpname.patch
src/main/java/org/gvsig/fmap/dal/store/csv/CSVStoreParameters.java Locally Modified (Based On LOCAL) | ||
---|---|---|
65 | 65 |
private static final String FIRST_LINE_HEADER = "firstLineHeader"; |
66 | 66 |
private static final String HEADER = "header"; |
67 | 67 |
private static final String SURROUNDINGSPACESNEEDQUOTES = "surroundingSpacesNeedQuotes"; |
68 |
private static final String ACCEPTDUPLICATES = "acceptDuplicates"; |
|
68 | 69 | |
69 | 70 |
//private static final String IGNOREEMPTYLINES = "ignoreEmptyLines"; |
70 | 71 |
private static final String CRS = "CRS"; |
... | ... | |
368 | 369 |
// return fieldSizes; |
369 | 370 |
// } |
370 | 371 | |
372 |
static boolean acceptDuplicates(DynObject dynobj) { |
|
373 |
Boolean b = (Boolean) dynobj.getDynValue(ACCEPTDUPLICATES); |
|
374 |
return BooleanUtils.isTrue(b); |
|
375 |
} |
|
376 |
|
|
371 | 377 |
static String getRawFieldTypes(DynObject dynobj) { |
372 | 378 |
String s = (String) dynobj.getDynValue(FIELDTYPES); |
373 | 379 |
if ( StringUtils.isBlank(s) ) { |
src/main/java/org/gvsig/fmap/dal/store/csv/CSVStoreProvider.java Locally Modified (Based On LOCAL) | ||
---|---|---|
37 | 37 |
import java.util.List; |
38 | 38 |
import java.util.Locale; |
39 | 39 |
import java.util.Map; |
40 |
import java.util.function.Function; |
|
40 | 41 |
import javax.json.JsonArray; |
41 | 42 |
import javax.json.JsonObject; |
42 | 43 |
import javax.json.JsonValue; |
... | ... | |
113 | 114 |
import org.slf4j.LoggerFactory; |
114 | 115 |
import org.supercsv.prefs.CsvPreference; |
115 | 116 |
import org.gvsig.tools.dataTypes.CoercionContext; |
117 |
import org.gvsig.tools.namestranslator.NamesTranslator; |
|
116 | 118 | |
117 | 119 |
@SuppressWarnings("UseSpecificCatch") |
118 | 120 |
public class CSVStoreProvider extends AbstractMemoryStoreProvider implements |
... | ... | |
669 | 671 |
// Una vez ya sabemos los tipos de datos rellenamos el feature-type |
670 | 672 |
// |
671 | 673 |
for (FieldTypeParser fieldType : fieldTypes) { |
672 |
EditableFeatureAttributeDescriptor fad = fType.add(fieldType.name, fieldType.type); |
|
674 |
String name = fieldType.name; |
|
675 |
if( fType.get(fieldType.name)!=null ) { |
|
676 |
// Campo duplicado. |
|
677 |
if( !CSVStoreParameters.acceptDuplicates(this.getParameters()) ) { |
|
678 |
throw new RuntimeException("Column name '"+name+"' duplicated."); |
|
679 |
} |
|
680 |
NamesTranslator translator = NamesTranslator.createBaseTranslator(); |
|
681 |
translator.updateSourceNames(fType, (Object t) -> ((FeatureAttributeDescriptor)t).getName()); |
|
682 |
name = translator.getSuggestion(name); |
|
683 |
} |
|
684 |
EditableFeatureAttributeDescriptor fad = fType.add(name, fieldType.type); |
|
673 | 685 |
if( fieldType.detectedValue!=null ) { |
674 | 686 |
fad.setDisplaySize(Math.max(fieldType.detectedValue.getDisplaySize(), fieldType.size)); |
675 | 687 |
fad.setSize(Math.max(fieldType.detectedValue.getDisplaySize(), fieldType.size)); |
src/main/resources/org/gvsig/fmap/dal/store/csv/CSVParameters.xml Locally Modified (Based On LOCAL) | ||
---|---|---|
63 | 63 |
<field name="commentStartMarker" type="string" mandatory="false" defaultValue="" group="Advanced"> |
64 | 64 |
<description>Sets the comment start marker of the format to the specified character.</description> |
65 | 65 |
</field> |
66 |
<field name="acceptDuplicates" label="Accept duplicates" type="boolean" mandatory="false" defaultValue="false" group="Advanced"> |
|
67 |
<description></description> |
|
68 |
</field> |
|
66 | 69 |
<field name="automaticTypesDetection" type="boolean" mandatory="false" defaultValue="true" group="Advanced"> |
67 | 70 |
<description>This flag activate the autodetection of types in the CSV. Can be slow.</description> |
68 | 71 |
</field> |