# HG changeset patch # User Ingo Weinzierl # Date 1327929452 0 # Node ID 5420b96dd0b39a0c74a965da143b480a59f43973 # Parent 6072f84608c2754df6ba438c1d245b7b173d92ad Added a method StateEngine.getStateData() that returns the StateData of a specific Artifact. artifacts/trunk@3827 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 6072f84608c2 -r 5420b96dd0b3 ChangeLog --- a/ChangeLog Mon Jan 30 13:15:52 2012 +0000 +++ b/ChangeLog Mon Jan 30 13:17:32 2012 +0000 @@ -1,3 +1,9 @@ +2012-01-30 Ingo Weinzierl + + * artifact-database/src/main/java/de/intevation/artifactdatabase/state/StateEngine.java: + Added a method that returns a StateData objects of a specific Artifact + based on the Artifact's StateData's name. + 2012-01-30 Ingo Weinzierl * artifact-database/src/main/java/de/intevation/artifactdatabase/state/AbstractState.java: diff -r 6072f84608c2 -r 5420b96dd0b3 artifact-database/src/main/java/de/intevation/artifactdatabase/state/StateEngine.java --- a/artifact-database/src/main/java/de/intevation/artifactdatabase/state/StateEngine.java Mon Jan 30 13:15:52 2012 +0000 +++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/state/StateEngine.java Mon Jan 30 13:17:32 2012 +0000 @@ -7,6 +7,9 @@ import org.apache.log4j.Logger; +import de.intevation.artifactdatabase.data.StateData; + + /** * The StateEngine stores all states and associated information about * outputs and facets for each Artifact. @@ -64,6 +67,30 @@ } + public StateData getStateData(String artifact, String dataName) { + List artifactStates = getStates(artifact); + + if (artifactStates == null || artifactStates.size() == 0) { + logger.warn("No States for Artifact '" + artifact + "' existing."); + return null; + } + + for (State state: artifactStates) { + StateData sd = state.getData(dataName); + + if (sd != null) { + return sd; + } + } + + logger.warn( + "No StateData for Artifact '" + artifact + + "' with name '" + dataName + "' existing."); + + return null; + } + + /** * Add new states for a specific artifact. *