Revision 44871

View differences:

trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/test/java/org/gvsig/fmap/dal/store/h2/operations/sql/TestPerformChanges.java
9 9
import org.gvsig.fmap.dal.feature.EditableFeatureType;
10 10
import org.gvsig.fmap.dal.feature.FeatureStore;
11 11
import org.gvsig.fmap.dal.feature.FeatureType;
12
import org.gvsig.fmap.dal.feature.spi.FeatureStoreProvider.FeatureTypeChanged;
12
import org.gvsig.fmap.dal.feature.FeatureType.FeatureTypeChanged;
13 13
import org.gvsig.fmap.dal.store.h2.TestUtils;
14 14
import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper;
15 15
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory;
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc/JDBCStoreProviderWriter.java
37 37
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
38 38
import org.gvsig.fmap.dal.feature.FeatureRules;
39 39
import org.gvsig.fmap.dal.feature.FeatureType;
40
import org.gvsig.fmap.dal.feature.FeatureType.FeatureTypeChanged;
40 41
import org.gvsig.fmap.dal.feature.exception.PerformEditingException;
41 42
import org.gvsig.fmap.dal.feature.spi.FeatureProvider;
42 43
import org.gvsig.fmap.dal.feature.spi.FeatureReferenceProviderServices;
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/PerformChangesOperation.java
17 17
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
18 18
import org.gvsig.fmap.dal.feature.FeatureReference;
19 19
import org.gvsig.fmap.dal.feature.FeatureType;
20
import org.gvsig.fmap.dal.feature.FeatureType.FeatureTypeChanged;
20 21
import org.gvsig.fmap.dal.feature.spi.FeatureProvider;
21 22
import org.gvsig.fmap.dal.feature.spi.FeatureReferenceProviderServices;
22 23
import org.gvsig.fmap.dal.feature.spi.FeatureStoreProvider;
......
55 56
            Iterator<FeatureReferenceProviderServices> deleteds,
56 57
            Iterator<FeatureProvider> inserteds,
57 58
            Iterator<FeatureProvider> updateds,
