Revision 47789

View differences:

trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.lib/src/main/java/org/gvsig/fmap/dal/store/simplereader/SimpleReaderStoreParameters.java
68 68

  
69 69
    protected DelegatedDynObject parameters;
70 70
    protected FeatureType featureType;
71
    protected boolean defaultValueOfAutomaticTypesDetection = true;
71
    protected boolean all_fields_declare_type = false;
72 72

  
73 73
    @SuppressWarnings("OverridableMethodCallInConstructor")
74 74
    public SimpleReaderStoreParameters(String parametersDefinitionName, String name) {
......
93 93
    }
94 94

  
95 95
    @Override
96
    public Object getDynValue(String name) {
97
        if(StringUtils.equalsIgnoreCase(name, AUTOMATICTYPESDETECTION)){
98
            //Si tenemos featureType y estan declarados todos los tipos, ya no es necesario hacer la deteccion automatica
99
            if(this.featureType != null){
100
                if( this.all_fields_declare_type ){
101
                    return false;
102
                }
103
            }
104
        }
105
        return super.getDynValue(name);
106
    }
107

  
108
    @Override
96 109
    public boolean isValid() {
97 110
        return getFileName(this) != null;
98 111
    }
......
310 323
            IProjection proj = null;
311 324
            FeatureType ftype = this.getFeatureType();
312 325
            if( ftype!=null ) {
313
                this.setDynValue(AUTOMATICTYPESDETECTION, defaultValueOfAutomaticTypesDetection);
314 326
                proj = ftype.getDefaultSRS();
315 327
                if( proj!=null ) {
316 328
                    this.setDynValue(CRS_PARAMTER_NAME, proj);
......
351 363
                if( featureTypeLoader!=null ) {
352 364
                    EditableFeatureType ftype = DALLocator.getDataManager().createFeatureType();
353 365
                    featureTypeLoader.loadFeatureType(ftype, false, null);
354
                    boolean all_fields_declare_type = featureTypeLoader.isAllFieldsDeclareType();
355
                    defaultValueOfAutomaticTypesDetection = !all_fields_declare_type;
366
                    this.all_fields_declare_type = featureTypeLoader.isAllFieldsDeclareType();
356 367
                    this.featureType = ftype;
357 368
                }
358 369
            } catch (Exception ex) {
......
362 373
        }
363 374
        return this.featureType;
364 375
    }
365

  
376
    
366 377
    @Override
367 378
    public String getSourceId() {
368 379
        return this.toString(); // FIXME: Check if is correnct
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.lib/src/main/java/org/gvsig/fmap/dal/store/simplereader/AutomaticDetectionOfTypes.java
82 82
        public boolean possibleTime = true;
83 83
        public boolean possibleTimestamp = true;
84 84
        public boolean possibleGeometry = true;
85
        public boolean hasData = false;
85 86
    }
86 87

  
87 88
    private final String filename;
......
166 167
                    while( possibleDataTypes.size()<row.size() ) {
167 168
                        possibleDataTypes.add(new PossibleDataType());
168 169
                    }
170
                    PossibleDataType possibleDataType = possibleDataTypes.get(i);
171
                    DetectedValueImpl detectedValue = detectedValues.get(i);
172

  
169 173
                    String rawvalue = row.get(i);
170
                    if( rawvalue == null ) {
174
                    if( StringUtils.isBlank(rawvalue) ) {
171 175
                       continue; 
172 176
                    }
177
                    possibleDataType.hasData = true;
173 178
                    
174
                    PossibleDataType possibleDataType = possibleDataTypes.get(i);
175
                    DetectedValueImpl detectedValue = detectedValues.get(i);
176 179
                    if( detectedValue.blank ) {
177 180
                        detectedValue.blank = StringUtils.isBlank(rawvalue);
178 181
                    }
......
268 271
            }
269 272
            int n = 0;
270 273
            for (PossibleDataType possibleDataType : possibleDataTypes) {
274
                if (!possibleDataType.hasData) {
275
                    detectedValues.get(n++).blank = true;
276
                    continue;
277
                }
271 278
                if (possibleDataType.possibleInt) {
272 279
                    detectedValues.get(n++).type = DataTypes.INT;
273 280
                    continue;
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.lib/src/main/java/org/gvsig/fmap/dal/store/simplereader/SimpleReaderFeatureTypeLoader.java
193 193
            if( StringUtils.isBlank(headers[headers.length-1]) &&
194 194
                (detectedTypes==null || detectedTypes[headers.length-1].isBlank()) ) {
195 195
                headers = ArrayUtils.remove(headers, headers.length-1);
196
                if(detectedTypes != null) {
197
                    detectedTypes = ArrayUtils.remove(detectedTypes, detectedTypes.length-1);
198
                }
196 199
            }
197 200
            if (detectedTypes != null && detectedTypes.length > headers.length) {
198 201
                // Se han detectado mas columnas que las que hay en la cabezera,

Also available in: Unified diff