comparison gnv-artifacts/src/main/java/de/intevation/gnv/transition/TransitionBase.java @ 252:f1e7ddeef5bc

Added Validation if a given maxvalue is greater than a given minvalue issue19 gnv-artifacts/trunk@323 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Wed, 11 Nov 2009 15:54:31 +0000
parents 113b06ab2110
children ce408af0ee57
comparison
equal deleted inserted replaced
251:113b06ab2110 252:f1e7ddeef5bc
244 if (inputValue != null) { 244 if (inputValue != null) {
245 if (this.inputData == null) { 245 if (this.inputData == null) {
246 this.inputData = new HashMap<String, InputData>( 246 this.inputData = new HashMap<String, InputData>(
247 inputData.size()); 247 inputData.size());
248 } 248 }
249
249 boolean valid = iv.isInputValid(tmpItem.getValue(), 250 boolean valid = iv.isInputValid(tmpItem.getValue(),
250 inputValue.getType()); 251 inputValue.getType());
251 if (valid) { 252 if (valid) {
253 if (tmpItem.getName().equals(MINVALUEFIELDNAME)){
254 String minValue = tmpItem.getValue();
255 String maxValue = this.getInputValue4ID(inputData, MAXVALUEFIELDNAME);
256 valid = iv.isInputValid(maxValue,inputValue.getType());
257 if (!valid){
258 String errMsg = "Wrong input for " + tmpItem.getValue()
259 + " is not an " + inputValue.getType()
260 + " Value.";
261 log.warn(errMsg);
262 throw new TransitionException(errMsg);
263 }
264
265 valid = iv.isInputValid(minValue,
266 maxValue,
267 inputValue.getType());
268 if (!valid){
269 String errMsg = "MaxValue-Input is less than MinValue-Input ";
270 log.warn(errMsg);
271 throw new TransitionException(errMsg);
272 }
273 }else if (tmpItem.getName().equals(MAXVALUEFIELDNAME)){
274 String minValue = this.getInputValue4ID(inputData, MINVALUEFIELDNAME);
275 String maxValue = tmpItem.getValue();
276 valid = iv.isInputValid(minValue,inputValue.getType());
277 if (!valid){
278 String errMsg = "Wrong input for " + tmpItem.getValue()
279 + " is not an " + inputValue.getType()
280 + " Value.";
281 log.warn(errMsg);
282 throw new TransitionException(errMsg);
283 }
284
285 valid = iv.isInputValid(minValue,
286 maxValue,
287 inputValue.getType());
288 if (!valid){
289 String errMsg = "MaxValue-Input is less than MinValue-Input ";
290 log.warn(errMsg);
291 throw new TransitionException(errMsg);
292 }
293 }
252 this.setSelection(tmpItem, uuid); 294 this.setSelection(tmpItem, uuid);
253 this.inputData.put(tmpItem.getName(), tmpItem); 295 this.inputData.put(tmpItem.getName(), tmpItem);
254 } else { 296 } else {
255 String errMsg = "Wrong input for " + tmpItem.getValue() 297 String errMsg = "Wrong input for " + tmpItem.getValue()
256 + " is not an " + inputValue.getType() 298 + " is not an " + inputValue.getType()
267 } 309 }
268 } 310 }
269 } else { 311 } else {
270 log.warn("No Inputdata given"); 312 log.warn("No Inputdata given");
271 } 313 }
314 }
315
316 private String getInputValue4ID(Collection<InputData> inputData, String inputName){
317 Iterator<InputData> it = inputData.iterator();
318 while (it.hasNext()) {
319 InputData tmpItem = it.next();
320 if (tmpItem.getName().equals(inputName)){
321 return tmpItem.getValue();
322 }
323 }
324 return null;
272 } 325 }
273 326
274 private void setSelection(InputData inputData, String uuid) { 327 private void setSelection(InputData inputData, String uuid) {
275 log.debug("TransitionBase.setSelection"); 328 log.debug("TransitionBase.setSelection");
276 329

http://dive4elements.wald.intevation.org