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

View differences:

DefaultFeatureType.java
45 45

  
46 46
import org.gvsig.fmap.dal.DataTypes;
47 47
import org.gvsig.fmap.dal.exception.DataException;
48
import org.gvsig.fmap.dal.feature.EditableFeature;
48 49
import org.gvsig.fmap.dal.feature.EditableFeatureType;
49 50
import org.gvsig.fmap.dal.feature.Feature;
50 51
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
......
70 71
import org.gvsig.tools.persistence.PersistentState;
71 72
import org.gvsig.tools.persistence.exception.PersistenceException;
72 73
import org.gvsig.fmap.dal.feature.FeatureExtraColumns;
73
import org.gvsig.fmap.dal.impl.expressionevaluator.DefaultFeatureAttributeEmulatorExpression;
74 74
import org.gvsig.json.Json;
75 75
import org.gvsig.json.JsonManager;
76 76
import org.gvsig.json.JsonObjectBuilder;
......
114 114
    private String label;
115 115
    private Tags tags;
116 116
    private FeatureExtraColumns extraColumns;
117
    protected boolean checkFeaturesAtFinishEditing;
118
    protected boolean checkFeaturesAtInsert;
117 119

  
118 120
    public DefaultFeatureType() {
119 121
        // Usado en la persistencia.
......
129 131
        this.allowAtomaticValues = false;
130 132
        this.tags = new DefaultTags();
131 133
        this.extraColumns = new DefaultFeatureExtraColumns();
134
        this.checkFeaturesAtFinishEditing = true;
135
        this.checkFeaturesAtInsert = true;
132 136
    }
133 137

  
134 138
    protected DefaultFeatureType(FeatureStore store, String id) {
......
163 167
        this.id = idSaved;
164 168
        this.internalID = internalIDSaved;
165 169
    }
166
    
170

  
171
    @Override
172
    public boolean isCheckFeaturesAtFinishEditing() {
173
        return this.checkFeaturesAtFinishEditing;
174
    }
175

  
176
    @Override
177
    public boolean isCheckFeaturesAtInsert() {
178
        return this.checkFeaturesAtInsert;
179
    }
180

  
181

  
167 182
    protected void addAll(FeatureType attributes) {
168 183
        for (FeatureAttributeDescriptor attribute : attributes) {
169 184
            DefaultFeatureAttributeDescriptor copy = this.getCopyAttributeDescriptor((DefaultFeatureAttributeDescriptor) attribute);
......
201 216
        } catch (CloneNotSupportedException ex) {
202 217
            
203 218
        }
219
        this.checkFeaturesAtFinishEditing = other.checkFeaturesAtFinishEditing;
220
        this.checkFeaturesAtInsert = other.checkFeaturesAtInsert;
204 221
    }
205 222
    
206 223
    protected DefaultFeatureAttributeDescriptor getCopyAttributeDescriptor(DefaultFeatureAttributeDescriptor src) {
......
361 378
                this.getDefaultGeometryAttributeIndex()).getSRS();
362 379
    }
