Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java @ 1094:b1c6d945848d
Added a new method to FLYSArtifact to destroy a single state (call its endOfLife).
flys-artifacts/trunk@2597 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 26 Aug 2011 14:55:18 +0000 |
parents | 825ea312116d |
children | ea80e652f033 |
comparison
equal
deleted
inserted
replaced
1093:139e7df1787c | 1094:b1c6d945848d |
---|---|
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 prevs.add(getCurrentStateId()); | |
378 destroyStates(prevs, context); | 377 destroyStates(prevs, context); |
379 | 378 |
380 for (int i = start; i >= targetIdx; i--) { | 379 for (int i = start; i >= targetIdx; i--) { |
381 String prev = prevs.get(i); | 380 String prev = prevs.get(i); |
382 logger.debug("Remove state id '" + prev + "'"); | 381 logger.debug("Remove state id '" + prev + "'"); |
383 | 382 |
384 prevs.remove(prev); | 383 prevs.remove(prev); |
385 facets.remove(prev); | 384 facets.remove(prev); |
386 } | 385 } |
387 | 386 |
387 destroyState(getCurrentStateId(), context); | |
388 setCurrentStateId(targetState); | 388 setCurrentStateId(targetState); |
389 | 389 |
390 return describe(target, context); | 390 return describe(target, context); |
391 } | 391 } |
392 | 392 |
917 logger.debug("++++++++++++++ END ARTIFACT DUMP +++++++++++++++++"); | 917 logger.debug("++++++++++++++ END ARTIFACT DUMP +++++++++++++++++"); |
918 } | 918 } |
919 } | 919 } |
920 | 920 |
921 | 921 |
922 protected void destroyState(String id, Object context) { | |
923 State s = getState(context, id); | |
924 s.endOfLife(this, context); | |
925 } | |
926 | |
927 | |
922 /** | 928 /** |
923 * Calls endOfLife() for each state in the list <i>ids</i>. | 929 * Calls endOfLife() for each state in the list <i>ids</i>. |
924 * | 930 * |
925 * @param ids The State IDs that should be destroyed. | 931 * @param ids The State IDs that should be destroyed. |
926 * @param context The FLYSContext. | 932 * @param context The FLYSContext. |
927 */ | 933 */ |
928 protected void destroyStates(List<String> ids, Object context) { | 934 protected void destroyStates(List<String> ids, Object context) { |
929 for (int i = 0, num = ids.size(); i < num; i++) { | 935 for (int i = 0, num = ids.size(); i < num; i++) { |
930 State s = getState(context, ids.get(i)); | 936 destroyState(ids.get(i), context); |
931 s.endOfLife(this, context); | |
932 } | 937 } |
933 } | 938 } |
934 | 939 |
935 | 940 |
936 @Override | 941 @Override |