Mercurial > dive4elements > gnv-client
annotate gnv-artifacts/src/main/java/de/intevation/gnv/transition/PresettingsValueCompareTransition.java @ 1116:2d393d79c097
Added author names.
gnv-artifacts/trunk@1262 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 04 Nov 2010 21:46:58 +0000 |
parents | f953c9a559d8 |
children | dec4257ad570 |
rev | line source |
---|---|
1115
f953c9a559d8
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
835
diff
changeset
|
1 /* |
f953c9a559d8
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
835
diff
changeset
|
2 * Copyright (c) 2010 by Intevation GmbH |
f953c9a559d8
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
835
diff
changeset
|
3 * |
f953c9a559d8
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
835
diff
changeset
|
4 * This program is free software under the LGPL (>=v2.1) |
f953c9a559d8
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
835
diff
changeset
|
5 * Read the file LGPL.txt coming with the software for details |
f953c9a559d8
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
835
diff
changeset
|
6 * or visit http://www.gnu.org/licenses/ if it does not exist. |
f953c9a559d8
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
835
diff
changeset
|
7 */ |
f953c9a559d8
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
835
diff
changeset
|
8 |
612
e86d37008fd1
Added new Transition and State for using the PreSettingsValue for the decision if a Transition could be used
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
9 package de.intevation.gnv.transition; |
e86d37008fd1
Added new Transition and State for using the PreSettingsValue for the decision if a Transition could be used
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
10 |
e86d37008fd1
Added new Transition and State for using the PreSettingsValue for the decision if a Transition could be used
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
11 import java.util.Map; |
e86d37008fd1
Added new Transition and State for using the PreSettingsValue for the decision if a Transition could be used
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
12 |
e86d37008fd1
Added new Transition and State for using the PreSettingsValue for the decision if a Transition could be used
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
13 import org.apache.log4j.Logger; |
779
b1f5f2a8840f
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
14 import org.w3c.dom.Node; |
612
e86d37008fd1
Added new Transition and State for using the PreSettingsValue for the decision if a Transition could be used
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
15 |
824
7e5995c47125
Added more Javadoc.
Tim Englich <tim.englich@intevation.de>
parents:
813
diff
changeset
|
16 import de.intevation.artifactdatabase.Config; |
7e5995c47125
Added more Javadoc.
Tim Englich <tim.englich@intevation.de>
parents:
813
diff
changeset
|
17 import de.intevation.gnv.state.InputData; |
7e5995c47125
Added more Javadoc.
Tim Englich <tim.englich@intevation.de>
parents:
813
diff
changeset
|
18 import de.intevation.gnv.state.State; |
7e5995c47125
Added more Javadoc.
Tim Englich <tim.englich@intevation.de>
parents:
813
diff
changeset
|
19 |
612
e86d37008fd1
Added new Transition and State for using the PreSettingsValue for the decision if a Transition could be used
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
20 /** |
824
7e5995c47125
Added more Javadoc.
Tim Englich <tim.englich@intevation.de>
parents:
813
diff
changeset
|
21 * Class which supports the possibility to validate if a |
7e5995c47125
Added more Javadoc.
Tim Englich <tim.englich@intevation.de>
parents:
813
diff
changeset
|
22 * Transition could be done using simple Valuecompare Operations. |
7e5995c47125
Added more Javadoc.
Tim Englich <tim.englich@intevation.de>
parents:
813
diff
changeset
|
23 * The Compareoperations will use the preSettings of an Artifact. |
7e5995c47125
Added more Javadoc.
Tim Englich <tim.englich@intevation.de>
parents:
813
diff
changeset
|
24 * At this Time equal and notequal-operations are supported. |
7e5995c47125
Added more Javadoc.
Tim Englich <tim.englich@intevation.de>
parents:
813
diff
changeset
|
25 * The Comparation is casesensitive. |
780
c4156275c1e1
Bring @author javadoc tags in form '@author <a href="john.doe@example.com">John Doe</a>'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
779
diff
changeset
|
26 * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a> |
612
e86d37008fd1
Added new Transition and State for using the PreSettingsValue for the decision if a Transition could be used
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
27 * |
e86d37008fd1
Added new Transition and State for using the PreSettingsValue for the decision if a Transition could be used
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
28 */ |
e86d37008fd1
Added new Transition and State for using the PreSettingsValue for the decision if a Transition could be used
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
29 public class PresettingsValueCompareTransition extends TransitionBase { |
e86d37008fd1
Added new Transition and State for using the PreSettingsValue for the decision if a Transition could be used
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
30 |
e86d37008fd1
Added new Transition and State for using the PreSettingsValue for the decision if a Transition could be used
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
31 /** |
e86d37008fd1
Added new Transition and State for using the PreSettingsValue for the decision if a Transition could be used
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
32 * the logger, used to log exceptions and additonaly information |
e86d37008fd1
Added new Transition and State for using the PreSettingsValue for the decision if a Transition could be used
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
33 */ |
e86d37008fd1
Added new Transition and State for using the PreSettingsValue for the decision if a Transition could be used
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
34 private static Logger log = Logger.getLogger(PresettingsValueCompareTransition.class); |
778
9a828e5a2390
Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
612
diff
changeset
|
35 |
824
7e5995c47125
Added more Javadoc.
Tim Englich <tim.englich@intevation.de>
parents:
813
diff
changeset
|
36 /** |
835
2423cefe7d39
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
824
diff
changeset
|
37 * The Name of the Datafield the Value that should be compared |
824
7e5995c47125
Added more Javadoc.
Tim Englich <tim.englich@intevation.de>
parents:
813
diff
changeset
|
38 * should be fetched from. |
7e5995c47125
Added more Javadoc.
Tim Englich <tim.englich@intevation.de>
parents:
813
diff
changeset
|
39 */ |
612
e86d37008fd1
Added new Transition and State for using the PreSettingsValue for the decision if a Transition could be used
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
40 private String dataName = null; |
824
7e5995c47125
Added more Javadoc.
Tim Englich <tim.englich@intevation.de>
parents:
813
diff
changeset
|
41 /** |
7e5995c47125
Added more Javadoc.
Tim Englich <tim.englich@intevation.de>
parents:
813
diff
changeset
|
42 * The Value that should be set to the State. |
7e5995c47125
Added more Javadoc.
Tim Englich <tim.englich@intevation.de>
parents:
813
diff
changeset
|
43 */ |
612
e86d37008fd1
Added new Transition and State for using the PreSettingsValue for the decision if a Transition could be used
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
44 private String dataValue = null; |
824
7e5995c47125
Added more Javadoc.
Tim Englich <tim.englich@intevation.de>
parents:
813
diff
changeset
|
45 /** |
7e5995c47125
Added more Javadoc.
Tim Englich <tim.englich@intevation.de>
parents:
813
diff
changeset
|
46 * The Operation that should be used (equal notequal) |
7e5995c47125
Added more Javadoc.
Tim Englich <tim.englich@intevation.de>
parents:
813
diff
changeset
|
47 */ |
612
e86d37008fd1
Added new Transition and State for using the PreSettingsValue for the decision if a Transition could be used
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
48 private String operator = null; |
778
9a828e5a2390
Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
612
diff
changeset
|
49 |
612
e86d37008fd1
Added new Transition and State for using the PreSettingsValue for the decision if a Transition could be used
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
50 /** |
e86d37008fd1
Added new Transition and State for using the PreSettingsValue for the decision if a Transition could be used
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
51 * The UID of this Class. |
e86d37008fd1
Added new Transition and State for using the PreSettingsValue for the decision if a Transition could be used
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
52 */ |
e86d37008fd1
Added new Transition and State for using the PreSettingsValue for the decision if a Transition could be used
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
53 private static final long serialVersionUID = -7846722158776823205L; |
e86d37008fd1
Added new Transition and State for using the PreSettingsValue for the decision if a Transition could be used
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
54 |
e86d37008fd1
Added new Transition and State for using the PreSettingsValue for the decision if a Transition could be used
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
55 /** |
e86d37008fd1
Added new Transition and State for using the PreSettingsValue for the decision if a Transition could be used
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
56 * Constructor |
e86d37008fd1
Added new Transition and State for using the PreSettingsValue for the decision if a Transition could be used
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
57 */ |
e86d37008fd1
Added new Transition and State for using the PreSettingsValue for the decision if a Transition could be used
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
58 public PresettingsValueCompareTransition() { |
e86d37008fd1
Added new Transition and State for using the PreSettingsValue for the decision if a Transition could be used
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
59 super(); |
e86d37008fd1
Added new Transition and State for using the PreSettingsValue for the decision if a Transition could be used
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
60 } |
e86d37008fd1
Added new Transition and State for using the PreSettingsValue for the decision if a Transition could be used
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
61 |
813
79c1db3ca7cc
Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
62 |
612
e86d37008fd1
Added new Transition and State for using the PreSettingsValue for the decision if a Transition could be used
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
63 public boolean isValid(State state) { |
e86d37008fd1
Added new Transition and State for using the PreSettingsValue for the decision if a Transition could be used
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
64 Map<String, InputData> preSettings = state.getPreSettings(); |
e86d37008fd1
Added new Transition and State for using the PreSettingsValue for the decision if a Transition could be used
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
65 if (preSettings != null){ |
e86d37008fd1
Added new Transition and State for using the PreSettingsValue for the decision if a Transition could be used
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
66 boolean dataAvailable = preSettings.containsKey(dataName); |
e86d37008fd1
Added new Transition and State for using the PreSettingsValue for the decision if a Transition could be used
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
67 if (dataAvailable){ |
e86d37008fd1
Added new Transition and State for using the PreSettingsValue for the decision if a Transition could be used
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
68 if (operator.equals("equal")){ |
e86d37008fd1
Added new Transition and State for using the PreSettingsValue for the decision if a Transition could be used
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
69 return preSettings.get(dataName).getValue().startsWith(dataValue); |
e86d37008fd1
Added new Transition and State for using the PreSettingsValue for the decision if a Transition could be used
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
70 }else if (operator.equals("notequal")){ |
e86d37008fd1
Added new Transition and State for using the PreSettingsValue for the decision if a Transition could be used
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
71 return !preSettings.get(dataName).getValue().startsWith(dataValue); |
e86d37008fd1
Added new Transition and State for using the PreSettingsValue for the decision if a Transition could be used
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
72 } |
e86d37008fd1
Added new Transition and State for using the PreSettingsValue for the decision if a Transition could be used
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
73 } |
e86d37008fd1
Added new Transition and State for using the PreSettingsValue for the decision if a Transition could be used
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
74 } |
e86d37008fd1
Added new Transition and State for using the PreSettingsValue for the decision if a Transition could be used
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
75 if (operator.equals("notequal")){ |
e86d37008fd1
Added new Transition and State for using the PreSettingsValue for the decision if a Transition could be used
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
76 return true; |
e86d37008fd1
Added new Transition and State for using the PreSettingsValue for the decision if a Transition could be used
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
77 } |
e86d37008fd1
Added new Transition and State for using the PreSettingsValue for the decision if a Transition could be used
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
78 return false; |
e86d37008fd1
Added new Transition and State for using the PreSettingsValue for the decision if a Transition could be used
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
79 } |
e86d37008fd1
Added new Transition and State for using the PreSettingsValue for the decision if a Transition could be used
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
80 |
813
79c1db3ca7cc
Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
81 |
612
e86d37008fd1
Added new Transition and State for using the PreSettingsValue for the decision if a Transition could be used
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
82 @Override |
e86d37008fd1
Added new Transition and State for using the PreSettingsValue for the decision if a Transition could be used
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
83 public void setup(Node configuration) { |
e86d37008fd1
Added new Transition and State for using the PreSettingsValue for the decision if a Transition could be used
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
84 super.setup(configuration); |
e86d37008fd1
Added new Transition and State for using the PreSettingsValue for the decision if a Transition could be used
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
85 this.dataName = Config.getStringXPath(configuration,"condition/@inputvalue"); |
e86d37008fd1
Added new Transition and State for using the PreSettingsValue for the decision if a Transition could be used
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
86 this.dataValue = Config.getStringXPath(configuration,"condition/@value"); |
e86d37008fd1
Added new Transition and State for using the PreSettingsValue for the decision if a Transition could be used
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
87 this.operator = Config.getStringXPath(configuration,"condition/@operator"); |
e86d37008fd1
Added new Transition and State for using the PreSettingsValue for the decision if a Transition could be used
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
88 } |
e86d37008fd1
Added new Transition and State for using the PreSettingsValue for the decision if a Transition could be used
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
89 } |
813
79c1db3ca7cc
Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
90 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |