annotate artifact-database/src/main/java/de/intevation/artifactdatabase/state/StateEngine.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 ece0fdb07975
rev   line source
104
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1 package de.intevation.artifactdatabase.state;
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
3 import java.util.HashMap;
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
4 import java.util.List;
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
5 import java.util.Map;
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
6
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
7 import org.apache.log4j.Logger;
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
8
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
9 /**
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10 * The StateEngine stores all states for each Artifact.
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11 *
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13 */
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14 public class StateEngine {
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
15
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
16 /** The logger used in this class. */
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
17 private static Logger logger = Logger.getLogger(StateEngine.class);
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19 /**
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20 * A map that contains the states of the artifacts. The key of this map is
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
21 * the name of an artifact, its value is a list of all states the artifact
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
22 * can reach.
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
23 */
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24 protected Map<String, List> states;
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
27 /**
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28 * The default constructor.
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29 */
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30 public StateEngine() {
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31 states = new HashMap<String, List>();
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32 }
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
33
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
34
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
35 /**
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
36 * Add new states for a specific artifact.
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
37 *
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38 * @param artifact The name of the artifact.
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
39 * @param states A list of states that the artifact can reach.
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40 *
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
41 * @return true, if the states were added, otherwise false.
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
42 */
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
43 public boolean addStates(String artifact, List states) {
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
44 List tmp = this.states.get(artifact);
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
46 if (tmp != null) {
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47 logger.info(
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
48 "States for the artifact '" + artifact + "' already stored.");
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
49
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
50 return false;
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
51 }
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
52
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
53 logger.debug("Add new states for the artifact '" + artifact + "'");
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
54 return this.states.put(artifact, states) != null;
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
55 }
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
56 }
26bfff409dd3 Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
57 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org