Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/inundationduration/LoadSingleYearSelectState.java @ 9178:2f5052835b76
uinfo inundationduration langjähr. Mittel, Uedauern.properties, Meldung
author | gernotbelger |
---|---|
date | Tue, 26 Jun 2018 19:48:35 +0200 |
parents | |
children | dace17e26d33 |
comparison
equal
deleted
inserted
replaced
9177:37db8c4c44b7 | 9178:2f5052835b76 |
---|---|
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.uinfo.inundationduration; | |
10 | |
11 import java.util.HashMap; | |
12 import java.util.List; | |
13 import java.util.Map; | |
14 | |
15 import org.apache.log4j.Logger; | |
16 import org.dive4elements.artifactdatabase.data.StateData; | |
17 import org.dive4elements.artifactdatabase.state.Facet; | |
18 import org.dive4elements.artifacts.Artifact; | |
19 import org.dive4elements.artifacts.CallContext; | |
20 import org.dive4elements.artifacts.CallMeta; | |
21 import org.dive4elements.artifacts.common.utils.XMLUtils.ElementCreator; | |
22 import org.dive4elements.river.artifacts.D4EArtifact; | |
23 import org.dive4elements.river.artifacts.states.AddTableDataHelper; | |
24 import org.dive4elements.river.artifacts.states.DefaultState; | |
25 import org.dive4elements.river.artifacts.uinfo.UINFOArtifact; | |
26 import org.w3c.dom.Element; | |
27 | |
28 /** State in which to fetch years for sedminent load calculation. */ | |
29 public class LoadSingleYearSelectState extends DefaultState { | |
30 private static final long serialVersionUID = 1L; | |
31 /** The log used in this class. */ | |
32 private static Logger log = Logger.getLogger(LoadSingleYearSelectState.class); | |
33 | |
34 private InundationDurationAccess access; | |
35 | |
36 /** | |
37 * The default constructor that initializes an empty State object. | |
38 */ | |
39 public LoadSingleYearSelectState() { | |
40 } | |
41 | |
42 /** Year Select Widget. */ | |
43 @Override | |
44 protected String getUIProvider() { | |
45 return "common.state.load_single_year_select"; | |
46 } | |
47 | |
48 @Override | |
49 protected void appendItems(final Artifact artifact, final ElementCreator creator, final String name, final CallContext context, final Element select) { | |
50 final String dataKey = "singleyear"; | |
51 try { | |
52 if (dataKey.equals(name)) { | |
53 | |
54 final AddTableDataHelper helper = new AddTableDataHelper(creator, select, "year", context.getMeta()); // pinKeycolum; nicht zu verweschseln mit | |
55 // datakey..artifact. | |
56 | |
57 helper.addColumn(0, "pinfrom", "60", "common.client.ui.selection", "ICON", "CENTER", "from"); | |
58 helper.addColumn(1, "year", "60", "year", "INTEGER", "LEFT", null); | |
59 final Map<String, StateData> data = super.getData(); | |
60 final UedauernPropertiesHelper properties = UedauernPropertiesHelper.getInstance(this.access.getRiverName()); | |
61 | |
62 for (final String year : properties.getEinzeljahre()) { | |
63 final Map<String, String> row = new HashMap<>(); | |
64 row.put("year", year); | |
65 helper.addRow(row); | |
66 | |
67 } | |
68 helper.submitMapToXml(); | |
69 } | |
70 } | |
71 catch (final IllegalArgumentException iae) { | |
72 iae.printStackTrace(); | |
73 } | |
74 } | |
75 | |
76 @Override | |
77 public Object computeInit(final D4EArtifact artifact, final String hash, final Object context, final CallMeta meta, final List<Facet> facets) { | |
78 if (artifact instanceof UINFOArtifact) { | |
79 this.access = new InundationDurationAccess((UINFOArtifact) artifact); | |
80 } | |
81 return super.computeInit(artifact, hash, context, meta, facets); | |
82 } | |
83 | |
84 } |