changeset 3203:1b9f791937c3

Moved FixationArtifactAccess to new access package. flys-artifacts/trunk@4820 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Thu, 28 Jun 2012 08:16:20 +0000
parents 307842cf8d9e
children 19ce06eb56c3
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/FixationArtifactAccess.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/FixationArtifactAccess.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/Fitting.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisEventsFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisPeriodsFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixAvSectorFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixCalculation.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixDerivateFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixDeviationFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixLongitudinalAnalysisFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixLongitudinalDeviationFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixLongitudinalReferenceFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixOutlierFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixReferenceEventsFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixWQCurveFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/fixation/FixationCompute.java
diffstat 18 files changed, 502 insertions(+), 462 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Wed Jun 27 17:29:33 2012 +0000
+++ b/flys-artifacts/ChangeLog	Thu Jun 28 08:16:20 2012 +0000
@@ -1,3 +1,34 @@
+2012-06-28	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	Moved FixationArtifactAccess into own package access because there are
+	more *Access to come e.g. SQRelationAccess.
+
+	TODO: Refactor the code for WINFO to use this *Access pattern. This
+	results in much cleaner, better scaling and better understandable code.
+
+	* src/main/java/de/intevation/flys/artifacts/FixationArtifactAccess.java: Deleted.
+	* src/main/java/de/intevation/flys/artifacts/access/FixationArtifactAccess.java: New.
+
+	* src/main/java/de/intevation/flys/artifacts/model/fixings/FixAvSectorFacet.java,
+	  src/main/java/de/intevation/flys/artifacts/model/fixings/FixCalculation.java,
+	  src/main/java/de/intevation/flys/artifacts/model/fixings/FixWQCurveFacet.java,
+	  src/main/java/de/intevation/flys/artifacts/model/fixings/FixLongitudinalDeviationFacet.java,
+	  src/main/java/de/intevation/flys/artifacts/model/fixings/FixLongitudinalAnalysisFacet.java,
+	  src/main/java/de/intevation/flys/artifacts/model/fixings/FixDerivateFacet.java,
+	  src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisEventsFacet.java,
+	  src/main/java/de/intevation/flys/artifacts/model/fixings/FixLongitudinalReferenceFacet.java,
+	  src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisPeriodsFacet.java,
+	  src/main/java/de/intevation/flys/artifacts/model/fixings/FixDeviationFacet.java,
+	  src/main/java/de/intevation/flys/artifacts/model/fixings/FixOutlierFacet.java,
+	  src/main/java/de/intevation/flys/artifacts/model/fixings/FixReferenceEventsFacet.java,
+	  src/main/java/de/intevation/flys/artifacts/access,
+	  src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java,
+	  src/main/java/de/intevation/flys/artifacts/states/fixation/FixationCompute.java:
+	  Addjusted imports.
+
+	* src/main/java/de/intevation/flys/artifacts/model/fixings/Fitting.java:
+	  Removed superfluous imports.
+
 2012-06-27	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/model/fixings/Fitting.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java	Wed Jun 27 17:29:33 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java	Thu Jun 28 08:16:20 2012 +0000
@@ -1307,6 +1307,9 @@
                     old = element.getValue();
                 }
             }
