comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/transitions/TransitionEngine.java @ 106:5864c41219db

Initializes a TransitionEngine storing all transitions for each artifact at the application start. flys-artifacts/trunk@1288 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 03 Feb 2011 10:23:30 +0000
parents
children
comparison
equal deleted inserted replaced
105:beb991dc4827 106:5864c41219db
1 package de.intevation.flys.artifacts.transitions;
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 artifact 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 artifact, List transitions) {
45 List tmp = this.transitions.get(artifact);
46
47 if (tmp != null) {
48 logger.info(
49 "Transitions for the artifact '"
50 + artifact
51 + "' already stored.");
52
53 return false;
54 }
55
56 logger.debug("Add new transitions for artifact '" + artifact + "'");
57 return this.transitions.put(artifact, transitions) != null;
58 }
59 }
60 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org