Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/LoadSingleEpochSelectState.java @ 9406:55e3b1a8aa06
salix pdf export column added
author | gernotbelger |
---|---|
date | Wed, 15 Aug 2018 15:10:01 +0200 |
parents | a978b601a034 |
children | 6dd539efebb1 |
rev | line source |
---|---|
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; | |
9245 | 12 import java.util.Iterator; |
13 import java.util.List; | |
9223 | 14 import java.util.Map; |
9245 | 15 import java.util.TreeMap; |
9223 | 16 |
17 import org.dive4elements.artifacts.Artifact; | |
18 import org.dive4elements.artifacts.CallContext; | |
19 import org.dive4elements.artifacts.common.utils.XMLUtils.ElementCreator; | |
20 import org.dive4elements.river.artifacts.states.AddTableDataHelper; | |
21 import org.dive4elements.river.artifacts.states.DefaultState; | |
9245 | 22 import org.dive4elements.river.artifacts.uinfo.UINFOArtifact; |
23 import org.dive4elements.river.model.BedHeight; | |
9223 | 24 import org.w3c.dom.Element; |
25 | |
9224 | 26 public class LoadSingleEpochSelectState extends DefaultState { |
9321
a978b601a034
Salix: Fixed ArrrayoutOfBoundsException; minor cleanup
gernotbelger
parents:
9248
diff
changeset
|
27 |
9224 | 28 private static final long serialVersionUID = 1L; |
9223 | 29 |
30 /** | |
31 * The default constructor that initializes an empty State object. | |
32 */ | |
9224 | 33 public LoadSingleEpochSelectState() { |
9223 | 34 } |
35 | |
36 @Override | |
37 protected String getUIProvider() { | |
9248 | 38 return "uinfo.salix.load_single_year_pseudo_epoch_select"; |
9223 | 39 } |
40 | |
41 @Override | |
42 protected void appendItems(final Artifact artifact, final ElementCreator creator, final String name, final CallContext context, final Element select) { | |
9224 | 43 final String datakey = "singleepoch"; |
9245 | 44 |
9223 | 45 try { |
46 if (datakey.equals(name)) { | |
9245 | 47 final SalixLineAccess access = new SalixLineAccess((UINFOArtifact) artifact); |
48 final List<BedHeight> bhs = BedHeight.getBedHeightEpochs(access.getRiver(), access.getLowerKm(), access.getUpperKm()); | |
9321
a978b601a034
Salix: Fixed ArrrayoutOfBoundsException; minor cleanup
gernotbelger
parents:
9248
diff
changeset
|
49 makeDataSourceYearEpoch(creator, select, context, bhs); |
9223 | 50 } |
51 } | |
52 catch ( | |
53 | |
9321
a978b601a034
Salix: Fixed ArrrayoutOfBoundsException; minor cleanup
gernotbelger
parents:
9248
diff
changeset
|
54 final IllegalArgumentException iae) { |
9223 | 55 iae.printStackTrace(); |
56 } | |
57 } | |
9245 | 58 |
9321
a978b601a034
Salix: Fixed ArrrayoutOfBoundsException; minor cleanup
gernotbelger
parents:
9248
diff
changeset
|
59 public static final void makeDataSourceYearEpoch(final ElementCreator creator, final Element select, final CallContext context, |
9245 | 60 final List<BedHeight> bedheights) { // TODO: maybe move to appropriate helper... |
61 | |
62 final AddTableDataHelper helper = new AddTableDataHelper(creator, select, "year", context.getMeta()); | |
63 | |
64 helper.addColumn(0, "pinfrom", "40", "common.client.ui.from", "ICON", "CENTER", "from"); | |
65 helper.addColumn(1, "year", "60", "year", "INTEGER", "LEFT", null); | |
66 helper.addColumn(2, "sounding", "500", "uinfo.salix.soundings", "STRING", "LEFT", null); | |
67 | |
68 final TreeMap<Integer, String> bedHeightSorted = new TreeMap<>(); | |
69 | |
70 for (final BedHeight bh : bedheights) { | |
71 final int year = bh.getYear(); | |
72 final String soundings = bedHeightSorted.containsKey(year) ? bedHeightSorted.get(year) + ", " : ""; | |
73 bedHeightSorted.put(year, soundings + bh.getDescription()); | |
74 } | |
75 final Iterator<Integer> iterator = bedHeightSorted.keySet().iterator(); | |
76 while (iterator.hasNext()) { | |
77 final int year = iterator.next(); | |
78 final String soundings = bedHeightSorted.get(year); | |
79 final Map<String, String> row = new HashMap<>(); | |
80 row.put("year", String.valueOf(year)); | |
81 row.put("sounding", soundings); | |
82 helper.addRow(row); | |
83 } | |
84 | |
85 helper.submitMapToXml(); | |
86 } | |
9321
a978b601a034
Salix: Fixed ArrrayoutOfBoundsException; minor cleanup
gernotbelger
parents:
9248
diff
changeset
|
87 } |