changeset 2133:767ce9d1991f

Added HYKFacet. flys-artifacts/trunk@3708 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 18 Jan 2012 14:45:24 +0000
parents e8fc770d2f8c
children 024d986b4f5b
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/HYKFacet.java
diffstat 2 files changed, 80 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Wed Jan 18 14:36:16 2012 +0000
+++ b/flys-artifacts/ChangeLog	Wed Jan 18 14:45:24 2012 +0000
@@ -1,3 +1,10 @@
+2012-01-18	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
+
+	Added accidentally ommitted HYKFacet, fixing build.
+
+	* src/main/java/de/intevation/flys/artifacts/model/HYKFacet.java:
+	  New, stubby facet for hyk infrastructure.
+
 2012-01-18  Raimund Renkert <raimund.renkert@intevation.de>
 
 	'New Chart' for computed discharge curve.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/HYKFacet.java	Wed Jan 18 14:45:24 2012 +0000
@@ -0,0 +1,73 @@
+package de.intevation.flys.artifacts.model;
+
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+import de.intevation.artifacts.Artifact;
+import de.intevation.artifacts.CallContext;
+import de.intevation.artifacts.DataProvider;
+
+import de.intevation.artifactdatabase.state.Facet;
+
+import de.intevation.flys.artifacts.HYKArtifact;
+
+import de.intevation.flys.artifacts.states.DefaultState.ComputeType;
+import de.intevation.flys.model.FastCrossSectionLine;
+
+
+/**
+ * Trival Facet for HYKs
+ */
+public class HYKFacet
+extends      DataFacet
+implements   FacetTypes {
+
+    private static Logger logger = Logger.getLogger(HYKFacet.class);
+
+
+    /** Trivial constructor, set (maybe localized) description. */
+    public HYKFacet(int idx, String description) {
+        super(idx, HYK, description, ComputeType.FEED, null, null);
+    }
+
+
+    /**
+     * 
+     * @param art artifact to get data from.
+     * @param context ignored
+     */
+     public Object getData(Artifact art, CallContext context) {
+        logger.debug("HYKFacet.getData");
+
+        String dataKey = CrossSectionFacet.BLACKBOARD_CS_MASTER_DATA;
+
+        List<DataProvider> providers = context.getDataProvider(dataKey);
+        if (providers.size() < 1) {
+            logger.warn("Could not find Cross-Section data provider to get master cs km.");
+            return null;
+        }
+                        
+        FastCrossSectionLine crossSection = (FastCrossSectionLine) providers.get(0)
+            .provideData(dataKey, null, context);
+
+        double km = crossSection.getKm();
+        logger.debug("HYKFacet.getData: Master Cross Section is at km: " + km);
+
+        // Set this km at hyk artifact to be evaluated.
+        HYKArtifact hyk = (HYKArtifact) art;
+        hyk.setKm(km);
+
+        return hyk.compute(context, hash, stateId, type, false);
+    }
+
+
+    /** Do a deep copy. */
+    @Override 
+    public Facet deepCopy() {
+        HYKFacet copy = new HYKFacet(this.index, this.description);
+        copy.set(this);
+        return copy;
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org