raimund@3058: package de.intevation.flys.artifacts.states;
raimund@3058:
ingo@3072: import java.util.ArrayList;
ingo@3072: import java.util.List;
ingo@3072:
raimund@3058: import org.apache.log4j.Logger;
raimund@3058:
ingo@3072: import de.intevation.artifacts.CallContext;
ingo@3072:
ingo@3072: import de.intevation.artifactdatabase.state.Facet;
ingo@3072:
ingo@3072: import de.intevation.flys.artifacts.FLYSArtifact;
ingo@3072: import de.intevation.flys.artifacts.MINFOArtifact;
ingo@3072: import de.intevation.flys.artifacts.model.DataFacet;
ingo@3072: import de.intevation.flys.artifacts.model.FacetTypes;
ingo@3072: import de.intevation.flys.artifacts.model.CalculationResult;
ingo@3072: import de.intevation.flys.artifacts.model.sq.SQCurveFacet;
ingo@3072: import de.intevation.flys.artifacts.model.sq.SQMeasurementFacet;
ingo@3072: import de.intevation.flys.artifacts.model.sq.SQOutlierFacet;
ingo@3072: import de.intevation.flys.artifacts.model.sq.SQRelationCalculation;
raimund@3058: import de.intevation.flys.artifacts.states.DefaultState;
raimund@3058:
raimund@3058: /**
raimund@3058: * @author Raimund Renkert
raimund@3058: */
ingo@3072: public class SQRelation extends DefaultState implements FacetTypes {
raimund@3058:
raimund@3058: private static Logger logger = Logger.getLogger(SQRelation.class);
raimund@3058:
raimund@3058:
raimund@3058: public SQRelation() {
raimund@3058: }
raimund@3058:
ingo@3072:
raimund@3058: @Override
ingo@3072: public Object computeAdvance(
ingo@3072: FLYSArtifact artifact,
ingo@3072: String hash,
ingo@3072: CallContext context,
ingo@3072: List facets,
ingo@3072: Object old
ingo@3072: ) {
ingo@3072: logger.debug("SQRelation.computeAdvance");
ingo@3072:
ingo@3072: List newFacets = new ArrayList();
ingo@3072:
ingo@3072: CalculationResult res = old instanceof CalculationResult
ingo@3072: ? (CalculationResult) old
ingo@3072: : new SQRelationCalculation().calculate((MINFOArtifact) artifact);
ingo@3072:
ingo@3072: if (facets == null || res == null) {
ingo@3072: return res;
ingo@3072: }
ingo@3072:
ingo@3072: logger.error("Facet creation NOT IMPLEMENTED!");
ingo@3072: // TODO
ingo@3072: //for (int idx = 0; idx < res.length; idx++) {
ingo@3072: int idx = 0;
ingo@3072: createFacets(newFacets, idx);
ingo@3072: //}
ingo@3072:
ingo@3072: Facet csv = new DataFacet(
ingo@3072: CSV, "CSV data", ComputeType.ADVANCE, hash, id);
ingo@3072:
ingo@3072: Facet pdf = new DataFacet(
ingo@3072: PDF, "PDF data", ComputeType.ADVANCE, hash, id);
ingo@3072:
ingo@3072: newFacets.add(csv);
ingo@3072: newFacets.add(pdf);
ingo@3072:
ingo@3072: logger.debug("Created " + newFacets.size() + " new Facets.");
ingo@3072:
ingo@3072: facets.addAll(newFacets);
ingo@3072:
ingo@3072: return res;
raimund@3058: }
raimund@3058:
ingo@3072:
ingo@3072: protected void createFacets(List container, int idx) {
ingo@3072: // TODO Create facets for each parameter type (A-F)
ingo@3072: Facet measurements, outliers, curve;
ingo@3072: measurements = new SQMeasurementFacet(idx, SQ_A_MEASUREMENT, "TODO");
ingo@3072: outliers = new SQOutlierFacet(idx, SQ_A_OUTLIER, "TODO");
ingo@3072: curve = new SQCurveFacet(idx, SQ_A_CURVE, "TODO");
ingo@3072:
ingo@3072: container.add(measurements);
ingo@3072: container.add(outliers);
ingo@3072: container.add(curve);
ingo@3072:
ingo@3072: measurements = new SQMeasurementFacet(idx, SQ_B_MEASUREMENT, "TODO");
ingo@3072: outliers = new SQOutlierFacet(idx, SQ_B_OUTLIER, "TODO");
ingo@3072: curve = new SQCurveFacet(idx, SQ_B_CURVE, "TODO");
ingo@3072:
ingo@3072: container.add(measurements);
ingo@3072: container.add(outliers);
ingo@3072: container.add(curve);
ingo@3072:
ingo@3072: measurements = new SQMeasurementFacet(idx, SQ_C_MEASUREMENT, "TODO");
ingo@3072: outliers = new SQOutlierFacet(idx, SQ_C_OUTLIER, "TODO");
ingo@3072: curve = new SQCurveFacet(idx, SQ_C_CURVE, "TODO");
ingo@3072:
ingo@3072: container.add(measurements);
ingo@3072: container.add(outliers);
ingo@3072: container.add(curve);
ingo@3072:
ingo@3072: measurements = new SQMeasurementFacet(idx, SQ_D_MEASUREMENT, "TODO");
ingo@3072: outliers = new SQOutlierFacet(idx, SQ_D_OUTLIER, "TODO");
ingo@3072: curve = new SQCurveFacet(idx, SQ_D_CURVE, "TODO");
ingo@3072:
ingo@3072: container.add(measurements);
ingo@3072: container.add(outliers);
ingo@3072: container.add(curve);
ingo@3072:
ingo@3072: measurements = new SQMeasurementFacet(idx, SQ_E_MEASUREMENT, "TODO");
ingo@3072: outliers = new SQOutlierFacet(idx, SQ_E_OUTLIER, "TODO");
ingo@3072: curve = new SQCurveFacet(idx, SQ_E_CURVE, "TODO");
ingo@3072:
ingo@3072: container.add(measurements);
ingo@3072: container.add(outliers);
ingo@3072: container.add(curve);
ingo@3072:
ingo@3072: measurements = new SQMeasurementFacet(idx, SQ_F_MEASUREMENT, "TODO");
ingo@3072: outliers = new SQOutlierFacet(idx, SQ_F_OUTLIER, "TODO");
ingo@3072: curve = new SQCurveFacet(idx, SQ_F_CURVE, "TODO");
ingo@3072:
ingo@3072: container.add(measurements);
ingo@3072: container.add(outliers);
ingo@3072: container.add(curve);
ingo@3072: }
raimund@3058: }
raimund@3058: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :