changeset 3072:0d3dd8230064

Added component stubs for SQ relation calculation. flys-artifacts/trunk@4663 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 14 Jun 2012 13:46:07 +0000
parents 9136fc8f35f0
children 0ace00c0c12a
files flys-artifacts/ChangeLog flys-artifacts/doc/conf/artifacts/minfo.xml flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/SQCurveFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/SQMeasurementFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/SQOutlierFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/SQRelationCalculation.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/SQRelation.java
diffstat 8 files changed, 386 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Thu Jun 14 12:11:30 2012 +0000
+++ b/flys-artifacts/ChangeLog	Thu Jun 14 13:46:07 2012 +0000
@@ -1,3 +1,21 @@
+2012-06-14  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java: Added
+	  new Facets for MINFO SQ relation calculation.
+
+	* doc/conf/artifacts/minfo.xml: Added output for chart and data export for
+	  sq relation calculation. Registered new facets.
+
+	* src/main/java/de/intevation/flys/artifacts/model/sq/SQRelationCalculation.java,
+	  src/main/java/de/intevation/flys/artifacts/model/sq/SQOutlierFacet.java,
+	  src/main/java/de/intevation/flys/artifacts/model/sq/SQCurveFacet.java,
+	  src/main/java/de/intevation/flys/artifacts/model/sq/SQMeasurementFacet.java:
+	  Stubs for calculation and Facets used for SQ relation calculation.
+
+	* src/main/java/de/intevation/flys/artifacts/states/SQRelation.java:
+	  Override computeAdvance() and implemented a stub for calculation and
+	  Facet creation.
+
 2012-06-11  Raimund Renkert <raimund.renkert@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/services/DistanceInfoService.java:
--- a/flys-artifacts/doc/conf/artifacts/minfo.xml	Thu Jun 14 12:11:30 2012 +0000
+++ b/flys-artifacts/doc/conf/artifacts/minfo.xml	Thu Jun 14 13:46:07 2012 +0000
@@ -137,9 +137,52 @@
 
         <state id="state.minfo.sq.relation" description="state.minfo.sq.relation" state="de.intevation.flys.artifacts.states.SQRelation">
             <outputmodes>
-                <outputmode name="sq_relation" description="output.sq_relation">
+                <outputmode name="sq_relation_a" description="output.sq_relation" type="chart">
                     <facets>
-                       <facet/>
+                        <facet name="sq_a_measurement" description="A facet for sq measurements"/>
+                        <facet name="sq_a_outlier" description="A facet fo sq outliers"/>
+                        <facet name="sq_a_curve" description="A facet for sq curve"/>
+                    </facets>
+                </outputmode>
+                <outputmode name="sq_relation_b" description="output.sq_relation" type="chart">
+                    <facets>
+                        <facet name="sq_b_measurement" description="A facet for sq measurements"/>
+                        <facet name="sq_b_outlier" description="A facet fo sq outliers"/>
+                        <facet name="sq_b_curve" description="A facet for sq curve"/>
+                    </facets>
+                </outputmode>
+                <outputmode name="sq_relation_c" description="output.sq_relation" type="chart">
+                    <facets>
+                        <facet name="sq_c_measurement" description="A facet for sq measurements"/>
+                        <facet name="sq_c_outlier" description="A facet fo sq outliers"/>
+                        <facet name="sq_c_curve" description="A facet for sq curve"/>
+                    </facets>
+                </outputmode>
+                <outputmode name="sq_relation_d" description="output.sq_relation" type="chart">
+                    <facets>
+                        <facet name="sq_d_measurement" description="A facet for sq measurements"/>
+                        <facet name="sq_d_outlier" description="A facet fo sq outliers"/>
+                        <facet name="sq_d_curve" description="A facet for sq curve"/>
+                    </facets>
+                </outputmode>
+                <outputmode name="sq_relation_e" description="output.sq_relation" type="chart">
+                    <facets>
+                        <facet name="sq_e_measurement" description="A facet for sq measurements"/>
+                        <facet name="sq_e_outlier" description="A facet fo sq outliers"/>
+                        <facet name="sq_e_curve" description="A facet for sq curve"/>
+                    </facets>
+                </outputmode>
+                <outputmode name="sq_relation_f" description="output.sq_relation" type="chart">
+                    <facets>
+                        <facet name="sq_f_measurement" description="A facet for sq measurements"/>
+                        <facet name="sq_f_outlier" description="A facet fo sq outliers"/>
+                        <facet name="sq_f_curve" description="A facet for sq curve"/>
+                    </facets>
+                </outputmode>
+                <outputmode name="sq_relation_export" description="output.sq_relation_export" type="export">
+                    <facets>
+                        <facet name="csv" description="facet.sq_export.csv" />
+                        <facet name="pdf" description="facet.sq_export.pdf" />
                     </facets>
                 </outputmode>
             </outputmodes>
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java	Thu Jun 14 12:11:30 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java	Thu Jun 14 13:46:07 2012 +0000
@@ -156,6 +156,30 @@
     String MIDDLE_BED_HEIGHT_EPOCH      = "bedheight_middle.epoch";
     String MIDDLE_BED_HEIGHT_ANNOTATION = "bedheight_middle.annotation";
 
