Mercurial > dive4elements > gnv-client
comparison gnv-artifacts/src/main/java/de/intevation/gnv/transition/PresettingsValueCompareTransition.java @ 657:af3f56758f59
merged gnv-artifacts/0.5
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:13:53 +0200 |
parents | e86d37008fd1 |
children | 9a828e5a2390 |
comparison
equal
deleted
inserted
replaced
590:5f5f273c8566 | 657:af3f56758f59 |
---|---|
1 /** | |
2 * | |
3 */ | |
4 package de.intevation.gnv.transition; | |
5 | |
6 import java.util.Map; | |
7 | |
8 import org.apache.log4j.Logger; | |
9 import org.w3c.dom.Node; | |
10 | |
11 import de.intevation.artifactdatabase.Config; | |
12 import de.intevation.gnv.state.InputData; | |
13 import de.intevation.gnv.state.State; | |
14 | |
15 /** | |
16 * @author Tim Englich <tim.englich@intevation.de> | |
17 * | |
18 */ | |
19 public class PresettingsValueCompareTransition extends TransitionBase { | |
20 | |
21 /** | |
22 * the logger, used to log exceptions and additonaly information | |
23 */ | |
24 private static Logger log = Logger.getLogger(PresettingsValueCompareTransition.class); | |
25 | |
26 private String dataName = null; | |
27 private String dataValue = null; | |
28 private String operator = null; | |
29 | |
30 /** | |
31 * The UID of this Class. | |
32 */ | |
33 private static final long serialVersionUID = -7846722158776823205L; | |
34 | |
35 /** | |
36 * Constructor | |
37 */ | |
38 public PresettingsValueCompareTransition() { | |
39 super(); | |
40 } | |
41 | |
42 /** | |
43 * @see de.intevation.gnv.transition.Transition#isValid(de.intevation.gnv.state.State) | |
44 */ | |
45 public boolean isValid(State state) { | |
46 Map<String, InputData> preSettings = state.getPreSettings(); | |
47 if (preSettings != null){ | |
48 boolean dataAvailable = preSettings.containsKey(dataName); | |
49 if (dataAvailable){ | |
50 if (operator.equals("equal")){ | |
51 return preSettings.get(dataName).getValue().startsWith(dataValue); | |
52 }else if (operator.equals("notequal")){ | |
53 return !preSettings.get(dataName).getValue().startsWith(dataValue); | |
54 } | |
55 } | |
56 } | |
57 if (operator.equals("notequal")){ | |
58 return true; | |
59 } | |
60 return false; | |
61 } | |
62 | |
63 @Override | |
64 public void setup(Node configuration) { | |
65 super.setup(configuration); | |
66 this.dataName = Config.getStringXPath(configuration,"condition/@inputvalue"); | |
67 this.dataValue = Config.getStringXPath(configuration,"condition/@value"); | |
68 this.operator = Config.getStringXPath(configuration,"condition/@operator"); | |
69 } | |
70 | |
71 | |
72 } |