comparison gwt-client/src/main/java/org/dive4elements/river/client/shared/model/FixAnalysisArtifact.java @ 9072:02739b8c010d

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

http://dive4elements.wald.intevation.org