+    String SQ_A_CURVE       = "sq_a_curve";
+    String SQ_A_MEASUREMENT = "sq_a_measurement";
+    String SQ_A_OUTLIER     = "sq_a_outlier";
+
+    String SQ_B_CURVE       = "sq_b_curve";
+    String SQ_B_MEASUREMENT = "sq_b_measurement";
+    String SQ_B_OUTLIER     = "sq_b_outlier";
+
+    String SQ_C_CURVE       = "sq_c_curve";
+    String SQ_C_MEASUREMENT = "sq_c_measurement";
+    String SQ_C_OUTLIER     = "sq_c_outlier";
+
+    String SQ_D_CURVE       = "sq_d_curve";
+    String SQ_D_MEASUREMENT = "sq_d_measurement";
+    String SQ_D_OUTLIER     = "sq_d_outlier";
+
+    String SQ_E_CURVE       = "sq_e_curve";
+    String SQ_E_MEASUREMENT = "sq_e_measurement";
+    String SQ_E_OUTLIER     = "sq_e_outlier";
+
+    String SQ_F_CURVE       = "sq_f_curve";
+    String SQ_F_MEASUREMENT = "sq_f_measurement";
+    String SQ_F_OUTLIER     = "sq_f_outlier";
+
     String RELATIVE_POINT = "relativepoint";
 
     String FIX_ANALYSIS_EVENTS_DWT = "fix_analysis_events_dwt";
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/SQCurveFacet.java	Thu Jun 14 13:46:07 2012 +0000
@@ -0,0 +1,51 @@
+package de.intevation.flys.artifacts.model.sq;
+
+import org.apache.log4j.Logger;
+
+import de.intevation.artifacts.Artifact;
+import de.intevation.artifacts.CallContext;
+
+
+import de.intevation.flys.artifacts.model.FacetTypes;
+import de.intevation.flys.artifacts.model.DataFacet;
+
+import de.intevation.flys.artifacts.states.DefaultState.ComputeType;
+
+
+/**
+ * Facet to show the curve in a sq relation.
+ *
+ * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
+ */
+public class SQCurveFacet extends DataFacet implements FacetTypes {
+
+    private static final Logger log = Logger.getLogger(SQCurveFacet.class);
+
+
+    public SQCurveFacet() {
+    }
+
+
+    public SQCurveFacet(int idx, String name, String description) {
+        super(idx, name, description, ComputeType.ADVANCE, null, null);
+    }
+
+
+    @Override
+    public Object getData(Artifact artifact, CallContext context) {
+        log.debug("SQCurveFacet.getData");
+        log.error("NOT IMPLEMENTED!");
+
+        return null;
+    }
+
+
+    @Override
+    public SQCurveFacet deepCopy() {
+        SQCurveFacet copy = new SQCurveFacet();
+        copy.set(this);
+
+        return copy;
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/SQMeasurementFacet.java	Thu Jun 14 13:46:07 2012 +0000
@@ -0,0 +1,51 @@
+package de.intevation.flys.artifacts.model.sq;
+
+import org.apache.log4j.Logger;
+
+import de.intevation.artifacts.Artifact;
+import de.intevation.artifacts.CallContext;
+
+
+import de.intevation.flys.artifacts.model.FacetTypes;
+import de.intevation.flys.artifacts.model.DataFacet;
+
+import de.intevation.flys.artifacts.states.DefaultState.ComputeType;
+
+
+/**
+ * Facet to show the outliers in a sq relation.
+ *
+ * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
+ */
+public class SQMeasurementFacet extends DataFacet implements FacetTypes {
+
+    private static final Logger log = Logger.getLogger(SQMeasurementFacet.class);
+
+
+    public SQMeasurementFacet() {
+    }
+
+
+    public SQMeasurementFacet(int idx, String name, String description) {
+        super(idx, name, description, ComputeType.ADVANCE, null, null);
+    }
+
+
+    @Override
+    public Object getData(Artifact artifact, CallContext context) {
+        log.debug("SQMeasurementFacet.getData");
+        log.error("NOT IMPLEMENTED!");
+
+        return null;
+    }
+
+
+    @Override
+    public SQMeasurementFacet deepCopy() {
+        SQMeasurementFacet copy = new SQMeasurementFacet();
+        copy.set(this);
+
+        return copy;
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/SQOutlierFacet.java	Thu Jun 14 13:46:07 2012 +0000
@@ -0,0 +1,51 @@
+package de.intevation.flys.artifacts.model.sq;
+
+import org.apache.log4j.Logger;
+
+import de.intevation.artifacts.Artifact;
+import de.intevation.artifacts.CallContext;
+
+
+import de.intevation.flys.artifacts.model.FacetTypes;
+import de.intevation.flys.artifacts.model.DataFacet;
+
+import de.intevation.flys.artifacts.states.DefaultState.ComputeType;
+
+
+/**
+ * Facet to show the curve in a sq relation.
+ *
+ * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
+ */
+public class SQOutlierFacet extends DataFacet implements FacetTypes {
+
+    private static final Logger log = Logger.getLogger(SQOutlierFacet.class);
+
+
+    public SQOutlierFacet() {
+    }
+
+
+    public SQOutlierFacet(int idx, String name, String description) {
+        super(idx, name, description, ComputeType.ADVANCE, null, null);
+    }
+
+
+    @Override
+    public Object getData(Artifact artifact, CallContext context) {
+        log.debug("SQOutlierFacet.getData");
+        log.error("NOT IMPLEMENTED!");
+
+        return null;
+    }
+
+
+    @Override
+    public SQOutlierFacet deepCopy() {
+        SQOutlierFacet copy = new SQOutlierFacet();
+        copy.set(this);
+
+        return copy;
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/SQRelationCalculation.java	Thu Jun 14 13:46:07 2012 +0000
@@ -0,0 +1,36 @@
+package de.intevation.flys.artifacts.model.sq;
+
+import org.apache.log4j.Logger;
+
+import de.intevation.flys.artifacts.model.Calculation;
+import de.intevation.flys.artifacts.model.CalculationResult;
+
+import de.intevation.flys.artifacts.MINFOArtifact;
+
+
+public class SQRelationCalculation extends Calculation {
+
+    private static final Logger logger =
+        Logger.getLogger(SQRelationCalculation.class);
+
+
+    public CalculationResult calculate(MINFOArtifact artifact) {
+        logger.info("SQRelationCalculation.calculate");
+
+        // TODO Collect input params and use them for buildCalculationResult()
+
+        return buildCalculationResult();
+    }
+
+
+    protected CalculationResult buildCalculationResult(
+        // TODO Insert input params here
+    ) {
+        logger.info("SQRelationCalculation.buildCalculationResult");
+
+        logger.error("Not implemented!");
+
+        return new CalculationResult(new Object[0], this);
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/SQRelation.java	Thu Jun 14 12:11:30 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/SQRelation.java	Thu Jun 14 13:46:07 2012 +0000
@@ -1,28 +1,131 @@
 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.states.DefaultState;
 
 /**
  * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
  */
-public class SQRelation extends DefaultState {
+public class SQRelation extends DefaultState implements FacetTypes {
 
-    /** The logger used in this class. */
     private static Logger logger = Logger.getLogger(SQRelation.class);
 
 
-    /**
-     * The default constructor that initializes an empty State object.
-     */
     public SQRelation() {
     }
 
+
     @Override
-    protected String getUIProvider() {
-        return "minfo.sq.relation";
+    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;
+        }
+
+        logger.error("Facet creation NOT IMPLEMENTED!");
+        // TODO
+        //for (int idx = 0; idx < res.length; idx++) {
+            int idx = 0;
+            createFacets(newFacets, idx);
+        //}
+
+        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, int idx) {
+        // TODO Create facets for each parameter type (A-F)
+        Facet measurements, outliers, curve;
+        measurements = new SQMeasurementFacet(idx, SQ_A_MEASUREMENT, "TODO");
+        outliers     = new SQOutlierFacet(idx, SQ_A_OUTLIER, "TODO");
+        curve        = new SQCurveFacet(idx, SQ_A_CURVE, "TODO");
+
+        container.add(measurements);
+        container.add(outliers);
+        container.add(curve);
+
+        measurements = new SQMeasurementFacet(idx, SQ_B_MEASUREMENT, "TODO");
+        outliers     = new SQOutlierFacet(idx, SQ_B_OUTLIER, "TODO");
+        curve        = new SQCurveFacet(idx, SQ_B_CURVE, "TODO");
+
+        container.add(measurements);
+        container.add(outliers);
+        container.add(curve);
+
+        measurements = new SQMeasurementFacet(idx, SQ_C_MEASUREMENT, "TODO");
+        outliers     = new SQOutlierFacet(idx, SQ_C_OUTLIER, "TODO");
+        curve        = new SQCurveFacet(idx, SQ_C_CURVE, "TODO");
+
+        container.add(measurements);
+        container.add(outliers);
+        container.add(curve);
+
+        measurements = new SQMeasurementFacet(idx, SQ_D_MEASUREMENT, "TODO");
+        outliers     = new SQOutlierFacet(idx, SQ_D_OUTLIER, "TODO");
+        curve        = new SQCurveFacet(idx, SQ_D_CURVE, "TODO");
+
+        container.add(measurements);
+        container.add(outliers);
+        container.add(curve);
+
+        measurements = new SQMeasurementFacet(idx, SQ_E_MEASUREMENT, "TODO");
+        outliers     = new SQOutlierFacet(idx, SQ_E_OUTLIER, "TODO");
+        curve        = new SQCurveFacet(idx, SQ_E_CURVE, "TODO");
+
+        container.add(measurements);
+        container.add(outliers);
+        container.add(curve);
+
+        measurements = new SQMeasurementFacet(idx, SQ_F_MEASUREMENT, "TODO");
+        outliers     = new SQOutlierFacet(idx, SQ_F_OUTLIER, "TODO");
+        curve        = new SQCurveFacet(idx, SQ_F_CURVE, "TODO");
+
+        container.add(measurements);
+        container.add(outliers);
+        container.add(curve);
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org