view gwt-client/src/main/java/org/dive4elements/river/client/shared/model/SINFOArtifact.java @ 9263:abf14917be32

Moved stepping behaviour of NaviOutputChart into an exchangeable strategy. Allows for distinct values stepping of sinfo flood duration.
author gernotbelger
date Tue, 17 Jul 2018 19:48:18 +0200
parents 7bbfb24e6eec
children 9826b465b751
line wrap: on
line source
/* Copyright (C) 2017 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.client.shared.model;

import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * The SINFO implementation of an Artifact.
 *
 * @author Gernot Belger
 */
public class SINFOArtifact extends DefaultArtifact {

    /** The name of this artifact: 'sinfo'. */
    private static final String NAME = "sinfo";

    /** Necessary for serialization */
    public SINFOArtifact() {
    }

    public SINFOArtifact(final String uuid, final String hash, final boolean inBackground, final List<CalculationMessage> messages) {
        super(uuid, hash, inBackground, messages);
    }

    @Override
    public String getName() {
        return NAME;
    }

    public Set<Double> getValidDurationChartKms(final CollectionItem item) {

        final String validKmsText = item.getData().get("validStations");
        if (validKmsText == null || validKmsText.trim().isEmpty())
            return Collections.emptySet();

        final String[] split = validKmsText.split(",");

        final Set<Double> validKms = new HashSet<Double>(split.length);

        for (final String stationText : split) {

            try {
                final double station = Double.parseDouble(stationText);
                validKms.add(station);
            }
            catch (final NumberFormatException e) {
                e.printStackTrace();
            }
        }

        return validKms;
    }
}

http://dive4elements.wald.intevation.org