# HG changeset patch # User Ingo Weinzierl # Date 1333100309 0 # Node ID 619f6dfec9019643169c6bd7de1e4f390595ef4c # Parent 15a3684c6bce138a915ef99aea58d8b1a373558b #460 Fixed duplicated Outputs in DESCRIBE documents. flys-artifacts/trunk@4186 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 15a3684c6bce -r 619f6dfec901 flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Thu Mar 29 11:09:26 2012 +0000 +++ b/flys-artifacts/ChangeLog Fri Mar 30 09:38:29 2012 +0000 @@ -1,3 +1,17 @@ +2012-03-30 Ingo Weinzierl + + flys/issue460 (W-Differenzen: Frühere Berechnungen aus den Datenkorb werden doppelt geladen) + + * src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java: Removed + code to find out all Outputs of this Artifacts. A method getOutputs() + had been implemented some time ago that does exactly this work. + + * src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java: Heavy + bugfix! Adding the current state id to the list of previous state ids + for temporary usage was no good idea! Now, the list of previous state + ids only modifified in advance(). This solves the problem of having + duplicated Outputs in the Artifact's DESCRIBE document. + 2012-03-29 Ingo Weinzierl flys/issue366 (W-INFO / Abflusskurve, Diagramm: Umbenennen von Themen und Anzeige im Diagramm) diff -r 15a3684c6bce -r 619f6dfec901 flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java Thu Mar 29 11:09:26 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java Fri Mar 30 09:38:29 2012 +0000 @@ -264,10 +264,12 @@ facets = flys.cloneFacets(); // Do not clone filter facets! - List stateIds = getPreviousStateIds(); - stateIds.add(getCurrentStateId()); + ArrayList stateIds = (ArrayList) getPreviousStateIds(); + ArrayList toInitialize = (ArrayList) stateIds.clone(); - for (String stateId: stateIds) { + toInitialize.add(getCurrentStateId()); + + for (String stateId: toInitialize) { State state = getState(context, stateId); if (state != null) { @@ -393,16 +395,19 @@ Element result = ec.create("result"); - String targetState = XMLUtils.xpathString( + String currentStateId = getCurrentStateId(); + String targetState = XMLUtils.xpathString( target, XPATH_ADVANCE_TARGET, ArtifactNamespaceContext.INSTANCE); logger.info("FLYSArtifact.advance() to '" + targetState + "'"); - if (isStateReachable(targetState, context)) { + if (!currentStateId.equals(targetState) + && isStateReachable(targetState, context)) + { logger.info("Advance: Step forward"); List prev = getPreviousStateIds(); - prev.add(getCurrentStateId()); + prev.add(currentStateId); setCurrentStateId(targetState); @@ -528,7 +533,9 @@ * @return #getPreviousStateIds() + #getCurrentStateId() */ public List getStateHistoryIds() { - List allIds = getPreviousStateIds(); + ArrayList prevIds = (ArrayList) getPreviousStateIds(); + ArrayList allIds = (ArrayList) prevIds.clone(); + allIds.add(getCurrentStateId()); return allIds; } @@ -1238,13 +1245,15 @@ public void endOfLife(Object context) { logger.info("FLYSArtifact.endOfLife: " + identifier()); - List ids = getPreviousStateIds(); - ids.add(getCurrentStateId()); + ArrayList ids = (ArrayList) getPreviousStateIds(); + ArrayList toDestroy = (ArrayList) ids.clone(); - destroyStates(ids, context); + toDestroy.add(getCurrentStateId()); + + destroyStates(toDestroy, context); } - - + + /** * Determines Facets initial disposition regarding activity (think of * selection in Client ThemeList GUI). This will be checked one time diff -r 15a3684c6bce -r 619f6dfec901 flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java Thu Mar 29 11:09:26 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java Fri Mar 30 09:38:29 2012 +0000 @@ -242,69 +242,10 @@ CallContext context, String uuid) { - List stateIds = getPreviousStateIds(); - - XMLUtils.ElementCreator creator = new XMLUtils.ElementCreator( - doc, - ArtifactNamespaceContext.NAMESPACE_URI, - ArtifactNamespaceContext.NAMESPACE_PREFIX); - - FLYSContext flysContext = FLYSUtils.getFlysContext(context); - StateEngine engine = (StateEngine) flysContext.get( - FLYSContext.STATE_ENGINE_KEY); - - for (String stateId: stateIds) { - logger.debug("Append output modes for state: " + stateId); - DefaultState state = (DefaultState) engine.getState(stateId); - - List list = state.getOutputs(); - if (list == null || list.size() == 0) { - logger.debug("-> No output modes for this state."); - continue; - } - - List fs = facets.get(stateId); - - if (fs == null || fs.size() == 0) { - logger.debug("No facets for previous state found."); - continue; - } - - logger.debug("Found " + fs.size() + " facets in previous states."); + List generated = getOutputs(context); + logger.debug("This Artifact has " + generated.size() + " Outputs."); - List generated = generateOutputs(list, fs); - - ProtocolUtils.appendOutputModes(doc, outs, generated); - } - - try { - DefaultState cur = (DefaultState) getCurrentState(context); - if (cur.validate(this)) { - List list = cur.getOutputs(); - if (list != null && list.size() > 0) { - logger.debug( - "Append output modes for current state: " + cur.getID()); - - List fs = facets.get(cur.getID()); - - if (fs != null && fs.size() > 0) { - List generated = generateOutputs(list, fs); - - logger.debug("Found " + fs.size() + " current facets."); - if (!generated.isEmpty()) { - ProtocolUtils.appendOutputModes( - doc, outs, generated); - } - } - else { - logger.debug("No facets found for the current state."); - } - } - } - } - catch (IllegalArgumentException iae) { - // state is not valid, so we do not append its outputs. - } + ProtocolUtils.appendOutputModes(doc, outs, generated); }