Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/CalculationSelectUinfo.java @ 9178:2f5052835b76
uinfo inundationduration langjähr. Mittel, Uedauern.properties, Meldung
author | gernotbelger |
---|---|
date | Tue, 26 Jun 2018 19:48:35 +0200 |
parents | c265c9fc915c |
children | dace17e26d33 |
rev | line source |
---|---|
8996 | 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.uinfo; | |
11 | |
12 import java.util.ArrayList; | |
13 import java.util.Collection; | |
14 | |
15 import org.apache.log4j.Logger; | |
16 import org.dive4elements.artifacts.Artifact; | |
17 import org.dive4elements.artifacts.CallContext; | |
18 import org.dive4elements.artifacts.CallMeta; | |
19 import org.dive4elements.artifacts.common.utils.XMLUtils; | |
20 import org.dive4elements.river.artifacts.resources.Resources; | |
21 import org.dive4elements.river.artifacts.states.DefaultState; | |
9178
2f5052835b76
uinfo inundationduration langjähr. Mittel, Uedauern.properties, Meldung
gernotbelger
parents:
9036
diff
changeset
|
22 import org.dive4elements.river.artifacts.uinfo.inundationduration.UedauernPropertiesHelper; |
8996 | 23 import org.w3c.dom.Element; |
24 | |
25 /** | |
26 * @author Gernot Belger | |
27 */ | |
28 public class CalculationSelectUinfo extends DefaultState { | |
29 | |
30 private static final long serialVersionUID = 1L; | |
31 | |
32 /** The log that is used in this class. */ | |
33 private static Logger log = Logger.getLogger(CalculationSelectUinfo.class); | |
34 | |
35 @Override | |
36 protected Element[] createItems(final XMLUtils.ElementCreator cr, final Artifact artifact, final String name, final CallContext context) { | |
37 final CallMeta meta = context.getMeta(); | |
38 | |
39 final Collection<Element> calcs = new ArrayList<>(UinfoCalcMode.values().length); | |
40 | |
41 for (final UinfoCalcMode calcMode : UinfoCalcMode.values()) { | |
42 final String calc = calcMode.name(); | |
43 | |
44 final String label = Resources.getMsg(meta, calc, calc); | |
45 | |
46 final Element element = createItem(cr, new String[] { label, calc }); | |
47 calcs.add(element); | |
48 } | |
49 | |
50 return calcs.toArray(new Element[calcs.size()]); | |
51 } | |
52 | |
53 @Override | |
54 public boolean validate(final Artifact artifact) throws IllegalArgumentException { | |
55 log.debug("CalculationSelect.validate"); | |
56 | |
9036 | 57 final UINFOArtifact uinfo = (UINFOArtifact) artifact; |
9178
2f5052835b76
uinfo inundationduration langjähr. Mittel, Uedauern.properties, Meldung
gernotbelger
parents:
9036
diff
changeset
|
58 final String calcDebug = uinfo.getCalculationMode().toString(); |
2f5052835b76
uinfo inundationduration langjähr. Mittel, Uedauern.properties, Meldung
gernotbelger
parents:
9036
diff
changeset
|
59 if (calcDebug.equals("uinfo_inundation_duration")) { |
2f5052835b76
uinfo inundationduration langjähr. Mittel, Uedauern.properties, Meldung
gernotbelger
parents:
9036
diff
changeset
|
60 |
2f5052835b76
uinfo inundationduration langjähr. Mittel, Uedauern.properties, Meldung
gernotbelger
parents:
9036
diff
changeset
|
61 final String river = uinfo.getRiver(); |
2f5052835b76
uinfo inundationduration langjähr. Mittel, Uedauern.properties, Meldung
gernotbelger
parents:
9036
diff
changeset
|
62 if (!UedauernPropertiesHelper.fileExistsForRiver(river)) { |
2f5052835b76
uinfo inundationduration langjähr. Mittel, Uedauern.properties, Meldung
gernotbelger
parents:
9036
diff
changeset
|
63 throw new IllegalArgumentException("error_river_inundationdur_file_not_found"); |
2f5052835b76
uinfo inundationduration langjähr. Mittel, Uedauern.properties, Meldung
gernotbelger
parents:
9036
diff
changeset
|
64 } |
2f5052835b76
uinfo inundationduration langjähr. Mittel, Uedauern.properties, Meldung
gernotbelger
parents:
9036
diff
changeset
|
65 } |
2f5052835b76
uinfo inundationduration langjähr. Mittel, Uedauern.properties, Meldung
gernotbelger
parents:
9036
diff
changeset
|
66 |
8996 | 67 /* throws an exception if calculation mode is invalid */ |
9178
2f5052835b76
uinfo inundationduration langjähr. Mittel, Uedauern.properties, Meldung
gernotbelger
parents:
9036
diff
changeset
|
68 |
8996 | 69 return true; |
70 } | |
71 } |