Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/CalculationSelectSinfo.java @ 8854:7bbfb24e6eec
SINFO - first prototype of BArt Fließtiefen
author | gernotbelger |
---|---|
date | Thu, 18 Jan 2018 18:34:41 +0100 |
parents | |
children | 28df64078f27 |
comparison
equal
deleted
inserted
replaced
8853:8c64617a7991 | 8854:7bbfb24e6eec |
---|---|
1 /* Copyright (C) 2017 by Bundesanstalt für Gewässerkunde | |
2 * Software engineering by Intevation GmbH | |
3 * | |
4 * This file is Free Software under the GNU AGPL (>=v3) | |
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the | |
6 * documentation coming with Dive4Elements River for details. | |
7 */ | |
8 | |
9 package org.dive4elements.river.artifacts.sinfo; | |
10 | |
11 import java.util.ArrayList; | |
12 import java.util.Collection; | |
13 | |
14 import org.apache.log4j.Logger; | |
15 import org.dive4elements.artifacts.Artifact; | |
16 import org.dive4elements.artifacts.CallContext; | |
17 import org.dive4elements.artifacts.CallMeta; | |
18 import org.dive4elements.artifacts.common.utils.XMLUtils; | |
19 import org.dive4elements.river.artifacts.resources.Resources; | |
20 import org.dive4elements.river.artifacts.states.DefaultState; | |
21 import org.w3c.dom.Element; | |
22 | |
23 /** | |
24 * @author Gernot Belger | |
25 */ | |
26 public class CalculationSelectSinfo extends DefaultState { | |
27 | |
28 private static final long serialVersionUID = 1L; | |
29 | |
30 /** The log that is used in this class. */ | |
31 private static Logger log = Logger.getLogger(CalculationSelectSinfo.class); | |
32 | |
33 public CalculationSelectSinfo() { | |
34 } | |
35 | |
36 | |
37 @Override | |
38 protected Element[] createItems( | |
39 XMLUtils.ElementCreator cr, | |
40 Artifact artifact, | |
41 String name, | |
42 CallContext context) | |
43 { | |
44 final CallMeta meta = context.getMeta(); | |
45 | |
46 final Collection<Element> calcs = new ArrayList<>(SinfoCalcMode.values().length); | |
47 | |
48 for (final SinfoCalcMode calcMode : SinfoCalcMode.values()) { | |
49 final String calc = calcMode.name(); | |
50 | |
51 final String label = Resources.getMsg(meta, calc, calc); | |
52 | |
53 final Element element = createItem( | |
54 cr, new String[] { | |
55 label, | |
56 calc | |
57 }); | |
58 calcs.add(element); | |
59 } | |
60 | |
61 return calcs.toArray(new Element[calcs.size()]); | |
62 } | |
63 | |
64 @Override | |
65 public boolean validate(Artifact artifact) | |
66 throws IllegalArgumentException | |
67 { | |
68 log.debug("CalculationSelect.validate"); | |
69 | |
70 final SINFOArtifact sinfo = (SINFOArtifact) artifact; | |
71 /* throws an exception if calculation mode is invalid */ | |
72 sinfo.getCalculationMode(); | |
73 return true; | |
74 } | |
75 } | |
76 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |