9063
|
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 |
9079
|
11 import java.util.HashMap; |
|
12 import java.util.List; |
|
13 import java.util.Map; |
|
14 |
9063
|
15 import org.apache.log4j.Logger; |
9079
|
16 import org.dive4elements.artifacts.Artifact; |
|
17 import org.dive4elements.artifacts.CallContext; |
|
18 import org.dive4elements.artifacts.common.utils.XMLUtils.ElementCreator; |
|
19 import org.dive4elements.river.artifacts.D4EArtifact; |
|
20 import org.dive4elements.river.artifacts.access.RiverAccess; |
|
21 import org.dive4elements.river.artifacts.model.CollisionHibernateFactory; |
|
22 import org.dive4elements.river.artifacts.states.AddTableDataHelper; |
9063
|
23 import org.dive4elements.river.artifacts.states.DefaultState; |
9079
|
24 import org.dive4elements.river.model.sinfo.Collision; |
|
25 import org.w3c.dom.Element; |
9063
|
26 |
|
27 public class LoadEpochSelect extends DefaultState { |
|
28 /** The log used in this class. */ |
|
29 private static Logger log = Logger.getLogger(LoadEpochSelect.class); |
|
30 |
|
31 /** |
|
32 * The default constructor that initializes an empty State object. |
|
33 */ |
|
34 public LoadEpochSelect() { |
|
35 } |
|
36 |
|
37 @Override |
|
38 protected String getUIProvider() { |
9066
|
39 return "uinfo.inundationduration.load_totalepoch_select"; |
9063
|
40 } |
9079
|
41 |
|
42 @Override |
|
43 protected void appendItems(final Artifact artifact, final ElementCreator creator, final String name, final CallContext context, final Element select) { |
|
44 final String dataKey = "totalepoch"; |
|
45 try { |
|
46 if (dataKey.equals(name)) { |
|
47 |
|
48 final AddTableDataHelper helper = new AddTableDataHelper(creator, select, "year", context.getMeta()); // pinKeycolum; nicht zu verweschseln mit |
|
49 // datakey..artifact. |
|
50 |
|
51 // helper.addColumn(0, "pinfrom", "60", "common.client.ui.selection", "ICON", "CENTER", "from"); |
|
52 helper.addColumn(0, "year", "60", "year", "INTEGER", "LEFT", null); // Keine Pins |
|
53 |
|
54 final RiverAccess access = new RiverAccess((D4EArtifact) artifact); |
|
55 final List<Collision> collisions = CollisionHibernateFactory.getCollisionsByRiver(access.getRiver());// TODO: DATASOURCE?! Has to be |
|
56 // uinfo.inundation_duration |
|
57 // (Überflutungsdauern Aue) irgendwas... |
|
58 |
|
59 for (final Collision coll : collisions) { |
|
60 final Integer year = coll.getYear(); |
|
61 final Map<String, String> row = new HashMap<>(); |
|
62 row.put("year", year.toString()); // Nullpointer? |
|
63 helper.addRow(row); |
|
64 |
|
65 } |
|
66 helper.submitMapToXml(); |
|
67 } |
|
68 } |
|
69 catch (final IllegalArgumentException iae) { |
|
70 iae.printStackTrace(); |
|
71 } |
|
72 } |
|
73 |
9063
|
74 } |