# HG changeset patch # User Ingo Weinzierl # Date 1314348817 0 # Node ID 825ea312116d34554708471ce8ffd2bb344d393a # Parent 07878836ee0d4760767af61ab0bd316f8a5a1329 Call State.endOfLife() for all States in the Artifact when Artifact.endOfLife() is called. flys-artifacts/trunk@2589 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 07878836ee0d -r 825ea312116d flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Fri Aug 26 08:49:18 2011 +0000 +++ b/flys-artifacts/ChangeLog Fri Aug 26 08:53:37 2011 +0000 @@ -1,3 +1,9 @@ +2011-08-26 Ingo Weinzierl + + * src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java: Call + State.endOfLife() for all States when endOfLife() of the Artifact is + called. + 2011-08-26 Felix Wolfsteller Also plot "W"-MainValues (on vertical axis), take correct parameters, but diff -r 07878836ee0d -r 825ea312116d flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java Fri Aug 26 08:49:18 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java Fri Aug 26 08:53:37 2011 +0000 @@ -370,21 +370,17 @@ else if (isPreviousState(targetState, context)) { logger.info("Advance: Step back to"); - List prevs = getPreviousStateIds(); + List prevs = getPreviousStateIds(); int targetIdx = prevs.indexOf(targetState); int start = prevs.size() - 1; - logger.debug("Remove current state: " + getCurrentStateId()); - State cur = getCurrentState(context); - cur.endOfLife(this, context); + prevs.add(getCurrentStateId()); + destroyStates(prevs, context); for (int i = start; i >= targetIdx; i--) { String prev = prevs.get(i); logger.debug("Remove state id '" + prev + "'"); - State s = getState(context, prev); - s.endOfLife(this, context); - prevs.remove(prev); facets.remove(prev); } @@ -921,5 +917,30 @@ logger.debug("++++++++++++++ END ARTIFACT DUMP +++++++++++++++++"); } } + + + /** + * Calls endOfLife() for each state in the list ids. + * + * @param ids The State IDs that should be destroyed. + * @param context The FLYSContext. + */ + protected void destroyStates(List ids, Object context) { + for (int i = 0, num = ids.size(); i < num; i++) { + State s = getState(context, ids.get(i)); + s.endOfLife(this, context); + } + } + + + @Override + public void endOfLife(Object context) { + logger.info("FLYSArtifact.endOfLife: " + identifier()); + + List ids = getPreviousStateIds(); + ids.add(getCurrentStateId()); + + destroyStates(ids, context); + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :