Revision 47378 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
DefaultFeatureRuleExpression.java | ||
---|---|---|
31 | 31 |
private static final String FEATURERULEEXPRESSION_PERSISTENCE_DEFINITION_NAME = "FeatureRuleExpression"; |
32 | 32 |
|
33 | 33 |
private Expression expression; |
34 |
private FeatureSymbolTable symbolTable; |
|
34 |
private FeatureSymbolTable featureSymbolTable; |
|
35 |
private SymbolTable symbolTable; |
|
35 | 36 |
|
36 | 37 |
public DefaultFeatureRuleExpression() { |
37 | 38 |
super(null, null, false, false); |
... | ... | |
41 | 42 |
boolean checkAtFinishEdition, Expression expression) { |
42 | 43 |
super(name, description, checkAtUpdate, checkAtFinishEdition); |
43 | 44 |
this.expression = expression; |
44 |
this.symbolTable = new FeatureSymbolTableImpl(); |
|
45 |
this.featureSymbolTable = new FeatureSymbolTableImpl(); |
|
46 |
this.symbolTable = this.featureSymbolTable.createParent(); |
|
45 | 47 |
} |
46 | 48 |
|
47 | 49 |
@Override |
... | ... | |
56 | 58 |
|
57 | 59 |
@Override |
58 | 60 |
public void validate(EditableFeature feature, FeatureStore featureStore) throws DataException { |
59 |
this.symbolTable.setFeature(feature);
|
|
60 |
Object value = this.expression.execute(symbolTable); |
|
61 |
this.featureSymbolTable.setFeature(feature);
|
|
62 |
Object value = this.expression.execute(this.symbolTable);
|
|
61 | 63 |
boolean ok = false; |
62 | 64 |
if (value != null) { |
63 | 65 |
if (value instanceof Boolean) { |
... | ... | |
95 | 97 |
definition.addDynFieldBoolean("checkAtFinishEdition"); |
96 | 98 |
definition.addDynFieldBoolean("checkAtUpdate"); |
97 | 99 |
definition.addDynFieldObject("expression").setClassOfValue(Expression.class); |
100 |
definition.addDynFieldInt("checkWhen").setMandatory(false); |
|
98 | 101 |
} |
99 | 102 |
} |
100 | 103 |
|
... | ... | |
102 | 105 |
public void loadFromState(PersistentState state) throws PersistenceException { |
103 | 106 |
this.name = state.getString("name"); |
104 | 107 |
this.description = state.getString("description"); |
105 |
this.checkAtFinishEdition = state.getBoolean("checkAtFinishEdition"); |
|
106 |
this.checkAtUpdate = state.getBoolean("checkAtUpdate"); |
|
108 |
this.checkwhen.set(state.getInt("checkWhen",0)); |
|
109 |
if( state.getBoolean("checkAtFinishEdition") ) { |
|
110 |
this.checkwhen.setBits(CHECK_WHEN_FINISH_EDITING); |
|
111 |
} |
|
112 |
if( state.getBoolean("checkAtUpdate") ) { |
|
113 |
this.checkwhen.setBits(CHECK_WHEN_INSERT_OR_UPDATE_FEATURE); |
|
114 |
} |
|
107 | 115 |
this.expression = (Expression) state.get("expression"); |
108 |
this.symbolTable = new FeatureSymbolTableImpl(); |
|
116 |
this.featureSymbolTable = new FeatureSymbolTableImpl(); |
|
117 |
this.symbolTable = this.featureSymbolTable.createParent(); |
|
109 | 118 |
} |
110 | 119 |
|
111 | 120 |
@Override |
112 | 121 |
public void saveToState(PersistentState state) throws PersistenceException { |
113 | 122 |
state.set("name", this.name); |
114 | 123 |
state.set("description", this.description); |
115 |
state.set("checkAtFinishEdition", this.checkAtFinishEdition); |
|
116 |
state.set("checkAtUpdate", this.checkAtUpdate); |
|
124 |
state.set("checkWhen", this.checkwhen.get()); |
|
125 |
state.set("checkAtFinishEdition", this.checkwhen.isSetBits(CHECK_WHEN_FINISH_EDITING)); |
|
126 |
state.set("checkAtUpdate", this.checkwhen.isSetBits(CHECK_WHEN_INSERT_OR_UPDATE_FEATURE)); |
|
117 | 127 |
state.set("expression", this.expression); |
118 | 128 |
} |
119 | 129 |
|
120 | 130 |
@Override |
121 | 131 |
public void setCheckAtUpdate(boolean checkAtUpdate) { |
122 |
this.checkAtUpdate = checkAtUpdate; |
|
132 |
if( checkAtUpdate ) { |
|
133 |
this.checkwhen.setBits(CHECK_WHEN_INSERT_OR_UPDATE_FEATURE); |
|
134 |
} else { |
|
135 |
this.checkwhen.clearBits(CHECK_WHEN_INSERT_OR_UPDATE_FEATURE); |
|
136 |
} |
|
123 | 137 |
} |
124 | 138 |
|
125 | 139 |
@Override |
126 | 140 |
public void setCheckAtFinishEditing(boolean checkAtFinishEditing) { |
127 |
this.checkAtFinishEdition = checkAtFinishEditing; |
|
141 |
if( checkAtFinishEditing ) { |
|
142 |
this.checkwhen.setBits(CHECK_WHEN_FINISH_EDITING); |
|
143 |
} else { |
|
144 |
this.checkwhen.clearBits(CHECK_WHEN_FINISH_EDITING); |
|
145 |
} |
|
128 | 146 |
} |
129 | 147 |
|
130 | 148 |
@Override |
... | ... | |
149 | 167 |
builder.add_class(this); |
150 | 168 |
builder.add("name", this.name); |
151 | 169 |
builder.add("description", this.description); |
152 |
builder.add("checkAtFinishEdition", this.checkAtFinishEdition); |
|
153 |
builder.add("checkAtUpdate", this.checkAtUpdate); |
|
170 |
builder.add("checkWhen", this.checkwhen.get()); |
|
171 |
builder.add("checkAtFinishEdition", this.checkwhen.isSetBits(CHECK_WHEN_FINISH_EDITING)); |
|
172 |
builder.add("checkAtUpdate", this.checkwhen.isSetBits(CHECK_WHEN_USER_EDIT_FEATURE)); |
|
154 | 173 |
builder.add("expression", this.expression.getPhrase()); |
155 | 174 |
return builder; |
156 | 175 |
} |
... | ... | |
159 | 178 |
public void fromJson(JsonObject json) { |
160 | 179 |
this.name = json.getString("name"); |
161 | 180 |
this.description = json.getString("description"); |
162 |
this.checkAtFinishEdition = json.getBoolean("checkAtFinishEdition", false); |
|
163 |
this.checkAtUpdate = json.getBoolean("checkAtUpdate", false); |
|
181 |
this.checkwhen.set(json.getInt("checkwhen", 0)); |
|
182 |
if( json.getBoolean("checkAtFinishEdition", false) ) { |
|
183 |
this.checkwhen.setBits(CHECK_WHEN_FINISH_EDITING); |
|
184 |
} |
|
185 |
if( json.getBoolean("checkAtUpdate", false) ) { |
|
186 |
this.checkwhen.setBits(CHECK_WHEN_INSERT_OR_UPDATE_FEATURE); |
|
187 |
} |
|
164 | 188 |
this.expression = ExpressionUtils.createExpression(json.getString("expression", null)); |
165 |
this.symbolTable = new FeatureSymbolTableImpl(); |
|
189 |
this.featureSymbolTable = new FeatureSymbolTableImpl(); |
|
190 |
this.symbolTable = this.featureSymbolTable.createParent(); |
|
166 | 191 |
} |
167 | 192 |
|
193 |
@Override |
|
194 |
public void setCheckWhen(int mask) { |
|
195 |
super.setCheckWhen(mask); |
|
196 |
} |
|
197 |
|
|
168 | 198 |
} |
Also available in: Unified diff