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

History | View | Annotate | Download (7.5 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.fmap.dal.DataSet;
28
import org.gvsig.fmap.dal.DataStore;
29
import org.gvsig.fmap.dal.feature.EditableFeature;
30
import org.gvsig.fmap.dal.feature.EditableFeatureType;
31
import org.gvsig.fmap.dal.feature.Feature;
32
import org.gvsig.fmap.dal.feature.FeatureIndex;
33
import org.gvsig.fmap.dal.feature.FeatureReference;
34
import org.gvsig.fmap.dal.feature.FeatureStore;
35
import org.gvsig.fmap.dal.feature.FeatureStoreNotification;
36
import org.gvsig.fmap.dal.feature.FeatureType;
37
import org.gvsig.fmap.dal.feature.FeatureType.FeatureTypeChanged;
38
import org.gvsig.tools.observer.BaseNotification;
39
import org.gvsig.tools.undo.command.Command;
40

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

    
46
  private static final int VALUE_SOURCE = 0;
47
  private static final int VALUE_FEATURE = 1;
48
  private static final int VALUE_COLLECTION_RESULT = 2;
49
  private static final int VALUE_LOAD_COLLECTION_SUCCESSFULLY = 3;
50
  private static final int VALUE_EXCEPTION_LOADING = 4;
51
  private static final int VALUE_COMMAND = 5;
52
  private static final int VALUE_FEATURE_INDEX = 6;
53
  private static final int VALUE_FEATURETYPE = 7;
54
  private static final int VALUE_CHANGEDS_FEATURETYPES = 8;
55
  private static final int VALUE_UPDATEDS_FEATURES = 9;
56
  private static final int VALUE_INSERTEDS_FEATURES = 10;
57
  private static final int VALUE_DELETEDS_FEATURES = 11;
58
  private static final int VALUE_IS_SELECTION_COMPROMISED = 12;
59
  private static final int VALUE_EDITING_SESSION = 13;
60
  private static final int VALUE_EDIT_MODE = 14;
61

    
62
  private static final int VALUES_COUNT = 15;
63

    
64
  public DefaultFeatureStoreNotification(String type) {
65
    super(type, VALUES_COUNT);
66
    this.setValue(VALUE_LOAD_COLLECTION_SUCCESSFULLY, false);
67
    this.setValue(VALUE_IS_SELECTION_COMPROMISED, false);
68
  }
69

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

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

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

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

    
93
  public DefaultFeatureStoreNotification(DataStore source, String type, Command command) {
94
    this(source, type);
95
    this.setValue(VALUE_SOURCE, source);
96
    this.setValue(VALUE_COMMAND, command);
97
  }
98

    
99
  public DefaultFeatureStoreNotification(DataStore source, String type, Exception exception) {
100
    this(source, type);
101
    this.setValue(VALUE_LOAD_COLLECTION_SUCCESSFULLY, false);
102
    this.setValue(VALUE_EXCEPTION_LOADING, exception);
103
  }
104

    
105
  public DefaultFeatureStoreNotification(DataStore source, String type, DataSet collection) {
106
    this(source, type);
107
    this.setValue(VALUE_LOAD_COLLECTION_SUCCESSFULLY, true);
108
    this.setValue(VALUE_COLLECTION_RESULT, collection);
109
  }
110

    
111
  public DefaultFeatureStoreNotification(DataStore source, String type,
112
          EditableFeatureType featureType) {
113
    this(source, type);
114
    this.setValue(VALUE_FEATURETYPE, featureType);
115
  }
116

    
117
  public DefaultFeatureStoreNotification(DataStore source, String type, FeatureIndex index) {
118
    this(source, type);
119
    this.setValue(VALUE_FEATURE_INDEX, index);
120
  }
121

    
122
  DefaultFeatureStoreNotification(DataStore source, String type, 
123
      String editingSession,
124
      Iterator<FeatureReference> deleteds, 
125
      Iterator<EditableFeature> inserteds, 
126
      Iterator<EditableFeature> updateds, 
127
      Iterator<FeatureType.FeatureTypeChanged> featureTypesChanged, 
128
      boolean isSelectionCompromised
129
    ) {
130
    this(source, type);
131
    this.setValue(VALUE_DELETEDS_FEATURES, deleteds);
132
    this.setValue(VALUE_INSERTEDS_FEATURES, inserteds);
133
    this.setValue(VALUE_UPDATEDS_FEATURES, updateds);
134
    this.setValue(VALUE_CHANGEDS_FEATURETYPES, featureTypesChanged);
135
    this.setValue(VALUE_IS_SELECTION_COMPROMISED, isSelectionCompromised);
136
    this.setValue(VALUE_EDITING_SESSION, editingSession);
137
  }
138

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

    
144
  @Override
145
  public String getEditingSession() {
146
    return (String) this.getValue(VALUE_EDITING_SESSION);
147
  }
148

    
149
  @Override
150
  public int getEditMode() {
151
      try {
152
        return (int) this.getValue(VALUE_EDIT_MODE);
153
      } catch(Exception ex) {
154
          return FeatureStore.MODE_UNKNOWN;
155
      }
156
  }
157

    
158
  @Override
159
  public EditableFeatureType getFeatureType() {
160
    return (EditableFeatureType) this.getValue(VALUE_FEATURETYPE);
161
  }
162

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

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

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

    
178
  @Override
179
  public Command getCommand() {
180
    return (Command) this.getValue(VALUE_COMMAND);
181
  }
182

    
183
  @Override
184
  public DataStore getSource() {
185
    return (DataStore) this.getValue(VALUE_SOURCE);
186
  }
187

    
188
  public FeatureIndex getIndex() {
189
    return (FeatureIndex) this.getValue(VALUE_FEATURE_INDEX);
190
  }
191
  
192
  @Override
193
  public boolean isSelectionCompromised() {
194
    return (boolean) this.getValue(VALUE_IS_SELECTION_COMPROMISED);
195
  }
196

    
197
  @Override
198
  public Iterator<FeatureReference> getDeletedsFeatures() {
199
    return (Iterator<FeatureReference>) this.getValue(VALUE_DELETEDS_FEATURES);
200
  }
201
  
202
  @Override
203
  public Iterator<Feature> getInsertedsFeatures() {
204
    return (Iterator<Feature>) this.getValue(VALUE_INSERTEDS_FEATURES);
205
  }
206
  
207
  @Override
208
  public Iterator<Feature> getUpdatedsFeatures() {
209
    return (Iterator<Feature>) this.getValue(VALUE_UPDATEDS_FEATURES);
210
  }
211
  
212
  @Override
213
  public Iterator<FeatureTypeChanged> getChangedsFeatureTypes() {
214
    return (Iterator<FeatureTypeChanged>) this.getValue(VALUE_CHANGEDS_FEATURETYPES);
215
  }
216
  
217
  
218
}