Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/LoadSingleEpochSelectState.java @ 9245:f5cff8708531
bedheight datasource for salix.historical
author | gernotbelger |
---|---|
date | Wed, 11 Jul 2018 14:45:01 +0200 |
parents | c3994657c15d |
children | 9e6b70cce337 |
comparison
equal
deleted
inserted
replaced
9244:b9505aa78cdd | 9245:f5cff8708531 |
---|---|
7 */ | 7 */ |
8 | 8 |
9 package org.dive4elements.river.artifacts.uinfo.salix; | 9 package org.dive4elements.river.artifacts.uinfo.salix; |
10 | 10 |
11 import java.util.HashMap; | 11 import java.util.HashMap; |
12 import java.util.Iterator; | |
13 import java.util.List; | |
12 import java.util.Map; | 14 import java.util.Map; |
15 import java.util.TreeMap; | |
13 | 16 |
14 import org.apache.log4j.Logger; | 17 import org.apache.log4j.Logger; |
15 import org.dive4elements.artifacts.Artifact; | 18 import org.dive4elements.artifacts.Artifact; |
16 import org.dive4elements.artifacts.CallContext; | 19 import org.dive4elements.artifacts.CallContext; |
17 import org.dive4elements.artifacts.common.utils.XMLUtils.ElementCreator; | 20 import org.dive4elements.artifacts.common.utils.XMLUtils.ElementCreator; |
18 import org.dive4elements.river.artifacts.states.AddTableDataHelper; | 21 import org.dive4elements.river.artifacts.states.AddTableDataHelper; |
19 import org.dive4elements.river.artifacts.states.DefaultState; | 22 import org.dive4elements.river.artifacts.states.DefaultState; |
23 import org.dive4elements.river.artifacts.uinfo.UINFOArtifact; | |
24 import org.dive4elements.river.model.BedHeight; | |
20 import org.w3c.dom.Element; | 25 import org.w3c.dom.Element; |
21 | 26 |
22 public class LoadSingleEpochSelectState extends DefaultState { | 27 public class LoadSingleEpochSelectState extends DefaultState { |
23 private static final long serialVersionUID = 1L; | 28 private static final long serialVersionUID = 1L; |
24 /** The log used in this class. */ | 29 /** The log used in this class. */ |
36 } | 41 } |
37 | 42 |
38 @Override | 43 @Override |
39 protected void appendItems(final Artifact artifact, final ElementCreator creator, final String name, final CallContext context, final Element select) { | 44 protected void appendItems(final Artifact artifact, final ElementCreator creator, final String name, final CallContext context, final Element select) { |
40 final String datakey = "singleepoch"; | 45 final String datakey = "singleepoch"; |
41 // TODO: MAKE DATASOURCE | 46 |
42 try { | 47 try { |
43 if (datakey.equals(name)) { | 48 if (datakey.equals(name)) { |
44 | 49 final SalixLineAccess access = new SalixLineAccess((UINFOArtifact) artifact); |
45 final AddTableDataHelper helper = new AddTableDataHelper(creator, select, "year", context.getMeta()); | 50 final List<BedHeight> bhs = BedHeight.getBedHeightEpochs(access.getRiver(), access.getLowerKm(), access.getUpperKm()); |
46 | 51 makeDataSourceYearEpoch(artifact, creator, select, context, bhs); |
47 helper.addColumn(0, "pinfrom", "40", "common.client.ui.from", "ICON", "CENTER", "from"); | |
48 helper.addColumn(1, "pinto", "40", "common.client.ui.to", "ICON", "CENTER", "to"); | |
49 helper.addColumn(2, "year", "60", "year", "INTEGER", "LEFT", null); | |
50 helper.addColumn(3, "sounding", "200", "uinfo.salix.soundings", "STRING", "LEFT", null); | |
51 // final CollisionAccess access = new CollisionAccess((SINFOArtifact) artifact); // Der River wurde im vorigen State | |
52 // bereits gesetzt | |
53 | |
54 // final List<Collision> collisions = CollisionHibernateFactory.getCollisionsByRiver(access.getRiver()); | |
55 // for (final Collision coll : collisions) { // TODO: Filter on Range (?) | |
56 // final Integer year = coll.getYear(); | |
57 // for (final Collision coll : collisions) { | |
58 for (int i = 0; i < 3; i++) {// : Collision.getYearsOfRiver(access.getRiver())) { | |
59 // final Integer year = coll.getYear(); | |
60 final Map<String, String> row = new HashMap<>(); | |
61 row.put("year", String.valueOf(1995 + i)); // Nullpointer? | |
62 row.put("sounding", "TODO: Peilungen für das Jahr in dieser Zelle auflisten."); | |
63 helper.addRow(row); | |
64 } | |
65 // } | |
66 helper.submitMapToXml(); | |
67 } | 52 } |
68 } | 53 } |
69 catch ( | 54 catch ( |
70 | 55 |
71 final IllegalArgumentException iae) { | 56 final IllegalArgumentException iae) { |
72 iae.printStackTrace(); | 57 iae.printStackTrace(); |
73 } | 58 } |
74 } | 59 } |
60 | |
61 public static final void makeDataSourceYearEpoch(final Artifact artifact, final ElementCreator creator, final Element select, final CallContext context, | |
62 final List<BedHeight> bedheights) { // TODO: maybe move to appropriate helper... | |
63 | |
64 final AddTableDataHelper helper = new AddTableDataHelper(creator, select, "year", context.getMeta()); | |
65 | |
66 helper.addColumn(0, "pinfrom", "40", "common.client.ui.from", "ICON", "CENTER", "from"); | |
67 helper.addColumn(1, "year", "60", "year", "INTEGER", "LEFT", null); | |
68 helper.addColumn(2, "sounding", "500", "uinfo.salix.soundings", "STRING", "LEFT", null); | |
69 | |
70 final TreeMap<Integer, String> bedHeightSorted = new TreeMap<>(); | |
71 | |
72 for (final BedHeight bh : bedheights) { | |
73 final int year = bh.getYear(); | |
74 final String soundings = bedHeightSorted.containsKey(year) ? bedHeightSorted.get(year) + ", " : ""; | |
75 bedHeightSorted.put(year, soundings + bh.getDescription()); | |
76 } | |
77 final Iterator<Integer> iterator = bedHeightSorted.keySet().iterator(); | |
78 while (iterator.hasNext()) { | |
79 final int year = iterator.next(); | |
80 final String soundings = bedHeightSorted.get(year); | |
81 final Map<String, String> row = new HashMap<>(); | |
82 row.put("year", String.valueOf(year)); | |
83 row.put("sounding", soundings); | |
84 helper.addRow(row); | |
85 } | |
86 | |
87 helper.submitMapToXml(); | |
88 } | |
89 | |
75 } | 90 } |