view artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/RiversideRadioChoice.java @ 9369:1a4d2ce77423

radio choice fix
author gernotbelger
date Thu, 02 Aug 2018 17:39:13 +0200
parents dace17e26d33
children f51e23eb036a
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.sinfo.flood_duration;

import java.util.LinkedHashMap;

import org.dive4elements.artifacts.Artifact;
import org.dive4elements.artifacts.CallMeta;
import org.dive4elements.river.artifacts.states.RadioSelect;
import org.dive4elements.river.model.Attribute.AttributeKey;

/**
 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
 */
public class RiversideRadioChoice extends RadioSelect {

    private static final long serialVersionUID = 1L;

    public enum RiversideChoiceKey {
        NONE("", AttributeKey.NONE), //
        LEFT("state.sinfo.riverside.left", AttributeKey.LEFT), //
        RIGHT("state.sinfo.riverside.right", AttributeKey.RIGHT), //
        BOTH("state.sinfo.riverside.both", AttributeKey.UNKNOWN);

        private final String key;
        private final AttributeKey attributeKey;

        RiversideChoiceKey(final String key, final AttributeKey attributeKey) {
            this.key = key;
            this.attributeKey = attributeKey;
        }

        public static RiversideChoiceKey fromKey(final String key) {
            for (final RiversideChoiceKey v : values()) {
                if (key.equalsIgnoreCase(v.key))
                    return v;
            }
            return NONE;
        }

        public String getKey() {
            return this.key;
        }

        public AttributeKey getAttributeKey() {
            return this.attributeKey;
        }
    }

    @Override
    protected LinkedHashMap<String, String> makeEntries(final CallMeta meta, final Artifact artifact) {
        final LinkedHashMap<String, String> entries = new LinkedHashMap<>();
        entries.put(RiversideChoiceKey.LEFT.getKey(), null);
        entries.put(RiversideChoiceKey.RIGHT.getKey(), null);
        entries.put(RiversideChoiceKey.BOTH.getKey(), null);
        return entries;
    }

    @Override
    protected String getDatakey() {
        return "riverside";
    }

    @Override
    protected String getUIProvider() {

        return "riverside_radio_panel";
    }
}

http://dive4elements.wald.intevation.org