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; ingo@2809: ingo@2809: tom@8559: public BedHeightValue() { ingo@2809: } ingo@2809: tom@8559: public BedHeightValue( tom@8559: BedHeight bedHeight, tom@6203: Double station, tom@6203: Double height, tom@6203: Double uncertainty, tom@6203: Double dataGap, tom@8554: Double soundingWidth ingo@2809: ) { 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; ingo@2809: } ingo@2809: ingo@2809: @Id ingo@2809: @SequenceGenerator( tom@8559: name = "SEQUENCE_BED_HEIGHT_VALUE_ID_SEQ", tom@8559: sequenceName = "BED_HEIGHT_VALUES_ID_SEQ", ingo@2809: allocationSize = 1) ingo@2809: @GeneratedValue( ingo@2809: strategy = GenerationType.SEQUENCE, tom@8559: generator = "SEQUENCE_BED_HEIGHT_VALUE_ID_SEQ") ingo@2809: @Column(name = "id") ingo@2809: public Integer getId() { ingo@2809: return id; ingo@2809: } ingo@2809: ingo@2809: public void setId(Integer id) { ingo@2809: this.id = id; ingo@2809: } ingo@2809: ingo@2809: @OneToOne tom@8559: @JoinColumn(name = "bed_height_id" ) tom@8559: public BedHeight getBedHeight() { ingo@2809: return bedHeight; ingo@2809: } ingo@2809: tom@8559: public void setBedHeight(BedHeight bedHeight) { ingo@2809: this.bedHeight = bedHeight; ingo@2809: } ingo@2809: ingo@2809: @Column(name = "station") tom@6203: public Double getStation() { ingo@2809: return station; ingo@2809: } ingo@2809: tom@6203: public void setStation(Double station) { ingo@2809: this.station = station; ingo@2809: } ingo@2809: ingo@2809: @Column(name = "height") tom@6203: public Double getHeight() { ingo@2809: return height; ingo@2809: } ingo@2809: tom@6203: public void setHeight(Double height) { ingo@2809: this.height = height; ingo@2809: } ingo@2809: ingo@2809: @Column(name="uncertainty") tom@6203: public Double getUncertainty() { ingo@2809: return uncertainty; ingo@2809: } ingo@2809: tom@6203: public void setUncertainty(Double uncertainty) { ingo@2809: this.uncertainty = uncertainty; ingo@2809: } ingo@2809: ingo@2809: @Column(name="data_gap") tom@6203: public Double getDataGap() { ingo@2809: return dataGap; ingo@2809: } ingo@2809: tom@6203: public void setDataGap(Double dataGap) { ingo@2809: this.dataGap = dataGap; ingo@2809: } ingo@2809: ingo@2809: @Column(name="sounding_width") tom@6298: public Double getSoundingWidth() { ingo@2809: return soundingWidth; ingo@2809: } ingo@2809: tom@6298: public void setSoundingWidth(Double soundingWidth) { ingo@2809: this.soundingWidth = soundingWidth; ingo@2809: } ingo@2809: 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 :