58
            Iterator<FeatureStoreProvider.FeatureTypeChanged> featureTypesChanged) {
59
            Iterator<FeatureTypeChanged> featureTypesChanged) {
59 60
        super(helper);
60 61
        this.deleteds = deleteds;
61 62
        this.inserteds = inserteds;
......
63 64
        this.table = table;
64 65
        this.featureType = featureType;
65 66
        if (featureTypesChanged.hasNext()) {
66
            FeatureStoreProvider.FeatureTypeChanged item = featureTypesChanged.next();
67
            FeatureTypeChanged item = featureTypesChanged.next();
67 68
            this.featureTypeSource = item.getSource();
68 69
            this.featureTypeTarget = item.getTarget();
69 70
            typeChanged = true;
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/main/java/org/gvsig/fmap/dal/DataStoreNotification.java
23 23
 */
24 24
package org.gvsig.fmap.dal;
25 25

  
26
import org.gvsig.tools.observer.Notification;
27

  
26 28
/**
27 29
 * This interface represents a notification produced by a DataStore.
28 30
 * 
......
30 32
 * of constants that represent the types of notifications that a DataStore 
31 33
 * can produce.
32 34
 */
33
public interface DataStoreNotification {
35
public interface DataStoreNotification extends Notification {
34 36

  
35 37
	/** Complex notification for special situations */
36 38
	public static final String COMPLEX_NOTIFICATION = "complex_notification";
......
65 67
	 */
66 68
	public DataStore getSource();
67 69
	
68
	/**
69
	 * Returns the type of this notification, represented by one of the constants defined in this interface.
70
	 * @return a String containing this notification's type
71
	 */
72
	public String getType();
73

  
74 70
}
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/main/java/org/gvsig/fmap/dal/DataManager.java
51 51
import org.gvsig.fmap.dal.expressionevaluator.FeatureAttributeEmulatorExpression;
52 52
import org.gvsig.fmap.dal.feature.DataProfile;
53 53
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor;
54
import org.gvsig.tools.observer.Observer;
54 55
import org.gvsig.tools.resourcesstorage.ResourcesStorage;
55 56

  
56 57
/**
......
90 91
    public static final String DAL_PREFERRED_COLUMNS = "DAL.Preferred.Columns";
91 92
    
92 93
    public static final String DAL_USE_LABELS = "DAL.useLabels";
94

  
93 95
    public static final int USE_LABELS_YES = 0;
94 96
    public static final int USE_LABELS_NO = 1;
95 97
    public static final int USE_LABELS_BOTH = 2;
......
559 561
    public DALExpressionBuilder createDALExpressionBuilder();
560 562
    
561 563
    public boolean isTheOldRasterRegistered();
564
    
565
    public void addStoreObserver(Observer observer);
566
    
567
    public void removeStoreObserver(Observer observer);
568
    
562 569
}
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/main/java/org/gvsig/fmap/dal/feature/FeatureStoreNotification.java
23 23
 */
24 24
package org.gvsig.fmap.dal.feature;
25 25

  
26
import java.util.Iterator;
26 27
import org.gvsig.fmap.dal.DataSet;
27 28
import org.gvsig.fmap.dal.DataStoreNotification;
29
import org.gvsig.fmap.dal.feature.FeatureType.FeatureTypeChanged;
28 30
import org.gvsig.tools.undo.command.Command;
29 31

  
30 32
public interface FeatureStoreNotification extends DataStoreNotification {
......
65 67
	public static final String AFTER_INSERT = "after_Insert_Feature";
66 68

  
67 69
	public static final String LOAD_FINISHED = "Load_Finished";
70
  
68 71
	public static final String TRANSFORM_CHANGE = "Transform_Change";
69 72

  
70 73
    /**
......
100 103
	public Command getCommand();
101 104

  
102 105
	public EditableFeatureType getFeatureType();
106
  
107
  public boolean isSelectionCompromised();
108

  
109
  public Iterator<FeatureReference> getDeletedsFeatures();
110
  
111
  public Iterator<Feature> getInsertedsFeatures();
112
  
113
  public Iterator<Feature> getUpdatedsFeatures();
114
  
115
  public Iterator<FeatureTypeChanged> getChangedsFeatureTypes();
116
  
103 117
}
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/main/java/org/gvsig/fmap/dal/feature/FeatureCache.java
54 54
	 * Add a set of features contained in a envelope for a concrete scale.
55 55
	 * @param featureSet
56 56
	 * The feature set retrieved from the server.
57
   * @param featureStore
57 58
	 * @throws DataException
58 59
	 */
59 60
	public void addFeatures(FeatureSet featureSet, FeatureStore featureStore) throws DataException;
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/main/java/org/gvsig/fmap/dal/feature/FeatureRule.java
24 24
package org.gvsig.fmap.dal.feature;
25 25

  
26 26
import org.gvsig.fmap.dal.exception.DataException;
27
import org.gvsig.tools.persistence.Persistent;
27 28

  
28 29
/**
29 30
 * Represents a Feature validation rule. These rules are used to 
......
35 36
 * del store.
36 37
 *
37 38
 */
38
public interface FeatureRule {
39
public interface FeatureRule extends Persistent{
39 40
	
40 41
	/**
41 42
	 * Returns the rule name
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/main/java/org/gvsig/fmap/dal/feature/FeatureType.java
80 80
 * </ul>
81 81
 */
82 82
public interface FeatureType extends DynClass, DynStruct_v2, UnmodifiableBasicList<FeatureAttributeDescriptor> {
83
	
84
    public interface FeatureTypeChanged {
85
      FeatureType getSource();
83 86

  
87
      FeatureType getTarget();
88
    }
89

  
84 90
    public static final Predicate<FeatureAttributeDescriptor> BASIC_TYPES_FILTER = new Predicate<FeatureAttributeDescriptor>() {
85 91
        @Override
86 92
        public boolean test(FeatureAttributeDescriptor attrdesc) {
......
96 102
            return true;
97 103
        }
98 104
    };
105
    
99 106
    /**
100 107
     * Returns a new copy of this FeatureType
101 108
     *
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/main/java/org/gvsig/fmap/dal/feature/rule/CheckMandatoryAttributesRule.java
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.rule;
25

  
26
import org.gvsig.fmap.dal.feature.FeatureRule;
27

  
28

  
29

  
30
/**
31
 * 
32
 * Empty interface to tag the FeatureRule that check the
33
 * compliance of mandatory attributes. This is used to
34
 * check if there is already a rule that checks this
35
 * in a certain feature type.
36
 * 
37
 * @author jldominguez
38
 *
39
 */
40
public interface CheckMandatoryAttributesRule extends FeatureRule {
41

  
42
}
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/main/java/org/gvsig/fmap/dal/feature/rule/FeatureRulePolygon.java
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.rule;
25

  
26
import org.gvsig.fmap.dal.exception.DataException;
27
import org.gvsig.fmap.dal.feature.AbstractFeatureRule;
28
import org.gvsig.fmap.dal.feature.EditableFeature;
29
import org.gvsig.fmap.dal.feature.Feature;
30
import org.gvsig.fmap.dal.feature.FeatureStore;
31
import org.gvsig.fmap.geom.Geometry;
32
import org.gvsig.fmap.geom.GeometryLocator;
33
import org.gvsig.fmap.geom.GeometryManager;
34
import org.gvsig.fmap.geom.Geometry.SUBTYPES;
35
import org.gvsig.fmap.geom.Geometry.TYPES;
36
import org.gvsig.fmap.geom.primitive.GeneralPathX;
37
import org.gvsig.fmap.geom.primitive.Surface;
38

  
39

  
40
public class FeatureRulePolygon extends AbstractFeatureRule {
41
	private static GeometryManager geomManager = GeometryLocator.getGeometryManager();
42
	
43
	public FeatureRulePolygon() {
44
		super("RulePolygon", "Ensure orientation of geometry");
45
	}
46

  
47
	public void validate(Feature feature, FeatureStore store)
48
			throws DataException {
49

  
50
        try {
51
			Geometry geom = feature.getDefaultGeometry();
52
			GeneralPathX gp = new GeneralPathX();
53
			gp.append(geom.getPathIterator(null, geomManager.getFlatness()), true);
54

  
55
			if (gp.isClosed()) {
56
				if (gp.isCCW()) {
57
					gp.flip();
58
					GeometryManager geomManager = GeometryLocator.getGeometryManager();
59
					Surface surface = (Surface)geomManager.create(TYPES.SURFACE, SUBTYPES.GEOM2D);
60
					surface.setGeneralPath(gp);
61
					geom = surface;
62
	        		EditableFeature editable = feature.getEditable();
63
					editable.setDefaultGeometry(geom);
64
					store.update(editable);
65
				}
66
	        }
67
		} catch (Exception e) {
68
			throw new FeatureRulePolygonException(e, store.getName());
69
		}
70
	}
71

  
72
	public class FeatureRulePolygonException extends DataException {
73

  
74
		/**
75
		 *
76
		 */
77
		private static final long serialVersionUID = -3014970171661713021L;
78
		private final static String MESSAGE_FORMAT = "Can't apply rule  in store %(store)s.";
79
		private final static String MESSAGE_KEY = "_FeatureRulePolygonException";
80

  
81
		public FeatureRulePolygonException(Throwable cause, String store) {
82
			super(MESSAGE_FORMAT, cause, MESSAGE_KEY, serialVersionUID);
83
			this.setValue("store", store);
84
		}
85
	}
86

  
87
}
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/main/java/org/gvsig/fmap/dal/feature/FeatureRuleExpression.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2020 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;
25

  
26
import org.gvsig.expressionevaluator.Expression;
27

  
28
public interface FeatureRuleExpression extends FeatureRule {
29
	
30
	public void setCheckAtUpdate(boolean checkAtUpdate);
31

  
32
  public void setCheckAtFinishEditing(boolean checkAtFinishEditing);
33
  
34
  public Expression getExpression();
35
  
36
  public void setExpression(Expression expression);
37
}
0 38

  
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/main/java/org/gvsig/fmap/dal/feature/FeatureRules.java
24 24
package org.gvsig.fmap.dal.feature;
25 25

  
26 26
import java.util.Iterator;
27
import org.gvsig.expressionevaluator.Expression;
28
import org.gvsig.tools.persistence.Persistent;
27 29

  
28 30
/**
29 31
 * This is a container for FeatureRules.
......
32 34
 * the whole structure.
33 35
 *
34 36
 */
35
public interface FeatureRules extends Iterable<FeatureRule> {
37
public interface FeatureRules extends Iterable<FeatureRule>, Persistent {
36 38

  
37 39
	/**
38 40
	 * Returns an object given its index.
......
42 44
	 * @return
43 45
	 * 		the object found in the given index
44 46
	 */
45
	public Object get(int index);
47
	public FeatureRule get(int index);
46 48

  
47 49
	/**
48 50
	 * Returns a {@link FeatureRule} given its index.
......
65 67
	 */
66 68
	public boolean add(FeatureRule rule);
67 69

  
70
  public boolean add(String name, String description, boolean checkAtUpdate,
71
			boolean checkAtFinishEdition, Expression expression);
72
  
68 73
	/**
69 74
	 * Returns the number of rules contained in this FeatureRules.
70 75
	 * 
......
73 78
	 */
74 79
	public int size();
75 80

  
76
    public boolean isEmpty();
81
  public boolean isEmpty();
77 82
    
78 83
	/**
79 84
	 * Clears this FeatureRules from any rules.
......
88 93
	 * @return
89 94
	 * 		returns the removed rule
90 95
	 */
91
	public Object remove(int index);
96
	public FeatureRule remove(int index);
92 97

  
93 98
	/**
94 99
	 * Removes the given rule from this FeatureRules.
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.spi/src/main/java/org/gvsig/fmap/dal/feature/spi/FeatureStoreProvider.java
69 69
	public int getOIDType();
70 70

  
71 71
	/**
72
	 * Factory of {@link FeatureProvider}. Create a new {@link FeatureProvider} instance
73
	 * valid for this Store.
72
	 * Factory of {@link FeatureProvider}. 
73
   * Create a new {@link FeatureProvider} instance valid for this Store.
74 74
	 *
75
	 * @param {@link FeatureType} of the {@link FeatureProvider}
75
	 * @param type, {@link FeatureType} of the {@link FeatureProvider}
76 76
	 * @return
77 77
	 * @throws DataException
78 78
	 */
......
131 131
	 * as {@link FeatureType}
132 132
	 *
133 133
	 * @param reference
134
   * @param featureType
134 135
	 * @return
135 136
	 * @throws DataException
136 137
	 */
......
140 141
	/**
141 142
	 * Informs that store supports write.
142 143
	 *
143
	 * @return <true> if write is supported
144
	 * @return true if write is supported
144 145
	 */
145 146
	public boolean allowWrite();
146 147

  
......
154 155
	 */
155 156
	public boolean canWriteGeometry(int geometryType, int geometrySubType) throws DataException;
156 157

  
157

  
158
	public interface FeatureTypeChanged {
159
		FeatureType getSource();
160

  
161
		FeatureType getTarget();
162
	}
163

  
164 158
	/**
165 159
	 * Perform changes on store.
166 160
	 *
......
182 176
	 *
183 177
	 * @return this store's total envelope (extent) or <code>null</code> if
184 178
	 *         store not have geometry information
179
   * @throws org.gvsig.fmap.dal.exception.DataException
185 180
	 */
186 181
	public Envelope getEnvelope() throws DataException;
187 182

  
......
231 226
	 * the {@link FeatureStoreProvider#getEnvelope()} method doesn't return
232 227
	 * the full envelope.
233 228
	 * 
234
	 * @return
235
	 * <true> if it knows the real envelope.
229
	 * @return true if it knows the real envelope.
236 230
	 */
237 231
	public boolean isKnownEnvelope(); 
238 232
	
......
240 234
	 * Return if the maximum number of features provided by the
241 235
	 * provider are limited.
242 236
	 * 
243
	 * @return
244
	 * <true> if there is a limit of features.
237
	 * @return true if there is a limit of features.
245 238
	 */
246 239
	public boolean hasRetrievedFeaturesLimit();
247 240
	
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.spi/src/main/java/org/gvsig/fmap/dal/feature/spi/FeatureStoreProviderServices.java
50 50
	 * Call this to send a notification to observers of this store
51 51
	 *
52 52
	 * @param notification
53
   * @return 
53 54
	 */
54
	public void notifyChange(String notification);
55
	public FeatureStoreNotification notifyChange(String notification);
55 56

  
56 57
	/**
57 58
	 * Call this to send a notification to observers of this store
58 59
	 * 
59 60
	 * @param notification
61
   * @param data
62
   * @return 
60 63
	 */
61
	public void notifyChange(String notification, FeatureProvider data);
64
	public FeatureStoreNotification notifyChange(String notification, FeatureProvider data);
62 65

  
63 66
	/**
64 67
	 * Call this to send a notification to observers of this store
65 68
	 * 
66
	 * @param notification
69
   * @param storeNotification
70
   * @return 
67 71
	 */
68
	public void notifyChange(FeatureStoreNotification storeNotification);
72
	public FeatureStoreNotification notifyChange(FeatureStoreNotification storeNotification);
69 73

  
70 74
	/**
71 75
	 * Call this to send a notification to observers of this store relative to
72 76
	 * Resources
73 77
	 * 
74 78
	 * @param notification
79
   * @param resource
80
   * @return 
75 81
	 */
76
	public void notifyChange(String notification, Resource resource);
82
	public FeatureStoreNotification notifyChange(String notification, Resource resource);
77 83

  
78 84
	/**
79 85
	 * Create a new instance of default implementation of a
......
88 94
	/**
89 95
	 * Create a new instance of default implementation of a {@link FeatureProvider}
90 96
	 *
97
   * @param type
91 98
	 * @return new {@link FeatureProvider}
92 99
	 * @throws DataException
93 100
	 */
......
100 107
	 * <strong>Note:</strong> <code>defaultType</code> must be in
101 108
	 * <code>types</code>
102 109
	 *
103
	 * @param list
104
	 *            of all {@link FeatureType} available
105
	 * @param {@link FeatureType} used in
106
	 *        {@link FeatureStore#getDefaultFeatureType()}
110
	 * @param types, list of all {@link FeatureType} available
111
   * @param defaultType, {@link FeatureType} used in {@link FeatureStore#getDefaultFeatureType()}
107 112
	 */
108 113
	public void setFeatureTypes(List types, FeatureType defaultType);
109 114

  
......
139 144
	public EditableFeatureType createFeatureType();
140 145

  
141 146
	/**
142
	 * Creates a new instance of EditableFeatureType. Uses 'id' as identifier.
147
	 * Creates a new instance of EditableFeatureType.Uses 'id' as identifier.
143 148
	 *
149
   * @param id
144 150
	 * @return
145 151
	 */
146 152
	public EditableFeatureType createFeatureType(String id);
......
156 162
	/**
157 163
	 * Return original {@link FeatureType} of {@link FeatureStoreProvider}.
158 164
	 *
159
	 * @param id
160
	 *            of the {@link FeatureType}
165
	 * @param featureTypeId, of the {@link FeatureType}
161 166
	 * @return
162
	 * @throws DataException
163 167
	 */
164 168
	public FeatureType getProviderFeatureType(String featureTypeId);
165 169

  
......
189 193
	 * Return default {@link FeatureType} of the store
190 194
	 *
191 195
	 * @return
196
   * @throws org.gvsig.fmap.dal.exception.DataException
192 197
	 */
193 198
	public FeatureType getDefaultFeatureType() throws DataException;
194 199
        
195
        public List getFeatureTypes() throws DataException;
200
  public List getFeatureTypes() throws DataException;
196 201

  
197 202
}
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.dbf/src/main/java/org/gvsig/fmap/dal/store/dbf/DBFStoreProvider.java
25 25
import java.io.File;
26 26
import java.io.IOException;
27 27
import java.math.BigDecimal;
28
import java.math.MathContext;
29
import java.math.RoundingMode;
30 28
import java.nio.charset.Charset;
31
import java.text.SimpleDateFormat;
32 29
import java.util.ArrayList;
33
import java.util.Date;
34 30
import java.util.Iterator;
35 31
import java.util.List;
36 32

  
......
58 54
import org.gvsig.fmap.dal.feature.FeatureSet;
59 55
import org.gvsig.fmap.dal.feature.FeatureStore;
60 56
import org.gvsig.fmap.dal.feature.FeatureType;
57
import org.gvsig.fmap.dal.feature.FeatureType.FeatureTypeChanged;
61 58
import org.gvsig.fmap.dal.feature.exception.AttributeNameException;
62 59
import org.gvsig.fmap.dal.feature.exception.AttributeNameTooLongException;
63 60
import org.gvsig.fmap.dal.feature.exception.PerformEditingException;
......
91 88

  
92 89
import org.slf4j.Logger;
93 90
import org.slf4j.LoggerFactory;
94
import org.gvsig.tools.dataTypes.CoercionContextDecimal;
95 91

  
96 92
public class DBFStoreProvider extends AbstractFeatureStoreProvider implements
97 93
        ResourceConsumer {
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/expressionevaluator/impl/DefaultFeatureRuleExpression.java
1
package org.gvsig.expressionevaluator.impl;
2

  
3
import org.gvsig.expressionevaluator.Expression;
4
import org.gvsig.expressionevaluator.impl.symboltable.FeatureSymbolTableImpl;
5
import org.gvsig.fmap.dal.exception.DataException;
6
import org.gvsig.fmap.dal.expressionevaluator.FeatureSymbolTable;
7
import org.gvsig.fmap.dal.feature.AbstractFeatureRule;
8
import org.gvsig.fmap.dal.feature.Feature;
9
import org.gvsig.fmap.dal.feature.FeatureRuleExpression;
10
import org.gvsig.fmap.dal.feature.FeatureStore;
11
import org.gvsig.fmap.dal.feature.exception.ValidateFeaturesException;
12
import org.gvsig.tools.dataTypes.DataTypeUtils;
13
import org.gvsig.tools.persistence.PersistentState;
14
import org.gvsig.tools.persistence.exception.PersistenceException;
15

  
16
/**
17
 *
18
 * @author gvSIG team
19
 */
20
public class DefaultFeatureRuleExpression 
21
        extends AbstractFeatureRule 
22
        implements FeatureRuleExpression
23
  {
24

  
25
  private Expression expression;
26
  private FeatureSymbolTable symbolTable;
27

  
28
  public DefaultFeatureRuleExpression(String name, String description, boolean checkAtUpdate,
29
			boolean checkAtFinishEdition, Expression expression) {
30
    super(name, description, checkAtUpdate, checkAtFinishEdition);
31
    this.expression = expression;
32
    this.symbolTable = new FeatureSymbolTableImpl();
33
  }
34
  
35
  @Override
36
  public void validate(Feature feature, FeatureStore featureStore) throws DataException {
37
    this.symbolTable.setFeature(feature);
38
    Object value = this.expression.execute(symbolTable);
39
    boolean ok = false;
40
    if( value!=null ) {
41
      if( value instanceof Boolean ) {
42
        ok = (Boolean)value;
43
      } else {
44
        ok = DataTypeUtils.toBoolean(value, false);
45
      }
46
    }
47
    if( ok ) {
48
      return;
49
    }
50
    throw new ValidateFeaturesException(null, featureStore.getName());
51
  }
52
  
53
  public static void selfRegister() {
54
    
55
  }
56

  
57
  @Override
58
  public void loadFromState(PersistentState state) throws PersistenceException {
59
    this.name = state.getString("name");
60
    this.description = state.getString("description");
61
    this.checkAtFinishEdition = state.getBoolean("checkAtFinishEdition");
62
    this.checkAtUpdate = state.getBoolean("checkAtUpdate");
63
    this.expression = (Expression) state.get("expression");
64
    this.symbolTable = new FeatureSymbolTableImpl();
65
  }
66

  
67
  @Override
68
  public void saveToState(PersistentState state) throws PersistenceException {
69
    state.set("name", this.name);
70
    state.set("description", this.description);
71
    state.set("checkAtFinishEdition", this.checkAtFinishEdition);
72
    state.set("checkAtUpdate", this.checkAtUpdate);
73
    state.set("expression", this.expression);
74
  }
75

  
76
  @Override
77
  public void setCheckAtUpdate(boolean checkAtUpdate) {
78
    this.checkAtUpdate = checkAtUpdate;
79
  }
80

  
81
  @Override
82
  public void setCheckAtFinishEditing(boolean checkAtFinishEditing) {
83
    this.checkAtFinishEdition = checkAtFinishEditing;
84
  }
85

  
86
  @Override
87
  public Expression getExpression() {
88
    return this.expression;
89
  }
90

  
91
  @Override
92
  public void setExpression(Expression expression) {
93
    this.expression = expression;
94
  }
95
  
96
}
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/raster/impl/DefaultCoverageStoreNotification.java
26 26

  
27 27
import org.gvsig.fmap.dal.DataStore;
28 28
import org.gvsig.fmap.dal.DataStoreNotification;
29
import org.gvsig.tools.observer.BaseNotification;
29 30
import org.gvsig.tools.undo.command.Command;
30 31

  
31
public class DefaultCoverageStoreNotification implements DataStoreNotification {
32
public class DefaultCoverageStoreNotification 
33
        extends BaseNotification
34
        implements DataStoreNotification 
35
  {
32 36

  
33 37
	public DefaultCoverageStoreNotification(
34
			DefaultCoverageStore defaultCoverageStore, String notification,
35
			Command command) {
36
		// TODO Auto-generated constructor stub
38
			DefaultCoverageStore defaultCoverageStore, String notification) {
39
    super(notification, 2);
40
    this.setValue(0, defaultCoverageStore);
37 41
	}
38 42

  
39 43
	public DefaultCoverageStoreNotification(
40
			DefaultCoverageStore defaultCoverageStore, String notification) {
41
		// TODO Auto-generated constructor stub
44
			DefaultCoverageStore defaultCoverageStore, String notification,
45
			Command command) {
46
    this(defaultCoverageStore, notification);
47
    this.setValue(1, command);
42 48
	}
43 49

  
50
  @Override
44 51
	public DataStore getSource() {
45
		// TODO Auto-generated method stub
46
		return null;
52
		return (DataStore) this.getValue(0);
47 53
	}
48 54

  
49
	public String getType() {
50
		// TODO Auto-generated method stub
51
		return null;
52
	}
53 55

  
54 56
}
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/raster/impl/DefaultRasterStoreNotification.java
24 24

  
25 25
import org.gvsig.fmap.dal.DataStore;
26 26
import org.gvsig.fmap.dal.raster.RasterStoreNotification;
27
import org.gvsig.tools.observer.BaseNotification;
27 28

  
28 29
/**
29 30
 * Implements RasterNofication
30 31
 * @author dmartinezizquierdo
31 32
 *
32 33
 */
33
public class DefaultRasterStoreNotification implements RasterStoreNotification{
34
public class DefaultRasterStoreNotification 
35
        extends BaseNotification
36
        implements RasterStoreNotification 
37
  {
34 38

  
35
    private String type;
36
    private DataStore source;
37

  
38
    protected void init(DataStore source, String type) {
39
        this.source = source;
40
        this.type = type;
41
    }
42

  
43 39
    /**
44 40
     * @param source
45 41
     * @param type
46 42
     */
47 43
    public DefaultRasterStoreNotification(DataStore source, String type) {
48
        this.init(source, type);
44
        super(type, 1);
45
        this.setValue(0, source);
49 46
    }
50 47

  
51 48
    @Override
52 49
    public DataStore getSource() {
53
        return source;
50
        return (DataStore) this.getValue(0);
54 51
    }
55 52

  
56
    @Override
57
    public String getType() {
58
        return type;
59
    }
60 53
}
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/impl/DefaultDataManager.java
7 7
import java.util.ArrayList;
8 8
import java.util.Collections;
9 9
import java.util.HashMap;
10
import java.util.HashSet;
10 11
import java.util.List;
11 12
import java.util.Map;
12 13
import java.util.Objects;
14
import java.util.Set;
13 15
import java.util.UUID;
14 16
import org.apache.commons.io.IOUtils;
15 17
import org.apache.commons.lang3.StringUtils;
......
30 32
import org.gvsig.fmap.dal.DataServerExplorerPool;
31 33
import org.gvsig.fmap.dal.DataStore;
32 34
import org.gvsig.fmap.dal.DataStoreFactory_v2_4;
35
import org.gvsig.fmap.dal.DataStoreNotification;
33 36
import org.gvsig.fmap.dal.DataStoreParameters;
34 37
import org.gvsig.fmap.dal.DataStoreProviderFactory;
35 38
import org.gvsig.fmap.dal.DataTypes;
......
105 108
import org.slf4j.Logger;
106 109
import org.slf4j.LoggerFactory;
107 110
import org.gvsig.fmap.dal.DatabaseWorkspaceManager.DatabaseWorkspaceListener;
111
import org.gvsig.fmap.dal.feature.FeatureStoreNotification;
112
import org.gvsig.tools.observer.Observer;
108 113

  
109 114
@SuppressWarnings("UseSpecificCatch")
110 115
public class DefaultDataManager
......
166 171
    private final Map<String, DatabaseWorkspaceManager> databaseWorkspaces = new HashMap<>();
167 172
 
168 173
    private final Map<String,DatabaseWorkspaceListener> addDatabaseWorkspaceListeners = new HashMap<>();
174

  
175
    private final Set<Observer>storeObservers = new HashSet<>();
169 176
    
170 177
    public DefaultDataManager() {
171 178
        this.registers = new Registers();
......
532 539
        DataStoreProvider provider = (DataStoreProvider) providerFactory.create(parameters, store);
533 540

  
534 541
        storeFactory.setProvider(store, provider);
542
        
543
        for (Observer storeObserver : storeObservers) {
544
          if( storeObserver!=null) {
545
            store.addObserver(storeObserver);
546
          }
547
        }
548
        if( store instanceof FeatureStoreProviderServices ) {
549
          ((FeatureStoreProviderServices) store).notifyChange(DataStoreNotification.AFTER_OPEN);
550
        }
535 551
        return store;
536 552
    }
537 553

  
554
    @Override
538 555
    public DataStore openStore(DataStoreParameters parameters, DataStoreProvider provider) {
539 556
        String storeName = this.getStoreName(parameters);
540 557
        if( StringUtils.isEmpty(storeName) ) {
......
551 568
        }
552 569
        DataStore store = (DataStore) storeFactory.create(parameters, this);
553 570
        storeFactory.setProvider(store, provider);
571
        for (Observer storeObserver : storeObservers) {
572
          if( storeObserver!=null) {
573
            store.addObserver(storeObserver);
574
          }
575
        }
576
        if( store instanceof FeatureStoreProviderServices ) {
577
          ((FeatureStoreProviderServices) store).notifyChange(DataStoreNotification.AFTER_OPEN);
578
        }
554 579
        return store;
555 580
    }
556 581
    
......
1298 1323
    return new DefaultDALExpressionBuilder();
1299 1324
  }
1300 1325

  
1326
  @Override
1327
  public void addStoreObserver(Observer observer) {
1328
    this.storeObservers.add(observer);
1329
  }
1330

  
1331
  @Override
1332
  public void removeStoreObserver(Observer observer) {
1333
    this.storeObservers.remove(observer);
1334
  }
1335
  
1301 1336
}
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/DefaultFeatureRules.java
24 24
package org.gvsig.fmap.dal.feature.impl;
25 25

  
26 26
import java.util.ArrayList;
27
import java.util.Iterator;
28
import org.gvsig.expressionevaluator.Expression;
29
import org.gvsig.expressionevaluator.impl.DefaultFeatureRuleExpression;
27 30

  
28 31
import org.gvsig.fmap.dal.exception.DataException;
29 32
import org.gvsig.fmap.dal.feature.Feature;
30 33
import org.gvsig.fmap.dal.feature.FeatureRule;
31 34
import org.gvsig.fmap.dal.feature.FeatureRules;
32 35
import org.gvsig.fmap.dal.feature.FeatureStore;
36
import org.gvsig.tools.persistence.PersistentState;
37
import org.gvsig.tools.persistence.exception.PersistenceException;
33 38
import org.slf4j.Logger;
34 39
import org.slf4j.LoggerFactory;
35 40

  
36 41
public class DefaultFeatureRules extends ArrayList<FeatureRule> implements FeatureRules {
37
        
38
        private final static Logger logger = LoggerFactory.getLogger(DefaultFeatureRules.class);
39
        
40
	/**
41
	 *
42
	 */
43
	private static final long serialVersionUID = -8084546505498274121L;
44 42

  
45
        @Override
46
	public boolean add(FeatureRule rule) {
47
		return super.add(rule);
48
	}
43
  private final static Logger LOGGER = LoggerFactory.getLogger(DefaultFeatureRules.class);
49 44

  
50
        @Override
51
	public FeatureRule getRule(int index) {
52
		return (FeatureRule) super.get(index);
53
	}
45
  /**
46
   *
47
   */
48
  private static final long serialVersionUID = -8084546505498274121L;
54 49

  
55
        @Override
56
	public boolean remove(FeatureRule rule) {
57
		return super.remove(rule);
58
	}
50
  @Override
51
  public boolean add(FeatureRule rule) {
52
    return super.add(rule);
53
  }
59 54

  
60
        @Override
61
	public FeatureRules getCopy() {
62
		DefaultFeatureRules copy = new DefaultFeatureRules();
63
		copy.addAll(this);
64
		return copy;
65
	}
55
  @Override
56
  public boolean add(String name, String description, boolean checkAtUpdate, boolean checkAtFinishEdition, Expression expression) {
57
    FeatureRule rule = new DefaultFeatureRuleExpression(name, description, checkAtUpdate, checkAtFinishEdition, expression);
58
    return this.add(rule);
59
  }
66 60

  
67
        /**
68
         * @deprecated use validate(Feature feature, int mode)
69
         * @param feature
70
         * @throws DataException 
71
         */
72
	public void validate(Feature feature) throws DataException {
73
            logger.warn("Calling deprecated method validate without mode.");
74
            FeatureStore store = ((DefaultFeature)feature).getStore();
75
            for( FeatureRule rule : this ) {
76
                rule.validate(feature, store);
77
            }
61
  @Override
62
  public FeatureRule getRule(int index) {
63
    return (FeatureRule) super.get(index);
64
  }
78 65

  
79
	}
66
  @Override
67
  public boolean remove(FeatureRule rule) {
68
    return super.remove(rule);
69
  }
80 70

  
81
	public void validate(Feature feature, int mode) throws DataException {
82
            FeatureStore store = ((DefaultFeature)feature).getStore();
83
            for( FeatureRule rule : this ) {
84
                if( rule.checkAtFinishEditing() && mode == Feature.FINISH_EDITING ) {
85
                    rule.validate(feature, store);
86
                }
87
                if( rule.checkAtUpdate() && mode == Feature.UPDATE ) {
88
                    rule.validate(feature, store);
89
                }
90
            }
71
  @Override
72
  public FeatureRules getCopy() {
73
    DefaultFeatureRules copy = new DefaultFeatureRules();
74
    copy.addAll(this);
75
    return copy;
76
  }
91 77

  
92
	}
78
//        /**
79
//         * @deprecated use validate(Feature feature, int mode)
80
//         * @param feature
81
//         * @throws DataException 
82
//         */
83
//	public void validate(Feature feature) throws DataException {
84
//            logger.warn("Calling deprecated method validate without mode.");
85
//            FeatureStore store = ((DefaultFeature)feature).getStore();
86
//            for( FeatureRule rule : this ) {
87
//                rule.validate(feature, store);
88
//            }
89
//
90
//	}
91
  public void validate(Feature feature, int mode) throws DataException {
92
    FeatureStore store = ((DefaultFeature) feature).getStore();
93
    for (FeatureRule rule : this) {
94
      if (rule.checkAtFinishEditing() && mode == Feature.FINISH_EDITING) {
95
        rule.validate(feature, store);
96
      }
97
      if (rule.checkAtUpdate() && mode == Feature.UPDATE) {
98
        rule.validate(feature, store);
99
      }
100
    }
93 101

  
102
  }
94 103

  
104
  public static void selfRegister() {
105
    
106
  }
95 107

  
108
  @Override
109
  public void saveToState(PersistentState state) throws PersistenceException {
110
    state.set("rules", this.iterator());
111
  }
96 112

  
113
  @Override
114
  public void loadFromState(PersistentState state) throws PersistenceException {
115
    this.clear();
116
    Iterator<FeatureRule> it = state.getIterator("rules");
117
    while (it.hasNext()) {
118
      FeatureRule rule = it.next();
119
      this.add(rule);
120
    }
121
  }
122
  
97 123
}
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/DefaultFeatureStore.java
94 94
import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters;
95 95
import org.gvsig.fmap.dal.feature.FeatureStoreTimeSupport;
96 96
import org.gvsig.fmap.dal.feature.FeatureStoreTransform;
97
import org.gvsig.fmap.dal.feature.FeatureType.FeatureTypeChanged;
97 98
import org.gvsig.fmap.dal.feature.exception.AlreadyEditingException;
98 99
import org.gvsig.fmap.dal.feature.exception.ConcurrentDataModificationException;
99 100
import org.gvsig.fmap.dal.feature.exception.CreateFeatureException;
......
368 369
                LOGGER.warn("Opening a store in editing/append mode ("+this.getFullName()+").",ex);
369 370
            }
370 371
        }
371
        this.notifyChange(DataStoreNotification.BEFORE_OPEN);
372
        if( this.notifyChange(DataStoreNotification.BEFORE_OPEN).isCanceled() ) {
373
          return;
374
        }
372 375
        this.provider.open();
373 376
        this.notifyChange(DataStoreNotification.AFTER_OPEN);
374 377
    }
......
378 381
        if (this.mode != MODE_QUERY) {
379 382
            throw new IllegalStateException();
380 383
        }
381
        this.notifyChange(FeatureStoreNotification.BEFORE_REFRESH);
384
        if( this.notifyChange(FeatureStoreNotification.BEFORE_REFRESH).isCanceled() ) {
385
          return;
386
        }
382 387
        if( state.isBroken() ) {
383 388
            this.load(state);
384 389
        } else {
......
397 402
                LOGGER.warn("Clossing a store in editing/append mode ("+this.getFullName()+").",ex);
398 403
            }
399 404
        }
400
        this.notifyChange(DataStoreNotification.BEFORE_CLOSE);
405
        if( this.notifyChange(DataStoreNotification.BEFORE_CLOSE).isCanceled() ) {
406
          return;
407
        }
401 408
        this.featureCount = null;
402 409
        this.provider.close();
403 410
        this.notifyChange(DataStoreNotification.AFTER_CLOSE);
......
413 420
                LOGGER.warn("Dispossing a store in editing/append mode ("+this.getFullName()+").",ex);
414 421
            }
415 422
        }
416
        this.notifyChange(DataStoreNotification.BEFORE_DISPOSE);
423
        if( this.notifyChange(DataStoreNotification.BEFORE_DISPOSE).isCanceled() ) {
424
          return;
425
        }
417 426
        this.disposeIndexes();
418 427
        if( this.provider!=null ) {
419 428
            this.provider.dispose();
......
898 907
    //
899 908

  
900 909
    @Override
901
    public void notifyChange(FeatureStoreNotification storeNotification) {
902
        try {
903
            delegateObservable.notifyObservers(storeNotification);
904
        } catch (Throwable ex) {
905
            LOGGER.warn("Problems notifying changes in the store '"+this.getName()+" ("+storeNotification.getType()+").",ex);
910
    public FeatureStoreNotification notifyChange(FeatureStoreNotification storeNotification) {
911
        if (delegateObservable != null) {
912
          try {
913
              delegateObservable.notifyObservers(storeNotification);
914
          } catch (Throwable ex) {
915
              LOGGER.warn("Problems notifying changes in the store '"+this.getName()+" ("+storeNotification.getType()+").",ex);
916
          }
906 917
        }
918
        return storeNotification;
907 919
    }
908 920

  
909 921
    @Override
910
    public void notifyChange(String notification) {
911
        if (delegateObservable != null) {
912
            notifyChange(new DefaultFeatureStoreNotification(this, notification));
913
        }
914

  
922
    public FeatureStoreNotification notifyChange(String notification) {
923
      return notifyChange(new DefaultFeatureStoreNotification(this, notification));
915 924
    }
925
    
926
    public FeatureStoreNotification notifyChange(String notification,
927
      Iterator<FeatureReference> deleteds, 
928
      Iterator<Feature> inserteds, 
929
      Iterator<Feature> updateds, 
930
      Iterator<FeatureTypeChanged> featureTypesChanged, 
931
      boolean isSelectionCompromised) {
932
        return notifyChange(new DefaultFeatureStoreNotification(this, notification,
933
            deleteds, inserteds, updateds, featureTypesChanged, isSelectionCompromised));
934
    }
916 935

  
917 936
    @Override
918
    public void notifyChange(String notification, FeatureProvider data) {
937
    public FeatureStoreNotification notifyChange(String notification, FeatureProvider data) {
919 938
        Feature f = null;
920
        try {
921
            f = createFeature(data);
922
        } catch (Throwable ex) {
923
            LOGGER.warn("Problems creating a feature to notifying changes in the store '"+this.getName()+" ("+notification+").",ex);
939
        if( data !=null ) {
940
          try {
941
              f = createFeature(data);
942
          } catch (Throwable ex) {
943
              LOGGER.warn("Problems creating a feature to notifying changes in the store '"+this.getName()+" ("+notification+").",ex);
944
          }
924 945
        }
925
        notifyChange(notification, f);
946
        return notifyChange(notification, f);
926 947
    }
927 948

  
928
    public void notifyChange(String notification, Feature feature) {
929
        notifyChange(new DefaultFeatureStoreNotification(this, notification,
949
    public FeatureStoreNotification notifyChange(String notification, Feature feature) {
950
        return notifyChange(new DefaultFeatureStoreNotification(this, notification,
930 951
            feature));
931 952
    }
932 953

  
933
    public void notifyChange(String notification, Command command) {
934
        notifyChange(new DefaultFeatureStoreNotification(this, notification,
954
    public FeatureStoreNotification notifyChange(String notification, Command command) {
955
        return notifyChange(new DefaultFeatureStoreNotification(this, notification,
935 956
            command));
936 957
    }
937 958

  
938
    public void notifyChange(String notification, EditableFeatureType type) {
939
        notifyChange(new DefaultFeatureStoreNotification(this, notification,
959
    public FeatureStoreNotification notifyChange(String notification, EditableFeatureType type) {
960
        return notifyChange(new DefaultFeatureStoreNotification(this, notification,
940 961
            type));
941 962
    }
942 963

  
943 964
    @Override
944
    public void notifyChange(String notification, Resource resource) {
945
        notifyChange(new DefaultFeatureStoreNotification(this,
965
    public FeatureStoreNotification notifyChange(String notification, Resource resource) {
966
        return notifyChange(new DefaultFeatureStoreNotification(this,
946 967
            DataStoreNotification.RESOURCE_CHANGED));
947 968
    }
948 969

  
......
1127 1148
                if (!this.transforms.isEmpty()) {
1128 1149
                    throw new IllegalStateException(this.getName());
1129 1150
                }
1130
                notifyChange(FeatureStoreNotification.BEFORE_STARTEDITING);
1151
                if( notifyChange(FeatureStoreNotification.BEFORE_STARTEDITING).isCanceled() ) {
1152
                  return;
1153
                }
1131 1154
                invalidateIndexes();
1132 1155
                featureManager = new FeatureManager();
1133 1156
                featureTypeManager = new FeatureTypeManager(this);
......
1145 1168
                if (!this.transforms.isEmpty()) {
1146 1169
                    throw new IllegalStateException(this.getName());
1147 1170
                }
1148
                notifyChange(FeatureStoreNotification.BEFORE_STARTEDITING);
1171
                if( notifyChange(FeatureStoreNotification.BEFORE_STARTEDITING).isCanceled() ) {
1172
                  return;
1173
                }
1149 1174
                invalidateIndexes();
1150 1175
                this.provider.beginAppend();
1151 1176
                this.mode = MODE_APPEND;
......
1236 1261
                throw new NullFeatureTypeException(getName());
1237 1262
            }
1238 1263
            if (mode == MODE_QUERY && type.hasOnlyMetadataChanges(this.defaultFeatureType)) {
1239
                notifyChange(FeatureStoreNotification.BEFORE_UPDATE_TYPE, type);
1264
                if( notifyChange(FeatureStoreNotification.BEFORE_UPDATE_TYPE, type).isCanceled() ) {
1265
                  return;
1266
                }
1240 1267
                FeatureType theType = type.getNotEditableCopy();
1241 1268
                if( defaultFeatureType.getId().equals(theType.getId()) ) {
1242 1269
                    defaultFeatureType = theType;
......
1261 1288
                throw new NeedEditingModeException(this.getName());
1262 1289
            }
1263 1290
            // FIXME: Comprobar que es un featureType aceptable.
1264
            notifyChange(FeatureStoreNotification.BEFORE_UPDATE_TYPE, type);
1291
            if( notifyChange(FeatureStoreNotification.BEFORE_UPDATE_TYPE, type).isCanceled() ) {
1292
              return;
1293
            }
1265 1294
            newVersionOfUpdate();
1266 1295
            
1267 1296
            FeatureType oldt = type.getSource().getCopy();
......
1288 1317
            if (feature instanceof EditableFeature) {
1289 1318
                throw new StoreDeleteEditableFeatureException(getName());
1290 1319
            }
1291
            notifyChange(FeatureStoreNotification.BEFORE_DELETE, feature);
1320
            if( notifyChange(FeatureStoreNotification.BEFORE_DELETE, feature).isCanceled() ) {
1321
              return;
1322
            }
1292 1323

  
1293 1324
            //Update the featureManager and the spatialManager
1294 1325
            featureManager.delete(feature.getReference());
......
1318 1349
                if (feature.getSource() != null) {
1319 1350
                    throw new NoNewFeatureInsertException(this.getName());
1320 1351
                }
1352
                if( notifyChange(FeatureStoreNotification.BEFORE_INSERT, feature).isCanceled() ) {
1353
                  return;
1354
                }
1321 1355
                this.featureCount = null;
1322
                notifyChange(FeatureStoreNotification.BEFORE_INSERT, feature);
1323 1356
                feature.validate(Feature.UPDATE);
1324 1357
                provider.append(((DefaultEditableFeature) feature).getData());
1325 1358
                hasStrongChanges = true;
......
1331 1364
                if (feature.getSource() != null) {
1332 1365
                    throw new NoNewFeatureInsertException(this.getName());
1333 1366
                }
1367
                feature.validate(Feature.UPDATE);
1334 1368
                commands.insert(feature);
1335 1369
            }
1336 1370
        } catch (Exception e) {
......
1344 1378

  
1345 1379
        waitForIndexes();
1346 1380

  
1347
        notifyChange(FeatureStoreNotification.BEFORE_INSERT, feature);
1381
        if( notifyChange(FeatureStoreNotification.BEFORE_INSERT, feature).isCanceled() ) {
1382
          return;
1383
        }
1348 1384
        newVersionOfUpdate();
1349 1385
        if ((lastChangedFeature == null)
1350 1386
            || (lastChangedFeature.getSource() != feature.getSource())) {
......
1380 1416
        try {
1381 1417
            checkInEditingMode();
1382 1418
            checkIsOwnFeature(feature);
1383
            notifyChange(FeatureStoreNotification.BEFORE_UPDATE, feature);
1419
            if( notifyChange(FeatureStoreNotification.BEFORE_UPDATE, feature).isCanceled() ) {
1420
              return;
1421
            }
1384 1422
            newVersionOfUpdate();
1385 1423
            if ((lastChangedFeature == null)
1386 1424
                || (lastChangedFeature.getSource() != feature.getSource())) {
......
1409 1447
        } catch (NeedEditingModeException ex) {
1410 1448
            throw new RedoException(redo, ex);
1411 1449
        }
1412
        notifyChange(FeatureStoreNotification.BEFORE_REDO, redo);
1450
        if( notifyChange(FeatureStoreNotification.BEFORE_REDO, redo).isCanceled() ) {
1451
          return;
1452
        }
1413 1453
        newVersionOfUpdate();
1414 1454
        commands.redo();
1415 1455
        hasStrongChanges = true;
......
1424 1464
        } catch (NeedEditingModeException ex) {
1425 1465
            throw new UndoException(undo, ex);
1426 1466
        }
1427
        notifyChange(FeatureStoreNotification.BEFORE_UNDO, undo);
1467
        if( notifyChange(FeatureStoreNotification.BEFORE_UNDO, undo).isCanceled() ) {
1468
          return;
1469
        }
1428 1470
        newVersionOfUpdate();
1429 1471
        commands.undo();
1430 1472
        hasStrongChanges = true;
......
1466 1508
                throw new NeedEditingModeException(this.getName());
1467 1509

  
1468 1510
            case MODE_APPEND:
1469
                notifyChange(FeatureStoreNotification.BEFORE_CANCELEDITING);
1511
                if( notifyChange(FeatureStoreNotification.BEFORE_CANCELEDITING).isCanceled() ) {
1512
                  return;
1513
                }
1470 1514
                provider.abortAppend();
1471 1515
                exitEditingMode();
1472 1516
                ((FeatureSelection) this.getSelection()).deselectAll();
......
1478 1522
                if (this.selection instanceof FeatureReferenceSelection) {
1479 1523
                    clearSelection = this.hasInserts;
1480 1524
                }
1481
                notifyChange(FeatureStoreNotification.BEFORE_CANCELEDITING);
1525
                if( notifyChange(FeatureStoreNotification.BEFORE_CANCELEDITING).isCanceled() ) {
1526
                  return;
1527
                }
1482 1528
                exitEditingMode();
1483 1529
                if (clearSelection) {
1484 1530
                    ((FeatureSelection) this.getSelection()).deselectAll();
......
1511 1557
                if( selection!=null ) {
1512 1558
                    selection = null;
1513 1559
                }
1514
                notifyChange(FeatureStoreNotification.BEFORE_FINISHEDITING);
1560
                if( notifyChange(FeatureStoreNotification.BEFORE_FINISHEDITING).isCanceled() ) {
1561
                  return;
1562
                }
1515 1563
                saveDALFile();
1516 1564
                provider.endAppend();
1517 1565
                exitEditingMode();
......
1525 1573
                if (hasStrongChanges && !this.allowWrite()) {
1526 1574
                    throw new WriteNotAllowedException(getName());
1527 1575
                }
1576
                if( notifyChange(FeatureStoreNotification.BEFORE_FINISHEDITING, 
1577
                        featureManager.getDeleted(),
1578
                        featureManager.getInsertedFeatures(),
1579
                        featureManager.getUpdatedFeatures(),
1580
                        featureTypeManager.getFeatureTypesChanged().iterator(),
1581
                        featureManager.isSelectionCompromised()).isCanceled() ) {
1582
                  return;
1583
                }
1528 1584
                saveDALFile();
1529 1585
                if(featureManager.isSelectionCompromised() && selection!=null ) {
1530 1586
                    selection = null;
1531 1587
                }
1532
                notifyChange(FeatureStoreNotification.BEFORE_FINISHEDITING);
1533 1588
                if (hasStrongChanges) {
1534 1589
                    validateFeatures(Feature.FINISH_EDITING);
1535 1590

  
......
1596 1651
        }
1597 1652
        
1598 1653
    }
1599
    private List<FeatureStoreProvider.FeatureTypeChanged> removeCalculatedAttributes(List<FeatureStoreProvider.FeatureTypeChanged> ftypes) {
1654
    private List<FeatureTypeChanged> removeCalculatedAttributes(List<FeatureTypeChanged> ftypes) {
1600 1655
        // FIXME: Falta por implementar
1601 1656
//        for (FeatureStoreProvider.FeatureTypeChanged ftype : ftypes) {
1602 1657
//            EditableFeatureType target = (EditableFeatureType) ftype.getTarget();
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/EditingManager.java
8 8
import org.gvsig.fmap.dal.feature.FeatureReference;
9 9
import org.gvsig.fmap.dal.feature.FeatureStore;
10 10
import org.gvsig.fmap.dal.feature.FeatureType;
11
import org.gvsig.fmap.dal.feature.FeatureType.FeatureTypeChanged;
11 12
import org.gvsig.fmap.dal.feature.spi.FeatureProvider;
12
import org.gvsig.fmap.dal.feature.spi.FeatureStoreProvider.FeatureTypeChanged;
13 13

  
14 14

  
15 15
public interface EditingManager {
......
60 60
    
61 61
    public boolean isSelectionCompromised();
62 62
    
63
    public Iterator<FeatureProvider> getDeletedFeatures();
63
    public Iterator<FeatureReference> getDeletedFeatures();
64 64
    public Iterator<FeatureProvider> getInsertedFeatures();
65 65
    public Iterator<FeatureProvider> getUpdatedFeatures();
66 66
    
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
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 {
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff