Revision 41251
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/DefaultFeature.java | ||
---|---|---|
40 | 40 |
import org.gvsig.fmap.dal.feature.FeatureType; |
41 | 41 |
import org.gvsig.fmap.dal.feature.exception.IllegalValueException; |
42 | 42 |
import org.gvsig.fmap.dal.feature.exception.SetReadOnlyAttributeException; |
43 |
import org.gvsig.fmap.dal.feature.exception.ValidateFeaturesException; |
|
43 | 44 |
import org.gvsig.fmap.dal.feature.impl.featureset.DynObjectFeatureFacade; |
44 | 45 |
import org.gvsig.fmap.dal.feature.spi.FeatureProvider; |
45 | 46 |
import org.gvsig.fmap.geom.Geometry; |
... | ... | |
277 | 278 |
|
278 | 279 |
} |
279 | 280 |
|
280 |
public void validate(int mode) { |
|
281 |
public void validate(int mode) throws DataException {
|
|
281 | 282 |
((DefaultFeatureType) this.data.getType()).validateFeature(this, mode); |
282 | 283 |
} |
283 | 284 |
|
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/DefaultFeatureType.java | ||
---|---|---|
36 | 36 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
37 | 37 |
import org.gvsig.fmap.dal.feature.Feature; |
38 | 38 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
39 |
import org.gvsig.fmap.dal.feature.FeatureRule; |
|
39 | 40 |
import org.gvsig.fmap.dal.feature.FeatureRules; |
40 | 41 |
import org.gvsig.fmap.dal.feature.FeatureType; |
42 |
import org.gvsig.fmap.dal.feature.exception.ValidateFeaturesException; |
|
41 | 43 |
import org.gvsig.tools.dynobject.DynClass; |
42 | 44 |
import org.gvsig.tools.dynobject.DynField; |
43 | 45 |
import org.gvsig.tools.dynobject.DynMethod; |
... | ... | |
224 | 226 |
this.getDefaultGeometryAttributeIndex()).getSRS(); |
225 | 227 |
} |
226 | 228 |
|
227 |
public void validateFeature(Feature feature, int mode) { |
|
228 |
if (Feature.UPDATE == mode){ |
|
229 |
((DefaultFeatureRules)getRules()).validate(feature); |
|
230 |
} |
|
229 |
public void validateFeature(Feature feature, int mode) throws DataException { |
|
230 |
DefaultFeatureRules rules = (DefaultFeatureRules) this.getRules(); |
|
231 |
rules.validate(feature,mode); |
|
231 | 232 |
} |
232 | 233 |
|
233 | 234 |
public FeatureType getSubtype(String[] names) throws DataException { |
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 | ||
---|---|---|
30 | 30 |
import org.gvsig.fmap.dal.feature.Feature; |
31 | 31 |
import org.gvsig.fmap.dal.feature.FeatureRule; |
32 | 32 |
import org.gvsig.fmap.dal.feature.FeatureRules; |
33 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
34 |
import org.gvsig.fmap.dal.feature.exception.ValidateFeaturesException; |
|
35 |
import org.slf4j.Logger; |
|
36 |
import org.slf4j.LoggerFactory; |
|
33 | 37 |
|
34 | 38 |
public class DefaultFeatureRules extends ArrayList implements FeatureRules { |
35 |
|
|
39 |
|
|
40 |
private final static Logger logger = LoggerFactory.getLogger(DefaultFeatureRules.class); |
|
41 |
|
|
36 | 42 |
/** |
37 | 43 |
* |
38 | 44 |
*/ |
... | ... | |
59 | 65 |
return copy; |
60 | 66 |
} |
61 | 67 |
|
62 |
public void validate(Feature feature) { |
|
63 |
Iterator featureRules=iterator(); |
|
64 |
while (featureRules.hasNext()) { |
|
65 |
FeatureRule rule = (FeatureRule) featureRules.next(); |
|
66 |
try { |
|
67 |
rule.validate(feature, ((DefaultFeature)feature).getStore()); |
|
68 |
} catch (DataException e) { |
|
69 |
e.printStackTrace(); |
|
70 |
} |
|
71 |
} |
|
68 |
/** |
|
69 |
* @deprecated use validate(Feature feature, int mode) |
|
70 |
* @param feature |
|
71 |
* @throws DataException |
|
72 |
*/ |
|
73 |
public void validate(Feature feature) throws DataException { |
|
74 |
logger.warn("Calling deprecated method validate without mode."); |
|
75 |
FeatureStore store = ((DefaultFeature)feature).getStore(); |
|
76 |
Iterator featureRules=iterator(); |
|
77 |
while (featureRules.hasNext()) { |
|
78 |
FeatureRule rule = (FeatureRule) featureRules.next(); |
|
79 |
rule.validate(feature, store); |
|
80 |
} |
|
72 | 81 |
|
73 | 82 |
} |
74 | 83 |
|
84 |
public void validate(Feature feature, int mode) throws DataException { |
|
85 |
FeatureStore store = ((DefaultFeature)feature).getStore(); |
|
86 |
Iterator featureRules=iterator(); |
|
87 |
while (featureRules.hasNext()) { |
|
88 |
FeatureRule rule = (FeatureRule) featureRules.next(); |
|
89 |
if( rule.checkAtFinishEditing() && mode == Feature.FINISH_EDITING ) { |
|
90 |
rule.validate(feature, store); |
|
91 |
} |
|
92 |
if( rule.checkAtUpdate() && mode == Feature.UPDATE ) { |
|
93 |
rule.validate(feature, store); |
|
94 |
} |
|
95 |
} |
|
75 | 96 |
|
97 |
} |
|
76 | 98 |
|
77 | 99 |
|
100 |
|
|
101 |
|
|
78 | 102 |
} |
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/Feature.java | ||
---|---|---|
27 | 27 |
import java.util.List; |
28 | 28 |
|
29 | 29 |
import org.cresques.cts.IProjection; |
30 |
import org.gvsig.fmap.dal.exception.DataException; |
|
31 |
import org.gvsig.fmap.dal.feature.exception.ValidateFeaturesException; |
|
30 | 32 |
|
31 | 33 |
import org.gvsig.fmap.geom.Geometry; |
32 | 34 |
import org.gvsig.fmap.geom.primitive.Envelope; |
... | ... | |
35 | 37 |
import org.gvsig.tools.dynobject.DynObject; |
36 | 38 |
import org.gvsig.tools.evaluator.Evaluator; |
37 | 39 |
import org.gvsig.tools.evaluator.EvaluatorData; |
38 |
|
|
39 | 40 |
|
41 |
|
|
40 | 42 |
/** |
41 | 43 |
* <p>Represents the basic data unit of a tabular structure, equivalent |
42 | 44 |
* to a record in a data base table. In SIG domain, a Feature is a compound |
... | ... | |
112 | 114 |
* |
113 | 115 |
* @param mode |
114 | 116 |
* one of the constants {ALL, UPDATE, FINISH_EDITING} |
117 |
* @throws DataException on validation errors |
|
115 | 118 |
*/ |
116 |
public void validate(int mode); |
|
119 |
public void validate(int mode) throws DataException;
|
|
117 | 120 |
|
118 | 121 |
/** |
119 | 122 |
* Returns the editable instance of this Feature. |
... | ... | |
449 | 452 |
* value of the specified attribute |
450 | 453 |
*/ |
451 | 454 |
public Interval getInterval(String name); |
452 |
|
|
455 |
|
|
453 | 456 |
public DynObject getAsDynObject(); |
454 | 457 |
|
455 | 458 |
/** |
Also available in: Unified diff