changeset 3603:d2ae58f6730d

FixA: Use the column cache to establish a consistent index scheme. flys-artifacts/trunk@5229 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Wed, 22 Aug 2012 10:51:29 +0000
parents e1fd2dfdcb80
children 2382b26079ac
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisCalculation.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/FixRealizingCalculation.java
diffstat 4 files changed, 45 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Wed Aug 22 10:18:00 2012 +0000
+++ b/flys-artifacts/ChangeLog	Wed Aug 22 10:51:29 2012 +0000
@@ -1,3 +1,17 @@
+2012-08-20	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	Use the column cache to establish a consistent index scheme.
+	TODO: Store the index values in the created QWDs.
+
+	* src/main/java/de/intevation/flys/artifacts/model/fixings/FixCalculation.java:
+	  doFitting() fetches the columns from column cache, too.
+
+	* src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisCalculation.java:
+	  Reuse same column cache from fitting to have the same index scheme.
+
+	* src/main/java/de/intevation/flys/artifacts/model/fixings/FixRealizingCalculation.java:
+	  Adjusted to use the column cache.
+
 2012-08-22	Christian Lins	<christian.lins@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/model/HYKFacet.java,
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisCalculation.java	Wed Aug 22 10:18:00 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisCalculation.java	Wed Aug 22 10:51:29 2012 +0000
@@ -68,7 +68,9 @@
         FixingsOverview overview,
         Function        func
     ) {
-        FitResult fitResult = doFitting(overview, func);
+        ColumnCache cc = new ColumnCache();
+
+        FitResult fitResult = doFitting(overview, cc, func);
 
         if (fitResult == null) {
             return new CalculationResult(this);
@@ -78,7 +80,8 @@
             calculateAnalysisPeriods(
                 func,
                 fitResult.getParameters(),
-                overview);
+                overview,
+                cc);
 
         analysisPeriods.sort();
 
@@ -103,15 +106,14 @@
     protected KMIndex<AnalysisPeriod []> calculateAnalysisPeriods(
         Function        function,
         Parameters      parameters,
-        FixingsOverview overview
+        FixingsOverview overview,
+        ColumnCache cc
     ) {
         Range range = new Range(from, to);
 
         int kmIndex   = parameters.columnIndex("km");
         int maxQIndex = parameters.columnIndex("max_q");
 
-        ColumnCache cc = new ColumnCache();
-
         double [] wq = new double[2];
 
         int [] parameterIndices =
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixCalculation.java	Wed Aug 22 10:18:00 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixCalculation.java	Wed Aug 22 10:51:29 2012 +0000
@@ -82,13 +82,15 @@
 
         protected Fixing.Column meta;
         protected FixingsColumn data;
+        protected int           index;
 
         public Column() {
         }
 
-        public Column(Fixing.Column meta, FixingsColumn data) {
-            this.meta = meta;
-            this.data = data;
+        public Column(Fixing.Column meta, FixingsColumn data, int index) {
+            this.meta  = meta;
+            this.data  = data;
+            this.index = index;
         }
 
         public Date getDate() {
@@ -99,6 +101,10 @@
             return meta.getDescription();
         }
 
+        public int getIndex() {
+            return index;
+        }
+
         public boolean getQW(
             double    km,
             double [] qs,
@@ -136,7 +142,7 @@
                     .getInstance()
                     .getColumnData(meta);
                 if (data != null) {
-                    column = new Column(meta, data);
+                    column = new Column(meta, data, columns.size());
                     columns.put(key, column);
                 }
             }
@@ -234,8 +240,10 @@
         return new IdsFilter(events);
     }
 
-    protected List<Column> getEventColumns(FixingsOverview overview) {
-
+    protected List<Column> getEventColumns(
+        FixingsOverview overview,
+        ColumnCache     cc
+    ) {
         FixingsColumnFactory fcf = FixingsColumnFactory.getInstance();
 
         Filter filter = createFilter();
@@ -246,23 +254,26 @@
 
         for (Fixing.Column meta: metas) {
 
-            FixingsColumn data = fcf.getColumnData(meta);
+            Column data = cc.getColumn(meta);
             if (data == null) {
                 addProblem("fix.cannot.load.data");
             }
             else {
-                columns.add(new Column(meta, data));
+                columns.add(data);
             }
         }
 
         return columns;
     }
 
-    protected FitResult doFitting(FixingsOverview overview, Function func) {
-
+    protected FitResult doFitting(
+        FixingsOverview overview,
+        ColumnCache     cc,
+        Function        func
+    ) {
         boolean debug = log.isDebugEnabled();
 
-        final List<Column> eventColumns = getEventColumns(overview);
+        final List<Column> eventColumns = getEventColumns(overview, cc);
 
         if (eventColumns.size() < 2) {
             addProblem("fix.too.less.data.columns");
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixRealizingCalculation.java	Wed Aug 22 10:18:00 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixRealizingCalculation.java	Wed Aug 22 10:51:29 2012 +0000
@@ -66,7 +66,8 @@
         FixingsOverview overview,
         Function        func
     ) {
-        FitResult fitResult = doFitting(overview, func);
+        ColumnCache cc = new ColumnCache();
+        FitResult fitResult = doFitting(overview, cc, func);
 
         if (fitResult == null) {
             return new CalculationResult(this);

http://dive4elements.wald.intevation.org