Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/SINFOArtifact.java @ 8956:ee5ce13016ed
Work on SINFO-Fließtiefenentwicklung
author | gernotbelger |
---|---|
date | Tue, 20 Mar 2018 13:30:07 +0100 |
parents | 5d5d482da3e9 |
children | b194fa64506a |
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; |
18 import org.dive4elements.river.artifacts.sinfo.common.FlowDepthDevelopmentProcessor; | |
19 import org.dive4elements.river.artifacts.sinfo.common.FlowDepthProcessor; | |
20 import org.dive4elements.river.artifacts.sinfo.common.TauProcessor; | |
21 import org.dive4elements.river.artifacts.sinfo.common.VelocityProcessor; | |
8854 | 22 |
23 /** | |
8869 | 24 * The default SINFO artifact. |
8854 | 25 * |
26 * @author Gernot Belger | |
27 */ | |
8946
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8869
diff
changeset
|
28 public class SINFOArtifact extends D4EArtifact { |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8869
diff
changeset
|
29 |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8869
diff
changeset
|
30 private static final long serialVersionUID = 1L; |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8869
diff
changeset
|
31 |
8854 | 32 /** Error message that is thrown if no mode has been chosen. */ |
8946
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8869
diff
changeset
|
33 private static final String ERROR_NO_CALCULATION_MODE = "error_feed_no_calculation_mode"; |
8854 | 34 |
8946
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8869
diff
changeset
|
35 /** |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8869
diff
changeset
|
36 * Error message that is thrown if an invalid calculation mode has been |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8869
diff
changeset
|
37 * chosen. |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8869
diff
changeset
|
38 */ |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8869
diff
changeset
|
39 private static final String ERROR_INVALID_CALCULATION_MODE = "error_feed_invalid_calculation_mode"; |
8854 | 40 |
41 /** The name of the artifact. */ | |
42 private static final String ARTIFACT_NAME = "sinfo"; | |
43 | |
8869 | 44 private static final String FIELD_RIVER = "river"; |
8854 | 45 |
46 private static final String FIELD_MODE = "calculation_mode"; | |
8946
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8869
diff
changeset
|
47 |
8956 | 48 static { |
49 // Active/deactivate facets. | |
50 // BEWARE: we can only define one activity for "sinfo", so we use the artifact as place for this | |
51 FacetActivity.Registry.getInstance().register("sinfo", new FacetActivity() { | |
52 @Override | |
53 public Boolean isInitialActive(final Artifact artifact, final Facet facet, final String output) { | |
54 | |
55 if ("sinfo_tkk".equals(output)) { | |
56 final String name = facet.getName(); | |
57 if (FlowDepthProcessor.FACET_FLOW_DEPTH_FILTERED.equals(name)) | |
58 return Boolean.FALSE; | |
59 if (VelocityProcessor.FACET_TKH_VELOCITY_FILTERED.equals(name)) | |
60 return Boolean.FALSE; | |
61 if (TauProcessor.FACET_TKH_TAU_FILTERED.equals(name)) | |
62 return Boolean.FALSE; | |
63 if (D50Processor.FACET_TKH_D50_FILTERED.equals(name)) | |
64 return Boolean.FALSE; | |
65 } | |
66 | |
67 if ("sinfo_flow_depth_development".equals(output)) { | |
68 final String name = facet.getName(); | |
69 if (FlowDepthProcessor.FACET_FLOW_DEPTH_CURRENT_FILTERED.equals(name)) | |
70 return Boolean.FALSE; | |
71 if (FlowDepthProcessor.FACET_FLOW_DEPTH_HISTORICAL_FILTERED.equals(name)) | |
72 return Boolean.FALSE; | |
73 if (FlowDepthDevelopmentProcessor.FACET_WATERLEVEL_DIFFERENCE_FILTERED.equals(name)) | |
74 return Boolean.FALSE; | |
75 if (FlowDepthDevelopmentProcessor.FACET_BEDHEIGHT_DIFFERENCE_FILTERED.equals(name)) | |
76 return Boolean.FALSE; | |
77 } | |
78 | |
79 return null; | |
80 } | |
81 }); | |
82 } | |
83 | |
8854 | 84 /** |
85 * Default constructor, because it's serializable. | |
86 */ | |
87 public SINFOArtifact() { | |
88 } | |
89 | |
90 /** | |
91 * Returns the name of the concrete artifact. | |
92 * | |
93 * @return the name of the concrete artifact. | |
94 */ | |
95 @Override | |
96 public String getName() { | |
97 return ARTIFACT_NAME; | |
98 } | |
8946
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8869
diff
changeset
|
99 |
8854 | 100 public SinfoCalcMode getCalculationMode() { |
101 | |
8946
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8869
diff
changeset
|
102 final String calc = getDataAsString(FIELD_MODE); |
8854 | 103 if (calc == null) { |
8946
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8869
diff
changeset
|
104 throw new IllegalArgumentException(ERROR_NO_CALCULATION_MODE); |
8854 | 105 } |
106 | |
107 try { | |
8946
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8869
diff
changeset
|
108 return SinfoCalcMode.valueOf(StringUtils.trimToEmpty(calc).toLowerCase()); |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8869
diff
changeset
|
109 } |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8869
diff
changeset
|
110 catch (final Exception e) { |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8869
diff
changeset
|
111 throw new IllegalArgumentException(ERROR_INVALID_CALCULATION_MODE, e); |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8869
diff
changeset
|
112 } |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8869
diff
changeset
|
113 } |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8869
diff
changeset
|
114 |
8854 | 115 public String getRiver() { |
8946
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8869
diff
changeset
|
116 return getDataAsString(FIELD_RIVER); |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8869
diff
changeset
|
117 } |
8854 | 118 } |