Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/SINFOArtifact.java @ 8946:5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
author | gernotbelger |
---|---|
date | Tue, 13 Mar 2018 18:49:33 +0100 |
parents | 20b85ea3b524 |
children | ee5ce13016ed |
comparison
equal
deleted
inserted
replaced
8945:4a6b6a3c279c | 8946:5d5d482da3e9 |
---|---|
1 /* Copyright (C) 2017 by Bundesanstalt für Gewässerkunde | 1 /* Copyright (C) 2017 by Bundesanstalt für Gewässerkunde |
2 * Software engineering by | 2 * Software engineering by |
3 * Björnsen Beratende Ingenieure GmbH | 3 * Björnsen Beratende Ingenieure GmbH |
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt | 4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt |
5 * | 5 * |
6 * This file is Free Software under the GNU AGPL (>=v3) | 6 * This file is Free Software under the GNU AGPL (>=v3) |
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the | 7 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
8 * documentation coming with Dive4Elements River for details. | 8 * documentation coming with Dive4Elements River for details. |
15 /** | 15 /** |
16 * The default SINFO artifact. | 16 * The default SINFO artifact. |
17 * | 17 * |
18 * @author Gernot Belger | 18 * @author Gernot Belger |
19 */ | 19 */ |
20 public class SINFOArtifact | 20 public class SINFOArtifact extends D4EArtifact { |
21 extends D4EArtifact | 21 |
22 { | 22 private static final long serialVersionUID = 1L; |
23 | |
23 /** Error message that is thrown if no mode has been chosen. */ | 24 /** Error message that is thrown if no mode has been chosen. */ |
24 private static final String ERROR_NO_CALCULATION_MODE = | 25 private static final String ERROR_NO_CALCULATION_MODE = "error_feed_no_calculation_mode"; |
25 "error_feed_no_calculation_mode"; | |
26 | 26 |
27 /** Error message that is thrown if an invalid calculation mode has been | 27 /** |
28 * chosen. */ | 28 * Error message that is thrown if an invalid calculation mode has been |
29 private static final String ERROR_INVALID_CALCULATION_MODE = | 29 * chosen. |
30 "error_feed_invalid_calculation_mode"; | 30 */ |
31 private static final String ERROR_INVALID_CALCULATION_MODE = "error_feed_invalid_calculation_mode"; | |
31 | 32 |
32 | |
33 /** The name of the artifact. */ | 33 /** The name of the artifact. */ |
34 private static final String ARTIFACT_NAME = "sinfo"; | 34 private static final String ARTIFACT_NAME = "sinfo"; |
35 | 35 |
36 private static final String FIELD_RIVER = "river"; | 36 private static final String FIELD_RIVER = "river"; |
37 | 37 |
38 private static final String FIELD_MODE = "calculation_mode"; | 38 private static final String FIELD_MODE = "calculation_mode"; |
39 | 39 |
40 /** | 40 /** |
41 * Default constructor, because it's serializable. | 41 * Default constructor, because it's serializable. |
42 */ | 42 */ |
43 public SINFOArtifact() { | 43 public SINFOArtifact() { |
44 } | 44 } |
50 */ | 50 */ |
51 @Override | 51 @Override |
52 public String getName() { | 52 public String getName() { |
53 return ARTIFACT_NAME; | 53 return ARTIFACT_NAME; |
54 } | 54 } |
55 | 55 |
56 public SinfoCalcMode getCalculationMode() { | 56 public SinfoCalcMode getCalculationMode() { |
57 | 57 |
58 final String calc = getDataAsString(FIELD_MODE); | 58 final String calc = getDataAsString(FIELD_MODE); |
59 if (calc == null) { | 59 if (calc == null) { |
60 throw new IllegalArgumentException(ERROR_NO_CALCULATION_MODE); | 60 throw new IllegalArgumentException(ERROR_NO_CALCULATION_MODE); |
61 } | 61 } |
62 | 62 |
63 try { | 63 try { |
64 return SinfoCalcMode.valueOf(StringUtils.trimToEmpty(calc).toLowerCase()); | 64 return SinfoCalcMode.valueOf(StringUtils.trimToEmpty(calc).toLowerCase()); |
65 } catch (Exception e) { | 65 } |
66 throw new IllegalArgumentException(ERROR_INVALID_CALCULATION_MODE, e); | 66 catch (final Exception e) { |
67 } | 67 throw new IllegalArgumentException(ERROR_INVALID_CALCULATION_MODE, e); |
68 } | 68 } |
69 | 69 } |
70 | |
70 public String getRiver() { | 71 public String getRiver() { |
71 return getDataAsString(FIELD_RIVER); | 72 return getDataAsString(FIELD_RIVER); |
72 } | 73 } |
73 } | 74 } |