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