+            else {
+                logger.debug("cache not configured.");
+            }
 
             Object res;
             switch (type) {
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FixationArtifactAccess.java	Wed Jun 27 17:29:33 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,386 +0,0 @@
-package de.intevation.flys.artifacts;
-
-import de.intevation.artifactdatabase.data.StateData;
-
-import de.intevation.flys.artifacts.model.fixings.DateRange;
-
-import de.intevation.flys.utils.FLYSUtils;
-
-import gnu.trove.TDoubleArrayList;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
-
-import org.apache.log4j.Logger;
-
-public class FixationArtifactAccess
-{
-    private static Logger log = Logger.getLogger(FixationArtifactAccess.class);
-
-    protected FLYSArtifact artifact;
-
-    protected String river;
-
-    protected String calculationMode;
-
-    protected Double from;
-    protected Double to;
-    protected Double step;
-
-    protected Long start;
-    protected Long end;
-
-    protected Integer qSectorStart;
-    protected Integer qSectorEnd;
-
-    protected DateRange    referencePeriod;
-    protected DateRange [] analysisPeriods;
-
-    protected int [] events;
-
-    protected Boolean preprocessing;
-
-    protected String  function;
-
-    protected double [] qs;
-
-    public FixationArtifactAccess() {
-    }
-
-    public FixationArtifactAccess(FLYSArtifact artifact) {
-        this.artifact = artifact;
-    }
-
-    public FLYSArtifact getArtifact() {
-        return artifact;
-    }
-
-    public String getRiver() {
-        if (river == null) {
-            StateData sd = artifact.getData("river");
-            if (sd == null) {
-                log.warn("missing 'river' value");
-                return null;
-            }
-            river = (String)sd.getValue();
-        }
-        if (log.isDebugEnabled()) {
-            log.debug("river: '" + river + "'");
-        }
-        return river;
-    }
-
-    public String getCalculationMode() {
-        if (calculationMode == null) {
-            StateData sd = artifact.getData("calculation.mode");
-            if (sd == null) {
-                log.warn("missing 'calculation.mode' value");
-                return null;
-            }
-            calculationMode = (String)sd.getValue();
-        }
-
-        if (log.isDebugEnabled()) {
-            log.debug("calculationMode: '" + calculationMode + "'");
-        }
-        return calculationMode;
-    }
-
-    public Double getFrom() {
-
-        if (from == null) {
-            StateData sd = artifact.getData("from");
-            if (sd == null) {
-                log.warn("missing 'from' value");
-                return null;
-            }
-            try {
-                from = Double.valueOf((String)sd.getValue());
-            }
-            catch (NumberFormatException nfe) {
-                log.warn("from '" + sd.getValue() + "' is not numeric.");
-            }
-        }
-
-        if (log.isDebugEnabled()) {
-            log.debug("from: '" + from + "'");
-        }
-
-        return from;
-    }
-
-    public Double getTo() {
-
-        if (to == null) {
-            StateData sd = artifact.getData("to");
-            if (sd == null) {
-                log.warn("missing 'to' value");
-                return null;
-            }
-            try {
-                to = Double.valueOf((String)sd.getValue());
-            }
-            catch (NumberFormatException nfe) {
-                log.warn("to '" + sd.getValue() + "' is not numeric.");
-            }
-        }
-
-        if (log.isDebugEnabled()) {
-            log.debug("to: '" + to + "'");
-        }
-
-        return to;
-    }
-
-    public Double getStep() {
-
-        if (step == null) {
-            StateData sd = artifact.getData("step");
-            if (sd == null) {
-                log.warn("missing 'step' value");
-                return null;
-            }
-            try {
-                step = Double.valueOf((String)sd.getValue());
-            }
-            catch (NumberFormatException nfe) {
-                log.warn("step '" + sd.getValue() + "' is not numeric.");
-            }
-        }
-
-        if (log.isDebugEnabled()) {
-            log.debug("step: '" + step + "'");
-        }
-
-        return step;
-    }
-
-    public Long getStart() {
-
-        if (start == null) {
-            StateData sd = artifact.getData("start");
-            if (sd == null) {
-                log.warn("missing 'start' value");
-                return null;
-            }
-            try {
-                start = Long.valueOf((String)sd.getValue());
-            }
-            catch (NumberFormatException nfe) {
-                log.warn("start '" + sd.getValue() + "' is not an integer.");
-            }
-        }
-
-        if (log.isDebugEnabled()) {
-            log.debug("start: '" + start + "'");
-        }
-
-        return start;
-    }
-
-    public Long getEnd() {
-
-        if (end == null) {
-            StateData sd = artifact.getData("end");
-            if (sd == null) {
-                log.warn("missing 'end' value");
-                return null;
-            }
-            try {
-                end = Long.valueOf((String)sd.getValue());
-            }
-            catch (NumberFormatException nfe) {
-                log.warn("end '" + sd.getValue() + "' is not an integer.");
-            }
-        }
-
-        if (log.isDebugEnabled()) {
-            log.debug("end: '" + end + "'");
-        }
-
-        return end;
-    }
-
-    public Integer getQSectorStart() {
-
-        if (qSectorStart == null) {
-            StateData sd = artifact.getData("q1");
-            if (sd == null) {
-                log.warn("missing 'q1' value");
-                return null;
-            }
-            try {
-                qSectorStart = Integer.valueOf((String)sd.getValue());
-            }
-            catch (NumberFormatException nfe) {
-                log.warn("q1 '" + sd.getValue() + "' is not an integer.");
-            }
-        }
-
-        return qSectorStart;
-    }
-
-    public Integer getQSectorEnd() {
-
-        if (qSectorEnd == null) {
-            StateData sd = artifact.getData("q2");
-            if (sd == null) {
-                log.warn("missing 'q2' value");
-                return null;
-            }
-            try {
-                qSectorEnd = Integer.valueOf((String)sd.getValue());
-            }
-            catch (NumberFormatException nfe) {
-                log.warn("q2 '" + sd.getValue() + "' is not an integer.");
-            }
-        }
-
-        return qSectorEnd;
-    }
-
-    public int [] getEvents() {
-        if (events == null) {
-            StateData sd = artifact.getData("events");
-            if (sd == null) {
-                log.warn("missing 'events' value");
-                return null;
-            }
-            events = FLYSUtils.intArrayFromString((String)sd.getValue());
-        }
-        return events;
-    }
-
-    public DateRange getReferencePeriod() {
-        if (referencePeriod == null) {
-            StateData refStart = artifact.getData("ref_start");
-            StateData refEnd   = artifact.getData("ref_end");
-
-            if (refStart == null || refEnd == null) {
-                log.warn("missing 'ref_start' or 'ref_start' value");
-                return null;
-            }
-
-            try {
-                long rs = Long.parseLong((String)refStart.getValue());
-                long re = Long.parseLong((String)refEnd  .getValue());
-
-                if (rs > re) { long t = rs; rs = re; re = t; }
-
-                Date from = new Date(rs);
-                Date to   = new Date(re);
-                referencePeriod = new DateRange(from, to);
-            }
-            catch (NumberFormatException nfe) {
-                log.warn("ref_start or ref_end is not an integer.");
-            }
-        }
-
-        return referencePeriod;
-    }
-
-    public DateRange [] getAnalysisPeriods() {
-        if (analysisPeriods == null) {
-            StateData sd = artifact.getData("ana_data");
-
-            if (sd == null) {
-                log.warn("missing 'ana_data'");
-                return null;
-            }
-
-            String data = (String)sd.getValue();
-            String[] pairs = data.split("\\s*;\\s*");
-
-            ArrayList<DateRange> aPs = new ArrayList<DateRange>(pairs.length);
-
-            for (int i = 0; i < pairs.length; i++) {
-                String[] fromTo = pairs[i].split("\\s*,\\s*");
-                if (fromTo.length >= 2) {
-                    try {
-                        Date from = new Date(Long.parseLong(fromTo[0]));
-                        Date to   = new Date(Long.parseLong(fromTo[1]));
-                        DateRange aP = new DateRange(from, to);
-                        if (!aPs.contains(aP)) {
-                            aPs.add(aP);
-                        }
-                    }
-                    catch (NumberFormatException nfe) {
-                        log.warn("ana_data contains no long values.", nfe);
-                    }
-                }
-            }
-
-            analysisPeriods = aPs.toArray(new DateRange[aPs.size()]);
-        }
-
-        if (log.isDebugEnabled()) {
-            for (int i = 0; i < analysisPeriods.length; ++i) {
-                DateRange ap = analysisPeriods[i];
-                log.debug("analysis period " +
-                    ap.getFrom() + " - " + ap.getTo());
-            }
-        }
-
-        return analysisPeriods;
-    }
-
-    public Boolean getPreprocessing() {
-        if (preprocessing == null) {
-            StateData sd = artifact.getData("preprocessing");
-            if (sd == null) {
-                log.warn("missing 'preprocessing'");
-                return null;
-            }
-            preprocessing = Boolean.valueOf((String)sd.getValue());
-        }
-        return preprocessing;
-    }
-
-    public String getFunction() {
-        if (function == null) {
-            StateData sd = artifact.getData("function");
-            if (sd == null) {
-                log.warn("missing 'function'");
-                return null;
-            }
-            function = (String)sd.getValue();
-        }
-        if (log.isDebugEnabled()) {
-            log.debug("function: " + function);
-        }
-        return function;
-    }
-
-    public double [] getQs() {
-        if (qs == null) {
-            StateData sd = artifact.getData("qs");
-            if (sd == null) {
-                log.warn("missing 'qs'");
-                return null;
-            }
-            String [] parts = ((String)sd.getValue()).split("[\\s;]");
-            TDoubleArrayList list = new TDoubleArrayList(parts.length);
-            for (String part: parts) {
-                try {
-                    list.add(Double.parseDouble(part));
-                }
-                catch (NumberFormatException nfe) {
-                    log.warn("'" + part + "' is not numeric.");
-                }
-            }
-            qs = list.toNativeArray();
-        }
-        if (log.isDebugEnabled()) {
-            log.debug("qs: " + Arrays.toString(qs));
-        }
-        return qs;
-    }
-
-
-    public double getCurrentKm() {
-        //TODO: get the current km.
-        return getFrom().doubleValue();
-    }
-}
-// 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/access/FixationArtifactAccess.java	Thu Jun 28 08:16:20 2012 +0000
@@ -0,0 +1,388 @@
+package de.intevation.flys.artifacts.access;
+
+import de.intevation.artifactdatabase.data.StateData;
+
+import de.intevation.flys.artifacts.FLYSArtifact;
+
+import de.intevation.flys.artifacts.model.fixings.DateRange;
+
+import de.intevation.flys.utils.FLYSUtils;
+
+import gnu.trove.TDoubleArrayList;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+
+import org.apache.log4j.Logger;
+
+public class FixationArtifactAccess
+{
+    private static Logger log = Logger.getLogger(FixationArtifactAccess.class);
+
+    protected FLYSArtifact artifact;
+
+    protected String river;
+
+    protected String calculationMode;
+
+    protected Double from;
+    protected Double to;
+    protected Double step;
+
+    protected Long start;
+    protected Long end;
+
+    protected Integer qSectorStart;
+    protected Integer qSectorEnd;
+
+    protected DateRange    referencePeriod;
+    protected DateRange [] analysisPeriods;
+
+    protected int [] events;
+
+    protected Boolean preprocessing;
+
+    protected String  function;
+
+    protected double [] qs;
+
+    public FixationArtifactAccess() {
+    }
+
+    public FixationArtifactAccess(FLYSArtifact artifact) {
+        this.artifact = artifact;
+    }
+
+    public FLYSArtifact getArtifact() {
+        return artifact;
+    }
+
+    public String getRiver() {
+        if (river == null) {
+            StateData sd = artifact.getData("river");
+            if (sd == null) {
+                log.warn("missing 'river' value");
+                return null;
+            }
+            river = (String)sd.getValue();
+        }
+        if (log.isDebugEnabled()) {
+            log.debug("river: '" + river + "'");
+        }
+        return river;
+    }
+
+    public String getCalculationMode() {
+        if (calculationMode == null) {
+            StateData sd = artifact.getData("calculation.mode");
+            if (sd == null) {
+                log.warn("missing 'calculation.mode' value");
+                return null;
+            }
+            calculationMode = (String)sd.getValue();
+        }
+
+        if (log.isDebugEnabled()) {
+            log.debug("calculationMode: '" + calculationMode + "'");
+        }
+        return calculationMode;
+    }
+
+    public Double getFrom() {
+
+        if (from == null) {
+            StateData sd = artifact.getData("from");
+            if (sd == null) {
+                log.warn("missing 'from' value");
+                return null;
+            }
+            try {
+                from = Double.valueOf((String)sd.getValue());
+            }
+            catch (NumberFormatException nfe) {
+                log.warn("from '" + sd.getValue() + "' is not numeric.");
+            }
+        }
+
+        if (log.isDebugEnabled()) {
+            log.debug("from: '" + from + "'");
+        }
+
+        return from;
+    }
+
+    public Double getTo() {
+
+        if (to == null) {
+            StateData sd = artifact.getData("to");
+            if (sd == null) {
+                log.warn("missing 'to' value");
+                return null;
+            }
+            try {
+                to = Double.valueOf((String)sd.getValue());
+            }
+            catch (NumberFormatException nfe) {
+                log.warn("to '" + sd.getValue() + "' is not numeric.");
+            }
+        }
+
+        if (log.isDebugEnabled()) {
+            log.debug("to: '" + to + "'");
+        }
+
+        return to;
+    }
+
+    public Double getStep() {
+
+        if (step == null) {
+            StateData sd = artifact.getData("step");
+            if (sd == null) {
+                log.warn("missing 'step' value");
+                return null;
+            }
+            try {
+                step = Double.valueOf((String)sd.getValue());
+            }
+            catch (NumberFormatException nfe) {
+                log.warn("step '" + sd.getValue() + "' is not numeric.");
+            }
+        }
+
+        if (log.isDebugEnabled()) {
+            log.debug("step: '" + step + "'");
+        }
+
+        return step;
+    }
+
+    public Long getStart() {
+
+        if (start == null) {
+            StateData sd = artifact.getData("start");
+            if (sd == null) {
+                log.warn("missing 'start' value");
+                return null;
+            }
+            try {
+                start = Long.valueOf((String)sd.getValue());
+            }
+            catch (NumberFormatException nfe) {
+                log.warn("start '" + sd.getValue() + "' is not an integer.");
+            }
+        }
+
+        if (log.isDebugEnabled()) {
+            log.debug("start: '" + start + "'");
+        }
+
+        return start;
+    }
+
+    public Long getEnd() {
+
+        if (end == null) {
+            StateData sd = artifact.getData("end");
+            if (sd == null) {
+                log.warn("missing 'end' value");
+                return null;
+            }
+            try {
+                end = Long.valueOf((String)sd.getValue());
+            }
+            catch (NumberFormatException nfe) {
+                log.warn("end '" + sd.getValue() + "' is not an integer.");
+            }
+        }
+
+        if (log.isDebugEnabled()) {
+            log.debug("end: '" + end + "'");
+        }
+
+        return end;
+    }
+
+    public Integer getQSectorStart() {
+
+        if (qSectorStart == null) {
+            StateData sd = artifact.getData("q1");
+            if (sd == null) {
+                log.warn("missing 'q1' value");
+                return null;
+            }
+            try {
+                qSectorStart = Integer.valueOf((String)sd.getValue());
+            }
+            catch (NumberFormatException nfe) {
+                log.warn("q1 '" + sd.getValue() + "' is not an integer.");
+            }
+        }
+
+        return qSectorStart;
+    }
+
+    public Integer getQSectorEnd() {
+
+        if (qSectorEnd == null) {
+            StateData sd = artifact.getData("q2");
+            if (sd == null) {
+                log.warn("missing 'q2' value");
+                return null;
+            }
+            try {
+                qSectorEnd = Integer.valueOf((String)sd.getValue());
+            }
+            catch (NumberFormatException nfe) {
+                log.warn("q2 '" + sd.getValue() + "' is not an integer.");
+            }
+        }
+
+        return qSectorEnd;
+    }
+
+    public int [] getEvents() {
+        if (events == null) {
+            StateData sd = artifact.getData("events");
+            if (sd == null) {
+                log.warn("missing 'events' value");
+                return null;
+            }
+            events = FLYSUtils.intArrayFromString((String)sd.getValue());
+        }
+        return events;
+    }
+
+    public DateRange getReferencePeriod() {
+        if (referencePeriod == null) {
+            StateData refStart = artifact.getData("ref_start");
+            StateData refEnd   = artifact.getData("ref_end");
+
+            if (refStart == null || refEnd == null) {
+                log.warn("missing 'ref_start' or 'ref_start' value");
+                return null;
+            }
+
+            try {
+                long rs = Long.parseLong((String)refStart.getValue());
+                long re = Long.parseLong((String)refEnd  .getValue());
+
+                if (rs > re) { long t = rs; rs = re; re = t; }
+
+                Date from = new Date(rs);
+                Date to   = new Date(re);
+                referencePeriod = new DateRange(from, to);
+            }
+            catch (NumberFormatException nfe) {
+                log.warn("ref_start or ref_end is not an integer.");
+            }
+        }
+
+        return referencePeriod;
+    }
+
+    public DateRange [] getAnalysisPeriods() {
+        if (analysisPeriods == null) {
+            StateData sd = artifact.getData("ana_data");
+
+            if (sd == null) {
+                log.warn("missing 'ana_data'");
+                return null;
+            }
+
+            String data = (String)sd.getValue();
+            String[] pairs = data.split("\\s*;\\s*");
+
+            ArrayList<DateRange> aPs = new ArrayList<DateRange>(pairs.length);
+
+            for (int i = 0; i < pairs.length; i++) {
+                String[] fromTo = pairs[i].split("\\s*,\\s*");
+                if (fromTo.length >= 2) {
+                    try {
+                        Date from = new Date(Long.parseLong(fromTo[0]));
+                        Date to   = new Date(Long.parseLong(fromTo[1]));
+                        DateRange aP = new DateRange(from, to);
+                        if (!aPs.contains(aP)) {
+                            aPs.add(aP);
+                        }
+                    }
+                    catch (NumberFormatException nfe) {
+                        log.warn("ana_data contains no long values.", nfe);
+                    }
+                }
+            }
+
+            analysisPeriods = aPs.toArray(new DateRange[aPs.size()]);
+        }
+
+        if (log.isDebugEnabled()) {
+            for (int i = 0; i < analysisPeriods.length; ++i) {
+                DateRange ap = analysisPeriods[i];
+                log.debug("analysis period " +
+                    ap.getFrom() + " - " + ap.getTo());
+            }
+        }
+
+        return analysisPeriods;
+    }
+
+    public Boolean getPreprocessing() {
+        if (preprocessing == null) {
+            StateData sd = artifact.getData("preprocessing");
+            if (sd == null) {
+                log.warn("missing 'preprocessing'");
+                return null;
+            }
+            preprocessing = Boolean.valueOf((String)sd.getValue());
+        }
+        return preprocessing;
+    }
+
+    public String getFunction() {
+        if (function == null) {
+            StateData sd = artifact.getData("function");
+            if (sd == null) {
+                log.warn("missing 'function'");
+                return null;
+            }
+            function = (String)sd.getValue();
+        }
+        if (log.isDebugEnabled()) {
+            log.debug("function: " + function);
+        }
+        return function;
+    }
+
+    public double [] getQs() {
+        if (qs == null) {
+            StateData sd = artifact.getData("qs");
+            if (sd == null) {
+                log.warn("missing 'qs'");
+                return null;
+            }
+            String [] parts = ((String)sd.getValue()).split("[\\s;]");
+            TDoubleArrayList list = new TDoubleArrayList(parts.length);
+            for (String part: parts) {
+                try {
+                    list.add(Double.parseDouble(part));
+                }
+                catch (NumberFormatException nfe) {
+                    log.warn("'" + part + "' is not numeric.");
+                }
+            }
+            qs = list.toNativeArray();
+        }
+        if (log.isDebugEnabled()) {
+            log.debug("qs: " + Arrays.toString(qs));
+        }
+        return qs;
+    }
+
+
+    public double getCurrentKm() {
+        //TODO: get the current km.
+        return getFrom().doubleValue();
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/Fitting.java	Wed Jun 27 17:29:33 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/Fitting.java	Thu Jun 28 08:16:20 2012 +0000
@@ -22,9 +22,6 @@
 
 import org.apache.log4j.Logger;
 
-import org.apache.commons.math.optimization.DifferentiableMultivariateVectorialOptimizer;
-import org.apache.commons.math.optimization.general.GaussNewtonOptimizer;
-
 public class Fitting
 {
     private static Logger log = Logger.getLogger(Fitting.class);
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisEventsFacet.java	Wed Jun 27 17:29:33 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisEventsFacet.java	Thu Jun 28 08:16:20 2012 +0000
@@ -1,21 +1,21 @@
 package de.intevation.flys.artifacts.model.fixings;
 
-import org.apache.log4j.Logger;
-
 import de.intevation.artifacts.Artifact;
 import de.intevation.artifacts.CallContext;
 
-import de.intevation.flys.utils.KMIndex;
-
 import de.intevation.flys.artifacts.FLYSArtifact;
-import de.intevation.flys.artifacts.FixationArtifactAccess;
 
+import de.intevation.flys.artifacts.access.FixationArtifactAccess;
+
+import de.intevation.flys.artifacts.model.CalculationResult;
+import de.intevation.flys.artifacts.model.DataFacet;
 import de.intevation.flys.artifacts.model.FacetTypes;
-import de.intevation.flys.artifacts.model.DataFacet;
-import de.intevation.flys.artifacts.model.CalculationResult;
 
 import de.intevation.flys.artifacts.states.DefaultState.ComputeType;
 
+import de.intevation.flys.utils.KMIndex;
+
+import org.apache.log4j.Logger;
 
 /**
  * Facet to show W values for Q values at km for a date.
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisPeriodsFacet.java	Wed Jun 27 17:29:33 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisPeriodsFacet.java	Thu Jun 28 08:16:20 2012 +0000
@@ -1,21 +1,21 @@
 package de.intevation.flys.artifacts.model.fixings;
 
-import org.apache.log4j.Logger;
-
 import de.intevation.artifacts.Artifact;
 import de.intevation.artifacts.CallContext;
 
-import de.intevation.flys.utils.KMIndex;
-
 import de.intevation.flys.artifacts.FLYSArtifact;
-import de.intevation.flys.artifacts.FixationArtifactAccess;
 
+import de.intevation.flys.artifacts.access.FixationArtifactAccess;
+
+import de.intevation.flys.artifacts.model.CalculationResult;
+import de.intevation.flys.artifacts.model.DataFacet;
 import de.intevation.flys.artifacts.model.FacetTypes;
-import de.intevation.flys.artifacts.model.DataFacet;
-import de.intevation.flys.artifacts.model.CalculationResult;
 
 import de.intevation.flys.artifacts.states.DefaultState.ComputeType;
 
+import de.intevation.flys.utils.KMIndex;
+
+import org.apache.log4j.Logger;
 
 /**
  * Facet to show W values for Q values at km for a date.
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixAvSectorFacet.java	Wed Jun 27 17:29:33 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixAvSectorFacet.java	Thu Jun 28 08:16:20 2012 +0000
@@ -1,20 +1,21 @@
 package de.intevation.flys.artifacts.model.fixings;
 
-import org.apache.log4j.Logger;
-
 import de.intevation.artifacts.Artifact;
 import de.intevation.artifacts.CallContext;
 
 import de.intevation.flys.artifacts.FLYSArtifact;
-import de.intevation.flys.artifacts.FixationArtifactAccess;
 
+import de.intevation.flys.artifacts.access.FixationArtifactAccess;
+
+import de.intevation.flys.artifacts.model.CalculationResult;
+import de.intevation.flys.artifacts.model.DataFacet;
 import de.intevation.flys.artifacts.model.FacetTypes;
-import de.intevation.flys.artifacts.model.DataFacet;
-import de.intevation.flys.artifacts.model.CalculationResult;
+
+import de.intevation.flys.artifacts.states.DefaultState.ComputeType;
 
 import de.intevation.flys.utils.KMIndex;
 
-import de.intevation.flys.artifacts.states.DefaultState.ComputeType;
+import org.apache.log4j.Logger;
 
 
 /**
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixCalculation.java	Wed Jun 27 17:29:33 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixCalculation.java	Thu Jun 28 08:16:20 2012 +0000
@@ -1,6 +1,6 @@
 package de.intevation.flys.artifacts.model.fixings;
 
-import de.intevation.flys.artifacts.FixationArtifactAccess;
+import de.intevation.flys.artifacts.access.FixationArtifactAccess;
 
 import de.intevation.flys.artifacts.math.fitting.Function;
 import de.intevation.flys.artifacts.math.fitting.FunctionFactory;
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixDerivateFacet.java	Wed Jun 27 17:29:33 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixDerivateFacet.java	Thu Jun 28 08:16:20 2012 +0000
@@ -4,7 +4,8 @@
 import de.intevation.artifacts.CallContext;
 
 import de.intevation.flys.artifacts.FLYSArtifact;
-import de.intevation.flys.artifacts.FixationArtifactAccess;
+
+import de.intevation.flys.artifacts.access.FixationArtifactAccess;
 
 import de.intevation.flys.artifacts.math.fitting.Function;
 import de.intevation.flys.artifacts.math.fitting.FunctionFactory;
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixDeviationFacet.java	Wed Jun 27 17:29:33 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixDeviationFacet.java	Thu Jun 28 08:16:20 2012 +0000
@@ -4,7 +4,7 @@
 import de.intevation.artifacts.CallContext;
 
 import de.intevation.flys.artifacts.FLYSArtifact;
-import de.intevation.flys.artifacts.FixationArtifactAccess;
+import de.intevation.flys.artifacts.access.FixationArtifactAccess;
 
 import de.intevation.flys.artifacts.model.CalculationResult;
 import de.intevation.flys.artifacts.model.DataFacet;
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixLongitudinalAnalysisFacet.java	Wed Jun 27 17:29:33 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixLongitudinalAnalysisFacet.java	Thu Jun 28 08:16:20 2012 +0000
@@ -1,21 +1,21 @@
 package de.intevation.flys.artifacts.model.fixings;
 
-import org.apache.log4j.Logger;
-
 import de.intevation.artifacts.Artifact;
 import de.intevation.artifacts.CallContext;
 
 import de.intevation.flys.artifacts.FLYSArtifact;
-import de.intevation.flys.artifacts.FixationArtifactAccess;
 
+import de.intevation.flys.artifacts.access.FixationArtifactAccess;
+
+import de.intevation.flys.artifacts.model.CalculationResult;
+import de.intevation.flys.artifacts.model.DataFacet;
 import de.intevation.flys.artifacts.model.FacetTypes;
-import de.intevation.flys.artifacts.model.DataFacet;
-import de.intevation.flys.artifacts.model.CalculationResult;
+
+import de.intevation.flys.artifacts.states.DefaultState.ComputeType;
 
 import de.intevation.flys.utils.KMIndex;
 
-import de.intevation.flys.artifacts.states.DefaultState.ComputeType;
-
+import org.apache.log4j.Logger;
 
 /**
  * Facet to show average W values for Q sectors.
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixLongitudinalDeviationFacet.java	Wed Jun 27 17:29:33 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixLongitudinalDeviationFacet.java	Thu Jun 28 08:16:20 2012 +0000
@@ -1,22 +1,22 @@
 package de.intevation.flys.artifacts.model.fixings;
 
-import org.apache.log4j.Logger;
-
 import de.intevation.artifacts.Artifact;
 import de.intevation.artifacts.CallContext;
 
 import de.intevation.flys.artifacts.FLYSArtifact;
-import de.intevation.flys.artifacts.FixationArtifactAccess;
 
+import de.intevation.flys.artifacts.access.FixationArtifactAccess;
+
+import de.intevation.flys.artifacts.model.CalculationResult;
+import de.intevation.flys.artifacts.model.DataFacet;
 import de.intevation.flys.artifacts.model.FacetTypes;
-import de.intevation.flys.artifacts.model.DataFacet;
-import de.intevation.flys.artifacts.model.CalculationResult;
 import de.intevation.flys.artifacts.model.Parameters;
 
+import de.intevation.flys.artifacts.states.DefaultState.ComputeType;
+
 import de.intevation.flys.utils.KMIndex;
 
-import de.intevation.flys.artifacts.states.DefaultState.ComputeType;
-
+import org.apache.log4j.Logger;
 
 /**
  * Facet to show average W values for Q sectors.
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixLongitudinalReferenceFacet.java	Wed Jun 27 17:29:33 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixLongitudinalReferenceFacet.java	Thu Jun 28 08:16:20 2012 +0000
@@ -1,20 +1,21 @@
 package de.intevation.flys.artifacts.model.fixings;
 
-import org.apache.log4j.Logger;
-
 import de.intevation.artifacts.Artifact;
 import de.intevation.artifacts.CallContext;
 
 import de.intevation.flys.artifacts.FLYSArtifact;
-import de.intevation.flys.artifacts.FixationArtifactAccess;
 
+import de.intevation.flys.artifacts.access.FixationArtifactAccess;
+
+import de.intevation.flys.artifacts.model.CalculationResult;
+import de.intevation.flys.artifacts.model.DataFacet;
 import de.intevation.flys.artifacts.model.FacetTypes;
-import de.intevation.flys.artifacts.model.DataFacet;
-import de.intevation.flys.artifacts.model.CalculationResult;
+
+import de.intevation.flys.artifacts.states.DefaultState.ComputeType;
 
 import de.intevation.flys.utils.KMIndex;
 
-import de.intevation.flys.artifacts.states.DefaultState.ComputeType;
+import org.apache.log4j.Logger;
 
 
 /**
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixOutlierFacet.java	Wed Jun 27 17:29:33 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixOutlierFacet.java	Thu Jun 28 08:16:20 2012 +0000
@@ -1,21 +1,21 @@
 package de.intevation.flys.artifacts.model.fixings;
 
-import org.apache.log4j.Logger;
-
 import de.intevation.artifacts.Artifact;
 import de.intevation.artifacts.CallContext;
 
-import de.intevation.flys.utils.KMIndex;
-
 import de.intevation.flys.artifacts.FLYSArtifact;
-import de.intevation.flys.artifacts.FixationArtifactAccess;
 
+import de.intevation.flys.artifacts.access.FixationArtifactAccess;
+
+import de.intevation.flys.artifacts.model.CalculationResult;
+import de.intevation.flys.artifacts.model.DataFacet;
 import de.intevation.flys.artifacts.model.FacetTypes;
-import de.intevation.flys.artifacts.model.DataFacet;
-import de.intevation.flys.artifacts.model.CalculationResult;
 
 import de.intevation.flys.artifacts.states.DefaultState.ComputeType;
 
+import de.intevation.flys.utils.KMIndex;
+
+import org.apache.log4j.Logger;
 
 /**
  * Facet to show the outliers in a fix calculation.
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixReferenceEventsFacet.java	Wed Jun 27 17:29:33 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixReferenceEventsFacet.java	Thu Jun 28 08:16:20 2012 +0000
@@ -1,20 +1,21 @@
 package de.intevation.flys.artifacts.model.fixings;
 
-import org.apache.log4j.Logger;
-
 import de.intevation.artifacts.Artifact;
 import de.intevation.artifacts.CallContext;
 
+import de.intevation.flys.artifacts.FLYSArtifact;
+
+import de.intevation.flys.artifacts.access.FixationArtifactAccess;
+
+import de.intevation.flys.artifacts.model.CalculationResult;
+import de.intevation.flys.artifacts.model.DataFacet;
+import de.intevation.flys.artifacts.model.FacetTypes;
+
+import de.intevation.flys.artifacts.states.DefaultState.ComputeType;
+
 import de.intevation.flys.utils.KMIndex;
 
-import de.intevation.flys.artifacts.FLYSArtifact;
-import de.intevation.flys.artifacts.FixationArtifactAccess;
-
-import de.intevation.flys.artifacts.model.FacetTypes;
-import de.intevation.flys.artifacts.model.DataFacet;
-import de.intevation.flys.artifacts.model.CalculationResult;
-
-import de.intevation.flys.artifacts.states.DefaultState.ComputeType;
+import org.apache.log4j.Logger;
 
 
 /**
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixWQCurveFacet.java	Wed Jun 27 17:29:33 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixWQCurveFacet.java	Thu Jun 28 08:16:20 2012 +0000
@@ -4,7 +4,8 @@
 import de.intevation.artifacts.CallContext;
 
 import de.intevation.flys.artifacts.FLYSArtifact;
-import de.intevation.flys.artifacts.FixationArtifactAccess;
+
+import de.intevation.flys.artifacts.access.FixationArtifactAccess;
 
 import de.intevation.flys.artifacts.math.fitting.Function;
 import de.intevation.flys.artifacts.math.fitting.FunctionFactory;
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/fixation/FixationCompute.java	Wed Jun 27 17:29:33 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/fixation/FixationCompute.java	Thu Jun 28 08:16:20 2012 +0000
@@ -1,38 +1,37 @@
 package de.intevation.flys.artifacts.states.fixation;
 
-import java.text.DateFormat;
-
 import de.intevation.artifactdatabase.state.Facet;
 
 import de.intevation.artifacts.CallContext;
 
 import de.intevation.flys.artifacts.FLYSArtifact;
-import de.intevation.flys.artifacts.FixationArtifactAccess;
+
+import de.intevation.flys.artifacts.access.FixationArtifactAccess;
 
 import de.intevation.flys.artifacts.model.CalculationResult;
 import de.intevation.flys.artifacts.model.DataFacet;
 import de.intevation.flys.artifacts.model.FacetTypes;
 import de.intevation.flys.artifacts.model.ReportFacet;
 
-import de.intevation.flys.artifacts.model.fixings.FixCalculation;
-
-import de.intevation.flys.artifacts.model.fixings.FixAvSectorFacet;
+import de.intevation.flys.artifacts.model.fixings.DateRange;
 import de.intevation.flys.artifacts.model.fixings.FixAnalysisEventsFacet;
 import de.intevation.flys.artifacts.model.fixings.FixAnalysisPeriodsFacet;
-import de.intevation.flys.artifacts.model.fixings.FixReferenceEventsFacet;
-import de.intevation.flys.artifacts.model.fixings.FixOutlierFacet;
-import de.intevation.flys.artifacts.model.fixings.FixWQCurveFacet;
+import de.intevation.flys.artifacts.model.fixings.FixAvSectorFacet;
+import de.intevation.flys.artifacts.model.fixings.FixCalculation;
 import de.intevation.flys.artifacts.model.fixings.FixDerivateFacet;
 import de.intevation.flys.artifacts.model.fixings.FixDeviationFacet;
 import de.intevation.flys.artifacts.model.fixings.FixLongitudinalAnalysisFacet;
 import de.intevation.flys.artifacts.model.fixings.FixLongitudinalDeviationFacet;
 import de.intevation.flys.artifacts.model.fixings.FixLongitudinalReferenceFacet;
+import de.intevation.flys.artifacts.model.fixings.FixOutlierFacet;
+import de.intevation.flys.artifacts.model.fixings.FixReferenceEventsFacet;
+import de.intevation.flys.artifacts.model.fixings.FixWQCurveFacet;
 
-import de.intevation.flys.artifacts.model.fixings.DateRange;
+import de.intevation.flys.artifacts.resources.Resources;
 
 import de.intevation.flys.artifacts.states.DefaultState;
 
-import de.intevation.flys.artifacts.resources.Resources;
+import java.text.DateFormat;
 
 import java.util.List;
 
@@ -98,6 +97,7 @@
     ) {
         log.debug("FixationCompute.computeAdvance");
 
+
         CalculationResult res;
 
         FixationArtifactAccess access =
@@ -105,8 +105,10 @@
 
         if (old instanceof CalculationResult) {
             res = (CalculationResult)old;
+            log.debug("---------- Using result from Cache --------");
         }
         else {
+            log.debug("+++++++++ Recalculating +++++++");
             FixCalculation calc =
                 new FixCalculation(access);
 
@@ -123,7 +125,7 @@
         facets.add(
             new DataFacet(CSV, "CSV data", ComputeType.ADVANCE, hash, id));
 
-	int maxId = -100;
+        int maxId = -100;
 
         int count = access.getAnalysisPeriods().length;
 

http://dive4elements.wald.intevation.org