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 @ 46672

History | View | Annotate | Download (7.96 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;
25

    
26
import java.util.Iterator;
27
import org.gvsig.expressionevaluator.Expression;
28
import org.gvsig.fmap.dal.DataSet;
29
import org.gvsig.fmap.dal.DataStore;
30
import org.gvsig.fmap.dal.feature.EditableFeature;
31
import org.gvsig.fmap.dal.feature.EditableFeatureType;
32
import org.gvsig.fmap.dal.feature.Feature;
33
import org.gvsig.fmap.dal.feature.FeatureIndex;
34
import org.gvsig.fmap.dal.feature.FeatureReference;
35
import org.gvsig.fmap.dal.feature.FeatureStore;
36
import org.gvsig.fmap.dal.feature.FeatureStoreNotification;
37
import org.gvsig.fmap.dal.feature.FeatureType;
38
import org.gvsig.fmap.dal.feature.FeatureType.FeatureTypeChanged;
39
import org.gvsig.tools.observer.BaseNotification;
40
import org.gvsig.tools.undo.command.Command;
41

    
42
@SuppressWarnings("OverridableMethodCallInConstructor")
43
public class DefaultFeatureStoreNotification
44
        extends BaseNotification
45
        implements FeatureStoreNotification {
46

    
47
  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
  private static final int VALUE_EDITING_SESSION = 13;
61
  private static final int VALUE_EDIT_MODE = 14;
62
  private static final int VALUE_EXPRESSION = 15;
63

    
64
  private static final int VALUES_COUNT = 16;
65

    
66
  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

    
72
  public DefaultFeatureStoreNotification(DataStore source, String type) {
73
    this(type);
74
    this.setValue(VALUE_SOURCE, source);
75
  }
76

    
77
  public DefaultFeatureStoreNotification(DataStore source, String type, String editingSession) {
78
    this(source, type);
79
    this.setValue(VALUE_EDITING_SESSION, editingSession);
80
  }
81

    
82
  public DefaultFeatureStoreNotification(DataStore source, String type, String editingSession, int editMode) {
83
    this(source, type, editingSession);
84
    this.setValue(VALUE_EDIT_MODE, editMode);
85
  }
86

    
87
  public DefaultFeatureStoreNotification(DataStore source, String type, String editingSession, int editMode, Feature feature) {
88
    this(source, type, editingSession, editMode);
89
    this.setValue(VALUE_FEATURE, feature);
90
  }
91

    
92
  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
    this.setValue(VALUE_COMMAND, command);
100
  }
101

    
102
  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

    
108
  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

    
114
  public DefaultFeatureStoreNotification(DataStore source, String type, String editingSession, int editMode,
115
          EditableFeatureType featureType) {
116
    this(source, type, editingSession, editMode);
117
    this.setValue(VALUE_FEATURETYPE, featureType);
118
  }
119

    
120
  public DefaultFeatureStoreNotification(DataStore source, String type, FeatureIndex index) {
121
    this(source, type);
122
    this.setValue(VALUE_FEATURE_INDEX, index);
123
  }
124

    
125
  DefaultFeatureStoreNotification(DataStore source, String type, String editingSession, int editMode,
126
      Iterator<FeatureReference> deleteds, 
127
      Iterator<EditableFeature> inserteds, 
128
      Iterator<EditableFeature> updateds, 
129
      Iterator<FeatureType.FeatureTypeChanged> featureTypesChanged, 
130
      boolean isSelectionCompromised
131
    ) {
132
    this(source, type, editingSession, editMode);
133
    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

    
140
  @Override
141
  public Feature getFeature() {
142
    return (Feature) this.getValue(VALUE_FEATURE);
143
  }
144

    
145
  @Override
146
  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
  public EditableFeatureType getFeatureType() {
161
    return (EditableFeatureType) this.getValue(VALUE_FEATURETYPE);
162
  }
163

    
164
  @Override
165
  public DataSet getCollectionResult() {
166
    return (DataSet) this.getValue(VALUE_COLLECTION_RESULT);
167
  }
168

    
169
  @Override
170
  public Exception getExceptionLoading() {
171
    return (Exception) this.getValue(VALUE_EXCEPTION_LOADING);
172
  }
173

    
174
  @Override
175
  public boolean loadSucefully() {
176
    return (boolean) this.getValue(VALUE_LOAD_COLLECTION_SUCCESSFULLY);
177
  }
178

    
179
  @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

    
218
  @Override
219
  public Expression getExpression() {
220
    return (Expression) this.getValue(VALUE_EXPRESSION);
221
  }
222
  
223
}