Mercurial > dive4elements > river
view artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/vegetationzones/VegetationZonesTableEditState.java @ 9402:e511eb935ccd
Changed hard coded standard vegetation zone table to fetching it from the database, i18n for the standard zone names
author | mschaefer |
---|---|
date | Tue, 14 Aug 2018 14:04:01 +0200 |
parents | 431f1c269be5 |
children | e2da9c8a7c57 |
line wrap: on
line source
/** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde * Software engineering by * Björnsen Beratende Ingenieure GmbH * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt * * 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.vegetationzones; import org.dive4elements.artifactdatabase.ProtocolUtils; import org.dive4elements.artifacts.Artifact; import org.dive4elements.artifacts.CallContext; import org.dive4elements.artifacts.common.utils.XMLUtils.ElementCreator; import org.dive4elements.river.artifacts.D4EArtifact; import org.dive4elements.river.artifacts.access.RiverAccess; import org.dive4elements.river.artifacts.states.DefaultState; import org.dive4elements.river.model.River; import org.w3c.dom.Element; /** * @author Domenico Nardi Tironi */ public class VegetationZonesTableEditState extends DefaultState { private static final long serialVersionUID = 1L; @Override protected String getUIProvider() { return "uinfo.vegetationzones.table.edit"; } @Override protected Element[] createItems(final ElementCreator cr, final Artifact artifact, final String name, final CallContext context) { final String datakey = "vegzones"; if (name.equals(datakey)) { final Element item = ProtocolUtils.createArtNode(cr, "item", null, null); final Element label = ProtocolUtils.createArtNode(cr, "label", null, null); final Element value = ProtocolUtils.createArtNode(cr, "value", null, null); final D4EArtifact flys = (D4EArtifact) artifact; final River river = new RiverAccess(flys).getRiver(); final String s = flys.getDataAsString(datakey) == null ? VegetationZone.parseListToDataString(VegetationZone.getStandardList(river, context)) : flys.getDataAsString(datakey); value.setTextContent(s); item.appendChild(label); item.appendChild(value); return new Element[] { item }; } return new Element[] {}; } @Override public boolean validate(final Artifact artifact) throws IllegalArgumentException { // TODO: check verstehen // final InundationDurationAccess access = new InundationDurationAccess((SINFOArtifact) artifact); // Second year should be later than first. // if (access.getYears() == null || access.getYears().length == 0) return true; // throw new IllegalArgumentException("error_years_wrong"); // return true; } /** * Creats the data element used for the static part of DESCRIBE document. */ // @Override // protected Element createStaticData(final D4EArtifact flys, final ElementCreator creator, final CallContext cc, final // String name, final String value, // final String type) { // final Element dataElement = creator.create("data"); // creator.addAttr(dataElement, "name", name, true); // creator.addAttr(dataElement, "type", type, true); // // final Element itemElement = creator.create("item"); // creator.addAttr(itemElement, "value", value, true); // // final String[] labels = getLabels(cc, value); // final Object[] obj = new Object[] { labels[0] }; // // // TODO own i18n // final String attrValue = Resources.getMsg(cc.getMeta(), "wsp.selected.string", "wsp.selected.string", obj); // // I18N_STATIC_KEY, I18N_STATIC_KEY, obj); // // creator.addAttr(itemElement, "label", attrValue, true); // dataElement.appendChild(itemElement); // // return dataElement; // } }