ingo@688: package de.intevation.flys.artifacts.states; ingo@688: ingo@688: import java.util.List; ingo@688: ingo@688: import org.apache.log4j.Logger; ingo@688: ingo@688: import de.intevation.artifacts.CallContext; ingo@688: ingo@688: import de.intevation.artifactdatabase.state.Facet; ingo@688: ingo@688: import de.intevation.flys.artifacts.FLYSArtifact; ingo@688: import de.intevation.flys.artifacts.WINFOArtifact; ingo@692: import de.intevation.flys.artifacts.model.FacetTypes; sascha@711: import de.intevation.flys.artifacts.model.ReportFacet; ingo@696: import de.intevation.flys.artifacts.model.WaterlevelFacet; ingo@692: import de.intevation.flys.artifacts.model.WQKms; ingo@688: sascha@703: import de.intevation.flys.artifacts.model.DataFacet; sascha@709: import de.intevation.flys.artifacts.model.CalculationResult; sascha@703: ingo@688: ingo@692: public class WaterlevelState ingo@692: extends DefaultState ingo@692: implements FacetTypes ingo@692: { ingo@688: /** The logger that is used in this state.*/ ingo@688: private static Logger logger = Logger.getLogger(WaterlevelState.class); ingo@688: ingo@688: ingo@688: @Override sascha@697: public Object computeAdvance( sascha@697: FLYSArtifact artifact, sascha@697: String hash, sascha@697: CallContext context, sascha@742: List facets, sascha@697: Object old sascha@697: ) { sascha@697: WINFOArtifact winfo = (WINFOArtifact)artifact; ingo@692: sascha@709: CalculationResult res = old instanceof CalculationResult sascha@709: ? (CalculationResult)old sascha@709: : winfo.getWaterlevelData(); ingo@692: sascha@705: if (facets == null) { sascha@705: return res; sascha@705: } sascha@705: sascha@709: WQKms [] wqkms = (WQKms [])res.getData(); sascha@709: sascha@709: for (int i = 0; i < wqkms.length; i++) { sascha@697: String nameW = null; sascha@697: String nameQ = null; ingo@692: sascha@697: if (winfo.isQ()) { sascha@709: nameQ = wqkms[i].getName(); sascha@697: nameW = "W(" + nameQ + ")"; ingo@688: } sascha@697: else { sascha@709: nameW = wqkms[i].getName(); sascha@697: nameQ = "Q(" + nameQ + ")"; sascha@697: } sascha@697: sascha@697: logger.debug("Create facet: " + nameW); sascha@697: logger.debug("Create facet: " + nameQ); sascha@697: sascha@697: Facet w = new WaterlevelFacet(i, LONGITUDINAL_W, nameW); sascha@697: Facet q = new WaterlevelFacet(i, LONGITUDINAL_Q, nameQ); sascha@697: sascha@697: facets.add(w); sascha@697: facets.add(q); sascha@697: } sascha@697: sascha@709: if (wqkms.length > 0) { sascha@703: Facet wst = new DataFacet(WST, "WST data"); sascha@703: Facet csv = new DataFacet(CSV, "CSV data"); sascha@703: sascha@703: facets.add(wst); sascha@703: facets.add(csv); sascha@703: } sascha@703: sascha@711: if (res.getReport().hasProblems()) { sascha@711: facets.add(new ReportFacet()); sascha@711: } sascha@711: sascha@697: return res; ingo@688: } ingo@688: } ingo@688: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :