Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/LoadSingleYearSelectState.java @ 9256:6c24c857ccf9
fixation refactoring and inputItem behaviour to interfaces
author | gernotbelger |
---|---|
date | Fri, 13 Jul 2018 12:04:21 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
9255:9be51f776798 | 9256:6c24c857ccf9 |
---|---|
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 | |
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.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; | |
23 import org.dive4elements.river.artifacts.states.DefaultState; | |
24 import org.dive4elements.river.model.sinfo.Collision; | |
25 import org.w3c.dom.Element; | |
26 | |
27 /** State in which to fetch years for sedminent load calculation. */ | |
28 public class LoadSingleYearSelectState extends DefaultState { | |
29 private static final long serialVersionUID = 1L; | |
30 /** The log used in this class. */ | |
31 private static Logger log = Logger.getLogger(LoadSingleYearSelectState.class); | |
32 | |
33 /** | |
34 * The default constructor that initializes an empty State object. | |
35 */ | |
36 public LoadSingleYearSelectState() { | |
37 } | |
38 | |
39 /** Year Select Widget. */ | |
40 @Override | |
41 protected String getUIProvider() { | |
42 return "common.state.load_single_year_select.show_hint"; | |
43 } | |
44 | |
45 @Override | |
46 protected void appendItems(final Artifact artifact, final ElementCreator creator, final String name, final CallContext context, final Element select) { | |
47 final String dataKey = "singleyear"; | |
48 try { | |
49 if (dataKey.equals(name)) { | |
50 | |
51 final AddTableDataHelper helper = new AddTableDataHelper(creator, select, "year", context.getMeta()); // pinKeycolum; nicht zu verweschseln mit | |
52 // datakey..artifact. | |
53 | |
54 helper.addColumn(0, "pinfrom", "60", "common.client.ui.selection", "ICON", "CENTER", "from"); | |
55 helper.addColumn(1, "year", "60", "year", "INTEGER", "LEFT", null); | |
56 | |
57 final RiverAccess access = new RiverAccess((D4EArtifact) artifact); | |
58 final List<Collision> collisions = CollisionHibernateFactory.getCollisionsByRiver(access.getRiver());// TODO: DATASOURCE?! Has to be | |
59 // uinfo.inundation_duration | |
60 // (Überflutungsdauern Aue) irgendwas... | |
61 | |
62 for (final Collision coll : collisions) { | |
63 final Integer year = coll.getYear(); | |
64 final Map<String, String> row = new HashMap<>(); | |
65 row.put("year", year.toString()); // Nullpointer-Check? | |
66 helper.addRow(row); | |
67 | |
68 } | |
69 helper.submitMapToXml(); | |
70 } | |
71 } | |
72 catch (final IllegalArgumentException iae) { | |
73 iae.printStackTrace(); | |
74 } | |
75 } | |
76 | |
77 @Override | |
78 public boolean validate(final Artifact artifact) throws IllegalArgumentException { | |
79 return true; | |
80 // final CollisionLoadYearEpochAccess access = new CollisionLoadYearEpochAccess((D4EArtifact) artifact); | |
81 // | |
82 // // Second year should be later than first. | |
83 // if (access.getYears() == null || access.getYears().length == 0) | |
84 // return true; // TODO: richtig in CollisionLoadYear... implementieren | |
85 // // throw new IllegalArgumentException("error_years_wrong"); | |
86 // | |
87 // return true; | |
88 } | |
89 } |