Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/CalculationSelectSinfo.java @ 8914:e3519c3e7a0a
Workflow for SINFO-Transport bodies heights inclduing winfo calculation
author | gernotbelger |
---|---|
date | Tue, 27 Feb 2018 18:06:52 +0100 |
parents | 28df64078f27 |
children | f692f5a0536a |
comparison
equal
deleted
inserted
replaced
8913:924cd9943337 | 8914:e3519c3e7a0a |
---|---|
1 /* Copyright (C) 2017 by Bundesanstalt für Gewässerkunde | 1 /* Copyright (C) 2017 by Bundesanstalt für Gewässerkunde |
2 * Software engineering by | 2 * Software engineering by |
3 * Björnsen Beratende Ingenieure GmbH | 3 * Björnsen Beratende Ingenieure GmbH |
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt | 4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt |
5 * | 5 * |
6 * This file is Free Software under the GNU AGPL (>=v3) | 6 * This file is Free Software under the GNU AGPL (>=v3) |
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the | 7 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
8 * documentation coming with Dive4Elements River for details. | 8 * documentation coming with Dive4Elements River for details. |
9 */ | 9 */ |
10 | |
11 package org.dive4elements.river.artifacts.sinfo; | 10 package org.dive4elements.river.artifacts.sinfo; |
12 | 11 |
13 import java.util.ArrayList; | 12 import java.util.ArrayList; |
14 import java.util.Collection; | 13 import java.util.Collection; |
15 | 14 |
25 /** | 24 /** |
26 * @author Gernot Belger | 25 * @author Gernot Belger |
27 */ | 26 */ |
28 public class CalculationSelectSinfo extends DefaultState { | 27 public class CalculationSelectSinfo extends DefaultState { |
29 | 28 |
30 private static final long serialVersionUID = 1L; | 29 private static final long serialVersionUID = 1L; |
31 | 30 |
32 /** The log that is used in this class. */ | 31 /** The log that is used in this class. */ |
33 private static Logger log = Logger.getLogger(CalculationSelectSinfo.class); | 32 private static Logger log = Logger.getLogger(CalculationSelectSinfo.class); |
34 | 33 |
35 public CalculationSelectSinfo() { | 34 @Override |
36 } | 35 protected Element[] createItems(final XMLUtils.ElementCreator cr, final Artifact artifact, final String name, final CallContext context) { |
36 final CallMeta meta = context.getMeta(); | |
37 | 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); | 38 final Collection<Element> calcs = new ArrayList<>(SinfoCalcMode.values().length); |
49 | 39 |
50 for (final SinfoCalcMode calcMode : SinfoCalcMode.values()) { | 40 for (final SinfoCalcMode calcMode : SinfoCalcMode.values()) { |
51 final String calc = calcMode.name(); | 41 final String calc = calcMode.name(); |
52 | 42 |
53 final String label = Resources.getMsg(meta, calc, calc); | 43 final String label = Resources.getMsg(meta, calc, calc); |
54 | 44 |
55 final Element element = createItem( | 45 final Element element = createItem(cr, new String[] { label, calc }); |
56 cr, new String[] { | 46 calcs.add(element); |
57 label, | 47 } |
58 calc | 48 |
59 }); | |
60 calcs.add(element); | |
61 } | |
62 | |
63 return calcs.toArray(new Element[calcs.size()]); | 49 return calcs.toArray(new Element[calcs.size()]); |
64 } | 50 } |
65 | 51 |
66 @Override | 52 @Override |
67 public boolean validate(Artifact artifact) | 53 public boolean validate(final Artifact artifact) throws IllegalArgumentException { |
68 throws IllegalArgumentException | |
69 { | |
70 log.debug("CalculationSelect.validate"); | 54 log.debug("CalculationSelect.validate"); |
71 | 55 |
72 final SINFOArtifact sinfo = (SINFOArtifact) artifact; | 56 final SINFOArtifact sinfo = (SINFOArtifact) artifact; |
73 /* throws an exception if calculation mode is invalid */ | 57 /* throws an exception if calculation mode is invalid */ |
74 sinfo.getCalculationMode(); | 58 sinfo.getCalculationMode(); |
75 return true; | 59 return true; |
76 } | 60 } |
77 } | 61 } |
78 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |