Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_dalfile / src / org / gvsig / fmap / dal / store / dbf / DBFStoreProvider.java @ 27875

History | View | Annotate | Download (19.9 KB)

1
package org.gvsig.fmap.dal.store.dbf;
2

    
3
import java.io.File;
4
import java.io.IOException;
5
import java.text.DateFormat;
6
import java.text.ParseException;
7
import java.util.ArrayList;
8
import java.util.Arrays;
9
import java.util.Date;
10
import java.util.Iterator;
11
import java.util.List;
12
import java.util.Locale;
13

    
14
import org.gvsig.fmap.dal.DALLocator;
15
import org.gvsig.fmap.dal.DataManager;
16
import org.gvsig.fmap.dal.DataServerExplorer;
17
import org.gvsig.fmap.dal.DataStoreNotification;
18
import org.gvsig.fmap.dal.DataTypes;
19
import org.gvsig.fmap.dal.exception.CloseException;
20
import org.gvsig.fmap.dal.exception.DataException;
21
import org.gvsig.fmap.dal.exception.FileNotFoundException;
22
import org.gvsig.fmap.dal.exception.InitializeException;
23
import org.gvsig.fmap.dal.exception.OpenException;
24
import org.gvsig.fmap.dal.exception.ReadException;
25
import org.gvsig.fmap.dal.exception.UnsupportedVersionException;
26
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
27
import org.gvsig.fmap.dal.feature.DisposableIterator;
28
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor;
29
import org.gvsig.fmap.dal.feature.EditableFeatureType;
30
import org.gvsig.fmap.dal.feature.Feature;
31
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
32
import org.gvsig.fmap.dal.feature.FeatureQuery;
33
import org.gvsig.fmap.dal.feature.FeatureSet;
34
import org.gvsig.fmap.dal.feature.FeatureStore;
35
import org.gvsig.fmap.dal.feature.FeatureType;
36
import org.gvsig.fmap.dal.feature.exception.PerformEditingException;
37
import org.gvsig.fmap.dal.feature.exception.UnknownDataTypeException;
38
import org.gvsig.fmap.dal.feature.spi.AbstractFeatureStoreProvider;
39
import org.gvsig.fmap.dal.feature.spi.FeatureData;
40
import org.gvsig.fmap.dal.feature.spi.FeatureReferenceProviderServices;
41
import org.gvsig.fmap.dal.feature.spi.FeatureSetProvider;
42
import org.gvsig.fmap.dal.feature.spi.FeatureStoreProvider;
43
import org.gvsig.fmap.dal.feature.spi.FeatureStoreProviderServices;
44
import org.gvsig.fmap.dal.resource.exception.AccessResourceException;
45
import org.gvsig.fmap.dal.resource.exception.ResourceBeginException;
46
import org.gvsig.fmap.dal.resource.exception.ResourceException;
47
import org.gvsig.fmap.dal.resource.exception.ResourceNotifyChangesException;
48
import org.gvsig.fmap.dal.resource.exception.ResourceNotifyCloseException;
49
import org.gvsig.fmap.dal.resource.exception.ResourceNotifyOpenException;
50
import org.gvsig.fmap.dal.resource.file.FileResource;
51
import org.gvsig.fmap.dal.resource.spi.ResourceConsumer;
52
import org.gvsig.fmap.dal.resource.spi.ResourceProvider;
53
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer;
54
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorerParameters;
55
import org.gvsig.fmap.dal.store.dbf.utils.DbaseFile;
56
import org.gvsig.tools.ToolsLocator;
57
import org.gvsig.tools.dynobject.DelegatedDynObject;
58
import org.gvsig.tools.dynobject.DynClass;
59
import org.gvsig.tools.dynobject.DynField;
60
import org.gvsig.tools.dynobject.DynObject;
61
import org.gvsig.tools.dynobject.DynObjectManager;
62
import org.gvsig.tools.dynobject.exception.DynFieldNotFoundException;
63
import org.gvsig.tools.exception.BaseException;
64
import org.gvsig.tools.persistence.PersistenceException;
65
import org.gvsig.tools.persistence.PersistentState;
66

    
67
public class DBFStoreProvider extends AbstractFeatureStoreProvider implements
68
                ResourceConsumer {
69

    
70
        public static String NAME = "DBFStore";
71
        public static String DESCRIPTION = "DBF file";
72
        //        private DBFResource dbf = null;
73
        private DbaseFile dbfFile = null;
74
        private ResourceProvider dbfResource;
75
        private static final Locale ukLocale = new Locale("en", "UK");
76
        private static final String DYNCLASS_NAME = "DBFStore";
77
        protected static DynClass DYNCLASS = null;
78
        private DBFStoreParameters dbfParams;
79
        private long counterNewsOIDs = -1;
80
        private DBFFeatureWriter writer;
81

    
82
        public DBFStoreProvider() throws InitializeException {
83
                super();
84
                writer = new DBFFeatureWriter(this.getName());
85
        }
86

    
87
        public DBFStoreProvider(DBFStoreParameters params)
88
                        throws InitializeException {
89
                super();
90
                this.init(params);
91
                writer = new DBFFeatureWriter(this.getName());
92
        }
93

    
94

    
95
        protected void init(DBFStoreParameters params) throws InitializeException {
96
                this.dbfParams = params;
97
                this.dynObject = (DelegatedDynObject) ToolsLocator
98
                                .getDynObjectManager().createDynObject(
99
                                DYNCLASS);
100

    
101
                this.dynObject.setDynValue("DefaultSRS", null);
102
                this.dynObject.setDynValue("Envelope", null);
103

    
104
                File theFile = getDBFParameters().getDBFFile();
105
                dbfResource = this.createResource(FileResource.NAME,
106
                                new Object[] { theFile.getAbsolutePath() });
107
                dbfResource.addConsumer(this);
108

    
109
                this.dbfFile = new DbaseFile(theFile);
110

    
111
        }
112

    
113
        public FeatureStoreProvider initialize(FeatureStoreProviderServices store)
114
                        throws InitializeException {
115
                super.initialize(store);
116
                this.initFeatureType();
117
                return this;
118
        }
119

    
120
        public String getName() {
121
                return NAME;
122
        }
123

    
124
        protected DBFStoreParameters getDBFParameters() {
125
                return dbfParams;
126
        }
127

    
128

    
129
        public DataServerExplorer getExplorer() throws ReadException {
130
                DataManager manager = DALLocator.getDataManager();
131
                FilesystemServerExplorerParameters params;
132
                try {
133
                        params = (FilesystemServerExplorerParameters) manager
134
                                        .createServerExplorerParameters(FilesystemServerExplorer.NAME);
135
                        params.setRoot(this.getDBFParameters().getDBFFile().getParent());
136
                        return manager.createServerExplorer(params);
137
                } catch (DataException e) {
138
                        throw new ReadException(this.getName(), e);
139
                } catch (ValidateDataParametersException e) {
140
                        // TODO Auto-generated catch block
141
                        throw new ReadException(this.getName(), e);
142
                }
143
        }
144

    
145
        public FeatureData getFeatureDataByReference(
146
                        FeatureReferenceProviderServices reference, FeatureType featureType)
147
                        throws DataException {
148

    
149
                return this.getFeatureDataByIndex(((Long) reference.getOID())
150
                                .longValue(),
151
                                featureType);
152
        }
153

    
154

    
155
        public FeatureData getFeatureDataByReference(
156
                        FeatureReferenceProviderServices reference) throws DataException {
157
                return this.getFeatureDataByReference(reference, this.store
158
                                .getDefaultFeatureType());
159
        }
160

    
161
        public void performEditing(Iterator deleteds, Iterator inserteds,
162
                        Iterator updateds)
163
                        throws PerformEditingException {
164

    
165
                try {
166
                        this.resourcesBegin();
167
                        FeatureSet set = this.store.getFeatureSet();
168
                        DBFStoreParameters tmpParams = (DBFStoreParameters) this
169
                                        .getDBFParameters().getCopy();
170

    
171
                        tmpParams.setDBFFileName(tmpParams.getDBFFileName() + ".tmp");
172

    
173
                        writer.begin(tmpParams, this.store
174
                                        .getDefaultFeatureType(), set.getSize());
175

    
176
                        DisposableIterator iter = set.fastIterator();
177
                        while (iter.hasNext()) {
178
                                Feature feature=(Feature) iter.next();
179
                                writer.append(feature);
180
                        }
181
                        iter.dispose();
182

    
183

    
184
                        writer.end();
185

    
186
                        try {
187
                                this.close();
188
                        } catch (CloseException e1) {
189
                                throw new PerformEditingException(this.getName(), e1);
190
                        }
191
                        this.getDBFParameters().getDBFFile().delete();
192
                        tmpParams.getDBFFile().renameTo(
193
                                        this.getDBFParameters().getDBFFile());
194

    
195
                        this.resourcesNotifyChanges();
196
                        this.initFeatureType();
197
                } catch (Exception e) {
198
                        throw new PerformEditingException(this.getName(), e);
199
                } finally {
200
                        this.resourcesEnd();
201
                }
202

    
203
                this.counterNewsOIDs = -1;
204
        }
205

    
206
        /*
207
         * ==================================================
208
         */
209

    
210
        public FeatureData createFeatureData(FeatureType type) throws DataException {
211
                return new DBFFeatureData(this, type);
212
        }
213

    
214

    
215
        /*
216
         * ===================================================
217
         */
218

    
219
        FeatureStoreProviderServices getProviderServices() {
220
                return this.store;
221
        }
222

    
223

    
224
        protected void initFeatureType() throws InitializeException {
225
                FeatureType defaultType = this.getTheFeatureType().getNotEditableCopy();
226
                List types = new ArrayList(1);
227
                types.add(defaultType);
228
                this.store.setFeatureTypes(types, defaultType);
229
        }
230

    
231
        protected EditableFeatureType getTheFeatureType() throws InitializeException {
232
                try {
233
                        this.open();
234
                        this.resourcesBegin();
235
                } catch (DataException e) {
236
                        throw new InitializeException(this.getName(), e);
237
                }
238
                try {
239
                        int fieldCount = -1;
240
                        fieldCount = dbfFile.getFieldCount();
241

    
242
                        EditableFeatureType fType = this.store.createFeatureType();
243

    
244
                        fType.setHasOID(true);
245
                        int precision;
246
                        for (int i = 0; i < fieldCount; i++) {
247
                                char fieldType = dbfFile.getFieldType(i);
248
                                EditableFeatureAttributeDescriptor attr;
249

    
250
                                if (fieldType == 'L') {
251
                                        attr = fType
252
                                                        .add(dbfFile.getFieldName(i), DataTypes.BOOLEAN);
253
                                        attr.setDefaultValue(new Boolean(false));
254
                                        attr.setAllowNull(false);
255

    
256
                                } else if ((fieldType == 'F') || (fieldType == 'N')) {
257
                                        precision = dbfFile.getFieldDecimalLength(i);
258
                                        if (precision > 0) {
259
                                                attr = fType.add(dbfFile.getFieldName(i),
260
                                                                DataTypes.DOUBLE, dbfFile.getFieldLength(i));
261
                                                attr.setPrecision(precision);
262
                                                attr.setDefaultValue(new Double(0));
263

    
264
                                        } else {
265
                                                attr = fType
266
                                                                .add(dbfFile.getFieldName(i), DataTypes.INT);
267
                                                attr.setDefaultValue(new Integer(0));
268
                                        }
269
                                        attr.setAllowNull(false);
270

    
271
                                } else if (fieldType == 'C') {
272
                                        attr = fType.add(dbfFile.getFieldName(i), DataTypes.STRING);
273
                                        attr.setSize(dbfFile.getFieldLength(i));
274
                                        attr.setDefaultValue("");
275
                                        attr.setAllowNull(false);
276

    
277
                                } else if (fieldType == 'D') {
278
                                        attr = fType.add(dbfFile.getFieldName(i), DataTypes.DATE);
279
                                        attr.setDefaultValue(null);
280
                                        attr.setAllowNull(true);
281
                                } else {
282
                                        throw new InitializeException(this.getName(),
283
                                                        new UnknownDataTypeException(
284
                                                                        dbfFile.getFieldName(i), "" + fieldType,
285
                                                                        this.getName()));
286
                                }
287
                        }
288
                        return fType;
289
                } finally {
290
                        this.resourcesEnd();
291
                }
292
        }
293

    
294

    
295
        protected void loadValue(FeatureData featureData, int rowIndex,
296
                        FeatureAttributeDescriptor descriptor) throws ReadException {
297
                if (descriptor.getEvaluator() != null) {
298
                        // Nothing to do
299
                        return;
300
                }
301

    
302

    
303
                int dbfIndex = this.dbfFile.getFieldIndex(descriptor.getName());
304
                String value = null;
305
                try {
306
                        value = this.dbfFile.getStringFieldValue(rowIndex, dbfIndex);
307
                } catch (DataException e) {
308
                        throw new ReadException(this.store.getName(), e);
309
                }
310
                value = value.trim();
311
                int fieldType = descriptor.getDataType();
312
                switch (fieldType) {
313
                case DataTypes.STRING:
314
                        featureData.set(descriptor.getIndex(), value);
315
                        break;
316

    
317
                case DataTypes.DOUBLE:
318
                        try {
319
                                featureData.set(descriptor.getIndex(), new Double(value));
320
                        } catch (NumberFormatException e) {
321
                                featureData.set(descriptor.getIndex(), null);
322
                        }
323
                        break;
324

    
325
                case DataTypes.INT:
326
                        try {
327
                                featureData.set(descriptor.getIndex(), new Integer(value));
328
                        } catch (NumberFormatException e) {
329
                                featureData.set(descriptor.getIndex(), null);
330
                        }
331
                        break;
332

    
333
                case DataTypes.FLOAT:
334
                        try {
335
                                featureData.set(descriptor.getIndex(), new Float(value));
336
                        } catch (NumberFormatException e) {
337
                                featureData.set(descriptor.getIndex(), null);
338
                        }
339
                        break;
340

    
341
                case DataTypes.LONG:
342
                        try {
343
                                featureData.set(descriptor.getIndex(), new Long(value));
344
                        } catch (NumberFormatException e) {
345
                                featureData.set(descriptor.getIndex(), null);
346
                        }
347
                        break;
348

    
349
                case DataTypes.BOOLEAN:
350
                        featureData.set(descriptor.getIndex(), new Boolean(value));
351
                        break;
352

    
353
                case DataTypes.BYTE:
354
                        try {
355
                                featureData.set(descriptor.getIndex(), new Byte(value));
356
                        } catch (NumberFormatException e) {
357
                                featureData.set(descriptor.getIndex(), null);
358
                        }
359
                        break;
360

    
361
                case DataTypes.DATE:
362
                        String year = value.substring(0, 4);
363
                        String month = value.substring(4, 6);
364
                        String day = value.substring(6, 8);
365
                        DateFormat df;
366
                        if (descriptor.getDateFormat() == null){
367
                                df = DateFormat.getDateInstance(DateFormat.SHORT,
368
                                                ukLocale);
369
                        } else{
370
                                df = descriptor.getDateFormat();
371
                        }
372
                        /*
373
                         * Calendar c = Calendar.getInstance(); c.clear();
374
                         * c.set(Integer.parseInt(year), Integer.parseInt(month),
375
                         * Integer.parseInt(day)); c.set(Calendar.MILLISECOND, 0);
376
                         */
377
                        String strAux = month + "/" + day + "/" + year;
378
                        Date dat = null;
379
                        try {
380
                                dat = df.parse(strAux);
381
                        } catch (ParseException e) {
382
                                throw new ReadException(this.store.getName(), e);
383
                        }
384
                        featureData.set(descriptor.getIndex(), dat);
385
                        break;
386

    
387

    
388
                default:
389
                        featureData
390
                                        .set(descriptor.getIndex(), descriptor.getDefaultValue());
391
                        break;
392
                }
393
        }
394

    
395

    
396
        /***
397
         * NOT supported in Alter Mode
398
         *
399
         * @param index
400
         * @return
401
         * @throws ReadException
402
         */
403
        protected FeatureData getFeatureDataByIndex(long index) throws DataException {
404
                return this
405
                                .getFeatureDataByIndex(index, this.store
406
                                .getDefaultFeatureType());
407
        }
408

    
409
        protected int getFeatureCount() throws ReadException, OpenException,
410
                        ResourceNotifyChangesException {
411
                this.open();
412
                try {
413
                        this.resourcesBegin();
414
                } catch (ResourceBeginException e) {
415
                        throw new ReadException(this.getName(), e);
416
                }
417
                try {
418
                        return this.dbfFile.getRecordCount();
419
                } finally {
420
                        this.resourcesEnd();
421
                }
422
        }
423

    
424
        public FeatureSetProvider createSet(FeatureQuery query, FeatureType featureType)
425
                        throws DataException {
426
                return new DBFSetProvider(this, query, featureType);
427
        }
428

    
429
        public boolean canCreate() {
430
                return true;
431
        }
432

    
433
        public boolean canWriteGeometry(int geometryType) throws DataException {
434
                return false;
435
        }
436

    
437
        public void open() throws OpenException {
438
                if (this.dbfFile.isOpen()) {
439
                        return;
440
                }
441
                try {
442
                        this.resourcesBegin();
443
                } catch (ResourceBeginException e) {
444
                        throw new OpenException(this.getName(), e);
445
                }
446
                try {
447
                        this.openFile();
448
                        this.resourcesOpen();
449

    
450
                        // Load metadata values
451
                        this.loadMetadataValues();
452

    
453
                } catch (UnsupportedVersionException e) {
454
                        throw new OpenException(this.getName(), e);
455
                } catch (ResourceNotifyOpenException e) {
456
                        throw new OpenException(this.getName(), e);
457
                } catch (FileNotFoundException e) {
458
                        throw new OpenException(this.getName(), e);
459
                } catch (IOException e) {
460
                        throw new OpenException(this.getName(), e);
461
                } catch (BaseException e) {
462
                        throw new OpenException(this.getName(), e);
463
                } finally {
464
                        this.resourcesEnd();
465
                }
466
        }
467

    
468
        protected void openFile() throws FileNotFoundException,
469
                        UnsupportedVersionException, IOException, DataException {
470
                this.dbfFile.open();
471
        }
472

    
473
        protected void loadMetadataValues() throws DynFieldNotFoundException,
474
                        ReadException {
475
                this.dynObject.setDynValue(DBFLibrary.DYNFIELD_CODEPAGE_NAME, new Byte(
476
                                this.dbfFile.getCodePage()));
477

    
478
        }
479

    
480
        public void close() throws CloseException {
481
                if (!this.dbfFile.isOpen()) {
482
                        return;
483
                }
484
                super.close();
485
                //Cerrar recurso
486
                try {
487
                        this.resourcesBegin();
488
                } catch (ResourceBeginException e) {
489
                        throw new CloseException(this.getName(), e);
490
                }
491
                try {
492
                        this.closeFile();
493
                        this.resourcesNotifyClose();
494

    
495
                } catch (ResourceNotifyCloseException e) {
496
                        throw new CloseException(this.getName(), e);
497
                } finally {
498
                        this.resourcesEnd();
499
                }
500
        }
501

    
502
        protected void closeFile() throws CloseException {
503
                this.dbfFile.close();
504
        }
505

    
506
        public void dispose() throws CloseException {
507
                this.close();
508
                dbfFile = null;
509
                this.dbfResource.removeConsumer(this);
510
                dbfResource = null;
511
                super.dispose();
512
        }
513

    
514
        public boolean closeResourceRequested(ResourceProvider resource) {
515
                try {
516
                        this.close();
517
                } catch (CloseException e) {
518
                        return false;
519
                }
520
                return true;
521
        }
522

    
523
        public boolean allowWrite() {
524
                File file;
525
                try {
526
                        file = new File((String) this.dbfResource.get());
527
                } catch (AccessResourceException e) {
528
                        return false;
529
                }
530
                return file.canWrite();
531
        }
532

    
533
        public void refresh() throws OpenException {
534
                try {
535
                        this.close();
536
                } catch (CloseException e) {
537
                        throw new OpenException(this.getName(), e);
538
                }
539
                this.open();
540
                try {
541
                        this.initFeatureType();
542
                } catch (InitializeException e) {
543
                        throw new OpenException(this.getName(), e);
544
                }
545
        }
546

    
547
        /**
548
         *
549
         * @param index
550
         * @param featureType
551
         * @return
552
         * @throws ReadException
553
         */
554
        protected FeatureData getFeatureDataByIndex(long index,
555
                        FeatureType featureType) throws DataException {
556
                FeatureData featureData = this.createFeatureData(featureType);
557
                featureData.setOID(new Long(index));
558
                return featureData;
559
        }
560

    
561
        protected void initFeatureDataByIndex(FeatureData featureData,
562
                        long index, FeatureType featureType) throws DataException {
563
                featureData.setOID(new Long(index));
564
        }
565

    
566
        /**
567
         *
568
         * @param featureData
569
         * @throws DataException
570
         */
571
        protected void loadFeatureDataByIndex(FeatureData featureData)
572
                        throws DataException {
573
                this.open();
574
                this.resourcesBegin();
575
                long index = ((Long) featureData.getOID()).longValue();
576
                try {
577
                        if (index >= this.dbfFile.getRecordCount()) {
578
                                // FIXME
579
                                throw new ArrayIndexOutOfBoundsException("" + index);
580
                        }
581
                        Iterator iterator = featureData.getType().iterator();
582
                        while (iterator.hasNext()) {
583
                                FeatureAttributeDescriptor descriptor = (FeatureAttributeDescriptor) iterator
584
                                                .next();
585
                                this.loadValue(featureData, (int) index, descriptor);
586
                        }
587

    
588

    
589
                } finally {
590
                        this.resourcesEnd();
591
                }
592
        }
593

    
594
        public int getFeatureReferenceOIDType() {
595
                return DataTypes.LONG;
596
        }
597

    
598
        public Object createNewOID() {
599
                if (this.counterNewsOIDs < 0) {
600
                        try {
601
                                this.counterNewsOIDs = this.getFeatureCount();
602
                        } catch (DataException e) {
603
                                e.printStackTrace();
604
                        }
605

    
606
                }else{
607
                        this.counterNewsOIDs++;
608
                }
609
                return new Long(counterNewsOIDs);
610
        }
611

    
612
        public boolean supportsAppendMode() {
613
                return true;
614
        }
615

    
616

    
617
        public void append(Feature feature) throws DataException {
618
                this.resourcesBegin();
619
                try {
620
                        writer.append(feature);
621
                } finally {
622
                        this.resourcesEnd();
623
                }
624
        }
625

    
626
        public void beginAppend() throws DataException {
627
                this.close();
628
                this.resourcesBegin();
629
                try {
630
                        FeatureSet set = this.store.getFeatureSet();
631
                        writer.begin(this.getDBFParameters(), this.store
632
                                        .getDefaultFeatureType(), set.getSize());
633
                } finally {
634
                        this.resourcesEnd();
635
                }
636
        }
637

    
638
        public void endAppend() throws DataException {
639
                this.resourcesBegin();
640
                try {
641
                        writer.end();
642

    
643
                        this.resourcesNotifyChanges();
644
                        this.counterNewsOIDs = -1;
645
                } finally {
646
                        this.resourcesEnd();
647
                }
648
        }
649

    
650
        public PersistentState getState() throws PersistenceException {
651
                // Nothing to do
652
                return null;
653
        }
654

    
655
        public void loadState(PersistentState state) throws PersistenceException {
656
                try {
657
                        this.init((DBFStoreParameters) this.store.getParameters());
658
                } catch (InitializeException e) {
659
                        throw new PersistenceException(e);
660
                }
661
        }
662

    
663
        public void setState(PersistentState state) throws PersistenceException {
664
                try {
665
                        this.init((DBFStoreParameters) this.store.getParameters());
666
                } catch (InitializeException e) {
667
                        throw new PersistenceException(e);
668
                }
669
        }
670

    
671
        public Iterator getChilds() {
672
                return Arrays.asList(new DynObject[] { this.dbfParams }).iterator();
673

    
674
        }
675

    
676
        protected static void registerDynClass() {
677
                DynObjectManager dynman = ToolsLocator.getDynObjectManager();
678
                DynClass dynClass;
679
                DynField field;
680
                if (DYNCLASS == null) {
681
                        dynClass = dynman.add(DYNCLASS_NAME,
682
                                        "DBF File Store");
683
                        field = DBFLibrary.addCodePageField(dynClass);
684

    
685
                        dynClass.extend(dynman.get(FeatureStore.DYNCLASS_NAME));
686

    
687
                        DYNCLASS = dynClass;
688
                }
689

    
690
        }
691

    
692
        public Object getDynValue(String name) throws DynFieldNotFoundException {
693
                try {
694
                        this.open();
695
                } catch (OpenException e) {
696
                        // FIXME
697
                        throw new RuntimeException(e);
698
                }
699
                return super.getDynValue(name);
700
        }
701

    
702

    
703
        /*
704
         * (non-Javadoc)
705
         *
706
         * @see
707
         * org.gvsig.fmap.dal.resource.spi.ResourceConsumer#resourceChanged(org.
708
         * gvsig.fmap.dal.resource.spi.ResourceProvider)
709
         */
710
        public void resourceChanged(ResourceProvider resource) {
711
                this.store.notifyChange(DataStoreNotification.RESOURCE_CHANGED,
712
                                resource);
713
        }
714

    
715
        protected void resourcesBegin() throws ResourceBeginException {
716
                this.dbfResource.begin();
717
        }
718

    
719
        protected void resourcesEnd() {
720
                this.dbfResource.end();
721
        }
722

    
723
        /**
724
         *
725
         * @throws ResourceNotifyChangesException
726
         */
727
        protected void resourcesNotifyChanges()
728
                        throws ResourceNotifyChangesException {
729
                this.dbfResource.notifyChanges();
730
        }
731

    
732
        /**
733
         * @throws ResourceNotifyCloseException
734
         *
735
         */
736
        protected void resourcesNotifyClose() throws ResourceNotifyCloseException {
737
                this.dbfResource.notifyClose();
738
        }
739

    
740
        /**
741
         * @throws ResourceNotifyOpenException
742
         *
743
         */
744
        protected void resourcesOpen() throws ResourceNotifyOpenException {
745
                this.dbfResource.notifyOpen();
746
        }
747

    
748
        public Object getSourceId() {
749
                return this.getDBFParameters().getFile();
750
        }
751

    
752
        protected void resourceCloseRequest() throws ResourceException {
753
                this.dbfResource.closeRequest();
754
        }
755
}