comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java @ 1086:825ea312116d

Call State.endOfLife() for all States in the Artifact when Artifact.endOfLife() is called. flys-artifacts/trunk@2589 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 26 Aug 2011 08:53:37 +0000
parents 583314dafdb6
children b1c6d945848d
comparison
equal deleted inserted replaced
1085:07878836ee0d 1086:825ea312116d
368 return describe(target, context); 368 return describe(target, context);
369 } 369 }
370 else if (isPreviousState(targetState, context)) { 370 else if (isPreviousState(targetState, context)) {
371 logger.info("Advance: Step back to"); 371 logger.info("Advance: Step back to");
372 372
373 List<String> prevs = getPreviousStateIds(); 373 List<String> prevs = getPreviousStateIds();
374 int targetIdx = prevs.indexOf(targetState); 374 int targetIdx = prevs.indexOf(targetState);
375 int start = prevs.size() - 1; 375 int start = prevs.size() - 1;
376 376
377 logger.debug("Remove current state: " + getCurrentStateId()); 377 prevs.add(getCurrentStateId());
378 State cur = getCurrentState(context); 378 destroyStates(prevs, context);
379 cur.endOfLife(this, context);
380 379
381 for (int i = start; i >= targetIdx; i--) { 380 for (int i = start; i >= targetIdx; i--) {
382 String prev = prevs.get(i); 381 String prev = prevs.get(i);
383 logger.debug("Remove state id '" + prev + "'"); 382 logger.debug("Remove state id '" + prev + "'");
384
385 State s = getState(context, prev);
386 s.endOfLife(this, context);
387 383
388 prevs.remove(prev); 384 prevs.remove(prev);
389 facets.remove(prev); 385 facets.remove(prev);
390 } 386 }
391 387
919 logger.debug("CURRENT STATE: " + getCurrentStateId()); 915 logger.debug("CURRENT STATE: " + getCurrentStateId());
920 916
921 logger.debug("++++++++++++++ END ARTIFACT DUMP +++++++++++++++++"); 917 logger.debug("++++++++++++++ END ARTIFACT DUMP +++++++++++++++++");
922 } 918 }
923 } 919 }
920
921
922 /**
923 * Calls endOfLife() for each state in the list <i>ids</i>.
924 *
925 * @param ids The State IDs that should be destroyed.
926 * @param context The FLYSContext.
927 */
928 protected void destroyStates(List<String> ids, Object context) {
929 for (int i = 0, num = ids.size(); i < num; i++) {
930 State s = getState(context, ids.get(i));
931 s.endOfLife(this, context);
932 }
933 }
934
935
936 @Override
937 public void endOfLife(Object context) {
938 logger.info("FLYSArtifact.endOfLife: " + identifier());
939
940 List<String> ids = getPreviousStateIds();
941 ids.add(getCurrentStateId());
942
943 destroyStates(ids, context);
944 }
924 } 945 }
925 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 946 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org