Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/BUNDUArtifact.java @ 9072:02739b8c010d
bundu progress (Klon FixationAnalysis +Vollmer funktioniert; Verzweigung neue Berechnungsart Bezugswst)
author | gernotbelger |
---|---|
date | Wed, 16 May 2018 17:43:47 +0200 |
parents | a561b882436d |
children | d194c5b24bf8 |
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; |
17 | |
18 /** | |
19 * The default BUNDU artifact. | |
20 * | |
21 * @author Gernot Belger | |
22 */ | |
23 public class BUNDUArtifact extends D4EArtifact { | |
24 | |
25 private static final long serialVersionUID = 1L; | |
26 | |
27 /** Error message that is thrown if no mode has been chosen. */ | |
28 private static final String ERROR_NO_CALCULATION_MODE = "error_feed_no_calculation_mode"; | |
29 | |
30 /** | |
31 * Error message that is thrown if an invalid calculation mode has been chosen. | |
32 */ | |
33 private static final String ERROR_INVALID_CALCULATION_MODE = "error_feed_invalid_calculation_mode"; | |
34 | |
35 /** The name of the artifact. */ | |
36 private static final String ARTIFACT_NAME = "bundu"; | |
37 | |
38 private static final String FIELD_RIVER = "river"; | |
39 | |
40 private static final String FIELD_MODE = "calculation_mode"; | |
41 | |
42 static { | |
43 // Active/deactivate facets. | |
44 // BEWARE: we can only define one activity for "sinfo", so we use the artifact | |
45 // as place for this | |
9072
02739b8c010d
bundu progress (Klon FixationAnalysis +Vollmer funktioniert; Verzweigung neue Berechnungsart Bezugswst)
gernotbelger
parents:
9071
diff
changeset
|
46 FacetActivity.Registry.getInstance().register(ARTIFACT_NAME, new FacetActivity() { |
02739b8c010d
bundu progress (Klon FixationAnalysis +Vollmer funktioniert; Verzweigung neue Berechnungsart Bezugswst)
gernotbelger
parents:
9071
diff
changeset
|
47 @Override |
02739b8c010d
bundu progress (Klon FixationAnalysis +Vollmer funktioniert; Verzweigung neue Berechnungsart Bezugswst)
gernotbelger
parents:
9071
diff
changeset
|
48 public Boolean isInitialActive(final Artifact artifact, final Facet facet, final String output) { |
02739b8c010d
bundu progress (Klon FixationAnalysis +Vollmer funktioniert; Verzweigung neue Berechnungsart Bezugswst)
gernotbelger
parents:
9071
diff
changeset
|
49 return null; |
02739b8c010d
bundu progress (Klon FixationAnalysis +Vollmer funktioniert; Verzweigung neue Berechnungsart Bezugswst)
gernotbelger
parents:
9071
diff
changeset
|
50 } |
02739b8c010d
bundu progress (Klon FixationAnalysis +Vollmer funktioniert; Verzweigung neue Berechnungsart Bezugswst)
gernotbelger
parents:
9071
diff
changeset
|
51 }); |
9071 | 52 } |
53 | |
54 /** | |
55 * Default constructor, because it's serializable. | |
56 */ | |
57 public BUNDUArtifact() { | |
58 } | |
59 | |
60 /** | |
61 * Returns the name of the concrete artifact. | |
62 * | |
63 * @return the name of the concrete artifact. | |
64 */ | |
65 @Override | |
66 public String getName() { | |
67 return ARTIFACT_NAME; | |
68 } | |
69 | |
70 public BunduCalcMode getCalculationMode() { | |
71 | |
72 final String calc = getDataAsString(FIELD_MODE); | |
73 if (calc == null) { | |
74 throw new IllegalArgumentException(ERROR_NO_CALCULATION_MODE); | |
75 } | |
76 | |
77 try { | |
78 return BunduCalcMode.valueOf(StringUtils.trimToEmpty(calc).toLowerCase()); | |
79 } | |
80 catch (final Exception e) { | |
81 throw new IllegalArgumentException(ERROR_INVALID_CALCULATION_MODE, e); | |
82 } | |
83 } | |
84 | |
85 public String getRiver() { | |
86 return getDataAsString(FIELD_RIVER); | |
87 } | |
88 } |