Mercurial > dive4elements > river
view flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/SQRelation.java @ 3081:26119b7b3154
Fixing output generator hacking
flys-artifacts/trunk@4677 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Sun, 17 Jun 2012 20:45:01 +0000 |
parents | 8ad8a227d983 |
children | 4a76da133144 |
line wrap: on
line source
package de.intevation.flys.artifacts.states; import java.util.ArrayList; import java.util.List; import org.apache.log4j.Logger; import de.intevation.artifacts.CallContext; import de.intevation.artifactdatabase.state.Facet; import de.intevation.flys.artifacts.FLYSArtifact; import de.intevation.flys.artifacts.MINFOArtifact; import de.intevation.flys.artifacts.model.DataFacet; import de.intevation.flys.artifacts.model.FacetTypes; import de.intevation.flys.artifacts.model.CalculationResult; import de.intevation.flys.artifacts.model.sq.SQCurveFacet; import de.intevation.flys.artifacts.model.sq.SQMeasurementFacet; import de.intevation.flys.artifacts.model.sq.SQOutlierFacet; import de.intevation.flys.artifacts.model.sq.SQRelationCalculation; import de.intevation.flys.artifacts.model.sq.SQResult; import de.intevation.flys.artifacts.states.DefaultState; /** * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> */ public class SQRelation extends DefaultState implements FacetTypes { private static Logger logger = Logger.getLogger(SQRelation.class); public SQRelation() { } @Override public Object computeAdvance( FLYSArtifact artifact, String hash, CallContext context, List<Facet> facets, Object old ) { logger.debug("SQRelation.computeAdvance"); List<Facet> newFacets = new ArrayList<Facet>(); CalculationResult res = old instanceof CalculationResult ? (CalculationResult) old : new SQRelationCalculation().calculate((MINFOArtifact) artifact); if (facets == null || res == null) { return res; } SQResult[] sqr = (SQResult[]) res.getData(); createFacets(newFacets, sqr, hash); Facet csv = new DataFacet( CSV, "CSV data", ComputeType.ADVANCE, hash, id); Facet pdf = new DataFacet( PDF, "PDF data", ComputeType.ADVANCE, hash, id); newFacets.add(csv); newFacets.add(pdf); logger.debug("Created " + newFacets.size() + " new Facets."); facets.addAll(newFacets); return res; } protected void createFacets( List<Facet> container, SQResult[] sqr, String hash ) { // TODO Create facets for each parameter type (A-F) container.add(new SQMeasurementFacet(0, SQ_A_MEASUREMENT, "TODO")); container.add(new SQCurveFacet(0, SQ_A_CURVE, "TODO")); for (int i = 0; i < sqr[0].getOutliersCount(); i++) { container.add(new SQOutlierFacet( 0, i, SQ_A_OUTLIER, "OUTLIER AT" + i, getID(), hash )); } } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :