Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/transitions/DefaultTransition.java @ 1078:048517d67215
Changed state spawning mechanism of MainValuesArtifact.
flys-artifacts/trunk@2575 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Thu, 25 Aug 2011 10:38:45 +0000 |
parents | 542f280d72c3 |
children | b2ea89a665bc |
rev | line source |
---|---|
106
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.transitions; |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
354
542f280d72c3
Bugfix: Added the missing init() method to a Transition and call it in the TransitionFactory after a Transition has been created.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
107
diff
changeset
|
3 import org.w3c.dom.Node; |
542f280d72c3
Bugfix: Added the missing init() method to a Transition and call it in the TransitionFactory after a Transition has been created.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
107
diff
changeset
|
4 |
542f280d72c3
Bugfix: Added the missing init() method to a Transition and call it in the TransitionFactory after a Transition has been created.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
107
diff
changeset
|
5 import de.intevation.artifacts.Artifact; |
542f280d72c3
Bugfix: Added the missing init() method to a Transition and call it in the TransitionFactory after a Transition has been created.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
107
diff
changeset
|
6 |
107
a228b39494a9
Improved the bootstrap process - the states are initialized.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
106
diff
changeset
|
7 import de.intevation.artifactdatabase.state.State; |
a228b39494a9
Improved the bootstrap process - the states are initialized.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
106
diff
changeset
|
8 import de.intevation.artifactdatabase.transition.Transition; |
106
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 |
354
542f280d72c3
Bugfix: Added the missing init() method to a Transition and call it in the TransitionFactory after a Transition has been created.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
107
diff
changeset
|
10 |
106
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 /** |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 * The default implementation of a <code>Transition</code>. |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 * |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 */ |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 public class DefaultTransition implements Transition { |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 /** The ID of the current state */ |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 protected String from; |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 /** The ID of the target state */ |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 protected String to; |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 /** |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 * The default constructor. |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 */ |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 public DefaultTransition() { |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 } |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 /** |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 * The default constructor. |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 * |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 * @param from The current state. |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
36 * @param to The target state. |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 */ |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
38 public DefaultTransition(String from, String to) { |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
39 this.from = from; |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 this.to = to; |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 } |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
43 |
354
542f280d72c3
Bugfix: Added the missing init() method to a Transition and call it in the TransitionFactory after a Transition has been created.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
107
diff
changeset
|
44 public void init(Node config) { |
542f280d72c3
Bugfix: Added the missing init() method to a Transition and call it in the TransitionFactory after a Transition has been created.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
107
diff
changeset
|
45 // nothing to do in the default transition |
542f280d72c3
Bugfix: Added the missing init() method to a Transition and call it in the TransitionFactory after a Transition has been created.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
107
diff
changeset
|
46 } |
542f280d72c3
Bugfix: Added the missing init() method to a Transition and call it in the TransitionFactory after a Transition has been created.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
107
diff
changeset
|
47 |
542f280d72c3
Bugfix: Added the missing init() method to a Transition and call it in the TransitionFactory after a Transition has been created.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
107
diff
changeset
|
48 |
106
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
49 /** |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 * Returns the current state ID. |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
51 * |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
52 * @return the current state ID. |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
53 */ |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
54 public String getFrom() { |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
55 return from; |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
56 } |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
57 |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
58 |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
59 /** |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
60 * Returns the target state ID. |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
61 * |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
62 * @return the target state ID. |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
63 */ |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
64 public String getTo() { |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
65 return to; |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
66 } |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
67 |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
68 |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
69 /** |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
70 * Set the current state ID. |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
71 * |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
72 * @param to the current state ID. |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
73 */ |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
74 public void setFrom(String from) { |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
75 this.from = from; |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
76 } |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
77 |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
78 |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
79 /** |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
80 * Set the target state ID. |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
81 * |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
82 * @param to the target state ID. |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
83 */ |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
84 public void setTo(String to) { |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
85 this.to = to; |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
86 } |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
87 |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
88 |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
89 /** |
354
542f280d72c3
Bugfix: Added the missing init() method to a Transition and call it in the TransitionFactory after a Transition has been created.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
107
diff
changeset
|
90 * Determines if its valid to step from state <i>a</i> of an artifact |
542f280d72c3
Bugfix: Added the missing init() method to a Transition and call it in the TransitionFactory after a Transition has been created.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
107
diff
changeset
|
91 * <i>artifact</i> to state <i>b</i>. This method always returns true - no |
542f280d72c3
Bugfix: Added the missing init() method to a Transition and call it in the TransitionFactory after a Transition has been created.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
107
diff
changeset
|
92 * validation takes place. |
106
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
93 * |
354
542f280d72c3
Bugfix: Added the missing init() method to a Transition and call it in the TransitionFactory after a Transition has been created.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
107
diff
changeset
|
94 * @param artifact The owner artifact of state a and b. |
542f280d72c3
Bugfix: Added the missing init() method to a Transition and call it in the TransitionFactory after a Transition has been created.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
107
diff
changeset
|
95 * @param a The current state. |
542f280d72c3
Bugfix: Added the missing init() method to a Transition and call it in the TransitionFactory after a Transition has been created.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
107
diff
changeset
|
96 * @param b The target state. |
106
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
97 * |
354
542f280d72c3
Bugfix: Added the missing init() method to a Transition and call it in the TransitionFactory after a Transition has been created.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
107
diff
changeset
|
98 * @return true, if it is valid to step from a to b, otherwise false. |
106
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
99 */ |
354
542f280d72c3
Bugfix: Added the missing init() method to a Transition and call it in the TransitionFactory after a Transition has been created.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
107
diff
changeset
|
100 public boolean isValid(Artifact artifact, State a, State b) { |
106
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
101 return true; |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
102 } |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
103 } |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
104 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |