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 / DefaultFeatureStoreNotification.java @ 46875

History | View | Annotate | Download (7.96 KB)

1 40559 jjdelcerro
/**
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 40435 jjdelcerro
package org.gvsig.fmap.dal.feature.impl;
25
26 44871 jjdelcerro
import java.util.Iterator;
27 46426 jjdelcerro
import org.gvsig.expressionevaluator.Expression;
28 40435 jjdelcerro
import org.gvsig.fmap.dal.DataSet;
29
import org.gvsig.fmap.dal.DataStore;
30 45739 jjdelcerro
import org.gvsig.fmap.dal.feature.EditableFeature;
31 40435 jjdelcerro
import org.gvsig.fmap.dal.feature.EditableFeatureType;
32
import org.gvsig.fmap.dal.feature.Feature;
33
import org.gvsig.fmap.dal.feature.FeatureIndex;
34 44871 jjdelcerro
import org.gvsig.fmap.dal.feature.FeatureReference;
35 45738 fdiaz
import org.gvsig.fmap.dal.feature.FeatureStore;
36 40435 jjdelcerro
import org.gvsig.fmap.dal.feature.FeatureStoreNotification;
37 44871 jjdelcerro
import org.gvsig.fmap.dal.feature.FeatureType;
38
import org.gvsig.fmap.dal.feature.FeatureType.FeatureTypeChanged;
39
import org.gvsig.tools.observer.BaseNotification;
40 40435 jjdelcerro
import org.gvsig.tools.undo.command.Command;
41
42 45738 fdiaz
@SuppressWarnings("OverridableMethodCallInConstructor")
43 44871 jjdelcerro
public class DefaultFeatureStoreNotification
44
        extends BaseNotification
45
        implements FeatureStoreNotification {
46 40435 jjdelcerro
47 44871 jjdelcerro
  private static final int VALUE_SOURCE = 0;
48
  private static final int VALUE_FEATURE = 1;
49
  private static final int VALUE_COLLECTION_RESULT = 2;
50
  private static final int VALUE_LOAD_COLLECTION_SUCCESSFULLY = 3;
51
  private static final int VALUE_EXCEPTION_LOADING = 4;
52
  private static final int VALUE_COMMAND = 5;
53
  private static final int VALUE_FEATURE_INDEX = 6;
54
  private static final int VALUE_FEATURETYPE = 7;
55
  private static final int VALUE_CHANGEDS_FEATURETYPES = 8;
56
  private static final int VALUE_UPDATEDS_FEATURES = 9;
57
  private static final int VALUE_INSERTEDS_FEATURES = 10;
58
  private static final int VALUE_DELETEDS_FEATURES = 11;
59
  private static final int VALUE_IS_SELECTION_COMPROMISED = 12;
60 45738 fdiaz
  private static final int VALUE_EDITING_SESSION = 13;
61
  private static final int VALUE_EDIT_MODE = 14;
62 46426 jjdelcerro
  private static final int VALUE_EXPRESSION = 15;
63 40435 jjdelcerro
64 46426 jjdelcerro
  private static final int VALUES_COUNT = 16;
65 40435 jjdelcerro
66 44871 jjdelcerro
  public DefaultFeatureStoreNotification(String type) {
67
    super(type, VALUES_COUNT);
68
    this.setValue(VALUE_LOAD_COLLECTION_SUCCESSFULLY, false);
69
    this.setValue(VALUE_IS_SELECTION_COMPROMISED, false);
70
  }
71 40435 jjdelcerro
72 44871 jjdelcerro
  public DefaultFeatureStoreNotification(DataStore source, String type) {
73
    this(type);
74
    this.setValue(VALUE_SOURCE, source);
75
  }
76 40435 jjdelcerro
77 45738 fdiaz
  public DefaultFeatureStoreNotification(DataStore source, String type, String editingSession) {
78 46426 jjdelcerro
    this(source, type);
79 45738 fdiaz
    this.setValue(VALUE_EDITING_SESSION, editingSession);
80
  }
81
82
  public DefaultFeatureStoreNotification(DataStore source, String type, String editingSession, int editMode) {
83 46426 jjdelcerro
    this(source, type, editingSession);
84 45738 fdiaz
    this.setValue(VALUE_EDIT_MODE, editMode);
85
  }
86
87 46426 jjdelcerro
  public DefaultFeatureStoreNotification(DataStore source, String type, String editingSession, int editMode, Feature feature) {
88
    this(source, type, editingSession, editMode);
89 44871 jjdelcerro
    this.setValue(VALUE_FEATURE, feature);
90
  }
91 40435 jjdelcerro
92 46426 jjdelcerro
  public DefaultFeatureStoreNotification(DataStore source, String type, String editingSession, int editMode, Expression expression) {
93
    this(source, type, editingSession, editMode);
94
    this.setValue(VALUE_EXPRESSION, expression);
95
  }
96
97
  public DefaultFeatureStoreNotification(DataStore source, String type, String editingSession, int editMode, Command command) {
98
    this(source, type, editingSession, editMode);
99 44871 jjdelcerro
    this.setValue(VALUE_COMMAND, command);
100
  }
101 40435 jjdelcerro
102 44871 jjdelcerro
  public DefaultFeatureStoreNotification(DataStore source, String type, Exception exception) {
103
    this(source, type);
104
    this.setValue(VALUE_LOAD_COLLECTION_SUCCESSFULLY, false);
105
    this.setValue(VALUE_EXCEPTION_LOADING, exception);
106
  }
107 40435 jjdelcerro
108 44871 jjdelcerro
  public DefaultFeatureStoreNotification(DataStore source, String type, DataSet collection) {
109
    this(source, type);
110
    this.setValue(VALUE_LOAD_COLLECTION_SUCCESSFULLY, true);
111
    this.setValue(VALUE_COLLECTION_RESULT, collection);
112
  }
113 40435 jjdelcerro
114 46426 jjdelcerro
  public DefaultFeatureStoreNotification(DataStore source, String type, String editingSession, int editMode,
115 44871 jjdelcerro
          EditableFeatureType featureType) {
116 46426 jjdelcerro
    this(source, type, editingSession, editMode);
117 44871 jjdelcerro
    this.setValue(VALUE_FEATURETYPE, featureType);
118
  }
119 40435 jjdelcerro
120 44871 jjdelcerro
  public DefaultFeatureStoreNotification(DataStore source, String type, FeatureIndex index) {
121
    this(source, type);
122
    this.setValue(VALUE_FEATURE_INDEX, index);
123
  }
124 40435 jjdelcerro
125 46426 jjdelcerro
  DefaultFeatureStoreNotification(DataStore source, String type, String editingSession, int editMode,
126 44871 jjdelcerro
      Iterator<FeatureReference> deleteds,
127 45739 jjdelcerro
      Iterator<EditableFeature> inserteds,
128
      Iterator<EditableFeature> updateds,
129 44871 jjdelcerro
      Iterator<FeatureType.FeatureTypeChanged> featureTypesChanged,
130 45738 fdiaz
      boolean isSelectionCompromised
131
    ) {
132 46426 jjdelcerro
    this(source, type, editingSession, editMode);
133 44871 jjdelcerro
    this.setValue(VALUE_DELETEDS_FEATURES, deleteds);
134
    this.setValue(VALUE_INSERTEDS_FEATURES, inserteds);
135
    this.setValue(VALUE_UPDATEDS_FEATURES, updateds);
136
    this.setValue(VALUE_CHANGEDS_FEATURETYPES, featureTypesChanged);
137
    this.setValue(VALUE_IS_SELECTION_COMPROMISED, isSelectionCompromised);
138
  }
139 40435 jjdelcerro
140 44871 jjdelcerro
  @Override
141
  public Feature getFeature() {
142
    return (Feature) this.getValue(VALUE_FEATURE);
143
  }
144 40435 jjdelcerro
145 44871 jjdelcerro
  @Override
146 45738 fdiaz
  public String getEditingSession() {
147
    return (String) this.getValue(VALUE_EDITING_SESSION);
148
  }
149
150
  @Override
151
  public int getEditMode() {
152
      try {
153
        return (int) this.getValue(VALUE_EDIT_MODE);
154
      } catch(Exception ex) {
155
          return FeatureStore.MODE_UNKNOWN;
156
      }
157
  }
158
159
  @Override
160 44871 jjdelcerro
  public EditableFeatureType getFeatureType() {
161
    return (EditableFeatureType) this.getValue(VALUE_FEATURETYPE);
162
  }
163 40435 jjdelcerro
164 44871 jjdelcerro
  @Override
165
  public DataSet getCollectionResult() {
166
    return (DataSet) this.getValue(VALUE_COLLECTION_RESULT);
167
  }
168 40435 jjdelcerro
169 44871 jjdelcerro
  @Override
170
  public Exception getExceptionLoading() {
171
    return (Exception) this.getValue(VALUE_EXCEPTION_LOADING);
172
  }
173 40435 jjdelcerro
174 44871 jjdelcerro
  @Override
175
  public boolean loadSucefully() {
176
    return (boolean) this.getValue(VALUE_LOAD_COLLECTION_SUCCESSFULLY);
177
  }
178 40435 jjdelcerro
179 44871 jjdelcerro
  @Override
180
  public Command getCommand() {
181
    return (Command) this.getValue(VALUE_COMMAND);
182
  }
183
184
  @Override
185
  public DataStore getSource() {
186
    return (DataStore) this.getValue(VALUE_SOURCE);
187
  }
188
189
  public FeatureIndex getIndex() {
190
    return (FeatureIndex) this.getValue(VALUE_FEATURE_INDEX);
191
  }
192
193
  @Override
194
  public boolean isSelectionCompromised() {
195
    return (boolean) this.getValue(VALUE_IS_SELECTION_COMPROMISED);
196
  }
197
198
  @Override
199
  public Iterator<FeatureReference> getDeletedsFeatures() {
200
    return (Iterator<FeatureReference>) this.getValue(VALUE_DELETEDS_FEATURES);
201
  }
202
203
  @Override
204
  public Iterator<Feature> getInsertedsFeatures() {
205
    return (Iterator<Feature>) this.getValue(VALUE_INSERTEDS_FEATURES);
206
  }
207
208
  @Override
209
  public Iterator<Feature> getUpdatedsFeatures() {
210
    return (Iterator<Feature>) this.getValue(VALUE_UPDATEDS_FEATURES);
211
  }
212
213
  @Override
214
  public Iterator<FeatureTypeChanged> getChangedsFeatureTypes() {
215
    return (Iterator<FeatureTypeChanged>) this.getValue(VALUE_CHANGEDS_FEATURETYPES);
216
  }
217 46426 jjdelcerro
218
  @Override
219
  public Expression getExpression() {
220
    return (Expression) this.getValue(VALUE_EXPRESSION);
221
  }
222 44871 jjdelcerro
223 40435 jjdelcerro
}