Revision 33657 branches/v2_0_0_prep/libraries/libFMap_dal/src/org/gvsig/fmap/dal/feature/impl/featureset/DefaultFeatureSet.java

View differences:

DefaultFeatureSet.java
11 11
import org.gvsig.fmap.dal.feature.EditableFeature;
12 12
import org.gvsig.fmap.dal.feature.Feature;
13 13
import org.gvsig.fmap.dal.feature.FeatureQuery;
14
import org.gvsig.fmap.dal.feature.FeatureQueryOrder.FeatureQueryOrderMember;
14 15
import org.gvsig.fmap.dal.feature.FeatureSet;
16
import org.gvsig.fmap.dal.feature.FeatureStore;
15 17
import org.gvsig.fmap.dal.feature.FeatureStoreNotification;
16 18
import org.gvsig.fmap.dal.feature.FeatureType;
17
import org.gvsig.fmap.dal.feature.FeatureQueryOrder.FeatureQueryOrderMember;
18 19
import org.gvsig.fmap.dal.feature.exception.ConcurrentDataModificationException;
19 20
import org.gvsig.fmap.dal.feature.exception.FeatureSetInitializeException;
20 21
import org.gvsig.fmap.dal.feature.impl.DefaultFeatureStore;
21 22
import org.gvsig.fmap.dal.feature.impl.DefaultFeatureStoreTransforms;
22 23
import org.gvsig.fmap.dal.feature.spi.FeatureSetProvider;
23 24
import org.gvsig.tools.dispose.DisposableIterator;
25
import org.gvsig.tools.dynobject.DynObjectSet;
24 26
import org.gvsig.tools.evaluator.Evaluator;
25 27
import org.gvsig.tools.exception.BaseException;
26 28
import org.gvsig.tools.observer.Observable;
......
43 45
	private static final int ORDERD_EDITED = 6;
44 46
	private static final int ORDERED_EDITED_FILTER = 7;
45 47

  
46
	private boolean modified;
48
	private boolean sourceStoreModified;
49
    private boolean ownFeaturesModified;
47 50
	DefaultFeatureStore store;
48 51
	private List featureTypes;
49 52
	FeatureQuery query;
......
62 65
	throws DataException {
63 66
		this.featureToIgnoreNotification = null;
64 67
		this.iteratorMode = NO_CHECKED;
65
		this.modified = false;
68
		this.sourceStoreModified = false;
69
        this.ownFeaturesModified = false;
66 70
		this.size = -1;
67 71
		this.orderedData = null;
68 72
		this.store = store;
......
191 195
	}
192 196

  
193 197
	public long getSize() throws DataException {
194
		this.checkModified();
198
		this.checkSourceStoreModified();
195 199
		if (size < 0) {
196 200
			size = calculateSize();
197 201
		}
......
250 254
	}
251 255

  
252 256
	public void update(Observable obsevable, Object notification) {
253
		if (modified) {
257
		if (sourceStoreModified) {
254 258
			return;
255 259
		}
256 260

  
......
264 268
			if( this.featureToIgnoreNotification == ((FeatureStoreNotification) notification).getFeature() ) {
265 269
				return;
266 270
			}
267
			modified = true;
271
			sourceStoreModified = true;
268 272
			return;
269 273
		}
270 274
		if (
271 275
				type.equalsIgnoreCase(FeatureStoreNotification.AFTER_UPDATE_TYPE)
272 276
				|| type.equalsIgnoreCase(FeatureStoreNotification.AFTER_REDO)
273 277
				|| type.equalsIgnoreCase(FeatureStoreNotification.AFTER_UNDO)
274
				|| type.equalsIgnoreCase(FeatureStoreNotification.AFTER_CANCELEDITING)
275 278
				|| type.equalsIgnoreCase(FeatureStoreNotification.AFTER_REFRESH)
276 279
				|| type.equalsIgnoreCase(FeatureStoreNotification.COMPLEX_NOTIFICATION)
277 280
				|| type.equalsIgnoreCase(FeatureStoreNotification.AFTER_CLOSE)
......
279 282
				|| type.equalsIgnoreCase(FeatureStoreNotification.RESOURCE_CHANGED)
280 283
				|| type.equalsIgnoreCase(FeatureStoreNotification.TRANSFORM_CHANGE)
281 284
		) {
282
			modified = true;
285
			sourceStoreModified = true;
283 286
			return;
284 287
		}
288
        if (type.equalsIgnoreCase(FeatureStoreNotification.AFTER_CANCELEDITING)
289
            && ownFeaturesModified) {
290
            sourceStoreModified = true;
291
            return;
292
        }
285 293
	}
286 294

  
287 295
	protected void doAccept(Visitor visitor, long firstValueIndex)
......
298 306
		}
299 307
	}
300 308

  
301
	protected void checkModified() {
302
		if (modified) {
309
	protected void checkSourceStoreModified() {
310
		if (sourceStoreModified) {
303 311
			throw new ConcurrentDataModificationException(store.getName());
304 312
		}
305 313
	}
306 314

  
307 315
	public boolean isEmpty() throws DataException {
308
		checkModified();
316
		checkSourceStoreModified();
309 317
		return this.getSize()==0 ;
310 318
	}
311 319

  
......
480 488

  
481 489
	public void delete(Feature feature) throws DataException {
482 490
		this.featureToIgnoreNotification = feature;
483
		this.store.delete(feature);
491
        this.store.delete(feature);
484 492
		if (this.size > 0) {
485
			this.size--;
493
            this.size--;
486 494
		}
487 495
		this.featureToIgnoreNotification = null;
496
        this.ownFeaturesModified = true;
488 497
	}
489 498

  
490 499
	public void insert(EditableFeature feature) throws DataException {
......
494 503
			this.size++;
495 504
		}
496 505
		this.featureToIgnoreNotification = null;
506
        this.ownFeaturesModified = true;
497 507
	}
498 508

  
499 509
	public void update(EditableFeature feature) throws DataException {
500 510
		this.featureToIgnoreNotification = feature;
501 511
		this.store.update(feature);
502 512
		this.featureToIgnoreNotification = null;
513
        this.ownFeaturesModified = true;
503 514
	}
504 515

  
516
    public DynObjectSet getDynObjectSet() {
517
        return this.getDynObjectSet(true);
518
    }
519

  
520
    public DynObjectSet getDynObjectSet(boolean fast) {
521
        return new DynObjectSetFeatureSetFacade(this, store, fast);
522
    }
523

  
524
    public FeatureStore getFeatureStore() {
525
        return store;
526
    }
505 527
}

Also available in: Unified diff