Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/states/WDifferencesState.java @ 6501:7cb247824ed1
Amtl. Linien: Added report if an official line was found in report.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Fri, 28 Jun 2013 14:11:58 +0200 |
parents | af13ceeba52a |
children | 7d86ed4537d9 |
rev | line source |
---|---|
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
2 * Software engineering by Intevation GmbH |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
3 * |
5994
af13ceeba52a
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5867
diff
changeset
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
5994
af13ceeba52a
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5867
diff
changeset
|
6 * documentation coming with Dive4Elements River for details. |
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
7 */ |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
8 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4054
diff
changeset
|
9 package org.dive4elements.river.artifacts.states; |
1151
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
10 |
1643
ff7bffb7d5f0
Let WDifferences-diagram show more than one difference, if asked to.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1626
diff
changeset
|
11 import java.util.ArrayList; |
1151
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
12 import java.util.List; |
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
13 |
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
14 import org.apache.log4j.Logger; |
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
15 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4054
diff
changeset
|
16 import org.dive4elements.artifactdatabase.state.Facet; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4054
diff
changeset
|
17 import org.dive4elements.artifactdatabase.data.StateData; |
1151
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
18 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4054
diff
changeset
|
19 import org.dive4elements.artifacts.CallContext; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4054
diff
changeset
|
20 import org.dive4elements.artifacts.Artifact; |
5867
59ff03ff48f1
River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5865
diff
changeset
|
21 import org.dive4elements.river.artifacts.D4EArtifact; |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4054
diff
changeset
|
22 import org.dive4elements.river.artifacts.StaticWKmsArtifact; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4054
diff
changeset
|
23 import org.dive4elements.river.artifacts.WINFOArtifact; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4054
diff
changeset
|
24 import org.dive4elements.river.artifacts.ChartArtifact; |
1151
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
25 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4054
diff
changeset
|
26 import org.dive4elements.river.artifacts.math.WKmsOperation; |
2136
3a5ef4ac8e0f
'New Chart' for w-differences curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1886
diff
changeset
|
27 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4054
diff
changeset
|
28 import org.dive4elements.river.artifacts.model.CalculationResult; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4054
diff
changeset
|
29 import org.dive4elements.river.artifacts.model.DataFacet; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4054
diff
changeset
|
30 import org.dive4elements.river.artifacts.model.DifferenceCurveFacet; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4054
diff
changeset
|
31 import org.dive4elements.river.artifacts.model.EmptyFacet; |
1151
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
32 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4054
diff
changeset
|
33 import org.dive4elements.river.artifacts.model.FacetTypes; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4054
diff
changeset
|
34 import org.dive4elements.river.artifacts.model.WKms; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4054
diff
changeset
|
35 import org.dive4elements.river.artifacts.model.WQKms; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4054
diff
changeset
|
36 |
5865
73da40528cf2
River artifacts: Renamed FLYSUtils to RiverUtils.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
37 import org.dive4elements.river.utils.RiverUtils; |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4054
diff
changeset
|
38 import org.dive4elements.river.utils.StringUtil; |
1151
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
39 |
1158
fbe18ad4caff
Removed needless imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1153
diff
changeset
|
40 |
1151
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
41 public class WDifferencesState |
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
42 extends DefaultState |
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
43 implements FacetTypes |
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
44 { |
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
45 /** The logger that is used in this state. */ |
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
46 private static Logger logger = Logger.getLogger(WDifferencesState.class); |
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
47 |
1173
2490d6ef394e
Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1161
diff
changeset
|
48 |
1151
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
49 public WDifferencesState() { |
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
50 } |
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
51 |
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
52 |
1173
2490d6ef394e
Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1161
diff
changeset
|
53 /** Specify to display nothing (this is kind of a "final" state). */ |
1151
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
54 @Override |
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
55 protected String getUIProvider() { |
1173
2490d6ef394e
Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1161
diff
changeset
|
56 return "noinput"; |
1151
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
57 } |
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
58 |
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
59 |
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
60 @Override |
1183
9c1cda9e2bc4
Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1173
diff
changeset
|
61 public boolean validate(Artifact artifact) |
9c1cda9e2bc4
Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1173
diff
changeset
|
62 throws IllegalArgumentException |
9c1cda9e2bc4
Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1173
diff
changeset
|
63 { |
5867
59ff03ff48f1
River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5865
diff
changeset
|
64 D4EArtifact flys = (D4EArtifact) artifact; |
1183
9c1cda9e2bc4
Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1173
diff
changeset
|
65 |
9c1cda9e2bc4
Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1173
diff
changeset
|
66 StateData data = flys.getData("diffids"); |
9c1cda9e2bc4
Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1173
diff
changeset
|
67 |
9c1cda9e2bc4
Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1173
diff
changeset
|
68 if (data == null) { |
9c1cda9e2bc4
Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1173
diff
changeset
|
69 throw new IllegalArgumentException("diffids is empty"); |
9c1cda9e2bc4
Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1173
diff
changeset
|
70 } |
9c1cda9e2bc4
Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1173
diff
changeset
|
71 |
9c1cda9e2bc4
Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1173
diff
changeset
|
72 // TODO: Also validate format. |
9c1cda9e2bc4
Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1173
diff
changeset
|
73 |
9c1cda9e2bc4
Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1173
diff
changeset
|
74 return true; |
9c1cda9e2bc4
Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1173
diff
changeset
|
75 } |
9c1cda9e2bc4
Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1173
diff
changeset
|
76 |
9c1cda9e2bc4
Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1173
diff
changeset
|
77 |
3122
721298eeb694
Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3076
diff
changeset
|
78 /** |
721298eeb694
Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3076
diff
changeset
|
79 * Access the data (wkms). |
721298eeb694
Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3076
diff
changeset
|
80 */ |
1732
1a57027286ce
Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1696
diff
changeset
|
81 protected WKms getWKms(String mingle, CallContext context) { |
1a57027286ce
Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1696
diff
changeset
|
82 String[] def = mingle.split(";"); |
1a57027286ce
Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1696
diff
changeset
|
83 String uuid = def[0]; |
1a57027286ce
Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1696
diff
changeset
|
84 String name = def[1]; |
1a57027286ce
Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1696
diff
changeset
|
85 int idx = Integer.parseInt(def[2]); |
1a57027286ce
Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1696
diff
changeset
|
86 |
1a57027286ce
Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1696
diff
changeset
|
87 if (name.startsWith("staticwkms")) { |
1a57027286ce
Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1696
diff
changeset
|
88 StaticWKmsArtifact staticWKms = |
5865
73da40528cf2
River artifacts: Renamed FLYSUtils to RiverUtils.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
89 (StaticWKmsArtifact) RiverUtils.getArtifact( |
1732
1a57027286ce
Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1696
diff
changeset
|
90 uuid, |
1a57027286ce
Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1696
diff
changeset
|
91 context); |
1a57027286ce
Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1696
diff
changeset
|
92 logger.debug("WDifferencesState obtain data from StaticWKms"); |
1a57027286ce
Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1696
diff
changeset
|
93 WKms wkms = staticWKms.getWKms(idx); |
1a57027286ce
Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1696
diff
changeset
|
94 if (wkms == null) |
1a57027286ce
Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1696
diff
changeset
|
95 logger.error("No WKms from artifact."); |
1a57027286ce
Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1696
diff
changeset
|
96 return wkms; |
1a57027286ce
Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1696
diff
changeset
|
97 } |
3076
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2180
diff
changeset
|
98 |
5865
73da40528cf2
River artifacts: Renamed FLYSUtils to RiverUtils.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
99 WINFOArtifact flys = (WINFOArtifact) RiverUtils.getArtifact( |
1732
1a57027286ce
Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1696
diff
changeset
|
100 uuid, |
1a57027286ce
Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1696
diff
changeset
|
101 context); |
1a57027286ce
Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1696
diff
changeset
|
102 |
1a57027286ce
Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1696
diff
changeset
|
103 if (flys == null) { |
1a57027286ce
Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1696
diff
changeset
|
104 logger.warn("One of the artifacts (1) for diff calculation could not be loaded"); |
1a57027286ce
Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1696
diff
changeset
|
105 return null; |
1a57027286ce
Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1696
diff
changeset
|
106 } |
1a57027286ce
Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1696
diff
changeset
|
107 else{ |
1a57027286ce
Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1696
diff
changeset
|
108 WQKms[] wqkms = (WQKms[]) flys.getWaterlevelData(). |
1a57027286ce
Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1696
diff
changeset
|
109 getData(); |
1a57027286ce
Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1696
diff
changeset
|
110 if (wqkms == null) |
1a57027286ce
Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1696
diff
changeset
|
111 logger.warn("not waterlevels in artifact"); |
1a57027286ce
Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1696
diff
changeset
|
112 else if (wqkms.length < idx) |
1a57027286ce
Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1696
diff
changeset
|
113 logger.warn("not enough waterlevels in artifact"); |
1a57027286ce
Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1696
diff
changeset
|
114 return wqkms[idx]; |
1a57027286ce
Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1696
diff
changeset
|
115 } |
1a57027286ce
Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1696
diff
changeset
|
116 } |
1a57027286ce
Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1696
diff
changeset
|
117 |
1a57027286ce
Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1696
diff
changeset
|
118 |
1643
ff7bffb7d5f0
Let WDifferences-diagram show more than one difference, if asked to.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1626
diff
changeset
|
119 /** |
1652
46a2a5dc98b7
In W-Difference-calculation, respect indices of selected facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1643
diff
changeset
|
120 * Return CalculationResult with Array of WKms that are difference of |
46a2a5dc98b7
In W-Difference-calculation, respect indices of selected facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1643
diff
changeset
|
121 * Waterlevels. Add respective facets (DifferencesCurveFacet, DataFacet). |
1643
ff7bffb7d5f0
Let WDifferences-diagram show more than one difference, if asked to.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1626
diff
changeset
|
122 */ |
1183
9c1cda9e2bc4
Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1173
diff
changeset
|
123 @Override |
1151
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
124 public Object computeAdvance( |
5867
59ff03ff48f1
River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5865
diff
changeset
|
125 D4EArtifact artifact, |
1151
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
126 String hash, |
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
127 CallContext context, |
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
128 List<Facet> facets, |
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
129 Object old |
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
130 ) { |
2136
3a5ef4ac8e0f
'New Chart' for w-differences curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1886
diff
changeset
|
131 if (artifact instanceof ChartArtifact) { |
3a5ef4ac8e0f
'New Chart' for w-differences curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1886
diff
changeset
|
132 ChartArtifact chart = (ChartArtifact)artifact; |
3a5ef4ac8e0f
'New Chart' for w-differences curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1886
diff
changeset
|
133 facets.add(new EmptyFacet()); |
3a5ef4ac8e0f
'New Chart' for w-differences curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1886
diff
changeset
|
134 return null; |
3a5ef4ac8e0f
'New Chart' for w-differences curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1886
diff
changeset
|
135 } |
1732
1a57027286ce
Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1696
diff
changeset
|
136 WINFOArtifact winfo = (WINFOArtifact) artifact; |
1173
2490d6ef394e
Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1161
diff
changeset
|
137 String id = getID(); |
1151
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
138 |
1183
9c1cda9e2bc4
Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1173
diff
changeset
|
139 // Load the Artifacts/facets that we want to subtract and display. |
9c1cda9e2bc4
Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1173
diff
changeset
|
140 // Expected format is: |
9c1cda9e2bc4
Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1173
diff
changeset
|
141 // [42537f1e-3522-42ef-8968-635b03d8e9c6;longitudinal_section.w;0]#[1231f2-....] |
1661
a890bf077de5
Use StringUtil.wWrap , fix wrong loop, minor refac and cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1655
diff
changeset
|
142 String diffids = winfo.getDataAsString("diffids"); |
1732
1a57027286ce
Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1696
diff
changeset
|
143 logger.debug("WDifferencesState has: " + diffids); |
1661
a890bf077de5
Use StringUtil.wWrap , fix wrong loop, minor refac and cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1655
diff
changeset
|
144 String datas[] = diffids.split("#"); |
1183
9c1cda9e2bc4
Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1173
diff
changeset
|
145 |
9c1cda9e2bc4
Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1173
diff
changeset
|
146 // Validate the Data-Strings. |
9c1cda9e2bc4
Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1173
diff
changeset
|
147 for (String s: datas) { |
4054
102050c4fc00
fix issue909: strange validation code. be fearles.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3122
diff
changeset
|
148 if (!WaterlevelSelectState.isValueValid(s)) { |
1183
9c1cda9e2bc4
Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1173
diff
changeset
|
149 // TODO: escalate. |
9c1cda9e2bc4
Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1173
diff
changeset
|
150 } |
9c1cda9e2bc4
Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1173
diff
changeset
|
151 } |
9c1cda9e2bc4
Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1173
diff
changeset
|
152 |
1626
b9b47af71564
Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1187
diff
changeset
|
153 if (datas.length < 2) { |
1183
9c1cda9e2bc4
Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1173
diff
changeset
|
154 // TODO crash with style |
9c1cda9e2bc4
Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1173
diff
changeset
|
155 } |
1151
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
156 |
1643
ff7bffb7d5f0
Let WDifferences-diagram show more than one difference, if asked to.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1626
diff
changeset
|
157 List<WKms> wkmss = new ArrayList<WKms>(); |
1151
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
158 |
1661
a890bf077de5
Use StringUtil.wWrap , fix wrong loop, minor refac and cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1655
diff
changeset
|
159 for(int i = 0; i < datas.length; i+=2) { |
1652
46a2a5dc98b7
In W-Difference-calculation, respect indices of selected facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1643
diff
changeset
|
160 // e.g.: |
46a2a5dc98b7
In W-Difference-calculation, respect indices of selected facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1643
diff
changeset
|
161 // 42537f1e-3522-42ef-8968-635b03d8e9c6;longitudinal_section.w;1 |
1732
1a57027286ce
Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1696
diff
changeset
|
162 WKms minuendWKms = getWKms(StringUtil.unbracket(datas[i+0]), |
1626
b9b47af71564
Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1187
diff
changeset
|
163 context); |
1732
1a57027286ce
Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1696
diff
changeset
|
164 WKms subtrahendWKms = getWKms(StringUtil.unbracket(datas[i+1]), |
1a57027286ce
Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1696
diff
changeset
|
165 context); |
1a57027286ce
Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1696
diff
changeset
|
166 |
1626
b9b47af71564
Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1187
diff
changeset
|
167 String facetName = "diff ()"; |
b9b47af71564
Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1187
diff
changeset
|
168 |
1732
1a57027286ce
Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1696
diff
changeset
|
169 if (minuendWKms != null && subtrahendWKms != null) { |
3076
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2180
diff
changeset
|
170 facetName = StringUtil.wWrap(minuendWKms.getName()) |
1732
1a57027286ce
Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1696
diff
changeset
|
171 + " - " + StringUtil.wWrap(subtrahendWKms.getName()); |
1a57027286ce
Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1696
diff
changeset
|
172 WKms wkms = WKmsOperation.SUBTRACTION.operate(minuendWKms, |
1a57027286ce
Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1696
diff
changeset
|
173 subtrahendWKms); |
1643
ff7bffb7d5f0
Let WDifferences-diagram show more than one difference, if asked to.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1626
diff
changeset
|
174 wkms.setName(facetName); |
ff7bffb7d5f0
Let WDifferences-diagram show more than one difference, if asked to.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1626
diff
changeset
|
175 wkmss.add(wkms); |
1626
b9b47af71564
Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1187
diff
changeset
|
176 logger.debug("WKMSSubtraction happened"); |
b9b47af71564
Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1187
diff
changeset
|
177 } |
b9b47af71564
Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1187
diff
changeset
|
178 if (facets != null) { |
1696
56953439dcae
Fixed incorrect indexing of facets when doing multiple (w)differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1670
diff
changeset
|
179 facets.add(new DifferenceCurveFacet(i/2, W_DIFFERENCES, facetName, |
1643
ff7bffb7d5f0
Let WDifferences-diagram show more than one difference, if asked to.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1626
diff
changeset
|
180 ComputeType.ADVANCE, id, hash)); |
1626
b9b47af71564
Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1187
diff
changeset
|
181 } |
2180
65b32220f197
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2136
diff
changeset
|
182 } |
65b32220f197
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2136
diff
changeset
|
183 |
65b32220f197
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2136
diff
changeset
|
184 if (facets != null) { |
65b32220f197
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2136
diff
changeset
|
185 facets.add(new DataFacet(CSV, "CSV data")); |
65b32220f197
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2136
diff
changeset
|
186 facets.add(new DataFacet(PDF, "PDF data")); |
65b32220f197
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2136
diff
changeset
|
187 logger.debug("Adding facets in WDifferencesState."); |
65b32220f197
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2136
diff
changeset
|
188 } |
65b32220f197
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2136
diff
changeset
|
189 else { |
65b32220f197
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2136
diff
changeset
|
190 logger.debug("Not adding facets in WDifferencesState."); |
1151
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
191 } |
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
192 |
1652
46a2a5dc98b7
In W-Difference-calculation, respect indices of selected facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1643
diff
changeset
|
193 // TODO Evaluate whether null is okay as reports. |
1643
ff7bffb7d5f0
Let WDifferences-diagram show more than one difference, if asked to.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1626
diff
changeset
|
194 WKms[] diffs = wkmss.toArray(new WKms[wkmss.size()]); |
1652
46a2a5dc98b7
In W-Difference-calculation, respect indices of selected facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1643
diff
changeset
|
195 CalculationResult result = new CalculationResult(diffs, null); |
1643
ff7bffb7d5f0
Let WDifferences-diagram show more than one difference, if asked to.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1626
diff
changeset
|
196 return result; |
1151
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
197 } |
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
198 } |
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
199 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |