Revision 36207

View differences:

branches/v2_0_0_prep/libraries/libFMap_dal/src/org/gvsig/fmap/dal/feature/impl/DefaultFeatureIndexes.java
225 225
		return index.apply();
226 226

  
227 227
	}
228

  
229
    public boolean areValid() {
230
        Iterator indexes = this.iterator();
231
        while (indexes.hasNext()) {
232
            FeatureIndex index = (FeatureIndex) indexes.next();
233
            if (!index.isValid()) {
234
                return false;
235
            }
236
        }
237
        return true;
238
    }
228 239
}
branches/v2_0_0_prep/libraries/libFMap_dal/src/org/gvsig/fmap/dal/feature/impl/DefaultFeatureStoreNotification.java
4 4
import org.gvsig.fmap.dal.DataStore;
5 5
import org.gvsig.fmap.dal.feature.EditableFeatureType;
6 6
import org.gvsig.fmap.dal.feature.Feature;
7
import org.gvsig.fmap.dal.feature.FeatureIndex;
7 8
import org.gvsig.fmap.dal.feature.FeatureStoreNotification;
8 9
import org.gvsig.tools.undo.command.Command;
9 10

  
......
17 18
	private EditableFeatureType featureType = null;
18 19
	private String type;
19 20
	private DataStore source;
21
    private FeatureIndex index;
20 22

  
21 23
	protected void init(DataStore source, String type) {
22 24
		this.source = source;
......
55 57
		this.featureType = featureType;
56 58
	}
57 59

  
60
    public DefaultFeatureStoreNotification(DataStore source, String type,
61
        FeatureIndex index) {
62
        this.init(source, type);
63
        this.index = index;
64
    }
65

  
58 66
	public Feature getFeature() {
59 67
		return feature;
60 68
	}
......
87 95
		return type;
88 96
	}
89 97

  
98
    public FeatureIndex getIndex() {
99
        return index;
100
    }
90 101
}
branches/v2_0_0_prep/libraries/libFMap_dal/src/org/gvsig/fmap/dal/feature/impl/featureset/DefaultFeatureSet.java
10 10
import org.gvsig.fmap.dal.exception.DataException;
11 11
import org.gvsig.fmap.dal.feature.EditableFeature;
12 12
import org.gvsig.fmap.dal.feature.Feature;
13
import org.gvsig.fmap.dal.feature.FeatureIndexes;
13 14
import org.gvsig.fmap.dal.feature.FeatureQuery;
14 15
import org.gvsig.fmap.dal.feature.FeatureQueryOrder.FeatureQueryOrderMember;
15 16
import org.gvsig.fmap.dal.feature.FeatureSet;
......
98 99
			this.defatulFeatureTypeForProvider = this.defatulFeatureType;
99 100
		}
