Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/BUNDUArtifact.java @ 9432:d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
author | mschaefer |
---|---|
date | Mon, 20 Aug 2018 09:46:02 +0200 |
parents | 02739b8c010d |
children | ecadc9ed0ba0 |
rev | line source |
---|---|
9071 | 1 /* Copyright (C) 2017 by Bundesanstalt für Gewässerkunde |
2 * Software engineering by | |
3 * Björnsen Beratende Ingenieure GmbH | |
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.bundu; | |
11 | |
12 import org.apache.commons.lang.StringUtils; | |
9072
02739b8c010d
bundu progress (Klon FixationAnalysis +Vollmer funktioniert; Verzweigung neue Berechnungsart Bezugswst)
gernotbelger
parents:
9071
diff
changeset
|
13 import org.dive4elements.artifactdatabase.state.Facet; |
9071 | 14 import org.dive4elements.artifactdatabase.state.FacetActivity; |
9072
02739b8c010d
bundu progress (Klon FixationAnalysis +Vollmer funktioniert; Verzweigung neue Berechnungsart Bezugswst)
gernotbelger
parents:
9071
diff
changeset
|
15 import org.dive4elements.artifacts.Artifact; |
9071 | 16 import org.dive4elements.river.artifacts.D4EArtifact; |
9432
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9072
diff
changeset
|
17 import org.dive4elements.river.artifacts.model.FacetTypes; |
9071 | 18 |
19 /** | |
20 * The default BUNDU artifact. | |
21 * | |
22 * @author Gernot Belger | |
23 */ | |
24 public class BUNDUArtifact extends D4EArtifact { | |
25 | |
26 private static final long serialVersionUID = 1L; | |
27 | |
28 /** Error message that is thrown if no mode has been chosen. */ | |
29 private static final String ERROR_NO_CALCULATION_MODE = "error_feed_no_calculation_mode"; | |
30 | |
31 /** | |
32 * Error message that is thrown if an invalid calculation mode has been chosen. | |
33 */ | |
34 private static final String ERROR_INVALID_CALCULATION_MODE = "error_feed_invalid_calculation_mode"; | |
35 | |
36 /** The name of the artifact. */ | |
37 private static final String ARTIFACT_NAME = "bundu"; | |
38 | |
39 private static final String FIELD_RIVER = "river"; | |
40 | |
41 private static final String FIELD_MODE = "calculation_mode"; | |
42 | |
43 static { | |
44 // Active/deactivate facets. | |
9432
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9072
diff
changeset
|
45 // BEWARE: we can only define one activity for "bundu", so we use the artifact |
9071 | 46 // as place for this |
9072
02739b8c010d
bundu progress (Klon FixationAnalysis +Vollmer funktioniert; Verzweigung neue Berechnungsart Bezugswst)
gernotbelger
parents:
9071
diff
changeset
|
47 FacetActivity.Registry.getInstance().register(ARTIFACT_NAME, new FacetActivity() { |
02739b8c010d
bundu progress (Klon FixationAnalysis +Vollmer funktioniert; Verzweigung neue Berechnungsart Bezugswst)
gernotbelger
parents:
9071
diff
changeset
|
48 @Override |
02739b8c010d
bundu progress (Klon FixationAnalysis +Vollmer funktioniert; Verzweigung neue Berechnungsart Bezugswst)
gernotbelger
parents:
9071
diff
changeset
|
49 public Boolean isInitialActive(final Artifact artifact, final Facet facet, final String output) { |
9432
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9072
diff
changeset
|
50 |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9072
diff
changeset
|
51 final String name = facet.getName(); |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9072
diff
changeset
|
52 |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9072
diff
changeset
|
53 if (FacetTypes.LONGITUDINAL_Q.equals(name)) |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9072
diff
changeset
|
54 return Boolean.FALSE; |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9072
diff
changeset
|
55 |
9072
02739b8c010d
bundu progress (Klon FixationAnalysis +Vollmer funktioniert; Verzweigung neue Berechnungsart Bezugswst)
gernotbelger
parents:
9071
diff
changeset
|
56 return null; |
02739b8c010d
bundu progress (Klon FixationAnalysis +Vollmer funktioniert; Verzweigung neue Berechnungsart Bezugswst)
gernotbelger
parents:
9071
diff
changeset
|
57 } |
02739b8c010d
bundu progress (Klon FixationAnalysis +Vollmer funktioniert; Verzweigung neue Berechnungsart Bezugswst)
gernotbelger
parents:
9071
diff
changeset
|
58 }); |
9071 | 59 } |
60 | |
61 /** | |
62 * Default constructor, because it's serializable. | |
63 */ | |
64 public BUNDUArtifact() { | |
65 } | |
66 | |
67 /** | |
68 * Returns the name of the concrete artifact. | |
69 * | |
70 * @return the name of the concrete artifact. | |
71 */ | |
72 @Override | |
73 public String getName() { | |
74 return ARTIFACT_NAME; | |
75 } | |
76 | |
77 public BunduCalcMode getCalculationMode() { | |
78 | |
79 final String calc = getDataAsString(FIELD_MODE); | |
80 if (calc == null) { | |
81 throw new IllegalArgumentException(ERROR_NO_CALCULATION_MODE); | |
82 } | |
83 | |
84 try { | |
85 return BunduCalcMode.valueOf(StringUtils.trimToEmpty(calc).toLowerCase()); | |
86 } | |
87 catch (final Exception e) { | |
88 throw new IllegalArgumentException(ERROR_INVALID_CALCULATION_MODE, e); | |
89 } | |
90 } | |
91 | |
92 public String getRiver() { | |
93 return getDataAsString(FIELD_RIVER); | |
94 } | |
95 } |