comparison flys-client/src/main/java/de/intevation/flys/client/shared/model/FixAnalysisArtifact.java @ 2884:88bca9f735c0

Implemented filter for fix analysis helper widgets. flys-client/trunk@4567 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Raimund Renkert <raimund.renkert@intevation.de>
date Fri, 01 Jun 2012 10:27:14 +0000
parents f0191dedee49
children 6ab6025cef20
comparison
equal deleted inserted replaced
2883:c3feb721035c 2884:88bca9f735c0
1 package de.intevation.flys.client.shared.model; 1 package de.intevation.flys.client.shared.model;
2 2
3 import java.util.List; 3 import java.util.List;
4 import java.lang.NumberFormatException;
5 import com.google.gwt.core.client.GWT;
4 6
7 import de.intevation.flys.client.client.ui.fixation.FixationPanel;
8 import de.intevation.flys.client.client.ui.fixation.FixationPanel.FixFilter;
5 9
6 /** 10 /**
7 * The Fixanalysis implementation of an Artifact. 11 * The Fixanalysis implementation of an Artifact.
8 * 12 *
9 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> 13 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
11 public class FixAnalysisArtifact extends DefaultArtifact { 15 public class FixAnalysisArtifact extends DefaultArtifact {
12 16
13 /** The name of this artifact: 'minfo'.*/ 17 /** The name of this artifact: 'minfo'.*/
14 public static final String NAME = "fixanalysis"; 18 public static final String NAME = "fixanalysis";
15 19
20 protected FixationPanel.FixFilter filter;
16 21
17 public FixAnalysisArtifact() { 22 public FixAnalysisArtifact() {
23 this.filter = null;
18 } 24 }
19 25
20 26
21 public FixAnalysisArtifact(String uuid, String hash) { 27 public FixAnalysisArtifact(String uuid, String hash) {
22 super(uuid, hash); 28 super(uuid, hash);
29 this.filter = null;
23 } 30 }
24 31
25 32
26 public FixAnalysisArtifact( 33 public FixAnalysisArtifact(
27 String uuid, 34 String uuid,
34 41
35 42
36 public String getName() { 43 public String getName() {
37 return NAME; 44 return NAME;
38 } 45 }
46
47
48 public FixationPanel.FixFilter getFilter () {
49 return createFilter();
50 }
51
52
53 protected FixFilter createFilter() {
54 if (this.filter == null) {
55 this.filter = new FixFilter();
56 }
57 DataList[] old = artifactDescription.getOldData();
58 for (int i = 0; i < old.length; i++) {
59 DataList data = old[i];
60 List<Data> items = data.getAll();
61 String state = data.getState();
62 if (state.equals("state.fix.river")) {
63 Data d = getData(items, "river");
64 this.filter.setRiver(d.getItems()[0].getLabel());
65 }
66 if (state.equals("state.fix.location")) {
67 Data df = getData(items, "from");
68 Data dt = getData(items, "to");
69 try {
70 String from = df.getItems()[0].getLabel();
71 String to = dt.getItems()[0].getLabel();
72 double fkm = Double.valueOf(from).doubleValue();
73 double tkm = Double.valueOf(to).doubleValue();
74 this.filter.setFromKm(fkm);
75 this.filter.setToKm(tkm);
76 if (fkm > filter.getCurrentKm()) {
77 this.filter.setCurrentKm(fkm);
78 }
79 }
80 catch(NumberFormatException nfe) {
81 }
82 }
83 if (state.equals("state.fix.period")) {
84 Data ds = getData(items, "start");
85 Data de = getData(items, "end");
86 try {
87 String start = ds.getItems()[0].getStringValue();
88 String end = de.getItems()[0].getStringValue();
89 long sp = Long.parseLong(start);
90 long ep = Long.parseLong(end);
91 this.filter.setFromDate(sp);
92 this.filter.setToDate(ep);
93 }
94 catch(NumberFormatException nfe) {
95 }
96 }
97 if (state.equals("state.fix.gaugerange")) {
98 Data gr1 = getData(items, "q1");
99 Data gr2 = getData(items, "q2");
100 try {
101 String q1s = gr1.getItems()[0].getLabel();
102 String q2s = gr2.getItems()[0].getLabel();
103 int q1 = Integer.valueOf(q1s).intValue();
104 int q2 = Integer.valueOf(q2s).intValue();
105 this.filter.setFromClass(q1);
106 this.filter.setToClass(q2);
107 }
108 catch(NumberFormatException nfe) {
109 }
110 }
111 if(state.equals("state.fix.eventselect")) {
112 Data de = getData(items, "events");
113 IntegerArrayData iad = (IntegerArrayData) de;
114 GWT.log(iad.getStringValue());
115 this.filter.setEvents(iad.getValues());
116 }
117 }
118 return this.filter;
119 }
120
121 protected Data getData(List<Data> data, String name) {
122 for (Data d: data) {
123 if (name.equals(d.getLabel())) {
124 return d;
125 }
126 }
127 return null;
128 }
129
130
39 } 131 }
40 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 132 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org