view backend/src/main/java/org/dive4elements/river/model/BedHeightValue.java @ 9444:ecadc9ed0ba0

Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
author mschaefer
date Tue, 21 Aug 2018 13:41:18 +0200
parents 8aa7d9eaaa21
children
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.model;

import java.io.Serializable;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.apache.log4j.Logger;
import org.dive4elements.river.backend.SessionHolder;
import org.hibernate.Query;
import org.hibernate.Session;


@Entity
@Table(name = "bed_height_values")
public class BedHeightValue
implements   Serializable
{
    private static Logger log =
            Logger.getLogger(BedHeightValue.class);

    private Integer id;

    private BedHeight bedHeight;

    private Double station;
    private Double height;
    private Double uncertainty;
    private Double dataGap;
    private Double soundingWidth;
    private Double minHeight;
    private Double maxHeight;
    private Double height01;
    private Double height02;
    private Double height03;
    private Double height04;
    private Double height05;
    private Double height06;
    private Double height07;
    private Double height08;
    private Double height09;
    private Double height10;


    public BedHeightValue() {
    }

    public BedHeightValue(final BedHeight bedHeight, final Double station, final Double height, final Double uncertainty, final Double dataGap,
            final Double soundingWidth, final Double minHeight, final Double maxHeight) {
        this.bedHeight     = bedHeight;
        this.station       = station;
        this.height        = height;
        this.uncertainty   = uncertainty;
        this.dataGap       = dataGap;
        this.soundingWidth = soundingWidth;
        this.minHeight = minHeight;
        this.maxHeight = maxHeight;
    }

    @Id
    @SequenceGenerator(name = "SEQUENCE_BED_HEIGHT_VALUE_ID_SEQ", sequenceName = "BED_HEIGHT_VALUES_ID_SEQ", allocationSize = 1)
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQUENCE_BED_HEIGHT_VALUE_ID_SEQ")
    @Column(name = "id")
    public Integer getId() {
        return this.id;
    }

    public void setId(final Integer id) {
        this.id = id;
    }

    @OneToOne
    @JoinColumn(name = "bed_height_id")
    public BedHeight getBedHeight() {
        return this.bedHeight;
    }

    public void setBedHeight(final BedHeight bedHeight) {
        this.bedHeight = bedHeight;
    }

    @Column(name = "station")
    public Double getStation() {
        return this.station;
    }

    public void setStation(final Double station) {
        this.station = station;
    }

    @Column(name = "height")
    public Double getHeight() {
        return this.height;
    }

    public void setHeight(final Double height) {
        this.height = height;
    }

    @Column(name="uncertainty")
    public Double getUncertainty() {
        return this.uncertainty;
    }

    public void setUncertainty(final Double uncertainty) {
        this.uncertainty = uncertainty;
    }

    @Column(name="data_gap")
    public Double getDataGap() {
        return this.dataGap;
    }

    public void setDataGap(final Double dataGap) {
        this.dataGap = dataGap;
    }

    @Column(name="sounding_width")
    public Double getSoundingWidth() {
        return this.soundingWidth;
    }

    public void setSoundingWidth(final Double soundingWidth) {
        this.soundingWidth = soundingWidth;
    }

    @Column(name = "min_height")
    public Double getMinHeight() {
        return this.minHeight;
    }

    public void setMinHeight(final Double minHeight) {
        this.minHeight = minHeight;
    }

    @Column(name = "max_height")
    public Double getMaxHeight() {
        return this.maxHeight;
    }

    public void setMaxHeight(final Double maxHeight) {
        this.maxHeight = maxHeight;
    }

    @Column(name = "height01")
    public Double getHeight01() {
        return this.height01;
    }

    public void setHeight01(final Double height) {
        this.height01 = height;
    }

    @Column(name = "height02")
    public Double getHeight02() {
        return this.height02;
    }

    public void setHeight02(final Double height) {
        this.height02 = height;
    }

    @Column(name = "height03")
    public Double getHeight03() {
        return this.height03;
    }

    public void setHeight03(final Double height) {
        this.height03 = height;
    }

    @Column(name = "height04")
    public Double getHeight04() {
        return this.height04;
    }

    public void setHeight04(final Double height) {
        this.height04 = height;
    }

    @Column(name = "height05")
    public Double getHeight05() {
        return this.height05;
    }

    public void setHeight05(final Double height) {
        this.height05 = height;
    }

    @Column(name = "height06")
    public Double getHeight06() {
        return this.height06;
    }

    public void setHeight06(final Double height) {
        this.height06 = height;
    }

    @Column(name = "height07")
    public Double getHeight07() {
        return this.height07;
    }

    public void setHeight07(final Double height) {
        this.height07 = height;
    }

    @Column(name = "height08")
    public Double getHeight08() {
        return this.height08;
    }

    public void setHeight08(final Double height) {
        this.height08 = height;
    }

    @Column(name = "height09")
    public Double getHeight09() {
        return this.height09;
    }

    public void setHeight09(final Double height) {
        this.height09 = height;
    }

    @Column(name = "height10")
    public Double getHeight10() {
        return this.height10;
    }

    public void setHeight10(final Double height) {
        this.height10 = height;
    }

    @Transient
    public Double getSectionHeight(final int index) {
        switch (index) {
        case 1:
            return this.height01;
        case 2:
            return this.height02;
        case 3:
            return this.height03;
        case 4:
            return this.height04;
        case 5:
            return this.height05;
        case 6:
            return this.height06;
        case 7:
            return this.height07;
        case 8:
            return this.height08;
        case 9:
            return this.height09;
        case 10:
            return this.height10;
        default:
            throw new IllegalArgumentException();
        }
    }

    @Transient
    public void setSectionHeight(final int index, final Double value) {
        switch (index) {
        case 1:
            this.height01 = value;
            break;
        case 2:
            this.height02 = value;
            break;
        case 3:
            this.height03 = value;
            break;
        case 4:
            this.height04 = value;
            break;
        case 5:
            this.height05 = value;
            break;
        case 6:
            this.height06 = value;
            break;
        case 7:
            this.height07 = value;
            break;
        case 8:
            this.height08 = value;
            break;
        case 9:
            this.height09 = value;
            break;
        case 10:
            this.height10 = value;
            break;
        default:
            break;
        }
    }

    public static List<BedHeightValue> getBedHeightValues(final BedHeight single) {
        final Session session = SessionHolder.HOLDER.get();
        final Query query = session.createQuery("FROM BedHeightValue WHERE bedHeight=:single");
        query.setParameter("single", single);
        return query.list();
    }


    public static List<BedHeightValue> getBedHeightValues(final BedHeight single, final double kmLo, final double kmHi) {
        final Session session = SessionHolder.HOLDER.get();
        final Query query = session.createQuery("FROM BedHeightValue WHERE (bedHeight=:single)"
                + " AND (station >= :kmLo) AND (station <= :kmHi)");
        query.setParameter("single", single);
        query.setParameter("kmLo", new Double(kmLo));
        query.setParameter("kmHi", new Double(kmHi));
        return query.list();
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org