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: import java.math.BigDecimal; 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 ingo@2809: @Table(name = "bed_height_single_values") ingo@2809: public class BedHeightSingleValue ingo@2809: implements Serializable ingo@2809: { ingo@2809: private static Logger logger = ingo@2809: Logger.getLogger(BedHeightSingleValue.class); ingo@2809: ingo@2809: private Integer id; ingo@2809: ingo@2809: private BedHeightSingle bedHeight; ingo@2809: tom@6200: private Double station; tom@6200: private Double height; tom@6200: private Double uncertainty; tom@6200: private Double dataGap; ingo@2809: private BigDecimal soundingWidth; tom@6200: private Double width; ingo@2809: ingo@2809: ingo@2809: public BedHeightSingleValue() { ingo@2809: } ingo@2809: ingo@2809: public BedHeightSingleValue( ingo@2809: BedHeightSingle bedHeight, tom@6200: Double station, tom@6200: Double height, tom@6200: Double uncertainty, tom@6200: Double dataGap, ingo@2809: BigDecimal soundingWidth, tom@6200: Double width 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: this.width = width; ingo@2809: } ingo@2809: ingo@2809: @Id ingo@2809: @SequenceGenerator( ingo@2809: name = "SEQUENCE_BED_SINGLE_VALUE_ID_SEQ", ingo@2809: sequenceName = "BED_SINGLE_VALUES_ID_SEQ", ingo@2809: allocationSize = 1) ingo@2809: @GeneratedValue( ingo@2809: strategy = GenerationType.SEQUENCE, ingo@2809: generator = "SEQUENCE_BED_SINGLE_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 ingo@2809: @JoinColumn(name = "bed_height_single_id" ) ingo@2809: public BedHeightSingle getBedHeight() { ingo@2809: return bedHeight; ingo@2809: } ingo@2809: ingo@2809: public void setBedHeight(BedHeightSingle bedHeight) { ingo@2809: this.bedHeight = bedHeight; ingo@2809: } ingo@2809: ingo@2809: @Column(name = "station") tom@6200: public Double getStation() { ingo@2809: return station; ingo@2809: } ingo@2809: tom@6200: public void setStation(Double station) { ingo@2809: this.station = station; ingo@2809: } ingo@2809: ingo@2809: @Column(name = "height") tom@6200: public Double getHeight() { ingo@2809: return height; ingo@2809: } ingo@2809: tom@6200: public void setHeight(Double height) { ingo@2809: this.height = height; ingo@2809: } ingo@2809: ingo@2809: @Column(name="uncertainty") tom@6200: public Double getUncertainty() { ingo@2809: return uncertainty; ingo@2809: } ingo@2809: tom@6200: public void setUncertainty(Double uncertainty) { ingo@2809: this.uncertainty = uncertainty; ingo@2809: } ingo@2809: ingo@2809: @Column(name="data_gap") tom@6200: public Double getDataGap() { ingo@2809: return dataGap; ingo@2809: } ingo@2809: tom@6200: public void setDataGap(Double dataGap) { ingo@2809: this.dataGap = dataGap; ingo@2809: } ingo@2809: ingo@2809: @Column(name="sounding_width") ingo@2809: public BigDecimal getSoundingWidth() { ingo@2809: return soundingWidth; ingo@2809: } ingo@2809: ingo@2809: public void setSoundingWidth(BigDecimal soundingWidth) { ingo@2809: this.soundingWidth = soundingWidth; ingo@2809: } ingo@2809: ingo@2809: @Column(name="width") tom@6200: public Double getWidth() { ingo@2809: return width; ingo@2809: } ingo@2809: tom@6200: public void setWidth(Double width) { ingo@2809: this.width = width; ingo@2809: } ingo@2873: ingo@2873: ingo@2874: public static List getBedHeightSingleValues( ingo@2873: BedHeightSingle 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( ingo@2873: "from BedHeightSingleValue where bedHeight=:single " + ingo@2873: " and station >= :kmLo and station <= :kmHi"); ingo@2873: ingo@2873: query.setParameter("single", single); tom@6200: query.setParameter("kmLo", new Double(kmLo)); tom@6200: 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 :