Mercurial > dive4elements > river
comparison gwt-client/src/main/java/org/dive4elements/river/client/shared/model/FixAnalysisArtifact.java @ 5838:5aa05a7a34b7
Rename modules to more fitting names.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 25 Apr 2013 15:23:37 +0200 |
parents | flys-client/src/main/java/org/dive4elements/river/client/shared/model/FixAnalysisArtifact.java@821a02bbfb4e |
children | 172338b1407f |
comparison
equal
deleted
inserted
replaced
5837:d9901a08d0a6 | 5838:5aa05a7a34b7 |
---|---|
1 package org.dive4elements.river.client.shared.model; | |
2 | |
3 import java.util.List; | |
4 | |
5 import com.google.gwt.core.client.GWT; | |
6 | |
7 | |
8 /** | |
9 * The Fixanalysis implementation of an Artifact (client side). | |
10 * | |
11 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> | |
12 */ | |
13 public class FixAnalysisArtifact extends DefaultArtifact { | |
14 | |
15 /** The name of this artifact: 'fixanalysis'.*/ | |
16 public static final String NAME = "fixanalysis"; | |
17 | |
18 protected FixFilter filter; | |
19 | |
20 | |
21 public FixAnalysisArtifact() { | |
22 this.filter = null; | |
23 } | |
24 | |
25 | |
26 public FixAnalysisArtifact(String uuid, String hash) { | |
27 super(uuid, hash); | |
28 this.filter = null; | |
29 } | |
30 | |
31 | |
32 public FixAnalysisArtifact( | |
33 String uuid, | |
34 String hash, | |
35 boolean inBackground, | |
36 List<CalculationMessage> messages | |
37 ) { | |
38 super(uuid, hash, inBackground, messages); | |
39 } | |
40 | |
41 | |
42 public String getName() { | |
43 return NAME; | |
44 } | |
45 | |
46 | |
47 public FixFilter getFilter () { | |
48 return createFilter(); | |
49 } | |
50 | |
51 | |
52 protected FixFilter createFilter() { | |
53 if (this.filter == null) { | |
54 this.filter = new FixFilter(); | |
55 } | |
56 DataList[] old = artifactDescription.getOldData(); | |
57 | |
58 String river = artifactDescription.getDataValueAsString("river"); | |
59 if (river != null) { | |
60 this.filter.setRiver(river); | |
61 } | |
62 | |
63 String from = artifactDescription.getDataValueAsString("ld_from"); | |
64 if (from != null) { | |
65 try { | |
66 double fkm = Double.parseDouble(from); | |
67 this.filter.setFromKm(fkm); | |
68 } | |
69 catch(NumberFormatException nfe) { | |
70 GWT.log("Could not parse from km."); | |
71 } | |
72 } | |
73 | |
74 String to = artifactDescription.getDataValueAsString("ld_to"); | |
75 if (to != null) { | |
76 try { | |
77 double tkm = Double.parseDouble(to); | |
78 this.filter.setToKm(tkm); | |
79 } | |
80 catch(NumberFormatException nfe) { | |
81 GWT.log("Could not parse to km"); | |
82 } | |
83 } | |
84 | |
85 String start = artifactDescription.getDataValueAsString("start"); | |
86 if (start != null) { | |
87 try { | |
88 long s = Long.parseLong(start); | |
89 this.filter.setFromDate(s); | |
90 } | |
91 catch(NumberFormatException nfe) { | |
92 GWT.log("Could not parse start date"); | |
93 } | |
94 } | |
95 | |
96 String end = artifactDescription.getDataValueAsString("end"); | |
97 if (end != null) { | |
98 try { | |
99 long e = Long.parseLong(end); | |
100 this.filter.setToDate(e); | |
101 } | |
102 catch(NumberFormatException nfe) { | |
103 GWT.log("Could not parse end date"); | |
104 } | |
105 } | |
106 | |
107 String q1 = artifactDescription.getDataValueAsString("q1"); | |
108 if (q1 != null) { | |
109 try { | |
110 int q1i = Integer.parseInt(q1); | |
111 this.filter.setFromClass(q1i); | |
112 } | |
113 catch(NumberFormatException nfe) { | |
114 GWT.log("Could not parse start class"); | |
115 } | |
116 } | |
117 | |
118 String q2 = artifactDescription.getDataValueAsString("q2"); | |
119 if (q2 != null) { | |
120 try { | |
121 int q2i = Integer.parseInt(q2); | |
122 this.filter.setToClass(q2i); | |
123 } | |
124 catch(NumberFormatException nfe) { | |
125 GWT.log("could not parse end class"); | |
126 } | |
127 } | |
128 | |
129 for (DataList list: old) { | |
130 List<Data> items = list.getAll(); | |
131 String state = list.getState(); | |
132 if(state.equals("state.fix.eventselect")) { | |
133 Data de = getData(items, "events"); | |
134 IntegerArrayData iad = (IntegerArrayData) de; | |
135 this.filter.setEvents(iad.getValues()); | |
136 } | |
137 } | |
138 | |
139 return this.filter; | |
140 } | |
141 | |
142 protected Data getData(List<Data> data, String name) { | |
143 for (Data d: data) { | |
144 if (name.equals(d.getLabel())) { | |
145 return d; | |
146 } | |
147 } | |
148 return null; | |
149 } | |
150 } | |
151 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |