view artifacts/src/main/java/org/dive4elements/river/artifacts/model/map/HWSContainer.java @ 7300:83bb52fa0c32

(issue1529) Be more tolerant in the fitting. The invalid value warning is removed because invalid data is expected there when datapoints are not valid for this KM
author Andre Heinecke <aheinecke@intevation.de>
date Fri, 11 Oct 2013 18:40:33 +0200
parents af13ceeba52a
children e4606eae8ea5
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.model.map;

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

import org.apache.log4j.Logger;

public class HWSContainer
{
    private static Logger logger = Logger.getLogger(HWSContainer.class);
    private String river;
    private HWS.TYPE type;
    private List<HWS> hws;

    public HWSContainer() {
        river = null;
        hws = new ArrayList<HWS>();
    }

    public HWSContainer(String river, HWS.TYPE type, List<HWS> hws) {
        this.river = river;
        this.hws = hws;
        this.type = type;
    }

    public void setRiver(String river) {
        this.river = river;
    }

    public String getRiver() {
        return this.river;
    }

    public HWS.TYPE getType() {
        return type;
    }

    public void setType(HWS.TYPE type) {
        this.type = type;
    }

    public List<HWS> getHws() {
        return hws;
    }

    public void addHws(HWS hws) {
        logger.debug("add hws: " + hws.getName());
        this.hws.add(hws);
    }

    public void addHws(List<HWS> hws) {
        this.hws.addAll(hws);
    }

    public List<HWS> getOfficialHWS() {
        if (hws == null || hws.size() == 0) {
            return new ArrayList<HWS>();
        }
        List<HWS> results = new ArrayList<HWS>();
        for (HWS h: hws) {
            if (h.isOfficial()) {
                results.add(h);
            }
        }
        return results;
    }

    public List<HWS> getHws(String name) {
        logger.debug("find: " + name + " in " + hws.size() + " elements");
        if (hws == null || hws.size() == 0) {
            return new ArrayList<HWS>();
        }
        List<HWS> results = new ArrayList<HWS>();
        for (HWS h: hws) {
            if (h.getName().equals(name)) {
                results.add(h);
            }
        }
        logger.debug("found: " + results.size());
        return results;
    }

    public List<HWS> getHws(List<String> list) {
        if (hws == null || hws.size() == 0) {
            return new ArrayList<HWS>();
        }
        List<HWS> results = new ArrayList<HWS>();
        for (String name : list) {
            results.addAll(getHws(name));
        }
        return results;
    }
}

http://dive4elements.wald.intevation.org