Statistics
| Revision:

svn-gvsig-desktop / 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 / featureset / DefaultFeatureSet.java @ 45989

History | View | Annotate | Download (24.7 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.fmap.dal.feature.impl.featureset;
25

    
26
import java.util.ArrayList;
27
import java.util.Collections;
28
import java.util.Iterator;
29
import java.util.List;
30
import java.util.NoSuchElementException;
31

    
32
import org.gvsig.fmap.dal.exception.DataException;
33
import org.gvsig.fmap.dal.feature.EditableFeature;
34
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor;
35
import org.gvsig.fmap.dal.feature.Feature;
36
import org.gvsig.fmap.dal.feature.FeatureIndexes;
37
import org.gvsig.fmap.dal.feature.FeatureQuery;
38
import org.gvsig.fmap.dal.feature.FeatureQueryOrder;
39
import org.gvsig.fmap.dal.feature.FeatureQueryOrder.FeatureQueryOrderMember;
40
import org.gvsig.fmap.dal.feature.FeatureSet;
41
import org.gvsig.fmap.dal.feature.FeatureStore;
42
import org.gvsig.fmap.dal.feature.FeatureStoreNotification;
43
import org.gvsig.fmap.dal.feature.FeatureType;
44
import org.gvsig.fmap.dal.feature.exception.ConcurrentDataModificationException;
45
import org.gvsig.fmap.dal.feature.exception.FeatureSetInitializeException;
46
import org.gvsig.fmap.dal.feature.impl.DefaultFeatureStore;
47
import org.gvsig.fmap.dal.feature.impl.DefaultFeatureStoreTransforms;
48
import org.gvsig.fmap.dal.feature.impl.DefaultFeatureType;
49
import org.gvsig.fmap.dal.feature.spi.FeatureSetProvider;
50
import org.gvsig.tools.ToolsLocator;
51
import org.gvsig.tools.dispose.DisposableIterator;
52
import org.gvsig.tools.dispose.DisposeUtils;
53
import org.gvsig.tools.evaluator.Evaluator;
54
import org.gvsig.tools.exception.BaseException;
55
import org.gvsig.tools.observer.Observable;
56
import org.gvsig.tools.observer.Observer;
57

    
58
public class DefaultFeatureSet extends AbstractFeatureSet implements
59
    FeatureSet, Observer {
60

    
61
    protected static final int NO_CHECKED = -1;
62
    protected static final int DEFAULT = 0;
63
    protected static final int FILTERED = 1;
64
    protected static final int ORDERED = 2;
65
    protected static final int ORDERED_FILTERED = 3;
66
    protected static final int EDITED = 4;
67
    protected static final int EDITED_FILTERED = 5;
68
    protected static final int ORDERD_EDITED = 6;
69
    protected static final int ORDERED_EDITED_FILTER = 7;
70

    
71
    protected Throwable sourceStoreModifiedCause;
72
    protected boolean sourceStoreModified;
73
    protected boolean ownFeaturesModified;
74
    protected DefaultFeatureStore store;
75
    protected List featureTypes;
76
    protected FeatureQuery query;
77
    protected FeatureSetProvider provider;
78
    protected long size;
79
    protected int iteratorMode;
80
    protected List orderedData;
81
    protected Feature featureToIgnoreNotification;
82
    protected DefaultFeatureStoreTransforms transform;
83
    protected FeatureQuery queryForProvider;
84
    protected FeatureType defaultFeatureType;
85
    protected FeatureType defatulFeatureTypeForProvider;
86
    protected boolean ignoreChanges;
87
    private boolean disposed = false;
88

    
89
    public DefaultFeatureSet(DefaultFeatureStore store, FeatureQuery query)
90
        throws DataException {
91
        DisposeUtils.bind(this);
92
        this.featureToIgnoreNotification = null;
93
        this.iteratorMode = NO_CHECKED;
94
        this.sourceStoreModified = false;
95
        this.ownFeaturesModified = false;
96
        this.size = -1;
97
        this.orderedData = null;
98
        this.store = store;
99
        DisposeUtils.bind(this.store);
100
        if (this.store.isEditing()) {
101
            this.transform = this.store.getFeatureTypeManager().getTransforms();
102
        } else {
103
            this.transform =
104
                (DefaultFeatureStoreTransforms) store.getTransforms();
105
        }
106
        this.query = query;
107
        try {
108
            this.queryForProvider = (FeatureQuery) query.clone();
109
        } catch (CloneNotSupportedException e) {
110
            throw new FeatureSetInitializeException(e);
111
        }
112

    
113
        this.featureTypes = new ArrayList();
114
        if (this.query.getFeatureTypeId() == null
115
            && this.query.getAttributeNames() == null) {
116
            this.defaultFeatureType = this.store.getDefaultFeatureType();
117
            this.featureTypes.addAll(this.store.getFeatureTypes());
118
        } else {
119
            this.defaultFeatureType = this.store.getFeatureType(this.query);
120
            List<EditableFeatureAttributeDescriptor> cols = this.query.getExtraColumn().getColumns();
121
            if (this.query!=null && cols!=null && !cols.isEmpty()) {
122
                DefaultFeatureType featureTypeExtraCols = (DefaultFeatureType) this.defaultFeatureType.getCopy();
123
                featureTypeExtraCols.setExtraColumn(this.query.getExtraColumn());
124
                this.defaultFeatureType = featureTypeExtraCols;
125
            }
126
            this.featureTypes.add(this.defaultFeatureType);
127
        }
128
        if (this.transform != null && !this.transform.isEmpty()) {
129
            this.fixQueryForProvider(this.queryForProvider, this.transform);
130
        } else {
131
            this.defatulFeatureTypeForProvider = this.defaultFeatureType;
132
        }
133

    
134
        FeatureIndexes indexes = store.getIndexes();
135
        if (this.queryForProvider.hasFilter() && indexes != null
136
            && indexes.areValid()) {
137
            this.provider =
138
                (FeatureSetProvider) indexes
139
                    .getFeatureSet(this.queryForProvider.getFilter());
140
        }
141
        if (this.provider == null) {
142
            this.provider =
143
                this.store.getProvider().createSet(this.queryForProvider,
144
                    this.defatulFeatureTypeForProvider);
145
        }
146
        this.store.addObserver(this);
147
    }
148

    
149
    private void fixQueryForProvider(FeatureQuery theQueryForProvider,
150
        DefaultFeatureStoreTransforms transformsToUse) throws DataException {
151
        theQueryForProvider.clearAttributeNames();
152
        FeatureType ftype =
153
            transformsToUse.getSourceFeatureTypeFrom(this.defaultFeatureType);
154
        theQueryForProvider.setFeatureTypeId(ftype.getId());
155
        this.defatulFeatureTypeForProvider = ftype;
156
        
157
        if (transformsToUse.isTransformsOriginalValues()) {
158
            theQueryForProvider.clearFilter();
159
            FeatureQueryOrder fqo = theQueryForProvider.getOrder();
160
            if (fqo != null) {
161
                fqo.clear();
162
            }
163
            return;
164

    
165
        }
166

    
167
        // Filter
168
        Evaluator filter = theQueryForProvider.getFilter();
169
        if (filter != null) {
170
            boolean canUseFilter;
171
            if (filter.getFieldsInfo() == null) {
172
                canUseFilter = false;
173
            } else {
174
                canUseFilter = areEvaluatorFieldsInAttributes(filter, ftype);
175
            }
176

    
177
            if (!canUseFilter) {
178
                theQueryForProvider.clearFilter();
179
            }
180

    
181
        }
182

    
183
        // Order
184
        if (theQueryForProvider.hasOrder()) {
185
            boolean canUseOrder = true;
186
            Iterator iter = theQueryForProvider.getOrder().iterator();
187
            FeatureQueryOrderMember item;
188
            while (iter.hasNext()) {
189
                item = (FeatureQueryOrderMember) iter.next();
190
                if (item.hasEvaluator()) {
191
                    if (!areEvaluatorFieldsInAttributes(item.getEvaluator(),
192
                        ftype)) {
193
                        canUseOrder = false;
194
                        break;
195
                    }
196
                } else {
197
                    if (ftype.get(item.getAttributeName()) == null) {
198
                        canUseOrder = false;
199
                        break;
200
                    }
201
                }
202
            }
203

    
204
            if (!canUseOrder) {
205
                theQueryForProvider.getOrder().clear();
206
            }
207
        }
208

    
209
    }
210

    
211
    private boolean areEvaluatorFieldsInAttributes(Evaluator evaluator,
212
        FeatureType fType) {
213
        if (evaluator.getFieldsInfo() == null) {
214
            return false;
215
        }
216
        String[] fieldNames = evaluator.getFieldsInfo().getFieldNames();
217
        if (fieldNames.length == 0) {
218
            return false;
219
        } else {
220
            for (String fieldName : fieldNames) {
221
                if (fType.get(fieldName) == null) {
222
                    return false;
223
                }
224
            }
225
        }
226
        return true;
227
    }
228

    
229
    @Override
230
    public FeatureType getDefaultFeatureType() {
231
        return this.defaultFeatureType;
232
    }
233

    
234
    @Override
235
    public List getFeatureTypes() {
236
        return Collections.unmodifiableList(this.featureTypes);
237
    }
238

    
239
    @Override
240
    public long getSize() throws DataException {
241
        this.checkSourceStoreModified();
242
        if (size < 0) {
243
            size = calculateSize();
244
        }
245
        return size;
246
    }
247

    
248
    private long calculateSize() throws DataException {
249
        long limit = this.query.getLimit();
250
        long mySize = 0;
251
        
252
        int mode = this.getIteratorMode();
253
        DisposableIterator iter = null;
254
        switch (mode) {
255
        case DEFAULT:
256
        case ORDERED:
257
            if (this.provider.isEmpty()) {
258
                return 0;
259
            }
260
            mySize = provider.getSize();
261
            return (limit>0 && mySize>limit)? limit:mySize;
262

    
263
        case FILTERED:
264
        case ORDERED_FILTERED:
265
            try {
266
                iter = this.fastIterator();
267
                while ((limit>0 && (mySize<limit)) || limit==0 ) {
268
                    iter.next();
269
                    mySize++;
270
                }
271
            } catch (NoSuchElementException e) {
272

    
273
            } finally {
274
                DisposeUtils.disposeQuietly(iter);
275
            }
276
            return (limit>0 && mySize>limit)? limit:mySize;
277

    
278
        case EDITED:
279
        case ORDERD_EDITED:
280
            mySize = provider.getSize()
281
                + store.getFeatureManager().getDeltaSize();
282
            return (limit>0 && mySize>limit)? limit:mySize;
283

    
284
        case EDITED_FILTERED:
285
        case ORDERED_EDITED_FILTER:
286
            try {
287
                iter = this.fastIterator();
288
                while ((limit>0 && (mySize<limit)) || limit==0 ) {
289
                    iter.next();
290
                    mySize++;
291
                }
292
            } catch (NoSuchElementException e) {
293

    
294
            } finally {
295
                DisposeUtils.disposeQuietly(iter);
296
            }
297
            return (limit>0 && mySize>limit)? limit:mySize;
298
            
299
        default:
300
            throw new IllegalArgumentException();
301
        }
302
    }
303
    
304
    @Override
305
    public synchronized final void dispose() {
306
        // Check if we have already been disposed, and don't do it again
307
        if (!disposed) {
308
            if (DisposeUtils.release(this)) {
309
                try {
310
                    doDispose();
311
                } catch (Exception ex) {
312
                    LOG.error("Error performing dispose", ex);
313
                } finally {
314
                    disposed = true;
315
                }
316
            }
317
        }
318
    }
319

    
320
    public void doDispose() {
321
        if( this.store!=null ) {
322
            this.store.deleteObserver(this);
323
            DisposeUtils.dispose(this.store);
324
            this.store = null;
325
        }
326
        if( this.provider!=null ) {
327
            this.provider.dispose();
328
            this.provider = null;
329
        }
330
        if (orderedData != null) {
331
            orderedData.clear();
332
            this.orderedData = null;
333
        }
334
        this.featureToIgnoreNotification = null;
335
        this.transform = null;
336
        this.query = null;
337
        this.queryForProvider = null;
338
        this.featureTypes = null;
339
        this.defaultFeatureType = null;
340
        this.defatulFeatureTypeForProvider = null;
341
    }
342

    
343
    public void update(Observable obsevable, Object notification) {
344
        if (sourceStoreModified) {
345
            return;
346
        }
347

    
348
        String type = ((FeatureStoreNotification) notification).getType();
349

    
350
        if (type.equalsIgnoreCase(FeatureStoreNotification.AFTER_INSERT)
351
            || type.equalsIgnoreCase(FeatureStoreNotification.AFTER_DELETE)
352
            || type.equalsIgnoreCase(FeatureStoreNotification.AFTER_UPDATE)) {
353
            if (this.featureToIgnoreNotification == ((FeatureStoreNotification) notification)
354
                .getFeature()) {
355
                return;
356
            }
357
            sourceStoreModified = true;
358
            sourceStoreModifiedCause = new Throwable();
359
            return;
360
        }
361
        if (type.equalsIgnoreCase(FeatureStoreNotification.AFTER_UPDATE_TYPE)
362
            || type.equalsIgnoreCase(FeatureStoreNotification.AFTER_REDO)
363
            || type.equalsIgnoreCase(FeatureStoreNotification.AFTER_UNDO)
364
            || type.equalsIgnoreCase(FeatureStoreNotification.AFTER_REFRESH)
365
            || type.equalsIgnoreCase(FeatureStoreNotification.COMPLEX_NOTIFICATION)
366
//            || type.equalsIgnoreCase(FeatureStoreNotification.AFTER_CLOSE)
367
//            || type.equalsIgnoreCase(FeatureStoreNotification.AFTER_DISPOSE)
368
            || type.equalsIgnoreCase(FeatureStoreNotification.TRANSFORM_CHANGE)) {
369
            sourceStoreModified = true;
370
            sourceStoreModifiedCause = new Throwable();
371
            return;
372
        }
373
        if (type.equalsIgnoreCase(FeatureStoreNotification.RESOURCE_CHANGED)) {
374
            if(!this.ignoreChanges) {
375
                sourceStoreModified = true;
376
                sourceStoreModifiedCause = new Throwable();
377
                return;
378
            }
379
        }
380
        if (type.equalsIgnoreCase(FeatureStoreNotification.AFTER_CANCELEDITING)) {
381
            if (ownFeaturesModified) {
382
                sourceStoreModified = true;
383
                sourceStoreModifiedCause = new Throwable();
384
                return;
385
            }
386
        }
387
    }
388
  
389
    protected void checkSourceStoreModified() {
390
        if (sourceStoreModified) {
391
            ConcurrentDataModificationException ex = new ConcurrentDataModificationException(
392
                    store == null ? "": store.getName()
393
            );
394
            ex.initCause(sourceStoreModifiedCause);
395
            throw ex;
396
        }
397
    }
398

    
399
    @Override
400
    public DisposableIterator fastIterator(long index) throws DataException {
401
        return fastIterator(index, 0);
402
    }
403
    
404
    @Override
405
    public DisposableIterator fastIterator(long index, long elements) throws DataException {
406
        if (index < 0) {
407
            throw new IndexOutOfBoundsException("The index (" + index
408
                + ") is less than 0");
409
        }
410
        DisposableIterator it;
411
        int mode = this.getIteratorMode();
412

    
413
        switch (mode) {
414
        case DEFAULT:
415
            it = new FastDefaultIterator(this, index, elements);
416
            break;
417

    
418
        case FILTERED:
419
            it = new FastFilteredIterator(this, index, elements);
420
            break;
421

    
422
        case ORDERED:
423
            if(this.provider.canOrder() && this.provider.canIterateFromIndex()){
424
                it = new FastDefaultIterator(this, index, elements);
425
            } else {
426
                if (this.orderedData != null) {
427
                    it = new FastOrderedIterator(this, index);
428
                } else {
429
                    it = new FastOrderedIterator(this, new FastDefaultIterator(this, 0, -1), index);
430
                }
431
            }
432
            break;
433
            
434
        case ORDERED_FILTERED:
435
            if(this.provider.canOrder() && this.provider.canFilter() && this.provider.canIterateFromIndex()){
436
                it = new FastFilteredIterator(this, index, elements);
437
            } else {
438
                if (this.orderedData != null) {
439
                    it = new FastOrderedIterator(this, index);
440
                } else {
441
                    it = new FastOrderedIterator(this, new FastFilteredIterator(
442
                        this, 0, -1), index);
443
                }
444
            }
445

    
446
            break;
447

    
448
        case EDITED:
449
            it = new FastEditedIterator(this, index, elements);
450
            break;
451

    
452
        case EDITED_FILTERED:
453
            it = new FastEditedFilteredIterator(this, index, elements);
454
            break;
455

    
456
        case ORDERD_EDITED:
457
            if(this.provider.canOrder() && this.provider.canIterateFromIndex() && !this.store.getFeatureManager().hasDeleteds()){
458
                it = new FastEditedIterator(this, index, elements);
459
            } else {
460
                if (this.orderedData != null) {
461
                    it = new FastOrderedIterator(this, index);
462
                } else {
463
                    it = new FastOrderedIterator(this, new FastEditedIterator(
464
                        this, 0, -1), index);
465
                }
466
            }
467
            break;
468

    
469
        case ORDERED_EDITED_FILTER:
470
            if(this.provider.canOrder() && this.provider.canFilter() && this.provider.canIterateFromIndex() && !this.store.getFeatureManager().hasDeleteds()){
471
                it = new FastEditedFilteredIterator(this, index, elements);
472
            } else {
473
                if (this.orderedData != null) {
474
                    it = new FastOrderedIterator(this, index);
475
                } else {
476
                    it = new FastOrderedIterator(this,
477
                        new FastEditedFilteredIterator(this, 0, -1), index);
478
                }
479
            }
480
            break;
481
            
482
        default:
483
            throw new IllegalArgumentException();
484
        }
485
        if( this.query!=null && this.query.getLimit()>0 ) {
486
            it = new LimitIterator(it,this.query.getLimit());
487
        }
488
        return it;
489
    }
490

    
491
    private class LimitIterator implements DisposableIterator {
492

    
493
        private final DisposableIterator it;
494
        private final long limit;
495
        private int count;
496

    
497
        private LimitIterator(DisposableIterator it, long limit) {
498
            this.it = it;
499
            this.limit = limit;
500
            this.count = 0;
501
        }
502

    
503
        @Override
504
        public void dispose() {
505
            this.it.dispose();
506
        }
507

    
508
        @Override
509
        public boolean hasNext() {
510
            if( this.count>=this.limit ) {
511
                return false;
512
            }
513
            return this.it.hasNext();
514
        }
515

    
516
        @Override
517
        public Object next() {
518
            if( this.count>=this.limit ) {
519
                return null;
520
            }
521
            this.count++;
522
            return this.it.next();
523
        }
524

    
525
        @Override
526
        public void remove() {
527
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
528
        }
529
        
530
    }
531

    
532
    @Override
533
    public DisposableIterator iterator(long index) throws DataException {
534
        return iterator(index,0);
535
    }
536
    
537
    @Override
538
    public DisposableIterator iterator(long index, long elements) throws DataException {        
539
        if (index < 0) {
540
            throw new IndexOutOfBoundsException("The index (" + index
541
                + ") is less than 0");
542
        }
543
        DisposableIterator it;
544
        int mode = this.getIteratorMode();
545

    
546
        switch (mode) {
547
        case DEFAULT:
548
            it = new DefaultIterator(this, index, elements);
549
            break;
550

    
551
        case FILTERED:
552
            it = new FilteredIterator(this, index, elements);
553
            break;
554

    
555
        case ORDERED:
556
            if(this.provider.canOrder() && this.provider.canIterateFromIndex()){
557
                it = new DefaultIterator(this, index, elements);
558
            } else {
559
                if (orderedData != null) {
560
                    it = new OrderedIterator(this, index);
561

    
562
                } else {
563
                    it = new OrderedIterator(this, new DefaultIterator(this, 0, elements),index);
564
                }
565
            }
566
            break;
567

    
568
        case ORDERED_FILTERED:
569
            if(this.provider.canOrder() && this.provider.canFilter() && this.provider.canIterateFromIndex()){
570
                it = new FilteredIterator(this, index, elements);
571
            } else {
572
                if (orderedData != null) {
573
                    it = new OrderedIterator(this, index);
574
                } else {
575
                    it = new OrderedIterator(this, new FilteredIterator(this, 0, -1),index);
576
                }
577
            }
578
            break;
579

    
580
        case EDITED:
581
            it = new EditedIterator(this, index, elements);
582
            break;
583

    
584
        case EDITED_FILTERED:
585
            it = new EditedFilteredIterator(this, index, elements);
586
            break;
587

    
588
        case ORDERD_EDITED:
589
            if(this.provider.canOrder() && this.provider.canIterateFromIndex() && !this.store.getFeatureManager().hasDeleteds()){
590
                it = new EditedIterator(this, index, elements);
591
            } else {
592
                if (orderedData != null) {
593
                    it = new OrderedIterator(this, index);
594
                } else {
595
                    it = new OrderedIterator(this,
596
                        new EditedIterator(this, 0, -1), index);
597
                }
598
            }
599
            break;
600

    
601
        case ORDERED_EDITED_FILTER:
602
            if(this.provider.canOrder() && this.providerCanFilter() && this.provider.canIterateFromIndex() && !this.store.getFeatureManager().hasDeleteds()){
603
                it = new EditedFilteredIterator(this, index, elements);
604
            } else {
605
                if (orderedData != null) {
606
                    it = new OrderedIterator(this, index);
607
                } else {
608
                    it = new OrderedIterator(this,
609
                        new EditedFilteredIterator(this, 0, -1), index);
610
                }
611
            }
612
            break;
613

    
614
        default:
615
            throw new IllegalArgumentException();
616
        }
617

    
618
        if( this.query!=null && this.query.getLimit()>0 ) {
619
            it = new LimitIterator(it,this.query.getLimit());
620
        }
621
        return it;
622
    }
623

    
624
    private boolean providerCanOrder() {
625
        return this.provider.canOrder();
626
    }
627

    
628
    private boolean providerCanFilter() {
629
        return this.provider.canFilter();
630
    }
631

    
632
    private int getIteratorMode() {
633

    
634
        if (this.iteratorMode != NO_CHECKED) {
635
            return this.iteratorMode;
636
        }
637

    
638
        // TODO Tener en cuenta las transformaciones ???
639

    
640
        if (store.isEditing() && (store.getFeatureTypeManager().hasChanges() || store.getFeatureManager().hasChanges())) {
641
            if (this.query.hasOrder()) { // En edicion siempre ordeno yo.
642
                if (this.query.hasFilter()) {
643
                    return ORDERED_EDITED_FILTER;
644
                } else {
645
                    return ORDERD_EDITED;
646
                }
647
            } else {
648
                if (this.query.hasFilter()) {
649
                    return EDITED_FILTERED;
650
                } else {
651
                    return EDITED;
652
                }
653
            }
654
        } else {
655
            boolean useMyFilter = this.query.hasFilter();
656
            boolean useMyOrder = this.query.hasOrder();
657
            if (this.providerCanOrder() && this.transform.isEmpty()) {
658
                useMyOrder = false;
659
            }
660
            if (this.providerCanFilter() && this.transform.isEmpty()) {
661
                useMyFilter = false;
662
            }
663

    
664
            if (useMyOrder) {
665
                if (useMyFilter) {
666
                    return ORDERED_FILTERED;
667
                } else {
668
                    return ORDERED;
669
                }
670
            } else {
671
                if (useMyFilter) {
672
                    return FILTERED;
673
                } else {
674
                    return DEFAULT;
675
                }
676
            }
677
        }
678

    
679
    }
680

    
681
    @Override
682
    public void delete(Feature feature) throws DataException {
683
        this.featureToIgnoreNotification = feature;
684
        this.store.delete(feature);
685
        if (this.size > 0) {
686
            this.size--;
687
        }
688
        this.featureToIgnoreNotification = null;
689
        this.ownFeaturesModified = true;
690
    }
691

    
692
    @Override
693
    public void insert(EditableFeature feature) throws DataException {
694
        this.featureToIgnoreNotification = feature;
695
        this.store.insert(feature);
696
        if (this.size >= 0) {
697
            this.size++;
698
        }
699
        this.featureToIgnoreNotification = null;
700
        this.ownFeaturesModified = true;
701
    }
702

    
703
    @Override
704
    public void update(EditableFeature feature) throws DataException {
705
        this.featureToIgnoreNotification = feature;
706
        this.store.update(feature);
707
        this.featureToIgnoreNotification = null;
708
        this.ownFeaturesModified = true;
709
    }
710
    
711
    @Override
712
    public void commitChanges() throws DataException {
713
        this.ignoreChanges = true;
714
        this.store.commitChanges();
715
        this.ignoreChanges = false;
716
        
717
    }
718

    
719
    @Override
720
    public FeatureStore getFeatureStore() {
721
        return store;
722
    }
723

    
724
}