Revision 44113
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/DefaultFeatureSelection.java | ||
---|---|---|
34 | 34 |
import org.gvsig.fmap.dal.exception.DataRuntimeException; |
35 | 35 |
import org.gvsig.fmap.dal.feature.EditableFeature; |
36 | 36 |
import org.gvsig.fmap.dal.feature.Feature; |
37 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
|
37 | 38 |
import org.gvsig.fmap.dal.feature.FeatureReference; |
38 | 39 |
import org.gvsig.fmap.dal.feature.FeatureSelection; |
39 | 40 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
40 | 41 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
42 |
import org.gvsig.fmap.dal.feature.FeatureStoreNotification; |
|
41 | 43 |
import org.gvsig.fmap.dal.feature.FeatureType; |
42 | 44 |
import org.gvsig.fmap.dal.feature.exception.ReversedSelectionIteratorException; |
43 | 45 |
import org.gvsig.fmap.dal.feature.impl.DefaultFeatureReferenceSelection.SelectionData; |
44 | 46 |
import org.gvsig.fmap.dal.feature.impl.featureset.AbstractFeatureSet; |
47 |
import org.gvsig.fmap.dal.feature.impl.featureset.DefaultFeatureSet; |
|
45 | 48 |
import org.gvsig.fmap.dal.feature.impl.undo.FeatureCommandsStack; |
46 | 49 |
import org.gvsig.tools.ToolsLocator; |
47 | 50 |
import org.gvsig.tools.dispose.DisposableIterator; |
... | ... | |
191 | 194 |
|
192 | 195 |
// Load a Set with all the store features |
193 | 196 |
try { |
194 |
featureSet = featureStore.getFeatureSet(); |
|
195 |
//if (fastIterator) { |
|
197 |
featureSet = new IgnoreInsertAndUpdateFeatureSet( |
|
198 |
(DefaultFeatureStore) featureStore, |
|
199 |
new DefaultFeatureQuery(featureStore.getDefaultFeatureType()) |
|
200 |
); |
|
196 | 201 |
iterator = featureSet.fastIterator(); |
197 |
// } else { |
|
198 |
// iterator = featureSet.iterator(); |
|
199 |
// } |
|
200 | 202 |
} catch (DataException ex) { |
201 | 203 |
throw new ReversedSelectionIteratorException(ex); |
202 | 204 |
} |
... | ... | |
764 | 766 |
} |
765 | 767 |
} |
766 | 768 |
|
769 |
private static class IgnoreInsertAndUpdateFeatureSet extends DefaultFeatureSet { |
|
770 |
|
|
771 |
public IgnoreInsertAndUpdateFeatureSet(DefaultFeatureStore store, FeatureQuery query) throws DataException { |
|
772 |
super(store, query); |
|
773 |
} |
|
774 |
|
|
775 |
public void update(Observable obsevable, Object notification) { |
|
776 |
String type = ((FeatureStoreNotification) notification).getType(); |
|
777 |
if (type.equalsIgnoreCase(FeatureStoreNotification.AFTER_INSERT) |
|
778 |
|| type.equalsIgnoreCase(FeatureStoreNotification.AFTER_UPDATE)) { |
|
779 |
return; |
|
780 |
} |
|
781 |
super.update(obsevable, notification); |
|
782 |
} |
|
783 |
|
|
784 |
} |
|
785 |
|
|
786 |
|
|
767 | 787 |
} |
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 | ||
---|---|---|
23 | 23 |
*/ |
24 | 24 |
package org.gvsig.fmap.dal.feature.impl.featureset; |
25 | 25 |
|
26 |
import org.gvsig.fmap.dal.feature.impl.dynobjectutils.DynObjectSetFeatureSetFacade; |
|
27 | 26 |
import java.util.ArrayList; |
28 | 27 |
import java.util.Collections; |
29 | 28 |
import java.util.Iterator; |
30 | 29 |
import java.util.List; |
31 | 30 |
import java.util.NoSuchElementException; |
32 | 31 |
|
33 |
import org.gvsig.fmap.dal.DataStore; |
|
34 | 32 |
import org.gvsig.fmap.dal.exception.DataException; |
35 | 33 |
import org.gvsig.fmap.dal.feature.EditableFeature; |
36 | 34 |
import org.gvsig.fmap.dal.feature.Feature; |
... | ... | |
48 | 46 |
import org.gvsig.fmap.dal.feature.impl.DefaultFeatureStoreTransforms; |
49 | 47 |
import org.gvsig.fmap.dal.feature.spi.FeatureSetProvider; |
50 | 48 |
import org.gvsig.tools.dispose.DisposableIterator; |
51 |
import org.gvsig.tools.dynobject.DynObjectSet;
|
|
49 |
import org.gvsig.tools.dispose.DisposeUtils;
|
|
52 | 50 |
import org.gvsig.tools.evaluator.Evaluator; |
53 |
import org.gvsig.tools.exception.BaseException; |
|
54 | 51 |
import org.gvsig.tools.observer.Observable; |
55 | 52 |
import org.gvsig.tools.observer.Observer; |
56 |
import org.gvsig.tools.visitor.VisitCanceledException; |
|
57 |
import org.gvsig.tools.visitor.Visitor; |
|
58 | 53 |
|
59 | 54 |
public class DefaultFeatureSet extends AbstractFeatureSet implements |
60 | 55 |
FeatureSet, Observer { |
61 | 56 |
|
62 |
private static final int NO_CHECKED = -1;
|
|
63 |
private static final int DEFAULT = 0;
|
|
64 |
private static final int FILTERED = 1;
|
|
65 |
private static final int ORDERED = 2;
|
|
66 |
private static final int ORDERED_FILTERED = 3;
|
|
67 |
private static final int EDITED = 4;
|
|
68 |
private static final int EDITED_FILTERED = 5;
|
|
69 |
private static final int ORDERD_EDITED = 6;
|
|
70 |
private static final int ORDERED_EDITED_FILTER = 7;
|
|
57 |
protected static final int NO_CHECKED = -1;
|
|
58 |
protected static final int DEFAULT = 0;
|
|
59 |
protected static final int FILTERED = 1;
|
|
60 |
protected static final int ORDERED = 2;
|
|
61 |
protected static final int ORDERED_FILTERED = 3;
|
|
62 |
protected static final int EDITED = 4;
|
|
63 |
protected static final int EDITED_FILTERED = 5;
|
|
64 |
protected static final int ORDERD_EDITED = 6;
|
|
65 |
protected static final int ORDERED_EDITED_FILTER = 7;
|
|
71 | 66 |
|
72 |
private boolean sourceStoreModified;
|
|
73 |
private boolean ownFeaturesModified;
|
|
74 |
DefaultFeatureStore store; |
|
75 |
private List featureTypes;
|
|
76 |
FeatureQuery query; |
|
77 |
FeatureSetProvider provider; |
|
78 |
private long size;
|
|
79 |
private int iteratorMode;
|
|
80 |
List orderedData; |
|
81 |
private Feature featureToIgnoreNotification;
|
|
82 |
DefaultFeatureStoreTransforms transform; |
|
83 |
private FeatureQuery queryForProvider;
|
|
84 |
private FeatureType defatulFeatureType;
|
|
85 |
private FeatureType defatulFeatureTypeForProvider;
|
|
86 |
private boolean ignoreChanges;
|
|
67 |
protected boolean sourceStoreModified;
|
|
68 |
protected boolean ownFeaturesModified;
|
|
69 |
protected DefaultFeatureStore store;
|
|
70 |
protected List featureTypes;
|
|
71 |
protected FeatureQuery query;
|
|
72 |
protected FeatureSetProvider provider;
|
|
73 |
protected long size;
|
|
74 |
protected int iteratorMode;
|
|
75 |
protected List orderedData;
|
|
76 |
protected Feature featureToIgnoreNotification;
|
|
77 |
protected DefaultFeatureStoreTransforms transform;
|
|
78 |
protected FeatureQuery queryForProvider;
|
|
79 |
protected FeatureType defatulFeatureType;
|
|
80 |
protected FeatureType defatulFeatureTypeForProvider;
|
|
81 |
protected boolean ignoreChanges;
|
|
87 | 82 |
|
88 | 83 |
public DefaultFeatureSet(DefaultFeatureStore store, FeatureQuery query) |
89 | 84 |
throws DataException { |
... | ... | |
158 | 153 |
// Filter |
159 | 154 |
Evaluator filter = theQueryForProvider.getFilter(); |
160 | 155 |
if (filter != null) { |
161 |
boolean canUseFilter = true;
|
|
156 |
boolean canUseFilter; |
|
162 | 157 |
if (filter.getFieldsInfo() == null) { |
163 | 158 |
canUseFilter = false; |
164 | 159 |
} else { |
... | ... | |
208 | 203 |
if (fieldNames.length == 0) { |
209 | 204 |
return false; |
210 | 205 |
} else { |
211 |
for (int i = 0; i < fieldNames.length; i++) {
|
|
212 |
if (fType.get(fieldNames[i]) == null) {
|
|
206 |
for (String fieldName : fieldNames) {
|
|
207 |
if (fType.get(fieldName) == null) { |
|
213 | 208 |
return false; |
214 | 209 |
} |
215 |
|
|
216 | 210 |
} |
217 | 211 |
} |
218 | 212 |
return true; |
... | ... | |
254 | 248 |
} catch (NoSuchElementException e) { |
255 | 249 |
return mySize; |
256 | 250 |
} finally { |
257 |
iter.dispose();
|
|
251 |
DisposeUtils.disposeQuietly(iter);
|
|
258 | 252 |
} |
259 | 253 |
} else if ((mode & EDITED) == EDITED) { |
260 | 254 |
long mySize = provider.getSize() |
Also available in: Unified diff