Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/FixationChoice.java @ 9366:3d006afee054
bundu.bezugswst workflow reviewed
author | gernotbelger |
---|---|
date | Thu, 02 Aug 2018 15:06:22 +0200 |
parents | 82c67b859aa7 |
children | 1a4d2ce77423 |
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 { | |
27 private static final long serialVersionUID = 1L; | |
28 | |
9178
2f5052835b76
uinfo inundationduration langjähr. Mittel, Uedauern.properties, Meldung
gernotbelger
parents:
9073
diff
changeset
|
29 @Override |
9267 | 30 protected final String getUIProvider() { |
31 return "custom_fixation_radio_panel"; | |
32 } | |
33 | |
34 @Override | |
9178
2f5052835b76
uinfo inundationduration langjähr. Mittel, Uedauern.properties, Meldung
gernotbelger
parents:
9073
diff
changeset
|
35 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
|
36 final LinkedHashMap<String, String> entries = new LinkedHashMap<>(); |
9366 | 37 entries.put("state.bundu.wst.fix.auto", null); |
38 entries.put("state.bundu.wst.fix.manual", null); | |
9178
2f5052835b76
uinfo inundationduration langjähr. Mittel, Uedauern.properties, Meldung
gernotbelger
parents:
9073
diff
changeset
|
39 return entries; |
9073 | 40 } |
41 | |
9267 | 42 @Override |
43 protected Element[] createItems(final XMLUtils.ElementCreator ec, final Artifact artifact, final String name, final CallContext context) { | |
44 | |
45 final Element[] elements = super.createItems(ec, artifact, name, context); | |
9270 | 46 |
9267 | 47 final BunduAccess access = new BunduAccess((D4EArtifact) artifact); |
48 final int[] eventsTemp = access.getEventsTemp(); | |
49 final StringBuilder builder = new StringBuilder(); | |
50 if (eventsTemp != null) { | |
51 for (final int event : eventsTemp) { | |
52 builder.append(event).append(";"); | |
53 } | |
54 } else { | |
55 builder.append("");// no values | |
56 } | |
57 final int year = access.getBezugsJahr(); | |
9277 | 58 final String[] values = new String[] { builder.toString(), String.valueOf(year) }; |
59 final String[] keys = new String[] { "ignore_events_temp", "ignore_singleyear" }; | |
9267 | 60 |
9277 | 61 return appendElements(ec, elements, keys, values); |
9267 | 62 |
9277 | 63 } |
9267 | 64 |
9277 | 65 public static final Element[] appendElements(final ElementCreator ec, final Element[] defaultElements, final String[] keys, final String[] values) { |
66 assert (values.length == keys.length); | |
67 // make bigger array | |
9288
82c67b859aa7
bundu.bezugswst worklflow incl. service impl for mainValues to be calculated
gernotbelger
parents:
9277
diff
changeset
|
68 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
|
69 final Element[] defaultAndAddedElements = new Element[defaultLength + values.length]; |
9277 | 70 |
9288
82c67b859aa7
bundu.bezugswst worklflow incl. service impl for mainValues to be calculated
gernotbelger
parents:
9277
diff
changeset
|
71 for (int i = 0; i < defaultLength; i++) { |
9277 | 72 defaultAndAddedElements[i] = defaultElements[i]; |
73 } | |
74 // add the new values: | |
75 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
|
76 defaultAndAddedElements[defaultLength + j] = createItem(ec, new String[] { keys[j], values[j] }); |
9277 | 77 } |
78 return defaultAndAddedElements; | |
9267 | 79 } |
80 | |
81 @Override | |
82 protected Element createStaticData(final D4EArtifact flys, final ElementCreator creator, final CallContext cc, final String name, final String value, | |
83 final String type) { | |
84 if (name.equals("events")) { | |
85 return EventSelect.createStaticDataPublic(flys, creator, cc, name, value, type); | |
86 | |
87 } else { | |
88 return super.createStaticData(flys, creator, cc, name, value, type); | |
89 } | |
90 } | |
91 | |
9073 | 92 } |