363 380

  
364
    public void validateFeature(Feature feature, int mode) throws DataException {
365
        DefaultFeatureRules rules = (DefaultFeatureRules) this.getRules();
366
        rules.validate(feature, mode);
381
    public void validateFeature(EditableFeature feature, int check) throws DataException {
382
        DefaultFeatureRules theRules = (DefaultFeatureRules) this.getRules();
383
        theRules.validate(feature, check);
367 384
    }
368 385

  
386
    public void validateFeature(Feature feature, int check) throws DataException {
387
        DefaultFeatureRules theRules = (DefaultFeatureRules) this.getRules();
388
        theRules.validate(feature, check);
389
    }
390

  
369 391
    public FeatureType getSubtype() throws DataException {
370 392
        return new SubtypeFeatureType(this, null, null, true);
371 393
    }
......
1130 1152
    public void loadFromState(PersistentState state)
1131 1153
            throws PersistenceException {
1132 1154

  
1133
//        FIXME: rules
1134 1155
        hasEvaluators = state.getBoolean("hasEvaluators");
1135 1156
        hasEmulators = state.getBoolean("hasEmulators");
1136 1157
        defaultGeometryAttributeName = state.getString("defaultGeometryAttributeName");
......
1147 1168
        if( tags == null ) {
1148 1169
            this.tags = new DefaultTags();
1149 1170
        }
1150

  
1171
        this.checkFeaturesAtFinishEditing = state.getBoolean("checkFeaturesAtFinishEditing");
1172
        this.checkFeaturesAtInsert = state.getBoolean("checkFeaturesAtInsert");
1173
        
1151 1174
        List<FeatureAttributeDescriptor> elements = state.getList("elements");
1152 1175
        for (FeatureAttributeDescriptor element : elements) {
1153 1176
            ((DefaultFeatureAttributeDescriptor) element).setFeatureType(this);
1154 1177
            super.add(element);
1155 1178
        }
1156 1179
        this.pk = null;
1180
        
1181
        this.rules = new DefaultFeatureRules();
1182
        this.rules.addAll(state.getList("rules"));
1157 1183
        this.fixAll();
1158 1184
    }
1159 1185

  
......
1178 1204
        elements.addAll(this);
1179 1205
        state.set("elements", elements);
1180 1206
        state.set("tags", tags);
1181

  
1207
        state.set("checkFeaturesAtFinishEditing",this.checkFeaturesAtFinishEditing);
1208
        state.set("checkFeaturesAtInsert",this.checkFeaturesAtInsert);
1209
        state.set("rules", this.rules.iterator());
1182 1210
    }
1183 1211

  
1184 1212
    private static final String FEATTYPE_PERSISTENCE_DEFINITION_NAME = "FeatureType";
......
1195 1223
                    null,
1196 1224
                    null
1197 1225
            );
1198
//            definition.addDynFieldObject("rules");
1199 1226
            definition.addDynFieldBoolean("hasEvaluators");
1200 1227
            definition.addDynFieldBoolean("hasEmulators");
1201 1228
            definition.addDynFieldString("defaultGeometryAttributeName");
......
1212 1239
            definition.addDynFieldList("elements")
1213 1240
                    .setClassOfItems(FeatureAttributeDescriptor.class);
1214 1241

  
1215
            definition.addDynFieldObject("tags")
1216
                    .setClassOfValue(Tags.class);
1217
            
1242
            definition.addDynFieldObject("tags").setClassOfValue(Tags.class);
1243
            definition.addDynFieldBoolean("checkFeaturesAtFinishEditing")
1244
                    .setMandatory(false)
1245
                    .setDefaultFieldValue(true);
1246
            definition.addDynFieldBoolean("checkFeaturesAtInsert")
1247
                    .setMandatory(false)
1248
                    .setDefaultFieldValue(true);
1249
            definition.addDynFieldList("rules")
1250
                    .setClassOfItems(FeatureRules.class);
1218 1251
        }
1219 1252
    }
1220 1253

  
......
1307 1340
        builder.add("hasOID",hasOID);
1308 1341
        builder.add("defaultGeometryAttributeName",defaultGeometryAttributeName);
1309 1342
        builder.add("defaultTimeAttributeName",defaultTimeAttributeName);        
1343
        builder.add("checkFeaturesAtFinishEditing",checkFeaturesAtFinishEditing);        
1344
        builder.add("checkFeaturesAtInsert",checkFeaturesAtInsert);        
1310 1345
        builder.add("tags", tags);
1311 1346
        builder.add("extraColumns", this.extraColumns);
1312 1347
        builder.add("descriptors", this.iterator());
......
1321 1356
        this.label = json.getString("label", null);
1322 1357
        this.description = json.getString("description",null);
1323 1358
        this.allowAtomaticValues = json.getBoolean("allowAtomaticValues",false);
1359
        this.checkFeaturesAtFinishEditing = json.getBoolean("checkFeaturesAtFinishEditing",true);
1360
        this.checkFeaturesAtInsert = json.getBoolean("checkFeaturesAtInsert",true);
1324 1361
        this.hasOID = json.getBoolean("hasOID", false);
1325 1362
        this.defaultGeometryAttributeName = json.getString("defaultGeometryAttributeName", null);
1326 1363
        this.defaultTimeAttributeName = json.getString("defaultTimeAttributeName",null);

Also available in: Unified diff