Revision 44871 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/DefaultFeatureStoreNotification.java
DefaultFeatureStoreNotification.java | ||
---|---|---|
23 | 23 |
*/ |
24 | 24 |
package org.gvsig.fmap.dal.feature.impl; |
25 | 25 |
|
26 |
import java.util.Iterator; |
|
26 | 27 |
import org.gvsig.fmap.dal.DataSet; |
27 | 28 |
import org.gvsig.fmap.dal.DataStore; |
28 | 29 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
29 | 30 |
import org.gvsig.fmap.dal.feature.Feature; |
30 | 31 |
import org.gvsig.fmap.dal.feature.FeatureIndex; |
32 |
import org.gvsig.fmap.dal.feature.FeatureReference; |
|
31 | 33 |
import org.gvsig.fmap.dal.feature.FeatureStoreNotification; |
34 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
35 |
import org.gvsig.fmap.dal.feature.FeatureType.FeatureTypeChanged; |
|
36 |
import org.gvsig.tools.observer.BaseNotification; |
|
32 | 37 |
import org.gvsig.tools.undo.command.Command; |
33 | 38 |
|
34 |
public class DefaultFeatureStoreNotification implements |
|
35 |
FeatureStoreNotification { |
|
36 |
private Feature feature = null; |
|
37 |
private DataSet collectionResult = null; |
|
38 |
private boolean loadCollectionSucefully = false; |
|
39 |
private Exception exceptionLoading = null; |
|
40 |
private Command command = null; |
|
41 |
private EditableFeatureType featureType = null; |
|
42 |
private String type; |
|
43 |
private DataStore source; |
|
44 |
private FeatureIndex index; |
|
39 |
public class DefaultFeatureStoreNotification |
|
40 |
extends BaseNotification |
|
41 |
implements FeatureStoreNotification { |
|
45 | 42 |
|
46 |
protected void init(DataStore source, String type) { |
|
47 |
this.source = source; |
|
48 |
this.type = type; |
|
49 |
} |
|
43 |
private static final int VALUE_SOURCE = 0; |
|
44 |
private static final int VALUE_FEATURE = 1; |
|
45 |
private static final int VALUE_COLLECTION_RESULT = 2; |
|
46 |
private static final int VALUE_LOAD_COLLECTION_SUCCESSFULLY = 3; |
|
47 |
private static final int VALUE_EXCEPTION_LOADING = 4; |
|
48 |
private static final int VALUE_COMMAND = 5; |
|
49 |
private static final int VALUE_FEATURE_INDEX = 6; |
|
50 |
private static final int VALUE_FEATURETYPE = 7; |
|
51 |
private static final int VALUE_CHANGEDS_FEATURETYPES = 8; |
|
52 |
private static final int VALUE_UPDATEDS_FEATURES = 9; |
|
53 |
private static final int VALUE_INSERTEDS_FEATURES = 10; |
|
54 |
private static final int VALUE_DELETEDS_FEATURES = 11; |
|
55 |
private static final int VALUE_IS_SELECTION_COMPROMISED = 12; |
|
50 | 56 |
|
51 |
public DefaultFeatureStoreNotification(DataStore source, String type) { |
|
52 |
this.init(source, type); |
|
53 |
} |
|
57 |
private static final int VALUES_COUNT = 13; |
|
54 | 58 |
|
55 |
public DefaultFeatureStoreNotification(DataStore source, String type, Feature feature) { |
|
56 |
this.init(source, type); |
|
57 |
this.feature = feature; |
|
58 |
} |
|
59 |
public DefaultFeatureStoreNotification(DataStore source, String type, Command command) { |
|
60 |
this.init(source, type); |
|
61 |
this.command = command; |
|
62 |
} |
|
59 |
public DefaultFeatureStoreNotification(String type) { |
|
60 |
super(type, VALUES_COUNT); |
|
61 |
this.setValue(VALUE_LOAD_COLLECTION_SUCCESSFULLY, false); |
|
62 |
this.setValue(VALUE_IS_SELECTION_COMPROMISED, false); |
|
63 |
} |
|
63 | 64 |
|
64 |
public DefaultFeatureStoreNotification(DataStore source, String type, Exception exception) { |
|
65 |
this.init(source, type); |
|
66 |
this.loadCollectionSucefully = false; |
|
67 |
this.exceptionLoading = exception; |
|
68 |
} |
|
65 |
public DefaultFeatureStoreNotification(DataStore source, String type) { |
|
66 |
this(type); |
|
67 |
this.setValue(VALUE_SOURCE, source); |
|
68 |
} |
|
69 | 69 |
|
70 |
public DefaultFeatureStoreNotification(DataStore source, String type, DataSet collection) { |
|
71 |
this.init(source, type); |
|
72 |
this.loadCollectionSucefully = true; |
|
73 |
this.collectionResult = collection; |
|
74 |
} |
|
70 |
public DefaultFeatureStoreNotification(DataStore source, String type, Feature feature) { |
|
71 |
this(source, type); |
|
72 |
this.setValue(VALUE_FEATURE, feature); |
|
73 |
} |
|
75 | 74 |
|
75 |
public DefaultFeatureStoreNotification(DataStore source, String type, Command command) { |
|
76 |
this(source, type); |
|
77 |
this.setValue(VALUE_SOURCE, source); |
|
78 |
this.setValue(VALUE_COMMAND, command); |
|
79 |
} |
|
76 | 80 |
|
77 |
public DefaultFeatureStoreNotification(DataStore source, String type,
|
|
78 |
EditableFeatureType featureType) {
|
|
79 |
this.init(source, type);
|
|
80 |
this.featureType = featureType;
|
|
81 |
}
|
|
81 |
public DefaultFeatureStoreNotification(DataStore source, String type, Exception exception) {
|
|
82 |
this(source, type);
|
|
83 |
this.setValue(VALUE_LOAD_COLLECTION_SUCCESSFULLY, false);
|
|
84 |
this.setValue(VALUE_EXCEPTION_LOADING, exception);
|
|
85 |
}
|
|
82 | 86 |
|
83 |
public DefaultFeatureStoreNotification(DataStore source, String type,
|
|
84 |
FeatureIndex index) {
|
|
85 |
this.init(source, type);
|
|
86 |
this.index = index;
|
|
87 |
}
|
|
87 |
public DefaultFeatureStoreNotification(DataStore source, String type, DataSet collection) {
|
|
88 |
this(source, type);
|
|
89 |
this.setValue(VALUE_LOAD_COLLECTION_SUCCESSFULLY, true);
|
|
90 |
this.setValue(VALUE_COLLECTION_RESULT, collection);
|
|
91 |
} |
|
88 | 92 |
|
89 |
public Feature getFeature() { |
|
90 |
return feature; |
|
91 |
} |
|
93 |
public DefaultFeatureStoreNotification(DataStore source, String type, |
|
94 |
EditableFeatureType featureType) { |
|
95 |
this(source, type); |
|
96 |
this.setValue(VALUE_FEATURETYPE, featureType); |
|
97 |
} |
|
92 | 98 |
|
93 |
public EditableFeatureType getFeatureType() { |
|
94 |
return featureType; |
|
95 |
} |
|
99 |
public DefaultFeatureStoreNotification(DataStore source, String type, FeatureIndex index) { |
|
100 |
this(source, type); |
|
101 |
this.setValue(VALUE_FEATURE_INDEX, index); |
|
102 |
} |
|
96 | 103 |
|
97 |
public DataSet getCollectionResult() { |
|
98 |
return this.collectionResult; |
|
99 |
} |
|
104 |
DefaultFeatureStoreNotification(DataStore source, String type, |
|
105 |
Iterator<FeatureReference> deleteds, |
|
106 |
Iterator<Feature> inserteds, |
|
107 |
Iterator<Feature> updateds, |
|
108 |
Iterator<FeatureType.FeatureTypeChanged> featureTypesChanged, |
|
109 |
boolean isSelectionCompromised) |
|
110 |
{ |
|
111 |
this(source, type); |
|
112 |
this.setValue(VALUE_DELETEDS_FEATURES, deleteds); |
|
113 |
this.setValue(VALUE_INSERTEDS_FEATURES, inserteds); |
|
114 |
this.setValue(VALUE_UPDATEDS_FEATURES, updateds); |
|
115 |
this.setValue(VALUE_CHANGEDS_FEATURETYPES, featureTypesChanged); |
|
116 |
this.setValue(VALUE_IS_SELECTION_COMPROMISED, isSelectionCompromised); |
|
117 |
} |
|
100 | 118 |
|
101 |
public Exception getExceptionLoading() { |
|
102 |
return this.exceptionLoading; |
|
103 |
} |
|
119 |
@Override |
|
120 |
public Feature getFeature() { |
|
121 |
return (Feature) this.getValue(VALUE_FEATURE); |
|
122 |
} |
|
104 | 123 |
|
105 |
public boolean loadSucefully() { |
|
106 |
return this.loadCollectionSucefully; |
|
107 |
} |
|
124 |
@Override |
|
125 |
public EditableFeatureType getFeatureType() { |
|
126 |
return (EditableFeatureType) this.getValue(VALUE_FEATURETYPE); |
|
127 |
} |
|
108 | 128 |
|
109 |
public Command getCommand() { |
|
110 |
return this.command; |
|
111 |
} |
|
129 |
@Override |
|
130 |
public DataSet getCollectionResult() { |
|
131 |
return (DataSet) this.getValue(VALUE_COLLECTION_RESULT); |
|
132 |
} |
|
112 | 133 |
|
113 |
public DataStore getSource() { |
|
114 |
return source; |
|
115 |
} |
|
134 |
@Override |
|
135 |
public Exception getExceptionLoading() { |
|
136 |
return (Exception) this.getValue(VALUE_EXCEPTION_LOADING); |
|
137 |
} |
|
116 | 138 |
|
117 |
public String getType() { |
|
118 |
return type; |
|
119 |
} |
|
139 |
@Override |
|
140 |
public boolean loadSucefully() { |
|
141 |
return (boolean) this.getValue(VALUE_LOAD_COLLECTION_SUCCESSFULLY); |
|
142 |
} |
|
120 | 143 |
|
121 |
public FeatureIndex getIndex() { |
|
122 |
return index; |
|
123 |
} |
|
144 |
@Override |
|
145 |
public Command getCommand() { |
|
146 |
return (Command) this.getValue(VALUE_COMMAND); |
|
147 |
} |
|
148 |
|
|
149 |
@Override |
|
150 |
public DataStore getSource() { |
|
151 |
return (DataStore) this.getValue(VALUE_SOURCE); |
|
152 |
} |
|
153 |
|
|
154 |
public FeatureIndex getIndex() { |
|
155 |
return (FeatureIndex) this.getValue(VALUE_FEATURE_INDEX); |
|
156 |
} |
|
157 |
|
|
158 |
@Override |
|
159 |
public boolean isSelectionCompromised() { |
|
160 |
return (boolean) this.getValue(VALUE_IS_SELECTION_COMPROMISED); |
|
161 |
} |
|
162 |
|
|
163 |
@Override |
|
164 |
public Iterator<FeatureReference> getDeletedsFeatures() { |
|
165 |
return (Iterator<FeatureReference>) this.getValue(VALUE_DELETEDS_FEATURES); |
|
166 |
} |
|
167 |
|
|
168 |
@Override |
|
169 |
public Iterator<Feature> getInsertedsFeatures() { |
|
170 |
return (Iterator<Feature>) this.getValue(VALUE_INSERTEDS_FEATURES); |
|
171 |
} |
|
172 |
|
|
173 |
@Override |
|
174 |
public Iterator<Feature> getUpdatedsFeatures() { |
|
175 |
return (Iterator<Feature>) this.getValue(VALUE_UPDATEDS_FEATURES); |
|
176 |
} |
|
177 |
|
|
178 |
@Override |
|
179 |
public Iterator<FeatureTypeChanged> getChangedsFeatureTypes() { |
|
180 |
return (Iterator<FeatureTypeChanged>) this.getValue(VALUE_CHANGEDS_FEATURETYPES); |
|
181 |
} |
|
182 |
|
|
183 |
|
|
124 | 184 |
} |
Also available in: Unified diff