# HG changeset patch # User Ingo Weinzierl # Date 1308230640 0 # Node ID af393c5eb2c8ecacff5391fdb9f9875cc78dc982 # Parent 22e4bffbe2405dbaf77a3e6ef7c56fa4fc56ce2f Write computed facets into artifacts describe document. flys-artifacts/branches/facets-slt@2133 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 22e4bffbe240 -r af393c5eb2c8 flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java Thu Jun 16 10:05:44 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java Thu Jun 16 13:24:00 2011 +0000 @@ -246,6 +246,9 @@ setCurrentStateId(targetState); + logger.debug("Compute data for state: " + targetState); + compute(context, ComputeType.ADVANCE); + return describe(target, context); } else if (isPreviousState(targetState, context)) { @@ -264,8 +267,6 @@ setCurrentStateId(targetState); - compute(context, ComputeType.ADVANCE); - return describe(target, context); } @@ -1071,9 +1072,9 @@ * @return the computed data. */ public Object compute(CallContext context, String hash, ComputeType type) { - String calc = (String) getData(CalculationSelect.FIELD_MODE).getValue(); + DefaultState current = (DefaultState) getCurrentState(context); - DefaultState current = (DefaultState) getCurrentState(context); + logger.debug("Create ComputeCallback for state: " + current.getID()); ComputeCallback callback = current.createComputeCallback(hash(), this); diff -r 22e4bffbe240 -r af393c5eb2c8 flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java Thu Jun 16 10:05:44 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java Thu Jun 16 13:24:00 2011 +0000 @@ -1,7 +1,10 @@ package de.intevation.flys.artifacts; +import java.util.ArrayList; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -13,6 +16,8 @@ import de.intevation.artifacts.CallContext; import de.intevation.artifactdatabase.ProtocolUtils; +import de.intevation.artifactdatabase.state.DefaultOutput; +import de.intevation.artifactdatabase.state.Facet; import de.intevation.artifactdatabase.state.Output; import de.intevation.artifactdatabase.state.State; import de.intevation.artifactdatabase.state.StateEngine; @@ -180,7 +185,7 @@ for (String stateId: stateIds) { logger.debug("Append output modes for state: " + stateId); - State state = engine.getState(stateId); + DefaultState state = (DefaultState) engine.getState(stateId); List list = state.getOutputs(); if (list == null || list.size() == 0) { @@ -188,7 +193,17 @@ continue; } - ProtocolUtils.appendOutputModes(creator, outs, list); + List fs = facets.get(stateId); + if (fs == null || fs.size() == 0) { + logger.debug("No facets found."); + continue; + } + + logger.debug("Found " + fs.size() + " facets."); + + List generated = generateOutputs(list, fs); + + ProtocolUtils.appendOutputModes(creator, outs, generated); } try { @@ -199,7 +214,19 @@ logger.debug( "Append output modes for state: " + cur.getID()); - ProtocolUtils.appendOutputModes(creator, outs, list); + List fs = facets.get(cur.getID()); + if (fs != null && fs.size() > 0) { + List generated = generateOutputs(list, fs); + + logger.debug("Found " + fs.size() + " facets."); + + ProtocolUtils.appendOutputModes( + creator, outs, generated); + } + else { + logger.debug("No facets found for the current state."); + } + } } } @@ -209,6 +236,36 @@ } + protected List generateOutputs(List list, List fs) { + List generated = new ArrayList(); + + for (Output out: list) { + Output o = new DefaultOutput( + out.getName(), + out.getDescription(), + out.getMimeType()); + + Set outtype = new HashSet(); + + for (Facet f: out.getFacets()) { + outtype.add(f.getName()); + } + + for (Facet f: fs) { + String type = f.getName(); + + if(outtype.contains(type)) { + o.addFacet(f); + } + } + + generated.add(o); + } + + return generated; + } + + /** * This method appends the static data - that has already been inserted by * the user - to the static node of the DESCRIBE document. diff -r 22e4bffbe240 -r af393c5eb2c8 flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java Thu Jun 16 10:05:44 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java Thu Jun 16 13:24:00 2011 +0000 @@ -6,8 +6,8 @@ String DISCHARGE_LONGITUDINAL_Q = "discharge_longitudinal_section.q"; String DISCHARGE_LONGITUDINAL_C = "discharge_longitudinal_section.c"; - String LONGITUDINAL_W = "facet.longitudinal_section.w"; - String LONGITUDINAL_Q = "facet.longitudinal_section.q"; + String LONGITUDINAL_W = "longitudinal_section.w"; + String LONGITUDINAL_Q = "longitudinal_section.q"; String COMPUTED_DISCHARGE_Q = "computed_discharge_curve.q"; diff -r 22e4bffbe240 -r af393c5eb2c8 flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java Thu Jun 16 10:05:44 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java Thu Jun 16 13:24:00 2011 +0000 @@ -45,6 +45,8 @@ public ComputeCallback createComputeCallback( String hash, FLYSArtifact flys) { + logger.debug("Create waterlevel ComputeCallback."); + final WINFOArtifact winfo = (WINFOArtifact) flys; return new ComputeCallbackAdapter() { @@ -74,6 +76,9 @@ nameQ = "Q(" + nameQ + ")"; } + logger.debug("Create facet: " + nameW); + logger.debug("Create facet: " + nameQ); + Facet w = new DefaultFacet(i, LONGITUDINAL_W, nameW); Facet q = new DefaultFacet(i, LONGITUDINAL_Q, nameQ);