view artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/CharDiameter.java @ 6665:b7945db8a43b

issue1413: Only show unknown sediment loads of selected unit type. Therefore, adjusted the factory to take the units name. Unfortunately, names in db do not match values of data items. Thus do manual replacing. In Facet and Calculate, take the chosen unit via access and to the string replacement. In Facet, do not transform data (we assume it comes in unit as labeled in the db), and removed the possibility of m3/a-data of unknown yields in a t/a diagram and vice versa.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 25 Jul 2013 15:08:13 +0200
parents af13ceeba52a
children 5d172bda6770
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.states.minfo;

import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;

import org.dive4elements.artifacts.Artifact;
import org.dive4elements.artifacts.CallContext;
import org.dive4elements.artifacts.CallMeta;
import org.dive4elements.artifacts.common.model.KVP;
import org.dive4elements.river.artifacts.resources.Resources;
import org.dive4elements.river.artifacts.states.MultiStringArrayState;

public class CharDiameter extends MultiStringArrayState {

    private static final Logger logger = Logger.getLogger(CharDiameter.class);

    public static final String UI_PROVIDER = "parameter-matrix";

    private static final String CHAR_DIAMETER_MIN  = "calc.bed.dmin";
    private static final String CHAR_DIAMETER_MAX  = "calc.bed.dmax";
    private static final String CHAR_DIAMETER_90  = "calc.bed.d90";
    private static final String CHAR_DIAMETER_84  = "calc.bed.d84";
    private static final String CHAR_DIAMETER_80  = "calc.bed.d80";
    private static final String CHAR_DIAMETER_75  = "calc.bed.d75";
    private static final String CHAR_DIAMETER_70  = "calc.bed.d70";
    private static final String CHAR_DIAMETER_60  = "calc.bed.d60";
    private static final String CHAR_DIAMETER_50  = "calc.bed.d50";
    private static final String CHAR_DIAMETER_40  = "calc.bed.d40";
    private static final String CHAR_DIAMETER_30  = "calc.bed.d30";
    private static final String CHAR_DIAMETER_25  = "calc.bed.d25";
    private static final String CHAR_DIAMETER_20  = "calc.bed.d20";
    private static final String CHAR_DIAMETER_16  = "calc.bed.d16";
    private static final String CHAR_DIAMETER_10  = "calc.bed.d10";

    public static final String[] CHAR_DIAMETER = {
        CHAR_DIAMETER_10,
        CHAR_DIAMETER_16,
        CHAR_DIAMETER_20,
        CHAR_DIAMETER_25,
        CHAR_DIAMETER_30,
        CHAR_DIAMETER_40,
        CHAR_DIAMETER_50,
        CHAR_DIAMETER_60,
        CHAR_DIAMETER_70,
        CHAR_DIAMETER_75,
        CHAR_DIAMETER_80,
        CHAR_DIAMETER_84,
        CHAR_DIAMETER_90,
        CHAR_DIAMETER_MAX,
        CHAR_DIAMETER_MIN
    };

    @Override
    public String getUIProvider() {
        return UI_PROVIDER;
    }

    @Override
    protected KVP<String, String>[] getOptions(
        Artifact artifact,
        String parameterName,
        CallContext context
    )
    throws IllegalArgumentException
    {
        CallMeta meta   = context.getMeta();

        List<KVP<String, String>> rows = new ArrayList<KVP<String, String>>();
        String key = parameterName;
        for (int i = 0; i < CHAR_DIAMETER.length; ++i) {
            String calc = CHAR_DIAMETER[i];
            rows.add(new KVP (calc,
                              Resources.getMsg(meta, calc, calc)));
        }

        return rows.toArray(new KVP[rows.size()]);
    }

    @Override
    protected String getLabelFor(CallContext cc, String parameterName,
            String value) throws IllegalArgumentException {

        return Resources.getMsg(cc.getMeta(), value, value);
    }

}

http://dive4elements.wald.intevation.org