Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/CalculationSelectUinfo.java @ 8996:fb9430250899
Work on uinfo
author | gernotbelger |
---|---|
date | Thu, 12 Apr 2018 19:13:39 +0200 |
parents | |
children | c265c9fc915c |
comparison
equal
deleted
inserted
replaced
8995:8c3e5682cb60 | 8996:fb9430250899 |
---|---|
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; | |
22 import org.w3c.dom.Element; | |
23 | |
24 /** | |
25 * @author Gernot Belger | |
26 */ | |
27 public class CalculationSelectUinfo extends DefaultState { | |
28 | |
29 private static final long serialVersionUID = 1L; | |
30 | |
31 /** The log that is used in this class. */ | |
32 private static Logger log = Logger.getLogger(CalculationSelectUinfo.class); | |
33 | |
34 @Override | |
35 protected Element[] createItems(final XMLUtils.ElementCreator cr, final Artifact artifact, final String name, final CallContext context) { | |
36 final CallMeta meta = context.getMeta(); | |
37 | |
38 final Collection<Element> calcs = new ArrayList<>(UinfoCalcMode.values().length); | |
39 | |
40 for (final UinfoCalcMode calcMode : UinfoCalcMode.values()) { | |
41 final String calc = calcMode.name(); | |
42 | |
43 final String label = Resources.getMsg(meta, calc, calc); | |
44 | |
45 final Element element = createItem(cr, new String[] { label, calc }); | |
46 calcs.add(element); | |
47 } | |
48 | |
49 return calcs.toArray(new Element[calcs.size()]); | |
50 } | |
51 | |
52 @Override | |
53 public boolean validate(final Artifact artifact) throws IllegalArgumentException { | |
54 log.debug("CalculationSelect.validate"); | |
55 | |
56 final UINFOArtifact sinfo = (UINFOArtifact) artifact; | |
57 /* throws an exception if calculation mode is invalid */ | |
58 sinfo.getCalculationMode(); | |
59 return true; | |
60 } | |
61 } |