Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/SINFOArtifact.java @ 9307:45bbd2c232f8
S-Info main value themes in flood duration w/q set to initially invisible
author | mschaefer |
---|---|
date | Wed, 25 Jul 2018 19:27:25 +0200 |
parents | b194fa64506a |
children | fbfd66e8fb81 |
rev | line source |
---|---|
8854 | 1 /* Copyright (C) 2017 by Bundesanstalt für Gewässerkunde |
8946
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8869
diff
changeset
|
2 * Software engineering by |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8869
diff
changeset
|
3 * Björnsen Beratende Ingenieure GmbH |
8854 | 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.artifacts.sinfo; | |
11 | |
12 import org.apache.commons.lang.StringUtils; | |
8956 | 13 import org.dive4elements.artifactdatabase.state.Facet; |
14 import org.dive4elements.artifactdatabase.state.FacetActivity; | |
15 import org.dive4elements.artifacts.Artifact; | |
8854 | 16 import org.dive4elements.river.artifacts.D4EArtifact; |
8956 | 17 import org.dive4elements.river.artifacts.sinfo.common.D50Processor; |
8980
b194fa64506a
SINFO - show results themes according to spec, either raw data or floating mean values.
gernotbelger
parents:
8956
diff
changeset
|
18 import org.dive4elements.river.artifacts.sinfo.common.FlowDepthDevelopmentPerYearProcessor; |
8956 | 19 import org.dive4elements.river.artifacts.sinfo.common.FlowDepthDevelopmentProcessor; |
20 import org.dive4elements.river.artifacts.sinfo.common.FlowDepthProcessor; | |
21 import org.dive4elements.river.artifacts.sinfo.common.TauProcessor; | |
22 import org.dive4elements.river.artifacts.sinfo.common.VelocityProcessor; | |
9307
45bbd2c232f8
S-Info main value themes in flood duration w/q set to initially invisible
mschaefer
parents:
8980
diff
changeset
|
23 import org.dive4elements.river.artifacts.sinfo.flood_duration.FloodDurationCurveProcessor; |
8854 | 24 |
25 /** | |
8869 | 26 * The default SINFO artifact. |
8854 | 27 * |
28 * @author Gernot Belger | |
29 */ | |
8946
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8869
diff
changeset
|
30 public class SINFOArtifact extends D4EArtifact { |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8869
diff
changeset
|
31 |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8869
diff
changeset
|
32 private static final long serialVersionUID = 1L; |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8869
diff
changeset
|
33 |
8854 | 34 /** Error message that is thrown if no mode has been chosen. */ |
8946
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8869
diff
changeset
|
35 private static final String ERROR_NO_CALCULATION_MODE = "error_feed_no_calculation_mode"; |
8854 | 36 |
8946
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8869
diff
changeset
|
37 /** |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8869
diff
changeset
|
38 * Error message that is thrown if an invalid calculation mode has been |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8869
diff
changeset
|
39 * chosen. |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8869
diff
changeset
|
40 */ |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8869
diff
changeset
|
41 private static final String ERROR_INVALID_CALCULATION_MODE = "error_feed_invalid_calculation_mode"; |
8854 | 42 |
43 /** The name of the artifact. */ | |
44 private static final String ARTIFACT_NAME = "sinfo"; | |
45 | |
8869 | 46 private static final String FIELD_RIVER = "river"; |
8854 | 47 |
48 private static final String FIELD_MODE = "calculation_mode"; | |
8946
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8869
diff
changeset
|
49 |
8956 | 50 static { |
51 // Active/deactivate facets. | |
52 // BEWARE: we can only define one activity for "sinfo", so we use the artifact as place for this | |
53 FacetActivity.Registry.getInstance().register("sinfo", new FacetActivity() { | |
54 @Override | |
55 public Boolean isInitialActive(final Artifact artifact, final Facet facet, final String output) { | |
56 | |
8980
b194fa64506a
SINFO - show results themes according to spec, either raw data or floating mean values.
gernotbelger
parents:
8956
diff
changeset
|
57 final String name = facet.getName(); |
b194fa64506a
SINFO - show results themes according to spec, either raw data or floating mean values.
gernotbelger
parents:
8956
diff
changeset
|
58 |
8956 | 59 if ("sinfo_tkk".equals(output)) { |
60 if (FlowDepthProcessor.FACET_FLOW_DEPTH_FILTERED.equals(name)) | |
61 return Boolean.FALSE; | |
62 if (VelocityProcessor.FACET_TKH_VELOCITY_FILTERED.equals(name)) | |
63 return Boolean.FALSE; | |
64 if (TauProcessor.FACET_TKH_TAU_FILTERED.equals(name)) | |
65 return Boolean.FALSE; | |
66 if (D50Processor.FACET_TKH_D50_FILTERED.equals(name)) | |
67 return Boolean.FALSE; | |
68 } | |
69 | |
70 if ("sinfo_flow_depth_development".equals(output)) { | |
71 if (FlowDepthProcessor.FACET_FLOW_DEPTH_CURRENT_FILTERED.equals(name)) | |
72 return Boolean.FALSE; | |
73 if (FlowDepthProcessor.FACET_FLOW_DEPTH_HISTORICAL_FILTERED.equals(name)) | |
74 return Boolean.FALSE; | |
75 if (FlowDepthDevelopmentProcessor.FACET_WATERLEVEL_DIFFERENCE_FILTERED.equals(name)) | |
76 return Boolean.FALSE; | |
77 if (FlowDepthDevelopmentProcessor.FACET_BEDHEIGHT_DIFFERENCE_FILTERED.equals(name)) | |
78 return Boolean.FALSE; | |
79 } | |
80 | |
8980
b194fa64506a
SINFO - show results themes according to spec, either raw data or floating mean values.
gernotbelger
parents:
8956
diff
changeset
|
81 if (FlowDepthProcessor.FACET_FLOW_DEPTH_RAW.equals(name)) |
b194fa64506a
SINFO - show results themes according to spec, either raw data or floating mean values.
gernotbelger
parents:
8956
diff
changeset
|
82 return Boolean.FALSE; |
b194fa64506a
SINFO - show results themes according to spec, either raw data or floating mean values.
gernotbelger
parents:
8956
diff
changeset
|
83 if (FlowDepthProcessor.FACET_FLOW_DEPTH_TKH_RAW.equals(name)) |
b194fa64506a
SINFO - show results themes according to spec, either raw data or floating mean values.
gernotbelger
parents:
8956
diff
changeset
|
84 return Boolean.FALSE; |
b194fa64506a
SINFO - show results themes according to spec, either raw data or floating mean values.
gernotbelger
parents:
8956
diff
changeset
|
85 if (FlowDepthProcessor.FACET_FLOW_DEPTH_CURRENT_RAW.equals(name)) |
b194fa64506a
SINFO - show results themes according to spec, either raw data or floating mean values.
gernotbelger
parents:
8956
diff
changeset
|
86 return Boolean.FALSE; |
b194fa64506a
SINFO - show results themes according to spec, either raw data or floating mean values.
gernotbelger
parents:
8956
diff
changeset
|
87 if (FlowDepthProcessor.FACET_FLOW_DEPTH_HISTORICAL_RAW.equals(name)) |
b194fa64506a
SINFO - show results themes according to spec, either raw data or floating mean values.
gernotbelger
parents:
8956
diff
changeset
|
88 return Boolean.FALSE; |
b194fa64506a
SINFO - show results themes according to spec, either raw data or floating mean values.
gernotbelger
parents:
8956
diff
changeset
|
89 if (FlowDepthProcessor.FACET_FLOW_DEPTH_MIN_RAW.equals(name)) |
b194fa64506a
SINFO - show results themes according to spec, either raw data or floating mean values.
gernotbelger
parents:
8956
diff
changeset
|
90 return Boolean.FALSE; |
b194fa64506a
SINFO - show results themes according to spec, either raw data or floating mean values.
gernotbelger
parents:
8956
diff
changeset
|
91 if (FlowDepthProcessor.FACET_FLOW_DEPTH_MAX_RAW.equals(name)) |
b194fa64506a
SINFO - show results themes according to spec, either raw data or floating mean values.
gernotbelger
parents:
8956
diff
changeset
|
92 return Boolean.FALSE; |
b194fa64506a
SINFO - show results themes according to spec, either raw data or floating mean values.
gernotbelger
parents:
8956
diff
changeset
|
93 |
b194fa64506a
SINFO - show results themes according to spec, either raw data or floating mean values.
gernotbelger
parents:
8956
diff
changeset
|
94 if (FlowDepthDevelopmentProcessor.FACET_FLOW_DEPTH_DEVELOPMENT_RAW.equals(name)) |
b194fa64506a
SINFO - show results themes according to spec, either raw data or floating mean values.
gernotbelger
parents:
8956
diff
changeset
|
95 return Boolean.FALSE; |
b194fa64506a
SINFO - show results themes according to spec, either raw data or floating mean values.
gernotbelger
parents:
8956
diff
changeset
|
96 if (FlowDepthDevelopmentPerYearProcessor.FACET_FLOW_DEPTH_DEVELOPMENT_PER_YEAR_RAW.equals(name)) |
b194fa64506a
SINFO - show results themes according to spec, either raw data or floating mean values.
gernotbelger
parents:
8956
diff
changeset
|
97 return Boolean.FALSE; |
b194fa64506a
SINFO - show results themes according to spec, either raw data or floating mean values.
gernotbelger
parents:
8956
diff
changeset
|
98 |
9307
45bbd2c232f8
S-Info main value themes in flood duration w/q set to initially invisible
mschaefer
parents:
8980
diff
changeset
|
99 if (FloodDurationCurveProcessor.FACET_FLOOD_DURATION_MAINVALUES_W.equals(name)) |
45bbd2c232f8
S-Info main value themes in flood duration w/q set to initially invisible
mschaefer
parents:
8980
diff
changeset
|
100 return Boolean.FALSE; |
45bbd2c232f8
S-Info main value themes in flood duration w/q set to initially invisible
mschaefer
parents:
8980
diff
changeset
|
101 if (FloodDurationCurveProcessor.FACET_FLOOD_DURATION_MAINVALUES_Q.equals(name)) |
45bbd2c232f8
S-Info main value themes in flood duration w/q set to initially invisible
mschaefer
parents:
8980
diff
changeset
|
102 return Boolean.FALSE; |
45bbd2c232f8
S-Info main value themes in flood duration w/q set to initially invisible
mschaefer
parents:
8980
diff
changeset
|
103 |
8956 | 104 return null; |
105 } | |
106 }); | |
107 } | |
108 | |
8854 | 109 /** |
110 * Default constructor, because it's serializable. | |
111 */ | |
112 public SINFOArtifact() { | |
113 } | |
114 | |
115 /** | |
116 * Returns the name of the concrete artifact. | |
117 * | |
118 * @return the name of the concrete artifact. | |
119 */ | |
120 @Override | |
121 public String getName() { | |
122 return ARTIFACT_NAME; | |
123 } | |
8946
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8869
diff
changeset
|
124 |
8854 | 125 public SinfoCalcMode getCalculationMode() { |
126 | |
8946
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8869
diff
changeset
|
127 final String calc = getDataAsString(FIELD_MODE); |
8854 | 128 if (calc == null) { |
8946
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8869
diff
changeset
|
129 throw new IllegalArgumentException(ERROR_NO_CALCULATION_MODE); |
8854 | 130 } |
131 | |
132 try { | |
8946
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8869
diff
changeset
|
133 return SinfoCalcMode.valueOf(StringUtils.trimToEmpty(calc).toLowerCase()); |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8869
diff
changeset
|
134 } |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8869
diff
changeset
|
135 catch (final Exception e) { |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8869
diff
changeset
|
136 throw new IllegalArgumentException(ERROR_INVALID_CALCULATION_MODE, e); |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8869
diff
changeset
|
137 } |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8869
diff
changeset
|
138 } |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8869
diff
changeset
|
139 |
8854 | 140 public String getRiver() { |
8946
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8869
diff
changeset
|
141 return getDataAsString(FIELD_RIVER); |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8869
diff
changeset
|
142 } |
8854 | 143 } |