diff flys-client/src/main/java/de/intevation/flys/client/shared/model/FixAnalysisArtifact.java @ 2906:1780841d79af

Added navigation to fix analysis charts. flys-client/trunk@4673 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Raimund Renkert <raimund.renkert@intevation.de>
date Fri, 15 Jun 2012 12:13:09 +0000
parents 93302bd16f42
children f14d4c668ec5
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/shared/model/FixAnalysisArtifact.java	Fri Jun 15 09:35:37 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/FixAnalysisArtifact.java	Fri Jun 15 12:13:09 2012 +0000
@@ -2,6 +2,8 @@
 
 import java.util.List;
 
+import com.google.gwt.core.client.GWT;
+
 import de.intevation.flys.client.client.ui.fixation.FixationPanel;
 import de.intevation.flys.client.client.ui.fixation.FixationPanel.FixFilter;
 
@@ -53,65 +55,88 @@
             this.filter = new FixFilter();
         }
         DataList[] old = artifactDescription.getOldData();
-        for (int i = 0; i < old.length; i++) {
-            DataList data = old[i];
-            List<Data> items = data.getAll();
-            String state = data.getState();
-            if (state.equals("state.fix.river")) {
-                Data d = getData(items, "river");
-                this.filter.setRiver(d.getItems()[0].getLabel());
-            }
-            if (state.equals("state.fix.location")) {
-                Data df = getData(items, "from");
-                Data dt = getData(items, "to");
-                try {
-                    String from = df.getItems()[0].getLabel();
-                    String to = dt.getItems()[0].getLabel();
-                    double fkm = Double.valueOf(from).doubleValue();
-                    double tkm = Double.valueOf(to).doubleValue();
-                    this.filter.setFromKm(fkm);
-                    this.filter.setToKm(tkm);
-                    if (fkm > filter.getCurrentKm()) {
-                        this.filter.setCurrentKm(fkm);
-                    }
-                }
-                catch(NumberFormatException nfe) {
-                }
+
+        String river = artifactDescription.getDataValueAsString("river");
+        if (river != null) {
+            this.filter.setRiver(river);
+        }
+
+        String from = artifactDescription.getDataValueAsString("from");
+        if (from != null) {
+            try {
+                double fkm = Double.valueOf(from).doubleValue();
+                this.filter.setFromKm(fkm);
             }
-            if (state.equals("state.fix.period")) {
-                Data ds = getData(items, "start");
-                Data de = getData(items, "end");
-                try {
-                    String start = ds.getItems()[0].getStringValue();
-                    String end = de.getItems()[0].getStringValue();
-                    long sp = Long.parseLong(start);
-                    long ep = Long.parseLong(end);
-                    this.filter.setFromDate(sp);
-                    this.filter.setToDate(ep);
-                }
-                catch(NumberFormatException nfe) {
-                }
+            catch(NumberFormatException nfe) {
+                GWT.log("Could not parse from km.");
             }
-            if (state.equals("state.fix.gaugerange")) {
-                Data gr1 = getData(items, "q1");
-                Data gr2 = getData(items, "q2");
-                try {
-                    String q1s = gr1.getItems()[0].getLabel();
-                    String q2s = gr2.getItems()[0].getLabel();
-                    int q1 = Integer.valueOf(q1s).intValue();
-                    int q2 = Integer.valueOf(q2s).intValue();
-                    this.filter.setFromClass(q1);
-                    this.filter.setToClass(q2);
-                }
-                catch(NumberFormatException nfe) {
-                }
+        }
+
+        String to = artifactDescription.getDataValueAsString("to");
+        if (to != null) {
+            try {
+                double tkm = Double.valueOf(to).doubleValue();
+                this.filter.setToKm(tkm);
             }
+            catch(NumberFormatException nfe) {
+                GWT.log("Could not parse to km");
+            }
+        }
+
+        String start = artifactDescription.getDataValueAsString("start");
+        if (start != null) {
+            try {
+                long s = Long.parseLong(start);
+                this.filter.setFromDate(s);
+            }
+            catch(NumberFormatException nfe) {
+                GWT.log("Could not parse start date");
+            }
+        }
+
+        String end = artifactDescription.getDataValueAsString("end");
+        if (end != null) {
+            try {
+                long e = Long.parseLong(end);
+                this.filter.setToDate(e);
+            }
+            catch(NumberFormatException nfe) {
+                GWT.log("Could not parse end date");
+            }
+        }
+
+        String q1 = artifactDescription.getDataValueAsString("q1");
+        if (q1 != null) {
+            try {
+                int q1i = Integer.valueOf(q1).intValue();
+                this.filter.setFromClass(q1i);
+            }
+            catch(NumberFormatException nfe) {
+                GWT.log("Could not parse start class");
+            }
+        }
+
+        String q2 = artifactDescription.getDataValueAsString("q2");
+        if (q2 != null) {
+            try {
+                int q2i =Integer.valueOf(q2).intValue();
+                this.filter.setToClass(q2i);
+            }
+            catch(NumberFormatException nfe) {
+                GWT.log("could not parse end class");
+            }
+        }
+
+        for (DataList list: old) {
+            List<Data> items = list.getAll();
+            String state = list.getState();
             if(state.equals("state.fix.eventselect")) {
                 Data de = getData(items, "events");
                 IntegerArrayData iad = (IntegerArrayData) de;
                 this.filter.setEvents(iad.getValues());
             }
         }
+
         return this.filter;
     }
 

http://dive4elements.wald.intevation.org