comparison artifact-database/src/main/java/de/intevation/artifactdatabase/transition/TransitionEngine.java @ 104:26bfff409dd3

Added interfaces and engines used in concrete artifact packages. artifacts/trunk@1289 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 03 Feb 2011 18:00:41 +0000
parents
children 9ece61d918b1
comparison
equal deleted inserted replaced
103:1282cf96d3eb 104:26bfff409dd3
1 package de.intevation.artifactdatabase.transition;
2
3 import java.util.HashMap;
4 import java.util.List;
5 import java.util.Map;
6
7 import org.apache.log4j.Logger;
8
9 /**
10 * The TransitionEngine stores all transitions for each Artifact and should be
11 * used to determine, if an Artifact is able to advance from one to another
12 * state.
13 *
14 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
15 */
16 public class TransitionEngine {
17
18 /** The logger used in this class. */
19 private static Logger logger = Logger.getLogger(TransitionEngine.class);
20
21 /**
22 * A map that contains the transitions of the artifacts. The key is the name
23 * of the artifact, its value is a list of all transitions of this artifact.
24 */
25 protected Map<String, List> transitions;
26
27
28 /**
29 * The default constructor.
30 */
31 public TransitionEngine() {
32 transitions = new HashMap<String, List>();
33 }
34
35
36 /**
37 * Add new transitions for a specific artifact.
38 *
39 * @param stateId the name of the Artifact.
40 * @param transitions the list of transition of the artifact.
41 *
42 * @return true, if the transitions were added, otherwise false.
43 */
44 public boolean addTransition(String stateId, List transitions) {
45 List tmp = this.transitions.get(stateId);
46
47 if (tmp != null) {
48 logger.info(
49 "Transitions for the state '"
50 + stateId
51 + "' already stored.");
52
53 return false;
54 }
55
56 logger.debug("Add new transitions for state '" + stateId + "'");
57 return this.transitions.put(stateId, transitions) != null;
58 }
59 }
60 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org