Mercurial > dive4elements > river
comparison gwt-client/src/main/java/org/dive4elements/river/client/shared/model/AbstractFixBunduArtifact.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 | |
children | 6c24c857ccf9 |
comparison
equal
deleted
inserted
replaced
9071:a561b882436d | 9072:02739b8c010d |
---|---|
1 /** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde | |
2 * Software engineering by | |
3 * Björnsen Beratende Ingenieure GmbH | |
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt | |
5 * | |
6 * This file is Free Software under the GNU AGPL (>=v3) | |
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the | |
8 * documentation coming with Dive4Elements River for details. | |
9 */ | |
10 package org.dive4elements.river.client.shared.model; | |
11 | |
12 import java.util.List; | |
13 | |
14 import com.google.gwt.core.client.GWT; | |
15 | |
16 /** | |
17 * @author Domenico Nardi Tironi | |
18 * | |
19 */ | |
20 public abstract class AbstractFixBunduArtifact extends DefaultArtifact { | |
21 | |
22 /** The name of this artifact: 'fixanalysis'. */ | |
23 | |
24 protected FixFilter filter; | |
25 | |
26 public AbstractFixBunduArtifact() { | |
27 this.filter = null; | |
28 } | |
29 | |
30 public AbstractFixBunduArtifact(final String uuid, final String hash) { | |
31 super(uuid, hash); | |
32 this.filter = null; | |
33 } | |
34 | |
35 public AbstractFixBunduArtifact(final String uuid, final String hash, final boolean inBackground, final List<CalculationMessage> messages) { | |
36 super(uuid, hash, inBackground, messages); | |
37 } | |
38 | |
39 public FixFilter getFilter() { | |
40 return createFilter(); | |
41 } | |
42 | |
43 protected abstract String getEventstateId(); | |
44 | |
45 protected FixFilter createFilter() { | |
46 if (this.filter == null) { | |
47 this.filter = new FixFilter(); | |
48 } | |
49 final DataList[] old = this.artifactDescription.getOldData(); | |
50 | |
51 final String river = this.artifactDescription.getDataValueAsString("river"); | |
52 if (river != null) { | |
53 this.filter.setRiver(river); | |
54 } | |
55 | |
56 final String from = this.artifactDescription.getDataValueAsString("ld_from"); | |
57 if (from != null) { | |
58 try { | |
59 final double fkm = Double.parseDouble(from); | |
60 this.filter.setFromKm(fkm); | |
61 } | |
62 catch (final NumberFormatException nfe) { | |
63 GWT.log("Could not parse from km."); | |
64 } | |
65 } | |
66 | |
67 final String to = this.artifactDescription.getDataValueAsString("ld_to"); | |
68 if (to != null) { | |
69 try { | |
70 final double tkm = Double.parseDouble(to); | |
71 this.filter.setToKm(tkm); | |
72 } | |
73 catch (final NumberFormatException nfe) { | |
74 GWT.log("Could not parse to km"); | |
75 } | |
76 } | |
77 | |
78 final String start = this.artifactDescription.getDataValueAsString("start"); | |
79 if (start != null) { | |
80 try { | |
81 final long s = Long.parseLong(start); | |
82 this.filter.setFromDate(s); | |
83 } | |
84 catch (final NumberFormatException nfe) { | |
85 GWT.log("Could not parse start date"); | |
86 } | |
87 } | |
88 | |
89 final String end = this.artifactDescription.getDataValueAsString("end"); | |
90 if (end != null) { | |
91 try { | |
92 final long e = Long.parseLong(end); | |
93 this.filter.setToDate(e); | |
94 } | |
95 catch (final NumberFormatException nfe) { | |
96 GWT.log("Could not parse end date"); | |
97 } | |
98 } | |
99 | |
100 final String q1 = this.artifactDescription.getDataValueAsString("q1"); | |
101 if (q1 != null) { | |
102 try { | |
103 final int q1i = Integer.parseInt(q1); | |
104 this.filter.setFromClass(q1i); | |
105 } | |
106 catch (final NumberFormatException nfe) { | |
107 GWT.log("Could not parse start class"); | |
108 } | |
109 } | |
110 | |
111 final String q2 = this.artifactDescription.getDataValueAsString("q2"); | |
112 if (q2 != null) { | |
113 try { | |
114 final int q2i = Integer.parseInt(q2); | |
115 this.filter.setToClass(q2i); | |
116 } | |
117 catch (final NumberFormatException nfe) { | |
118 GWT.log("could not parse end class"); | |
119 } | |
120 } | |
121 | |
122 for (final DataList list : old) { | |
123 final List<Data> items = list.getAll(); | |
124 final String state = list.getState(); | |
125 if (state.equals(getEventstateId())) { | |
126 final Data de = getData(items, "events"); | |
127 final IntegerArrayData iad = (IntegerArrayData) de; | |
128 this.filter.setEvents(iad.getValues()); | |
129 } | |
130 } | |
131 | |
132 return this.filter; | |
133 } | |
134 | |
135 protected Data getData(final List<Data> data, final String name) { | |
136 for (final Data d : data) { | |
137 if (name.equals(d.getLabel())) { | |
138 return d; | |
139 } | |
140 } | |
141 return null; | |
142 } | |
143 } |