Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/CalculationSelectSinfo.java @ 8860:28df64078f27
Merge with 0862ea5d66baf60e7eee496d130a35157cc9ec12
author | gernotbelger |
---|---|
date | Fri, 19 Jan 2018 11:23:42 +0100 |
parents | 7bbfb24e6eec |
children | e3519c3e7a0a |
rev | line source |
---|---|
8854 | 1 /* Copyright (C) 2017 by Bundesanstalt für Gewässerkunde |
8860
28df64078f27
Merge with 0862ea5d66baf60e7eee496d130a35157cc9ec12
gernotbelger
parents:
8854
diff
changeset
|
2 * Software engineering by |
28df64078f27
Merge with 0862ea5d66baf60e7eee496d130a35157cc9ec12
gernotbelger
parents:
8854
diff
changeset
|
3 * Björnsen Beratende Ingenieure GmbH |
28df64078f27
Merge with 0862ea5d66baf60e7eee496d130a35157cc9ec12
gernotbelger
parents:
8854
diff
changeset
|
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt |
8854 | 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 | |
11 package org.dive4elements.river.artifacts.sinfo; | |
12 | |
13 import java.util.ArrayList; | |
14 import java.util.Collection; | |
15 | |
16 import org.apache.log4j.Logger; | |
17 import org.dive4elements.artifacts.Artifact; | |
18 import org.dive4elements.artifacts.CallContext; | |
19 import org.dive4elements.artifacts.CallMeta; | |
20 import org.dive4elements.artifacts.common.utils.XMLUtils; | |
21 import org.dive4elements.river.artifacts.resources.Resources; | |
22 import org.dive4elements.river.artifacts.states.DefaultState; | |
23 import org.w3c.dom.Element; | |
24 | |
25 /** | |
26 * @author Gernot Belger | |
27 */ | |
28 public class CalculationSelectSinfo 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(CalculationSelectSinfo.class); | |
34 | |
35 public CalculationSelectSinfo() { | |
36 } | |
37 | |
38 | |
39 @Override | |
40 protected Element[] createItems( | |
41 XMLUtils.ElementCreator cr, | |
42 Artifact artifact, | |
43 String name, | |
44 CallContext context) | |
45 { | |
46 final CallMeta meta = context.getMeta(); | |
47 | |
48 final Collection<Element> calcs = new ArrayList<>(SinfoCalcMode.values().length); | |
49 | |
50 for (final SinfoCalcMode calcMode : SinfoCalcMode.values()) { | |
51 final String calc = calcMode.name(); | |
52 | |
53 final String label = Resources.getMsg(meta, calc, calc); | |
54 | |
55 final Element element = createItem( | |
56 cr, new String[] { | |
57 label, | |
58 calc | |
59 }); | |
60 calcs.add(element); | |
61 } | |
62 | |
63 return calcs.toArray(new Element[calcs.size()]); | |
64 } | |
65 | |
66 @Override | |
67 public boolean validate(Artifact artifact) | |
68 throws IllegalArgumentException | |
69 { | |
70 log.debug("CalculationSelect.validate"); | |
71 | |
72 final SINFOArtifact sinfo = (SINFOArtifact) artifact; | |
73 /* throws an exception if calculation mode is invalid */ | |
74 sinfo.getCalculationMode(); | |
75 return true; | |
76 } | |
77 } | |
78 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |