Mercurial > dive4elements > river
view flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/HistoricalDischargeComputeState.java @ 3445:b6c301cb3871
Handle FixationArtifacts in WQAdapted-State.
flys-artifacts/trunk@5108 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Mon, 23 Jul 2012 15:11:12 +0000 |
parents | d20215a0afd8 |
children | d7db9baa4e62 |
line wrap: on
line source
package de.intevation.flys.artifacts.states; import java.util.List; import org.w3c.dom.Element; import org.apache.log4j.Logger; import de.intevation.artifacts.Artifact; import de.intevation.artifacts.CallContext; import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator; import de.intevation.artifactdatabase.state.Facet; import de.intevation.flys.artifacts.FLYSArtifact; import de.intevation.flys.artifacts.WINFOArtifact; import de.intevation.flys.artifacts.model.CalculationResult; import de.intevation.flys.artifacts.model.DataFacet; import de.intevation.flys.artifacts.model.FacetTypes; import de.intevation.flys.artifacts.model.HistoricalDischargeFacet; import de.intevation.flys.artifacts.model.HistoricalDischargeDifferenceFacet; import de.intevation.flys.artifacts.model.HistoricalWQTimerange; import de.intevation.flys.artifacts.model.ReportFacet; import de.intevation.flys.artifacts.model.WQTimerange; /** * State to calculate historical discharge curves. * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> */ public class HistoricalDischargeComputeState extends DefaultState implements FacetTypes { private static final Logger logger = Logger.getLogger(HistoricalDischargeComputeState.class); @Override protected void appendItems( Artifact artifact, ElementCreator creator, String name, CallContext context, Element select ) { // TODO IMPLEMENT ME } @Override public Object computeAdvance( FLYSArtifact artifact, String hash, CallContext context, List<Facet> facets, Object old ) { logger.debug("HistoricalDischargeComputeState.computeAdvance"); WINFOArtifact winfo = (WINFOArtifact) artifact; CalculationResult res = old instanceof CalculationResult ? (CalculationResult) old : winfo.getHistoricalDischargeData(); if (facets == null) { return res; } if (res.getReport().hasProblems()) { facets.add(new ReportFacet(ComputeType.ADVANCE, hash, id)); } WQTimerange[] data = (WQTimerange[]) res.getData(); if (data == null || data.length == 0) { logger.warn("Historical Discharge calculation has no results!"); return res; } facets.add( new DataFacet(CSV, "CSV data", ComputeType.ADVANCE, hash, id)); facets.add( new DataFacet(PDF, "PDF data", ComputeType.ADVANCE, hash, id)); prepareFacets(facets, data); return res; } protected void prepareFacets(List<Facet> facets, WQTimerange[] wqts) { int i = 0; for (WQTimerange wqt: wqts) { logger.debug("Prepare facet for: " + wqt.getName()); // TODO CREATE BETTER TITLE FOR FACETS facets.add(new HistoricalDischargeFacet( i, HISTORICAL_DISCHARGE_Q, wqt.getName())); if (wqt instanceof HistoricalWQTimerange) { logger.debug("Create another facet for historical differences."); facets.add(new HistoricalDischargeDifferenceFacet( i, HISTORICAL_DISCHARGE_Q_DIFF, "DIFF: " + wqt.getName())); } i++; } } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :