Mercurial > dive4elements > river
changeset 1971:741d2067cfe1
Given CrossSections a name, let crosssection facets survive.
flys-artifacts/trunk@3387 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Mon, 12 Dec 2011 11:19:56 +0000 |
parents | 368040e5c400 |
children | 3c3e81fca092 |
files | flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/CrossSectionArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/StaticState.java |
diffstat | 3 files changed, 79 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Mon Dec 12 08:15:12 2011 +0000 +++ b/flys-artifacts/ChangeLog Mon Dec 12 11:19:56 2011 +0000 @@ -1,3 +1,18 @@ +2011-12-12 Felix Wolfsteller <felix.wolfsteller@intevation.de> + + Resolve todo about wrongly named cross sections. + Open StaticState to allow that facets survive a compute. + + * src/main/java/de/intevation/flys/artifacts/states/StaticState.java + (computeAdvance, computeFeed, computeInit): Override to call + staticCompute. + (staticCompute): New. Do nothing but be able to be overridden. + + * src/main/java/de/intevation/flys/artifacts/CrossSectionArtifact.java + (setup): Fetch facets name from db (resolves todo). + (getCurrentState): override staticstates staticcompute to let + facets survive a compute. + 2011-12-12 Ingo Weinzierl <ingo@intevation.de> * src/main/java/de/intevation/flys/wsplgen/JobExecutor.java,
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/CrossSectionArtifact.java Mon Dec 12 08:15:12 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/CrossSectionArtifact.java Mon Dec 12 11:19:56 2011 +0000 @@ -90,10 +90,10 @@ addStringData(DATA_IS_MASTER, "0"); List<Facet> fs = new ArrayList<Facet>(); - fs.add(new CrossSectionFacet(0, "TODO GET NAME FROM DB")); + CrossSection cs = CrossSectionFactory.getCrossSection(Integer.valueOf(ids)); + fs.add(new CrossSectionFacet(0, cs.getDescription())); StaticState state = (StaticState) getCurrentState(context); - state.computeInit(this, hash(), context, callMeta, fs); if (!fs.isEmpty()) { facets.put(getCurrentStateId(), fs); @@ -117,9 +117,16 @@ */ @Override public State getCurrentState(Object cc) { - StaticState state = new StaticState(STATIC_STATE_NAME); + final List<Facet> fs = facets.get(getCurrentStateId()); - List<Facet> fs = facets.get(getCurrentStateId()); + StaticState state = new StaticState(STATIC_STATE_NAME) { + public Object staticCompute(List<Facet> facets) { + if (facets != null) { + facets.addAll(fs); + } + return null; + } + }; state.addDefaultChartOutput("cross_section", fs);
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/StaticState.java Mon Dec 12 08:15:12 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/StaticState.java Mon Dec 12 11:19:56 2011 +0000 @@ -9,6 +9,11 @@ import de.intevation.artifactdatabase.state.Facet; import de.intevation.artifactdatabase.state.DefaultOutput; +import de.intevation.flys.artifacts.FLYSArtifact; + +import de.intevation.artifacts.CallContext; +import de.intevation.artifacts.CallMeta; + /** * Yet, a non-abstract DefaultState. */ @@ -40,5 +45,53 @@ nameDesc, "image/png", facets, "chart"); getOutputs().add(output); } + + + /** + * Do nothing (override to include your logic). + * @param facets List of facets (to add to). + */ + public Object staticCompute(List<Facet> facets) { + return null; + } + + + /** Call staticCompute to allow easy adjustments. */ + @Override + public Object computeAdvance( + FLYSArtifact artifact, + String hash, + CallContext context, + List<Facet> facets, + Object old + ) { + return staticCompute(facets); + } + + + /** Call staticCompute to allow easy adjustments. */ + @Override + public Object computeFeed( + FLYSArtifact artifact, + String hash, + CallContext context, + List<Facet> facets, + Object old + ) { + return staticCompute(facets); + } + + + /** Call staticCompute to allow easy adjustments. */ + @Override + public Object computeInit( + FLYSArtifact artifact, + String hash, + Object context, + CallMeta meta, + List<Facet> facets + ) { + return staticCompute(facets); + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :