Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/states/WDifferencesState.java @ 6582:7216143665d9
issue1394, issue1366: Prepare difference state to handle other artifacts, esp.
FixationArtifacts (for vollmer-curves).
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 17 Jul 2013 12:15:00 +0200 |
parents | 7d86ed4537d9 |
children | e8e76d50d119 |
comparison
equal
deleted
inserted
replaced
6581:5f0e3e9cf6f3 | 6582:7216143665d9 |
---|---|
16 import org.dive4elements.artifactdatabase.state.Facet; | 16 import org.dive4elements.artifactdatabase.state.Facet; |
17 import org.dive4elements.artifactdatabase.data.StateData; | 17 import org.dive4elements.artifactdatabase.data.StateData; |
18 | 18 |
19 import org.dive4elements.artifacts.CallContext; | 19 import org.dive4elements.artifacts.CallContext; |
20 import org.dive4elements.artifacts.Artifact; | 20 import org.dive4elements.artifacts.Artifact; |
21 import org.dive4elements.river.artifacts.ChartArtifact; | |
21 import org.dive4elements.river.artifacts.D4EArtifact; | 22 import org.dive4elements.river.artifacts.D4EArtifact; |
23 import org.dive4elements.river.artifacts.FixationArtifact; | |
24 import org.dive4elements.river.artifacts.MINFOArtifact; | |
22 import org.dive4elements.river.artifacts.StaticWKmsArtifact; | 25 import org.dive4elements.river.artifacts.StaticWKmsArtifact; |
23 import org.dive4elements.river.artifacts.WINFOArtifact; | 26 import org.dive4elements.river.artifacts.WINFOArtifact; |
24 import org.dive4elements.river.artifacts.ChartArtifact; | |
25 | 27 |
26 import org.dive4elements.river.artifacts.math.WKmsOperation; | 28 import org.dive4elements.river.artifacts.math.WKmsOperation; |
27 | 29 |
28 import org.dive4elements.river.artifacts.model.CalculationResult; | 30 import org.dive4elements.river.artifacts.model.CalculationResult; |
29 import org.dive4elements.river.artifacts.model.DataFacet; | 31 import org.dive4elements.river.artifacts.model.DataFacet; |
30 import org.dive4elements.river.artifacts.model.DifferenceCurveFacet; | 32 import org.dive4elements.river.artifacts.model.DifferenceCurveFacet; |
31 import org.dive4elements.river.artifacts.model.EmptyFacet; | 33 import org.dive4elements.river.artifacts.model.EmptyFacet; |
32 | |
33 import org.dive4elements.river.artifacts.model.FacetTypes; | 34 import org.dive4elements.river.artifacts.model.FacetTypes; |
34 import org.dive4elements.river.artifacts.model.WKms; | 35 import org.dive4elements.river.artifacts.model.WKms; |
35 import org.dive4elements.river.artifacts.model.WQKms; | 36 import org.dive4elements.river.artifacts.model.WQKms; |
37 | |
38 import org.dive4elements.river.artifacts.model.fixings.FixRealizingResult; | |
36 | 39 |
37 import org.dive4elements.river.utils.RiverUtils; | 40 import org.dive4elements.river.utils.RiverUtils; |
38 import org.dive4elements.river.utils.StringUtil; | 41 import org.dive4elements.river.utils.StringUtil; |
39 | 42 |
40 /** State of a WINFOArtifact to get differences of data of other artifacts. */ | 43 /** State of a WINFOArtifact to get differences of data of other artifacts. */ |
74 return true; | 77 return true; |
75 } | 78 } |
76 | 79 |
77 | 80 |
78 /** | 81 /** |
79 * Access the data (wkms). | 82 * Access the data (wkms) of an artifact, coded in mingle. |
80 */ | 83 */ |
81 protected WKms getWKms(String mingle, CallContext context) { | 84 protected WKms getWKms(String mingle, CallContext context) { |
85 logger.debug("WDifferencesState.getWKms " + mingle); | |
82 String[] def = mingle.split(";"); | 86 String[] def = mingle.split(";"); |
83 String uuid = def[0]; | 87 String uuid = def[0]; |
84 String name = def[1]; | 88 String name = def[1]; |
85 int idx = Integer.parseInt(def[2]); | 89 int idx = Integer.parseInt(def[2]); |
86 | 90 |
94 if (wkms == null) | 98 if (wkms == null) |
95 logger.error("No WKms from artifact."); | 99 logger.error("No WKms from artifact."); |
96 return wkms; | 100 return wkms; |
97 } | 101 } |
98 | 102 |
99 WINFOArtifact flys = (WINFOArtifact) RiverUtils.getArtifact( | 103 D4EArtifact d4eArtifact = RiverUtils.getArtifact( |
100 uuid, | 104 uuid, |
101 context); | 105 context); |
102 | 106 |
103 if (flys == null) { | 107 if (d4eArtifact == null) { |
104 logger.warn("One of the artifacts (1) for diff calculation could not be loaded"); | 108 logger.warn("One of the artifacts (1) for diff calculation could not be loaded"); |
105 return null; | 109 return null; |
106 } | 110 } |
107 else{ | 111 |
112 if (d4eArtifact instanceof WINFOArtifact) { | |
113 logger.debug("Get WKms from WINFOArtifact"); | |
114 WINFOArtifact flys = (WINFOArtifact) d4eArtifact; | |
115 | |
108 WQKms[] wqkms = (WQKms[]) flys.getWaterlevelData(). | 116 WQKms[] wqkms = (WQKms[]) flys.getWaterlevelData(). |
109 getData(); | 117 getData(); |
110 if (wqkms == null) | 118 if (wqkms == null) { |
111 logger.warn("not waterlevels in artifact"); | 119 logger.warn("no waterlevels in artifact"); |
112 else if (wqkms.length < idx) | 120 } |
113 logger.warn("not enough waterlevels in artifact"); | 121 else if (wqkms.length < idx+1) { |
122 logger.warn("not enough waterlevels in artifact"); | |
123 return new WQKms(); | |
124 } | |
114 return wqkms[idx]; | 125 return wqkms[idx]; |
115 } | 126 } |
127 else if (d4eArtifact instanceof MINFOArtifact) { | |
128 logger.debug("Get WKms from MINFOArtifact"); | |
129 CalculationResult r = (CalculationResult) | |
130 d4eArtifact.compute(context, ComputeType.ADVANCE, false); | |
131 } | |
132 else if (d4eArtifact instanceof FixationArtifact) { | |
133 logger.debug ("Get WKms from FixationArtifact."); | |
134 CalculationResult r = (CalculationResult) | |
135 d4eArtifact.compute(context, ComputeType.ADVANCE, false); | |
136 FixRealizingResult frR = (FixRealizingResult) r.getData(); | |
137 return frR.getWQKms()[idx]; | |
138 } | |
139 | |
140 logger.error("Do not know how to handle (getWKms) minuend/subtrahend"); | |
141 return null; | |
116 } | 142 } |
117 | 143 |
118 | 144 |
119 /** | 145 /** |
120 * Return CalculationResult with Array of WKms that are difference of | 146 * Return CalculationResult with Array of WKms that are difference of |