Mercurial > dive4elements > river
view artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/LoadSingleEpochSelectState.java @ 9511:73819a194bfd
Wrong/not translated column
author | gernotbelger |
---|---|
date | Fri, 28 Sep 2018 18:12:11 +0200 |
parents | a978b601a034 |
children | 6dd539efebb1 |
line wrap: on
line source
/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde * Software engineering by Intevation GmbH * * This file is Free Software under the GNU AGPL (>=v3) * and comes with ABSOLUTELY NO WARRANTY! Check out the * documentation coming with Dive4Elements River for details. */ package org.dive4elements.river.artifacts.uinfo.salix; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.TreeMap; import org.dive4elements.artifacts.Artifact; import org.dive4elements.artifacts.CallContext; import org.dive4elements.artifacts.common.utils.XMLUtils.ElementCreator; import org.dive4elements.river.artifacts.states.AddTableDataHelper; import org.dive4elements.river.artifacts.states.DefaultState; import org.dive4elements.river.artifacts.uinfo.UINFOArtifact; import org.dive4elements.river.model.BedHeight; import org.w3c.dom.Element; public class LoadSingleEpochSelectState extends DefaultState { private static final long serialVersionUID = 1L; /** * The default constructor that initializes an empty State object. */ public LoadSingleEpochSelectState() { } @Override protected String getUIProvider() { return "uinfo.salix.load_single_year_pseudo_epoch_select"; } @Override protected void appendItems(final Artifact artifact, final ElementCreator creator, final String name, final CallContext context, final Element select) { final String datakey = "singleepoch"; try { if (datakey.equals(name)) { final SalixLineAccess access = new SalixLineAccess((UINFOArtifact) artifact); final List<BedHeight> bhs = BedHeight.getBedHeightEpochs(access.getRiver(), access.getLowerKm(), access.getUpperKm()); makeDataSourceYearEpoch(creator, select, context, bhs); } } catch ( final IllegalArgumentException iae) { iae.printStackTrace(); } } public static final void makeDataSourceYearEpoch(final ElementCreator creator, final Element select, final CallContext context, final List<BedHeight> bedheights) { // TODO: maybe move to appropriate helper... final AddTableDataHelper helper = new AddTableDataHelper(creator, select, "year", context.getMeta()); helper.addColumn(0, "pinfrom", "40", "common.client.ui.from", "ICON", "CENTER", "from"); helper.addColumn(1, "year", "60", "year", "INTEGER", "LEFT", null); helper.addColumn(2, "sounding", "500", "uinfo.salix.soundings", "STRING", "LEFT", null); final TreeMap<Integer, String> bedHeightSorted = new TreeMap<>(); for (final BedHeight bh : bedheights) { final int year = bh.getYear(); final String soundings = bedHeightSorted.containsKey(year) ? bedHeightSorted.get(year) + ", " : ""; bedHeightSorted.put(year, soundings + bh.getDescription()); } final Iterator<Integer> iterator = bedHeightSorted.keySet().iterator(); while (iterator.hasNext()) { final int year = iterator.next(); final String soundings = bedHeightSorted.get(year); final Map<String, String> row = new HashMap<>(); row.put("year", String.valueOf(year)); row.put("sounding", soundings); helper.addRow(row); } helper.submitMapToXml(); } }