comparison artifacts/src/main/java/org/dive4elements/river/artifacts/states/LoadSingleYearSelectState.java @ 9077:2b13de1b0897

moved single_year/multi_year common code to AbstractPanel
author gernotbelger
date Tue, 22 May 2018 15:32:00 +0200
parents cd650cacc926
children af73fdd96920
comparison
equal deleted inserted replaced
9076:22d8928895a1 9077:2b13de1b0897
6 * documentation coming with Dive4Elements River for details. 6 * documentation coming with Dive4Elements River for details.
7 */ 7 */
8 8
9 package org.dive4elements.river.artifacts.states; 9 package org.dive4elements.river.artifacts.states;
10 10
11 import java.util.HashMap;
12 import java.util.List;
13 import java.util.Map;
14
11 import org.apache.log4j.Logger; 15 import org.apache.log4j.Logger;
12 import org.dive4elements.artifacts.Artifact; 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.model.sinfo.Collision;
23 import org.w3c.dom.Element;
13 24
14 /** State in which to fetch years for sedminent load calculation. */ 25 /** State in which to fetch years for sedminent load calculation. */
15 public class LoadSingleYearSelectState extends DefaultState { 26 public class LoadSingleYearSelectState extends DefaultState {
16 private static final long serialVersionUID = 1L; 27 private static final long serialVersionUID = 1L;
17 /** The log used in this class. */ 28 /** The log used in this class. */
28 protected String getUIProvider() { 39 protected String getUIProvider() {
29 return "common.state.load_single_year_select"; 40 return "common.state.load_single_year_select";
30 } 41 }
31 42
32 @Override 43 @Override
44 protected void appendItems(final Artifact artifact, final ElementCreator creator, final String name, final CallContext context, final Element select) {
45 final String dataKey = "singleyear";
46 try {
47 if (dataKey.equals(name)) {
48
49 final AddTableDataHelper helper = new AddTableDataHelper(creator, select, "year", context.getMeta()); // pinKeycolum; nicht zu verweschseln mit
50 // datakey..artifact.
51
52 helper.addColumn(0, "pinfrom", "60", "common.client.ui.selection", "ICON", "CENTER", "from");
53 helper.addColumn(1, "year", "60", "year", "INTEGER", "LEFT", null);
54
55 final RiverAccess access = new RiverAccess((D4EArtifact) artifact);
56 final List<Collision> collisions = CollisionHibernateFactory.getCollisionsByRiver(access.getRiver());// TODO: DATASOURCE?! Has to be
57 // uinfo.inundation_duration
58 // (Überflutungsdauern Aue) irgendwas...
59
60 for (final Collision coll : collisions) {
61 final Integer year = coll.getYear();
62 final Map<String, String> row = new HashMap<>();
63 row.put("year", year.toString()); // Nullpointer?
64 helper.addRow(row);
65
66 }
67 helper.submitMapToXml();
68 }
69 }
70 catch (final IllegalArgumentException iae) {
71 iae.printStackTrace();
72 }
73 }
74
75 @Override
33 public boolean validate(final Artifact artifact) throws IllegalArgumentException { 76 public boolean validate(final Artifact artifact) throws IllegalArgumentException {
34 return true; 77 return true;
35 // final CollisionLoadYearEpochAccess access = new CollisionLoadYearEpochAccess((D4EArtifact) artifact); 78 // final CollisionLoadYearEpochAccess access = new CollisionLoadYearEpochAccess((D4EArtifact) artifact);
36 // 79 //
37 // // Second year should be later than first. 80 // // Second year should be later than first.
40 // // throw new IllegalArgumentException("error_years_wrong"); 83 // // throw new IllegalArgumentException("error_years_wrong");
41 // 84 //
42 // return true; 85 // return true;
43 } 86 }
44 } 87 }
45 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org