teichmann@5844: /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde teichmann@5844: * Software engineering by Intevation GmbH teichmann@5844: * teichmann@5992: * This file is Free Software under the GNU AGPL (>=v3) teichmann@5844: * and comes with ABSOLUTELY NO WARRANTY! Check out the teichmann@5992: * documentation coming with Dive4Elements River for details. teichmann@5844: */ teichmann@5844: teichmann@5829: package org.dive4elements.river.model; ingo@2809: ingo@2873: import java.util.List; ingo@2873: ingo@2809: import java.io.Serializable; ingo@2809: ingo@2809: import javax.persistence.Entity; ingo@2809: import javax.persistence.Id; ingo@2809: import javax.persistence.Table; ingo@2809: import javax.persistence.GeneratedValue; ingo@2809: import javax.persistence.Column; ingo@2809: import javax.persistence.SequenceGenerator; ingo@2809: import javax.persistence.GenerationType; ingo@2809: import javax.persistence.JoinColumn; ingo@2809: import javax.persistence.OneToOne; ingo@2809: ingo@2809: import org.apache.log4j.Logger; ingo@2809: ingo@2873: import org.hibernate.Session; ingo@2873: import org.hibernate.Query; ingo@2873: teichmann@5829: import org.dive4elements.river.backend.SessionHolder; ingo@2873: ingo@2809: ingo@2809: @Entity tom@8559: @Table(name = "bed_height_values") tom@8559: public class BedHeightValue ingo@2809: implements Serializable ingo@2809: { teichmann@8200: private static Logger log = tom@8559: Logger.getLogger(BedHeightValue.class); ingo@2809: ingo@2809: private Integer id; ingo@2809: tom@8559: private BedHeight bedHeight; ingo@2809: tom@6203: private Double station; tom@6203: private Double height; tom@6203: private Double uncertainty; tom@6203: private Double dataGap; tom@6298: private Double soundingWidth; mschaefer@8955: private Double minHeight; mschaefer@8955: private Double maxHeight; ingo@2809: ingo@2809: tom@8559: public BedHeightValue() { ingo@2809: } ingo@2809: mschaefer@8955: public BedHeightValue(final BedHeight bedHeight, final Double station, final Double height, final Double uncertainty, final Double dataGap, mschaefer@8955: final Double soundingWidth, final Double minHeight, final Double maxHeight) { ingo@2809: this.bedHeight = bedHeight; ingo@2809: this.station = station; ingo@2809: this.height = height; ingo@2809: this.uncertainty = uncertainty; ingo@2809: this.dataGap = dataGap; ingo@2809: this.soundingWidth = soundingWidth; mschaefer@8955: this.minHeight = minHeight; mschaefer@8955: this.maxHeight = maxHeight; ingo@2809: } ingo@2809: ingo@2809: @Id mschaefer@8955: @SequenceGenerator(name = "SEQUENCE_BED_HEIGHT_VALUE_ID_SEQ", sequenceName = "BED_HEIGHT_VALUES_ID_SEQ", allocationSize = 1) mschaefer@8955: @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQUENCE_BED_HEIGHT_VALUE_ID_SEQ") ingo@2809: @Column(name = "id") ingo@2809: public Integer getId() { mschaefer@8955: return this.id; ingo@2809: } ingo@2809: mschaefer@8955: public void setId(final Integer id) { ingo@2809: this.id = id; ingo@2809: } ingo@2809: ingo@2809: @OneToOne tom@8842: @JoinColumn(name = "bed_height_id") tom@8559: public BedHeight getBedHeight() { mschaefer@8955: return this.bedHeight; ingo@2809: } ingo@2809: mschaefer@8955: public void setBedHeight(final BedHeight bedHeight) { ingo@2809: this.bedHeight = bedHeight; ingo@2809: } ingo@2809: ingo@2809: @Column(name = "station") tom@6203: public Double getStation() { mschaefer@8955: return this.station; ingo@2809: } ingo@2809: mschaefer@8955: public void setStation(final Double station) { ingo@2809: this.station = station; ingo@2809: } ingo@2809: ingo@2809: @Column(name = "height") tom@6203: public Double getHeight() { mschaefer@8955: return this.height; ingo@2809: } ingo@2809: mschaefer@8955: public void setHeight(final Double height) { ingo@2809: this.height = height; ingo@2809: } ingo@2809: ingo@2809: @Column(name="uncertainty") tom@6203: public Double getUncertainty() { mschaefer@8955: return this.uncertainty; ingo@2809: } ingo@2809: mschaefer@8955: public void setUncertainty(final Double uncertainty) { ingo@2809: this.uncertainty = uncertainty; ingo@2809: } ingo@2809: ingo@2809: @Column(name="data_gap") tom@6203: public Double getDataGap() { mschaefer@8955: return this.dataGap; ingo@2809: } ingo@2809: mschaefer@8955: public void setDataGap(final Double dataGap) { ingo@2809: this.dataGap = dataGap; ingo@2809: } ingo@2809: ingo@2809: @Column(name="sounding_width") tom@6298: public Double getSoundingWidth() { mschaefer@8955: return this.soundingWidth; ingo@2809: } ingo@2809: mschaefer@8955: public void setSoundingWidth(final Double soundingWidth) { ingo@2809: this.soundingWidth = soundingWidth; ingo@2809: } ingo@2809: mschaefer@8955: @Column(name = "min_height") mschaefer@8955: public Double getMinHeight() { mschaefer@8955: return this.minHeight; mschaefer@8955: } mschaefer@8955: mschaefer@8955: public void setMinHeight(final Double minHeight) { mschaefer@8955: this.minHeight = minHeight; mschaefer@8955: } mschaefer@8955: mschaefer@8955: @Column(name = "max_height") mschaefer@8955: public Double getMaxHeight() { mschaefer@8955: return this.maxHeight; mschaefer@8955: } mschaefer@8955: mschaefer@8955: public void setMaxHeight(final Double maxHeight) { mschaefer@8955: this.maxHeight = maxHeight; mschaefer@8955: } mschaefer@8955: mschaefer@8955: andre@8721: public static List getBedHeightValues( andre@8721: BedHeight single) { andre@8721: Session session = SessionHolder.HOLDER.get(); andre@8721: andre@8721: Query query = session.createQuery( andre@8721: "from BedHeightValue where bedHeight=:single"); andre@8721: andre@8721: query.setParameter("single", single); andre@8721: return query.list(); andre@8721: } andre@8721: ingo@2873: tom@8559: public static List getBedHeightValues( tom@8559: BedHeight single, ingo@2873: double kmLo, ingo@2873: double kmHi ingo@2873: ) { ingo@2873: Session session = SessionHolder.HOLDER.get(); ingo@2873: ingo@2873: Query query = session.createQuery( tom@8559: "from BedHeightValue where bedHeight=:single " + ingo@2873: " and station >= :kmLo and station <= :kmHi"); ingo@2873: ingo@2873: query.setParameter("single", single); tom@6203: query.setParameter("kmLo", new Double(kmLo)); tom@6203: query.setParameter("kmHi", new Double(kmHi)); ingo@2873: ingo@2873: return query.list(); ingo@2873: } ingo@2809: } ingo@2809: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :