changeset 2196:5f3726f31f00

"Bezugslinienverfahren": Added facet classes. flys-artifacts/trunk@3812 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Fri, 27 Jan 2012 17:45:26 +0000
parents e14beb93a854
children 5781847433d8
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/NormalizedReferenceCurveFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/ReferenceCurveFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WaterlevelFacet.java
diffstat 4 files changed, 138 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Fri Jan 27 17:17:45 2012 +0000
+++ b/flys-artifacts/ChangeLog	Fri Jan 27 17:45:26 2012 +0000
@@ -1,3 +1,13 @@
+2012-01-27	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/model/NormalizedReferenceCurveFacet.java:
+	  New. Facet for the normalized W~W relation.
+	  TODO: Implement the on-the-fly creation logic.
+
+	* src/main/java/de/intevation/flys/artifacts/model/ReferenceCurveFacet.java:
+	  New. Facet for the W~W relation.
+
+	* src/main/java/de/intevation/flys/artifacts/model/WaterlevelFacet.java: Cosmetics.
 2012-01-27	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/states/ReferenceCurveState.java:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/NormalizedReferenceCurveFacet.java	Fri Jan 27 17:45:26 2012 +0000
@@ -0,0 +1,47 @@
+package de.intevation.flys.artifacts.model;
+
+import de.intevation.artifactdatabase.state.Facet;
+
+import de.intevation.flys.artifacts.states.DefaultState.ComputeType;
+
+public class NormalizedReferenceCurveFacet
+extends      ReferenceCurveFacet
+{
+    public NormalizedReferenceCurveFacet() {
+    }
+
+    public NormalizedReferenceCurveFacet(
+        int    index,
+        String name,
+        String description
+    ) {
+        super(index, name, description, ComputeType.ADVANCE, null, null);
+    }
+
+    public NormalizedReferenceCurveFacet(
+        int         index,
+        String      name,
+        String      description,
+        ComputeType type,
+        String      stateID,
+        String      hash
+    ) {
+        super(index, name, description, type, hash, stateID);
+    }
+
+    @Override
+    protected Object getInternalData(WW [] wws) {
+        // TODO: On-the-fly generation of normalized WW.
+        return wws[index];
+    }
+
+    /** Copy deeply. */
+    @Override
+    public Facet deepCopy() {
+        NormalizedReferenceCurveFacet copy =
+            new NormalizedReferenceCurveFacet();
+        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/ReferenceCurveFacet.java	Fri Jan 27 17:45:26 2012 +0000
@@ -0,0 +1,74 @@
+package de.intevation.flys.artifacts.model;
+
+import de.intevation.artifactdatabase.state.Facet;
+
+import de.intevation.artifacts.Artifact;
+import de.intevation.artifacts.CallContext;
+
+import de.intevation.flys.artifacts.FLYSArtifact;
+
+import de.intevation.flys.artifacts.states.DefaultState.ComputeType;
+
+import org.apache.log4j.Logger;
+
+public class ReferenceCurveFacet 
+extends      DataFacet
+{
+    private static Logger log = Logger.getLogger(ReferenceCurveFacet.class);
+
+    public ReferenceCurveFacet() {
+    }
+
+    public ReferenceCurveFacet(int index, String name, String description) {
+        super(index, name, description, ComputeType.ADVANCE, null, null);
+    }
+
+    public ReferenceCurveFacet(
+        int         index,
+        String      name,
+        String      description,
+        ComputeType type,
+        String      stateID,
+        String      hash
+    ) {
+        super(index, name, description, type, hash, stateID);
+    }
+
+    public Object getData(Artifact artifact, CallContext context) {
+
+        if (log.isDebugEnabled()) {
+            log.debug("Get data for reference curve at index: " + index +
+                " /stateId: " + stateId);
+        }
+
+        FLYSArtifact winfo = (FLYSArtifact)artifact;
+
+        CalculationResult res = (CalculationResult)
+            winfo.compute(context, hash, stateId, type, false);
+
+        return getInternalData((WW [])res.getData());
+    }
+
+    /** To be overwritten by normalized reference curve. */
+    protected Object getInternalData(WW [] wws) {
+        return wws[index];
+    }
+
+    @Override
+    public void set(Facet other) {
+        super.set(other);
+        ReferenceCurveFacet o= (ReferenceCurveFacet)other;
+        type    = o.type;
+        hash    = o.hash;
+        stateId = o.stateId;
+    }
+
+    /** Copy deeply. */
+    @Override
+    public Facet deepCopy() {
+        ReferenceCurveFacet copy = new ReferenceCurveFacet();
+        copy.set(this);
+        return copy;
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WaterlevelFacet.java	Fri Jan 27 17:17:45 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WaterlevelFacet.java	Fri Jan 27 17:45:26 2012 +0000
@@ -1,16 +1,15 @@
 package de.intevation.flys.artifacts.model;
 
-import org.apache.log4j.Logger;
+import de.intevation.artifactdatabase.state.Facet;
 
 import de.intevation.artifacts.Artifact;
 import de.intevation.artifacts.CallContext;
 
-import de.intevation.artifactdatabase.state.Facet;
-
 import de.intevation.flys.artifacts.FLYSArtifact;
 
 import de.intevation.flys.artifacts.states.DefaultState.ComputeType;
 
+import org.apache.log4j.Logger;
 
 /**
  * Facet of a Waterlevel (WQKms).
@@ -44,8 +43,11 @@
      * @return a WQKms at given index.
      */
     public Object getData(Artifact artifact, CallContext context) {
-        logger.debug("Get data for waterlevels at index: " + index +
-            " /stateId: " + stateId);
+
+        if (logger.isDebugEnabled()) {
+            logger.debug("Get data for waterlevels at index: " + index +
+                " /stateId: " + stateId);
+        }
 
         FLYSArtifact winfo = (FLYSArtifact)artifact;
 

http://dive4elements.wald.intevation.org