100 101

  
101
		if (this.queryForProvider.hasFilter() && store.getIndexes() != null) {
102
			this.provider = (FeatureSetProvider) store.getIndexes()
102
        FeatureIndexes indexes = store.getIndexes();
103
        if (this.queryForProvider.hasFilter() && indexes != null
104
            && indexes.areValid()) {
105
            this.provider =
106
                (FeatureSetProvider) indexes
103 107
					.getFeatureSet(this.queryForProvider.getFilter());
104 108
		}
105 109
		if (this.provider == null) {
branches/v2_0_0_prep/libraries/libFMap_dal/src/org/gvsig/fmap/dal/feature/impl/DefaultFeatureIndex.java
31 31
import java.util.ArrayList;
32 32
import java.util.List;
33 33

  
34
import org.slf4j.Logger;
35
import org.slf4j.LoggerFactory;
36

  
34 37
import org.gvsig.fmap.dal.DataTypes;
35 38
import org.gvsig.fmap.dal.exception.DataException;
36 39
import org.gvsig.fmap.dal.exception.InitializeException;
37 40
import org.gvsig.fmap.dal.feature.Feature;
38 41
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
39 42
import org.gvsig.fmap.dal.feature.FeatureSet;
43
import org.gvsig.fmap.dal.feature.FeatureStoreNotification;
40 44
import org.gvsig.fmap.dal.feature.FeatureType;
41 45
import org.gvsig.fmap.dal.feature.exception.FeatureIndexException;
42 46
import org.gvsig.fmap.dal.feature.exception.InvalidFeatureIndexException;
......
45 49
import org.gvsig.fmap.dal.feature.spi.FeatureStoreProviderServices;
46 50
import org.gvsig.fmap.dal.feature.spi.index.FeatureIndexProvider;
47 51
import org.gvsig.fmap.dal.feature.spi.index.FeatureIndexProviderServices;
52
import org.gvsig.tools.ToolsLocator;
48 53
import org.gvsig.tools.dispose.DisposableIterator;
49 54
import org.gvsig.tools.dispose.DisposeUtils;
55
import org.gvsig.tools.observer.impl.BaseWeakReferencingObservable;
56
import org.gvsig.tools.task.SimpleTaskStatus;
57
import org.gvsig.tools.task.TaskStatusManager;
50 58

  
51 59
/**
52 60
 * Default feature index provider services.
......
54 62
 * @author jyarza
55 63
 * 
56 64
 */
57
public class DefaultFeatureIndex implements FeatureIndexProviderServices {
65
public class DefaultFeatureIndex extends BaseWeakReferencingObservable
66
    implements FeatureIndexProviderServices {
58 67

  
68
    private static final Logger LOG = LoggerFactory
69
        .getLogger(DefaultFeatureIndex.class);
70

  
59 71
    private final FeatureStoreProviderServices featureStore;
60 72
    private final FeatureType featureType;
61 73
    private final String attributeName;
......
132 144
        return dataType;
133 145
    }
134 146

  
135
    /**
136
     * Fills this index with all the data in its FeatureStore
137
     */
138
    public final void fill() throws FeatureIndexException {
147
    public synchronized final void fill() throws FeatureIndexException {
148
        fill(false);
149
    }
150

  
151
    public void fill(boolean background) throws FeatureIndexException {
139 152
        if (!isValid()) {
140 153
            throw new InvalidFeatureIndexException();
141 154
        }
155
        if (background) {
156
            filling = true;
157

  
158
            Runnable task = new Runnable() {
159

  
160
                public void run() {
161
                    try {
162
                        clearAndFill();
163
                    } catch (DataException e) {
164
                        LOG.error("Error filling index: " + this, e);
165
                    }
166
                }
167
            };
168

  
169
            Thread thread = new Thread(task, "Fill index data");
170
            thread.start();
171
        } else {
172
            try {
173
                clearAndFill();
174
            } catch (DataException e) {
175
                throw new FeatureIndexException(e);
176
            }
177
        }
178
    }
179

  
180
    /**
181
     * @throws DataException
182
     */
183
    private void clearAndFill() throws DataException {
142 184
        FeatureSet set = null;
143 185
        try {
186
            filling = true;
144 187
            set =
145 188
                getFeatureStoreProviderServices().getFeatureStore()
146 189
                    .getFeatureSet();
147
            filling = true;
148 190
            clear();
149 191
            doInsert(set);
192
            filling = false;
193
            notify(this, new DefaultFeatureStoreNotification(
194
                getFeatureStoreProviderServices().getFeatureStore(),
195
                FeatureStoreNotification.INDEX_FILLED_SUCCESSFULLY, this));
150 196
        } catch (DataException e) {
197
            filling = false;
198
            setValid(false);
199
            notify(this, new DefaultFeatureStoreNotification(
200
                getFeatureStoreProviderServices().getFeatureStore(),
201
                FeatureStoreNotification.INDEX_FILLING_ERROR, e));
151 202
            throw new FeatureIndexException(e);
152 203
        } finally {
153
            filling = false;
154 204
            DisposeUtils.dispose(set);
155 205
        }
156 206
    }
157 207

  
158
    public final void insert(FeatureSet data) throws DataException {
208
    public synchronized final void insert(FeatureSet data) throws DataException {
159 209
        if (!isValid()) {
160 210
            throw new InvalidFeatureIndexException();
161 211
        }
......
169 219

  
170 220
    private void doInsert(FeatureSet data) throws DataException {
171 221
        DisposableIterator it = null;
172

  
222
        TaskStatusManager statusManager = ToolsLocator.getTaskStatusManager();
223
        SimpleTaskStatus status =
224
            statusManager.createDefaultSimpleTaskStatus("Filling index");
225
        status.setCancellable(false);
226
        // status.setRangeOfValues(0, data.getSize());
227
        status.add();
228
        long counter = 0;
173 229
        try {
174 230
            it = data.fastIterator();
175 231
            while (it.hasNext()) {
176 232
                Feature feat = (Feature) it.next();
177 233
                doInsert(feat);
234
                status.setCurValue(counter++);
178 235
            }
236
        } catch (RuntimeException e) {
237
            status.abort();
238
            throw e;
179 239
        } finally {
180 240
            DisposeUtils.dispose(it);
241
            status.remove();
181 242
        }
182 243
    }
183 244

  
184
    public void insert(Feature feat) {
245
    public synchronized final void insert(Feature feat) {
185 246
        if (!isValid()) {
186 247
            throw new RuntimeException(new InvalidFeatureIndexException());
187 248
        }
......
247 308
        indexProvider.initialize();
248 309
    }
249 310

  
250
    public void delete(Feature feat) {
311
    public synchronized final void delete(Feature feat) {
251 312
        if (!isValid()) {
252 313
            throw new RuntimeException(new InvalidFeatureIndexException());
253 314
        }
......
264 325
            (FeatureReferenceProviderServices) feat.getReference());
265 326
    }
266 327

  
267
    public void delete(FeatureSet data) throws FeatureIndexException {
328
    public synchronized final void delete(FeatureSet data)
329
        throws FeatureIndexException {
268 330
        if (!isValid()) {
269 331
            throw new InvalidFeatureIndexException();
270 332
        }
branches/v2_0_0_prep/libraries/libFMap_dal/src/org/gvsig/fmap/dal/feature/impl/SpatialManager.java
122 122
		if (featureIndex == null) {
123 123
		    try{
124 124
		        featureIndex = featureStore.createIndex(fType, attr.getName(),
125
		        "QuadtreeJts");
125
                        "QuadtreeJts", null);
126 126
		    }catch (Exception e) {
127 127
		        LOG.info("It can not create an index", e);
128 128
		    }
branches/v2_0_0_prep/libraries/libFMap_dal/src/org/gvsig/fmap/dal/feature/impl/DefaultFeatureStore.java
143 143
import org.gvsig.tools.visitor.Visitor;
144 144

  
145 145
public final class DefaultFeatureStore extends AbstractDisposable implements
146
    DataStoreInitializer, FeatureStoreProviderServices, FeatureStore,
147
    Observer {
146
    DataStoreInitializer, FeatureStoreProviderServices, FeatureStore, Observer {
148 147

  
149
    final static private Logger logger =
150
        LoggerFactory.getLogger(DefaultFeatureStore.class);
148
    private static final Logger LOG = LoggerFactory
149
        .getLogger(DefaultFeatureStore.class);
151 150

  
152 151
    private static final String PERSISTENCE_DEFINITION_NAME = "FeatureStore";
153 152

  
......
210 209
            (DelegatedDynObject) dynManager.createDynObject(
211 210
                METADATA_DEFINITION_NAME, MetadataManager.METADATA_NAMESPACE);
212 211

  
213
        this.dataManager = (DefaultDataManager)dataManager;
212
        this.dataManager = (DefaultDataManager) dataManager;
214 213

  
215 214
        this.parameters = parameters;
216 215
        this.transforms = new DefaultFeatureStoreTransforms(this);
......
360 359
    public FeatureProvider createDefaultFeatureProvider(FeatureType type)
361 360
        throws DataException {
362 361
        if (type.hasOID()) {
363
            return new DefaultFeatureProvider(type, this.provider
364
                .createNewOID());
362
            return new DefaultFeatureProvider(type,
363
                this.provider.createNewOID());
365 364
        }
366 365
        return new DefaultFeatureProvider(type);
367 366
    }
368 367

  
369 368
    public void saveToState(PersistentState state) throws PersistenceException {
370 369
        if (this.mode != FeatureStore.MODE_QUERY) {
371
            throw new PersistenceException(new IllegalStateException(this
372
                .getName()));
370
            throw new PersistenceException(new IllegalStateException(
371
                this.getName()));
373 372
        }
374 373
        state.set("dataStoreName", this.getName());
375 374
        state.set("parameters", this.parameters);
......
451 450
                        }
452 451
                    }
453 452
                    if (fTypePos < 0) {
454
                        throw new PersistenceCantFindFeatureTypeException(this
455
                            .getName(), (String) entry.getKey());
453
                        throw new PersistenceCantFindFeatureTypeException(
454
                            this.getName(), (String) entry.getKey());
456 455
                    }
457 456
                    DefaultEditableFeatureType eType =
458 457
                        (DefaultEditableFeatureType) type.getEditable();
......
499 498
            definition.addDynFieldString("dataStoreName").setMandatory(true)
500 499
                .setPersistent(true);
501 500

  
502
            definition.addDynFieldObject("parameters").setClassOfValue(
503
                DynObject.class).setMandatory(true).setPersistent(true);
501
            definition.addDynFieldObject("parameters")
502
                .setClassOfValue(DynObject.class).setMandatory(true)
503
                .setPersistent(true);
504 504

  
505
            definition.addDynFieldObject("selection").setClassOfValue(
506
                FeatureSelection.class).setMandatory(false).setPersistent(true);
507

  
508
            definition.addDynFieldObject("transforms").setClassOfValue(
509
                DefaultFeatureStoreTransforms.class).setMandatory(true)
505
            definition.addDynFieldObject("selection")
506
                .setClassOfValue(FeatureSelection.class).setMandatory(false)
510 507
                .setPersistent(true);
511 508

  
512
            definition.addDynFieldMap("evaluatedAttributes").setClassOfItems(
513
                List.class) // List<DefaultFeatureAttributeDescriptor>
509
            definition.addDynFieldObject("transforms")
510
                .setClassOfValue(DefaultFeatureStoreTransforms.class)
511
                .setMandatory(true).setPersistent(true);
512

  
513
            definition.addDynFieldMap("evaluatedAttributes")
514
                .setClassOfItems(List.class) // List<DefaultFeatureAttributeDescriptor>
514 515
                .setMandatory(false).setPersistent(true);
515 516

  
516
            definition.addDynFieldString("defaultFeatureTypeId").setMandatory(
517
                true).setPersistent(true);
517
            definition.addDynFieldString("defaultFeatureTypeId")
518
                .setMandatory(true).setPersistent(true);
518 519
        }
519 520
    }
520 521

  
......
639 640
        try {
640 641
            notifyChange(notification, createFeature(data));
641 642
        } catch (DataException ex) {
642
            logger.error("Error notifying about the notification: "
643
                + notification + ", with the data: " + data, ex);
643
            LOG.error("Error notifying about the notification: " + notification
644
                + ", with the data: " + data, ex);
644 645
        }
645 646
    }
646 647

  
......
679 680

  
680 681
    public FeatureLocks getLocks() throws DataException {
681 682
        if (!this.provider.isLocksSupported()) {
682
            logger.warn("Locks not supporteds");
683
            LOG.warn("Locks not supporteds");
683 684
            return null;
684 685
        }
685 686
        if (locks == null) {
......
868 869
    }
869 870

  
870 871
    private void invalidateIndexes() {
871
        setIndexesStatus(false);
872
        setIndexesValidStatus(false);
872 873
    }
873 874

  
874
    private void validateIndexes() {
875
        setIndexesStatus(true);
876
    }
877

  
878
    private void setIndexesStatus(boolean valid) {
875
    private void setIndexesValidStatus(boolean valid) {
879 876
        FeatureIndexes indexes = getIndexes();
880 877
        for (Iterator iterator = indexes.iterator(); iterator.hasNext();) {
881 878
            FeatureIndex index = (FeatureIndex) iterator.next();
......
885 882
        }
886 883
    }
887 884

  
888
    private void fillIndexes() throws FeatureIndexException {
885
    private void updateIndexes() throws FeatureIndexException {
889 886
        FeatureIndexes indexes = getIndexes();
890 887
        for (Iterator iterator = indexes.iterator(); iterator.hasNext();) {
891 888
            FeatureIndex index = (FeatureIndex) iterator.next();
892
            if (index instanceof DefaultFeatureIndex) {
893
                ((DefaultFeatureIndex) index).fill();
889
            if (index instanceof FeatureIndexProviderServices) {
890
                FeatureIndexProviderServices indexServices =
891
                    (FeatureIndexProviderServices) index;
892
                indexServices.setValid(false);
893
                indexServices.fill();
894
                indexServices.setValid(true);
894 895
            }
895 896
        }
896 897
    }
......
1084 1085
            if (clearSelection) {
1085 1086
                ((FeatureSelection) this.getSelection()).deselectAll();
1086 1087
            }
1087
            fillIndexes();
1088
            validateIndexes();
1088
            updateIndexes();
1089 1089
            notifyChange(FeatureStoreNotification.AFTER_CANCELEDITING);
1090 1090
        } catch (Exception e) {
1091 1091
            throw new StoreCancelEditingException(e, this.getName());
......
1102 1102
                notifyChange(FeatureStoreNotification.BEFORE_FINISHEDITING);
1103 1103
                provider.endAppend();
1104 1104
                exitEditingMode();
1105
                fillIndexes();
1106
                validateIndexes();
1105
                updateIndexes();
1107 1106
                notifyChange(FeatureStoreNotification.AFTER_FINISHEDITING);
1108 1107
                break;
1109 1108

  
......
1116 1115
                if (hasStrongChanges) {
1117 1116
                    validateFeatures(Feature.FINISH_EDITING);
1118 1117
                    provider.performChanges(featureManager.getDeleted(),
1119
                        featureManager.getInserted(), featureManager
1120
                            .getUpdated(), featureTypeManager
1121
                            .getFeatureTypesChanged());
1118
                        featureManager.getInserted(),
1119
                        featureManager.getUpdated(),
1120
                        featureTypeManager.getFeatureTypesChanged());
1122 1121
                }
1123 1122
                exitEditingMode();
1124
                fillIndexes();
1125
                validateIndexes();
1123
                updateIndexes();
1126 1124
                notifyChange(FeatureStoreNotification.AFTER_FINISHEDITING);
1127 1125
                break;
1128 1126
            }
......
1267 1265
        DefaultFeatureType fType =
1268 1266
            (DefaultFeatureType) this.getFeatureType(featureQuery
1269 1267
                .getFeatureTypeId());
1270
        if ((featureQuery.getAttributeNames() != null) && (featureQuery.getAttributeNames().length > 0)) {
1268
        if ((featureQuery.getAttributeNames() != null)
1269
            && (featureQuery.getAttributeNames().length > 0)) {
1271 1270
            return fType.getSubtype(featureQuery.getAttributeNames());
1272 1271
        }
1273 1272
        return fType;
......
1318 1317
            query = new DefaultFeatureQuery(this.getDefaultFeatureType());
1319 1318
        }
1320 1319
        LoadInBackGround task = new LoadInBackGround(this, query, observer);
1321
        Thread thread = new Thread(task);
1322
        thread.run();
1320
        Thread thread = new Thread(task, "Load Feature Set in background");
1321
        thread.start();
1323 1322
    }
1324 1323

  
1325 1324
    public Feature getFeatureByReference(FeatureReference reference)
......
1353 1352
            }
1354 1353
        }
1355 1354
        DefaultFeature feature =
1356
            new DefaultFeature(this, this.provider
1357
                .getFeatureProviderByReference(
1355
            new DefaultFeature(this,
1356
                this.provider.getFeatureProviderByReference(
1358 1357
                    (FeatureReferenceProviderServices) reference, featureType));
1359 1358

  
1360 1359
        if (!this.transforms.isEmpty()) {
......
1652 1651
    public FeatureIndex createIndex(String indexTypeName,
1653 1652
        FeatureType featureType, String attributeName, String indexName)
1654 1653
        throws DataException {
1654

  
1655
        return createIndex(indexTypeName, featureType, attributeName,
1656
            indexName, false, null);
1657
    }
1658

  
1659
    public FeatureIndex createIndex(FeatureType featureType,
1660
        String attributeName, String indexName, Observer observer)
1661
        throws DataException {
1662
        return createIndex(null, featureType, attributeName, indexName,
1663
            observer);
1664
    }
1665

  
1666
    public FeatureIndex createIndex(String indexTypeName,
1667
        FeatureType featureType, String attributeName, String indexName,
1668
        final Observer observer) throws DataException {
1669

  
1670
        return createIndex(indexTypeName, featureType, attributeName,
1671
            indexName, true, observer);
1672
    }
1673

  
1674
    private FeatureIndex createIndex(String indexTypeName,
1675
        FeatureType featureType, String attributeName, String indexName,
1676
        boolean background, final Observer observer) throws DataException {
1677

  
1655 1678
        checkNotInAppendMode();
1656 1679
        FeatureIndexProviderServices index = null;
1657 1680
        index =
1658 1681
            dataManager.createFeatureIndexProvider(indexTypeName, this,
1659
                featureType, indexName, featureType
1660
                    .getAttributeDescriptor(attributeName));
1682
                featureType, indexName,
1683
                featureType.getAttributeDescriptor(attributeName));
1684

  
1685
        if (observer != null) {
1686
            index.addObserver(observer);
1687
        }
1661 1688
        try {
1662
            index.fill();
1689
            index.fill(background);
1663 1690
        } catch (FeatureIndexException e) {
1664 1691
            throw new InitializeException(index.getName(), e);
1665 1692
        }
1693

  
1666 1694
        ((DefaultFeatureIndexes) getIndexes()).addIndex(index);
1667 1695
        return index;
1668 1696
    }
1669 1697

  
1670
    public FeatureIndex createIndex(FeatureType featureType,
1671
        String attributeName, String indexName, Observer observer) {
1672
        return createIndex(null, featureType, attributeName, indexName,
1673
            observer);
1674
    }
1675

  
1676
    public FeatureIndex createIndex(String indexTypeName,
1677
        FeatureType featureType, String attributeName, String indexName,
1678
        Observer observer) {
1679
        // TODO Implement observer interaction
1680
        throw new UnsupportedOperationException();
1681
    }
1682

  
1683 1698
    //
1684 1699
    // ====================================================================
1685 1700
    // Transforms related methods
branches/v2_0_0_prep/libraries/libFMap_dal/src/org/gvsig/fmap/dal/feature/FeatureIndexes.java
73 73
	 * @return Iterator over the FeatureIndex(es).
74 74
	 */
75 75
	public Iterator iterator();
76

  
77
    /**
78
     * Returns if all the indexes are valid and might be used to get Features.
79
     * 
80
     * @return if the indexes are valid
81
     */
82
    public boolean areValid();
83

  
76 84
}
branches/v2_0_0_prep/libraries/libFMap_dal/src/org/gvsig/fmap/dal/feature/spi/index/FeatureIndexProviderServices.java
1 1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
* 
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
* 
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
* 
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
* MA  02110-1301, USA.
20
* 
21
*/
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 * 
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 * 
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 * 
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
 * MA  02110-1301, USA.
20
 * 
21
 */
22 22

  
23 23
/*
24
* AUTHORS (In addition to CIT):
25
* 2008 {{Company}}   {{Task}}
26
*/
27
 
24
 * AUTHORS (In addition to CIT):
25
 * 2008 {{Company}}   {{Task}}
26
 */
28 27

  
29 28
package org.gvsig.fmap.dal.feature.spi.index;
30 29

  
31 30
import org.gvsig.fmap.dal.exception.InitializeException;
32 31
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
33 32
import org.gvsig.fmap.dal.feature.FeatureIndex;
33
import org.gvsig.fmap.dal.feature.FeatureStoreNotification;
34 34
import org.gvsig.fmap.dal.feature.FeatureType;
35 35
import org.gvsig.fmap.dal.feature.exception.FeatureIndexException;
36 36
import org.gvsig.fmap.dal.feature.spi.FeatureStoreProviderServices;
37
import org.gvsig.tools.observer.Observable;
37 38

  
38

  
39 39
/**
40
 * SPI for all index implementations
41
 * @author jyarza
42
 *
40
 * SPI for all index implementations.
41
 * 
42
 * This observable object provides notificationswhen the index has finished
43
 * filling with data and is available to be used. The observer will
44
 * receive then a {@link FeatureStoreNotification#INDEX_FILLED_SUCCESSFULLY}
45
 * notification, with the index object if it has finished
46
 * successfully, or a {@link FeatureStoreNotification#INDEX_FILLING_ERROR}
47
 * notification with the exception object if there has been
48
 * any error in the process.
49
 * 
50
 * @see FeatureStoreNotification#INDEX_FILLED_SUCCESSFULLY
51
 * @see FeatureStoreNotification#INDEX_FILLING_ERROR
52
 * 
53
 * @author gvSIG team
43 54
 */
44
public interface FeatureIndexProviderServices extends FeatureIndex {
45
	
46
	/** Initializes this provider */
47
	public void initialize() throws InitializeException;
48
	
49
	/** Column to which belongs this index */
50
	public FeatureAttributeDescriptor getFeatureAttributeDescriptor();
51
	
52
	/** FeatureType to which belongs this index */
53
	public FeatureType getFeatureType();
54
	
55
	/** FeatureStore to which belongs this index */
56
	public FeatureStoreProviderServices getFeatureStoreProviderServices();
57
	
58
	/** Returns the absolute path (directory + filename) where this index is or will be stored */
59
	public String getFileName();
60
	
61
	/** Returns a temporary absolute path (directory + filename) according to the system environment */
62
	public String getTemporaryFileName();
63
	
64
	/** Calculates and returns a new filename for an index, using the given prefix and suffix */
65
	public String getNewFileName(String prefix, String sufix);
66
	
67
	/** Fills this index with the store's data */
68
	public void fill() throws FeatureIndexException;	
55
public interface FeatureIndexProviderServices extends FeatureIndex, Observable {
56

  
57
    /** Initializes this provider */
58
    public void initialize() throws InitializeException;
59

  
60
    /** Column to which belongs this index */
61
    public FeatureAttributeDescriptor getFeatureAttributeDescriptor();
62

  
63
    /** FeatureType to which belongs this index */
64
    public FeatureType getFeatureType();
65

  
66
    /** FeatureStore to which belongs this index */
67
    public FeatureStoreProviderServices getFeatureStoreProviderServices();
68

  
69
    /**
70
     * Returns the absolute path (directory + filename) where this index is or
71
     * will be stored
72
     */
73
    public String getFileName();
74

  
75
    /**
76
     * Returns a temporary absolute path (directory + filename) according to the
77
     * system environment
78
     */
79
    public String getTemporaryFileName();
80

  
81
    /**
82
     * Calculates and returns a new filename for an index, using the given
83
     * prefix and suffix
84
     */
85
    public String getNewFileName(String prefix, String sufix);
86

  
87
    /**
88
     * Fills this index with the store's data. This operation will not return
89
     * until the index has filled with all the store's data.
90
     * 
91
     * @throws FeatureIndexException
92
     *             if there is an error while filling the index
93
     */
94
    public void fill() throws FeatureIndexException;
95

  
96
    /**
97
     * Fills this index with the store's data.
98
     * 
99
     * @param background
100
     *            if the filling must be performed in background
101
     * 
102
     * @throws FeatureIndexException
103
     *             if there is an error while filling the index
104
     */
105
    public void fill(boolean background) throws FeatureIndexException;
106

  
107
    /**
108
     * Sets the index as valid or invalid, so it may be used or not.
109
     * 
110
     * @param valid
111
     *            status to set the index to
112
     */
113
    public void setValid(boolean valid);
69 114
}
70

  

Also available in: Unified diff