9223
|
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.salix; |
|
10 |
|
11 import java.util.HashMap; |
|
12 import java.util.Map; |
|
13 |
|
14 import org.apache.log4j.Logger; |
|
15 import org.dive4elements.artifacts.Artifact; |
|
16 import org.dive4elements.artifacts.CallContext; |
|
17 import org.dive4elements.artifacts.common.utils.XMLUtils.ElementCreator; |
|
18 import org.dive4elements.river.artifacts.states.AddTableDataHelper; |
|
19 import org.dive4elements.river.artifacts.states.DefaultState; |
|
20 import org.w3c.dom.Element; |
|
21 |
|
22 public class LoadMultipleEpochSelectState extends DefaultState { |
|
23 /** The log used in this class. */ |
|
24 private static Logger log = Logger.getLogger(LoadMultipleEpochSelectState.class); |
|
25 |
|
26 /** |
|
27 * The default constructor that initializes an empty State object. |
|
28 */ |
|
29 public LoadMultipleEpochSelectState() { |
|
30 } |
|
31 |
|
32 @Override |
|
33 protected String getUIProvider() { |
|
34 return "sinfo.collision.load_epoch_select"; |
|
35 } |
|
36 |
|
37 @Override |
|
38 protected void appendItems(final Artifact artifact, final ElementCreator creator, final String name, final CallContext context, final Element select) { |
|
39 final String datakey = "epochs"; |
|
40 // TODO: MAKE DATASOURCE |
|
41 try { |
|
42 if (datakey.equals(name)) { |
|
43 |
|
44 final AddTableDataHelper helper = new AddTableDataHelper(creator, select, "year", context.getMeta()); |
|
45 |
|
46 helper.addColumn(0, "pinfrom", "40", "common.client.ui.from", "ICON", "CENTER", "from"); |
|
47 helper.addColumn(1, "pinto", "40", "common.client.ui.to", "ICON", "CENTER", "to"); |
|
48 helper.addColumn(2, "year", "60", "year", "INTEGER", "LEFT", null); |
|
49 |
|
50 // final CollisionAccess access = new CollisionAccess((SINFOArtifact) artifact); // Der River wurde im vorigen State |
|
51 // bereits gesetzt |
|
52 |
|
53 // final List<Collision> collisions = CollisionHibernateFactory.getCollisionsByRiver(access.getRiver()); |
|
54 // for (final Collision coll : collisions) { // TODO: Filter on Range (?) |
|
55 // final Integer year = coll.getYear(); |
|
56 final Map<String, String> row = new HashMap<>(); |
|
57 row.put("year", "1995");// year.toString()); // Nullpointer? |
|
58 helper.addRow(row); |
|
59 final Map<String, String> row2 = new HashMap<>(); |
|
60 row2.put("year", "1996"); |
|
61 helper.addRow(row2); |
|
62 final Map<String, String> row3 = new HashMap<>(); |
|
63 row3.put("year", "1998"); |
|
64 helper.addRow(row3); |
|
65 |
|
66 // } |
|
67 helper.submitMapToXml(); |
|
68 } |
|
69 } |
|
70 catch ( |
|
71 |
|
72 final IllegalArgumentException iae) { |
|
73 iae.printStackTrace(); |
|
74 } |
|
75 } |
|
76 } |