# HG changeset patch # User Felix Wolfsteller # Date 1384426607 -3600 # Node ID f89ad512f4261115608e63e7d5ebbe5c1f6f8d50 # Parent f4c13fbde072dbff4e4e2bed0319e6486319c114 issue1020: In WaterlevelSelectState create label more differentiated at which data comes out of calculation. diff -r f4c13fbde072 -r f89ad512f426 artifacts/src/main/java/org/dive4elements/river/artifacts/states/WaterlevelSelectState.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/WaterlevelSelectState.java Thu Nov 14 11:54:02 2013 +0100 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/WaterlevelSelectState.java Thu Nov 14 11:56:47 2013 +0100 @@ -125,20 +125,36 @@ D4EArtifact artifact = RiverUtils.getArtifact(parts[0], cc); - CalculationResult rawData = (CalculationResult) artifact.compute( + Object rawData = artifact.compute( cc, null, - WINFO_WSP_STATE_ID, + //WINFO_WSP_STATE_ID, + artifact.getCurrentStateId(), ComputeType.ADVANCE, false); WQKms[] wqkms; - if (rawData.getData() instanceof ExtremeResult) { - wqkms = ((ExtremeResult) rawData.getData()).getWQKms(); + // TODO issue1020: Fetch cases in which only WKms or + // other weird stuff arrives. + if (rawData instanceof CalculationResult) { + CalculationResult calcResult = (CalculationResult) rawData; + if (calcResult.getData() instanceof ExtremeResult) { + wqkms = ((ExtremeResult) calcResult.getData()).getWQKms(); + } + else { + wqkms = (WQKms[]) calcResult.getData(); + } + } + else if (rawData instanceof WQKms) { + wqkms = new WQKms[] {(WQKms) rawData}; + } + else if (rawData instanceof WQKms[]) { + wqkms = (WQKms[]) rawData; } else { - wqkms = (WQKms[]) rawData.getData(); + logger.error("Do not know how to handle " + rawData.getClass()); + wqkms = null; } int idx = -1;