Revision 44331

View differences:

trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.spi/src/main/java/org/gvsig/fmap/dal/feature/spi/AbstractFeatureStoreProvider.java
70 70
import org.gvsig.tools.dynobject.exception.DynFieldNotFoundException;
71 71
import org.gvsig.tools.dynobject.exception.DynMethodException;
72 72
import org.gvsig.tools.exception.BaseException;
73
import org.gvsig.tools.resourcesstorage.ResourcesStorage;
73 74
import org.gvsig.tools.util.UnmodifiableBasicMap;
74 75

  
75 76
/**
......
489 490
        public StoresRepository getStoresRepository() {
490 491
            return null;
491 492
        }
493
        
494
        @Override
495
        public ResourcesStorage getResourcesStorage() {
496
            return null;
497
        }
492 498

  
493 499
	/**
494 500
	 * unsupported by default (return null), override this otherwise
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.spi/src/main/java/org/gvsig/fmap/dal/spi/DataStoreProvider.java
39 39
import org.gvsig.timesupport.Time;
40 40
import org.gvsig.tools.dispose.Disposable;
41 41
import org.gvsig.tools.dynobject.DynObject_v2;
42
import org.gvsig.tools.resourcesstorage.ResourcesStorage;
42 43
import org.gvsig.tools.util.UnmodifiableBasicMap;
43 44

  
44 45
/**
......
60 61

  
61 62
        public StoresRepository getStoresRepository();
62 63
        
64
        public ResourcesStorage getResourcesStorage();
63 65
	/**
64 66
	 * Create a {@link DataServerExplorer} from the same source that this store.
65 67
	 *
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/feature/spi/simpleprovider/SimpleSequentialReader.java
11 11
import org.gvsig.fmap.dal.StoresRepository;
12 12
import org.gvsig.fmap.dal.feature.OpenFeatureStoreParameters;
13 13
import org.gvsig.fmap.dal.feature.spi.simpleprovider.AutomaticDetectionOfTypes.Rows;
14
import org.gvsig.tools.resourcesstorage.ResourcesStorage;
14 15

  
15 16
/**
16 17
 *
......
46 47
    public long getRowCount();
47 48
    
48 49
    public StoresRepository getStoresRepository();
50

  
51
    public ResourcesStorage getResourcesStorage();
49 52
    
50 53
    public OpenFeatureStoreParameters getParameters();
51 54
}
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/feature/spi/simpleprovider/AbstractSimpleSequentialReader.java
5 5
import java.util.Map;
6 6
import org.gvsig.fmap.dal.StoresRepository;
7 7
import org.gvsig.fmap.dal.feature.OpenFeatureStoreParameters;
8
import org.gvsig.tools.resourcesstorage.ResourcesStorage;
8 9

  
9 10
/**
10 11
 *
......
72 73
        return null;
73 74
    }
74 75
    
76
    @Override
77
    public ResourcesStorage getResourcesStorage() {
78
        return null;
79
    }
75 80
}
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/feature/spi/simpleprovider/SimpleSequentialReaderStoreProvider.java
89 89
import org.gvsig.tools.dynobject.Tags;
90 90
import org.gvsig.tools.dynobject.exception.DynFieldNotFoundException;
91 91
import org.gvsig.tools.exception.BaseException;
92
import org.gvsig.tools.resourcesstorage.ResourcesStorage;
92 93
import org.gvsig.tools.task.SimpleTaskStatus;
93 94
import org.gvsig.tools.task.TaskStatusManager;
94 95
import org.gvsig.tools.util.UnmodifiableBasicMap;
......
139 140
        private DataStore store;
140 141
        private StoresRepository storesRepository;
141 142
        private OpenFeatureStoreParameters parameters;
142

  
143
        private ResourcesStorage resourcesStorage;
144
        
143 145
        public ReaderData() {
144 146
            this.needCalculateEnvelope = false;
145 147
            this.features = new ArrayList<>();
......
232 234
            return storesRepository;
233 235
        }
234 236

  
237
        public ResourcesStorage getResourcesStorage() {
238
            return resourcesStorage;
239
        }
240

  
241
        public void setResourcesStorage(ResourcesStorage resourcesStorage) {
242
            this.resourcesStorage = resourcesStorage;
243
        }
244

  
235 245
        public void setParameters(OpenFeatureStoreParameters parameters) {
236 246
            if( parameters==null ) {
237 247
                LOGGER.warn("Can't set parameters to null");
......
1100 1110
            taskStatus.message("_preparing");
1101 1111
            readerData.setName(reader.getName());
1102 1112
            readerData.setStoresRepository(reader.getStoresRepository());
1113
            readerData.setResourcesStorage(reader.getResourcesStorage());
1103 1114
            readerData.setParameters(reader.getParameters());
1104 1115
            readerData.setAlias(reader.getAlias());
1105 1116
            
......
1281 1292
        return repo;
1282 1293
    }
1283 1294
    
1295
    @Override
1296
    public ResourcesStorage getResourcesStorage() {
1297
        ResourcesStorage storage = this.readerData.getResourcesStorage();
1298
        return storage;
1299
    }
1284 1300
}
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/feature/impl/DefaultFeatureStore.java
3017 3017

  
3018 3018
    @Override
3019 3019
    public ResourcesStorage getResourcesStorage() {
3020
        ResourcesStorage resourcesStorage;
3020 3021
        try {
3022
            resourcesStorage = this.provider.getResourcesStorage();
3023
            if( resourcesStorage!=null ) {
3024
                return resourcesStorage;
3025
            }
3026
        } catch(Throwable th) {
3027
            
3028
        }
3029
        try {
3021 3030
            DataServerExplorer explorer = this.getExplorer();
3022 3031
            if( explorer==null ) {
3023 3032
                return null;
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/feature/impl/DefaultFeature.java
278 278
        return this.reference;
279 279
    }
280 280

  
281
    @Override
282
    public Object getOrDefault(String name, Object defaultValue) {
283
        int index = this.data.getType().getIndex(name);
284
        if( index < 0 ) {
285
            return defaultValue;
286
        }
287
        return this.get(index);
288
    }
289

  
290
    @Override
291
    public String getStringOrDefault(String name, String defaultValue) {
292
        int index = this.data.getType().getIndex(name);
293
        if( index < 0 ) {
294
            return defaultValue;
295
        }
296
        try {
297
            return (String) this.get(index);
298
        } catch(Throwable th) {
299
            return defaultValue;
300
        }
301
    }
302

  
303
    @Override
304
    public int getIntOrDefault(String name, int defaultValue) {
305
        int index = this.data.getType().getIndex(name);
306
        if( index < 0 ) {
307
            return defaultValue;
308
        }
309
        try {
310
            return (int) this.get(index);
311
        } catch(Throwable th) {
312
            return defaultValue;
313
        }
314
    }
315

  
316
    @Override
317
    public long getLongOrDefault(String name, long defaultValue) {
318
        int index = this.data.getType().getIndex(name);
319
        if( index < 0 ) {
320
            return defaultValue;
321
        }
322
        try {
323
            return (long) this.get(index);
324
        } catch(Throwable th) {
325
            return defaultValue;
326
        }
327
    }
328

  
329
    @Override
330
    public float getFloatOrDefault(String name, float defaultValue) {
331
        int index = this.data.getType().getIndex(name);
332
        if( index < 0 ) {
333
            return defaultValue;
334
        }
335
        try {
336
            return (float) this.get(index);
337
        } catch(Throwable th) {
338
            return defaultValue;
339
        }
340
    }
341

  
342
    @Override
343
    public double getDoubleOrDefault(String name, double defaultValue) {
344
        int index = this.data.getType().getIndex(name);
345
        if( index < 0 ) {
346
            return defaultValue;
347
        }
348
        try {
349
            return (double) this.get(index);
350
        } catch(Throwable th) {
351
            return defaultValue;
352
        }
353
    }
354

  
355
    @Override
356
    public Date getDateOrDefault(String name, Date defaultValue) {
357
        int index = this.data.getType().getIndex(name);
358
        if( index < 0 ) {
359
            return defaultValue;
360
        }
361
        try {
362
            return (Date) this.get(index);
363
        } catch(Throwable th) {
364
            return defaultValue;
365
        }
366
    }
367

  
368
    @Override
369
    public Object getOrDefault(int index, Object defaultValue) {
370
        if( index < 0 || index >= this.data.getType().size() ) {
371
            return defaultValue;
372
        }
373
        try {
374
            return this.get(index);
375
        } catch(Throwable th) {
376
            return defaultValue;
377
        }
378
    }
379

  
380
    @Override
381
    public String getStringOrDefault(int index, String defaultValue) {
382
        if( index < 0 || index >= this.data.getType().size() ) {
383
            return defaultValue;
384
        }
385
        try {
386
            return (String) this.get(index);
387
        } catch(Throwable th) {
388
            return defaultValue;
389
        }
390
    }
391

  
392
    @Override
393
    public int getIntOrDefault(int index, int defaultValue) {
394
        if( index < 0 || index >= this.data.getType().size() ) {
395
            return defaultValue;
396
        }
397
        try {
398
            return (int) this.get(index);
399
        } catch(Throwable th) {
400
            return defaultValue;
401
        }
402
    }
403

  
404
    @Override
405
    public long getLongOrDefault(int index, long defaultValue) {
406
        if( index < 0 || index >= this.data.getType().size() ) {
407
            return defaultValue;
408
        }
409
        try {
410
            return (long) this.get(index);
411
        } catch(Throwable th) {
412
            return defaultValue;
413
        }
414
    }
415

  
416
    @Override
417
    public float getFloatOrDefault(int index, float defaultValue) {
418
        if( index < 0 || index >= this.data.getType().size() ) {
419
            return defaultValue;
420
        }
421
        try {
422
            return (float) this.get(index);
423
        } catch(Throwable th) {
424
            return defaultValue;
425
        }
426
    }
427

  
428
    @Override
429
    public double getDoubleOrDefault(int index, double defaultValue) {
430
        if( index < 0 || index >= this.data.getType().size() ) {
431
            return defaultValue;
432
        }
433
        try {
434
            return (double) this.get(index);
435
        } catch(Throwable th) {
436
            return defaultValue;
437
        }
438
    }
439

  
440
    @Override
441
    public Date getDateOrDefault(int index, Date defaultValue) {
442
        if( index < 0 || index >= this.data.getType().size() ) {
443
            return defaultValue;
444
        }
445
        try {
446
            return (Date) this.get(index);
447
        } catch(Throwable th) {
448
            return defaultValue;
449
        }
450
    }
451

  
281 452
    class UnableToGetReferenceException extends BaseRuntimeException {
282 453

  
283 454
        /**
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/OperationsFactoryBase.java
72 72
        public boolean hasSubquery() {
73 73
            return this.subquery != null;
74 74
        }
75

  
76
        @Override
77
        public String toString() {
78
            StringBuilder builder = new StringBuilder();
79
            if( this.hasDatabase() ) {
80
                builder.append(this.database);
81
                builder.append(".");
82
            }
83
            if( this.hasSchema()) {
84
                builder.append(this.schema);
85
                builder.append(".");
86
            }
87
            builder.append(this.table);
88
            if( this.hasSubquery() ) {
89
                builder.append("[");
90
                builder.append(this.subquery);
91
                builder.append("]");
92
            }
93
            return builder.toString();
94
        }
75 95
        
96
        
76 97
    }
77 98
    
78 99
    protected final JDBCHelper helper;
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/FetchFeatureTypeOperation.java
89 89
        ResultSet rs = null;
90 90
        try {
91 91
            if (CollectionUtils.isEmpty(pks)) {
92
                if (!table.hasSubquery()) {
93
                    pks = this.getPrimaryKeysFromMetadata(conn, null, table.getSchema(), table.getTable());
94
                    if (CollectionUtils.isEmpty(pks)) {
95
                        pks = getPrimaryKeysFromInformationSchema(conn, null, table.getSchema(), table.getTable());
96
                    }
92
                if (table.hasSubquery()) {
93
                    LOGGER.info("Searching pk in a table with a subquery ("+table.toString()+".");
97 94
                }
95
                pks = this.getPrimaryKeysFromMetadata(conn, null, table.getSchema(), table.getTable());
96
                if (CollectionUtils.isEmpty(pks)) {
97
                    pks = getPrimaryKeysFromInformationSchema(conn, null, table.getSchema(), table.getTable());
98
                }
98 99
            }
99 100

  
100 101
            JDBCSQLBuilderBase sqlbuilder = this.createSQLBuilder();
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/JDBCStoreProviderBase.java
464 464
            );
465 465
        fetchFeatureType.perform();
466 466

  
467
        if( !StringUtils.isEmpty(params.getDefaultGeometryField()) ) {
467
        if( !StringUtils.isBlank(params.getDefaultGeometryField()) ) {
468 468
            if( !params.getDefaultGeometryField().equalsIgnoreCase(type.getDefaultGeometryAttributeName()) ) {
469 469
                type.setDefaultGeometryAttributeName(params.getDefaultGeometryField());
470 470
                EditableFeatureAttributeDescriptor attr = (EditableFeatureAttributeDescriptor) type.getDefaultGeometryAttribute();
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/main/java/org/gvsig/fmap/dal/feature/Feature.java
126 126
	 */
127 127
	public EditableFeature getEditable();
128 128

  
129
	/**
129
        public Object getOrDefault(String name, Object defaultValue);
130
        public String getStringOrDefault(String name, String defaultValue);
131
        public int getIntOrDefault(String name, int defaultValue);
132
        public long getLongOrDefault(String name, long defaultValue);
133
        public float getFloatOrDefault(String name, float defaultValue);
134
        public double getDoubleOrDefault(String name, double defaultValue);
135
        public Date getDateOrDefault(String name, Date defaultValue);
136
        
137
        public Object getOrDefault(int index, Object defaultValue);
138
        public String getStringOrDefault(int index, String defaultValue);
139
        public int getIntOrDefault(int index, int defaultValue);
140
        public long getLongOrDefault(int index, long defaultValue);
141
        public float getFloatOrDefault(int index, float defaultValue);
142
        public double getDoubleOrDefault(int index, double defaultValue);
143
        public Date getDateOrDefault(int index, Date defaultValue);
144
        
145
        /**
130 146
	 * Returns the value of an attribute given its name.
131 147
	 *
132 148
	 * @param name

Also available in: Unified diff