Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/FixationChoice.java @ 9636:ac41551a8e4d
Bundu/Bzws: Error message for missing channel/year, Nachtrag Pos. 20: import of two levels of infrastructure types
author | mschaefer |
---|---|
date | Mon, 11 Nov 2019 16:29:36 +0100 |
parents | 1a4d2ce77423 |
children |
rev | line source |
---|---|
9073 | 1 /* Copyright (C) 2011, 2012, 2013 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.bundu.bezugswst; | |
10 | |
9178
2f5052835b76
uinfo inundationduration langjähr. Mittel, Uedauern.properties, Meldung
gernotbelger
parents:
9073
diff
changeset
|
11 import java.util.LinkedHashMap; |
9073 | 12 |
9178
2f5052835b76
uinfo inundationduration langjähr. Mittel, Uedauern.properties, Meldung
gernotbelger
parents:
9073
diff
changeset
|
13 import org.dive4elements.artifacts.Artifact; |
9267 | 14 import org.dive4elements.artifacts.CallContext; |
9178
2f5052835b76
uinfo inundationduration langjähr. Mittel, Uedauern.properties, Meldung
gernotbelger
parents:
9073
diff
changeset
|
15 import org.dive4elements.artifacts.CallMeta; |
9267 | 16 import org.dive4elements.artifacts.common.utils.XMLUtils; |
17 import org.dive4elements.artifacts.common.utils.XMLUtils.ElementCreator; | |
18 import org.dive4elements.river.artifacts.D4EArtifact; | |
9073 | 19 import org.dive4elements.river.artifacts.states.RadioSelect; |
9267 | 20 import org.dive4elements.river.artifacts.states.fixation.EventSelect; |
21 import org.w3c.dom.Element; | |
9073 | 22 |
23 /** | |
24 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | |
25 */ | |
26 public class FixationChoice extends RadioSelect { | |
9369 | 27 |
9073 | 28 private static final long serialVersionUID = 1L; |
29 | |
9178
2f5052835b76
uinfo inundationduration langjähr. Mittel, Uedauern.properties, Meldung
gernotbelger
parents:
9073
diff
changeset
|
30 @Override |
9267 | 31 protected final String getUIProvider() { |
32 return "custom_fixation_radio_panel"; | |
33 } | |
34 | |
35 @Override | |
9178
2f5052835b76
uinfo inundationduration langjähr. Mittel, Uedauern.properties, Meldung
gernotbelger
parents:
9073
diff
changeset
|
36 protected LinkedHashMap<String, String> makeEntries(final CallMeta meta, final Artifact artifact) { |
2f5052835b76
uinfo inundationduration langjähr. Mittel, Uedauern.properties, Meldung
gernotbelger
parents:
9073
diff
changeset
|
37 final LinkedHashMap<String, String> entries = new LinkedHashMap<>(); |
9366 | 38 entries.put("state.bundu.wst.fix.auto", null); |
39 entries.put("state.bundu.wst.fix.manual", null); | |
9178
2f5052835b76
uinfo inundationduration langjähr. Mittel, Uedauern.properties, Meldung
gernotbelger
parents:
9073
diff
changeset
|
40 return entries; |
9073 | 41 } |
42 | |
9267 | 43 @Override |
44 protected Element[] createItems(final XMLUtils.ElementCreator ec, final Artifact artifact, final String name, final CallContext context) { | |
45 | |
46 final Element[] elements = super.createItems(ec, artifact, name, context); | |
9270 | 47 |
9267 | 48 final BunduAccess access = new BunduAccess((D4EArtifact) artifact); |
49 final int[] eventsTemp = access.getEventsTemp(); | |
50 final StringBuilder builder = new StringBuilder(); | |
51 if (eventsTemp != null) { | |
52 for (final int event : eventsTemp) { | |
53 builder.append(event).append(";"); | |
54 } | |
55 } else { | |
56 builder.append("");// no values | |
57 } | |
58 final int year = access.getBezugsJahr(); | |
9277 | 59 final String[] values = new String[] { builder.toString(), String.valueOf(year) }; |
60 final String[] keys = new String[] { "ignore_events_temp", "ignore_singleyear" }; | |
9267 | 61 |
9277 | 62 return appendElements(ec, elements, keys, values); |
9267 | 63 |
9277 | 64 } |
9267 | 65 |
9277 | 66 public static final Element[] appendElements(final ElementCreator ec, final Element[] defaultElements, final String[] keys, final String[] values) { |
67 assert (values.length == keys.length); | |
68 // make bigger array | |
9288
82c67b859aa7
bundu.bezugswst worklflow incl. service impl for mainValues to be calculated
gernotbelger
parents:
9277
diff
changeset
|
69 final int defaultLength = defaultElements == null ? 0 : defaultElements.length; |
82c67b859aa7
bundu.bezugswst worklflow incl. service impl for mainValues to be calculated
gernotbelger
parents:
9277
diff
changeset
|
70 final Element[] defaultAndAddedElements = new Element[defaultLength + values.length]; |
9277 | 71 |
9288
82c67b859aa7
bundu.bezugswst worklflow incl. service impl for mainValues to be calculated
gernotbelger
parents:
9277
diff
changeset
|
72 for (int i = 0; i < defaultLength; i++) { |
9277 | 73 defaultAndAddedElements[i] = defaultElements[i]; |
74 } | |
75 // add the new values: | |
76 for (int j = 0; j < keys.length; j++) { | |
9288
82c67b859aa7
bundu.bezugswst worklflow incl. service impl for mainValues to be calculated
gernotbelger
parents:
9277
diff
changeset
|
77 defaultAndAddedElements[defaultLength + j] = createItem(ec, new String[] { keys[j], values[j] }); |
9277 | 78 } |
79 return defaultAndAddedElements; | |
9267 | 80 } |
81 | |
82 @Override | |
83 protected Element createStaticData(final D4EArtifact flys, final ElementCreator creator, final CallContext cc, final String name, final String value, | |
84 final String type) { | |
85 if (name.equals("events")) { | |
86 return EventSelect.createStaticDataPublic(flys, creator, cc, name, value, type); | |
87 | |
88 } else { | |
89 return super.createStaticData(flys, creator, cc, name, value, type); | |
90 } | |
91 } | |
92 | |
9369 | 93 @Override |
94 protected String getDatakey() { | |
95 return "fix_choice"; | |
96 } | |
97 | |
9073 | 98 } |