Mercurial > dive4elements > gnv-client
annotate gnv-artifacts/src/main/java/de/intevation/gnv/transition/ValueCompareTransition.java @ 801:d766fe2d917a
More javadoc.
gnv-artifacts/trunk@883 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 06 Apr 2010 16:53:43 +0000 |
parents | c4156275c1e1 |
children | 79c1db3ca7cc |
rev | line source |
---|---|
337
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.gnv.transition; |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
2 |
779
b1f5f2a8840f
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
3 import de.intevation.artifactdatabase.Config; |
b1f5f2a8840f
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
4 |
b1f5f2a8840f
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
5 import de.intevation.gnv.state.InputData; |
b1f5f2a8840f
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
6 import de.intevation.gnv.state.State; |
b1f5f2a8840f
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
7 |
b1f5f2a8840f
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
8 import de.intevation.gnv.state.exception.StateException; |
b1f5f2a8840f
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
9 |
337
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
10 import java.util.Iterator; |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
11 |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
12 import org.apache.log4j.Logger; |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
13 |
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; |
337
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
15 |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
16 /** |
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
|
17 * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a> |
337
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
18 * |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
19 */ |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
20 public class ValueCompareTransition extends TransitionBase { |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
21 |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
22 /** |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
23 * the logger, used to log exceptions and additonaly information |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
24 */ |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
25 private static Logger log = Logger.getLogger(ValueCompareTransition.class); |
778
9a828e5a2390
Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
337
diff
changeset
|
26 |
337
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
27 private String dataName = null; |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
28 private String dataValue = null; |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
29 private String operator = null; |
778
9a828e5a2390
Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
337
diff
changeset
|
30 |
337
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
31 /** |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
32 * The UID of this Class. |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
33 */ |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
34 private static final long serialVersionUID = -7846722158776823205L; |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
35 |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
36 /** |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
37 * Constructor |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
38 */ |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
39 public ValueCompareTransition() { |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
40 super(); |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
41 } |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
42 |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
43 /** |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
44 * @see de.intevation.gnv.transition.Transition#isValid(de.intevation.gnv.state.State) |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
45 */ |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
46 public boolean isValid(State state) { |
778
9a828e5a2390
Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
337
diff
changeset
|
47 |
337
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
48 try { |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
49 Iterator<InputData> it = state.getInputData().iterator(); |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
50 while (it.hasNext()){ |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
51 InputData inputData = it.next(); |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
52 if (inputData.getName().equals(this.dataName)){ |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
53 boolean returnValue = false; |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
54 if (operator.equals("equal")){ |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
55 returnValue = this.dataValue.equals(inputData.getValue()); |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
56 }else if (operator.equals("notequal")){ |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
57 returnValue = !this.dataValue.equals(inputData.getValue()); |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
58 } |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
59 return returnValue; |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
60 } |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
61 } |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
62 if (operator.equals("notequal")){ |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
63 // data is not given. So the constraint not Equals is fullfilled. |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
64 return true; |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
65 } |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
66 } catch (StateException e) { |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
67 log.error(e,e); |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
68 return false; |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
69 } |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
70 return false; |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
71 } |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
72 |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
73 @Override |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
74 public void setup(Node configuration) { |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
75 super.setup(configuration); |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
76 this.dataName = Config.getStringXPath(configuration,"condition/@inputvalue"); |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
77 this.dataValue = Config.getStringXPath(configuration,"condition/@value"); |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
78 this.operator = Config.getStringXPath(configuration,"condition/@operator"); |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
79 } |
778
9a828e5a2390
Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
337
diff
changeset
|
80 |
337
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
81 |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
82 } |