ingo@2809: package de.intevation.flys.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: ingo@2873: import de.intevation.flys.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: ingo@2809: private BigDecimal station; ingo@2809: private BigDecimal height; ingo@2809: private BigDecimal uncertainty; ingo@2809: private BigDecimal dataGap; ingo@2809: private BigDecimal soundingWidth; ingo@2809: private BigDecimal width; ingo@2809: ingo@2809: ingo@2809: public BedHeightSingleValue() { ingo@2809: } ingo@2809: ingo@2809: public BedHeightSingleValue( ingo@2809: BedHeightSingle bedHeight, ingo@2809: BigDecimal station, ingo@2809: BigDecimal height, ingo@2809: BigDecimal uncertainty, ingo@2809: BigDecimal dataGap, ingo@2809: BigDecimal soundingWidth, ingo@2809: BigDecimal 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") ingo@2809: public BigDecimal getStation() { ingo@2809: return station; ingo@2809: } ingo@2809: ingo@2809: public void setStation(BigDecimal station) { ingo@2809: this.station = station; ingo@2809: } ingo@2809: ingo@2809: @Column(name = "height") ingo@2809: public BigDecimal getHeight() { ingo@2809: return height; ingo@2809: } ingo@2809: ingo@2809: public void setHeight(BigDecimal height) { ingo@2809: this.height = height; ingo@2809: } ingo@2809: ingo@2809: @Column(name="uncertainty") ingo@2809: public BigDecimal getUncertainty() { ingo@2809: return uncertainty; ingo@2809: } ingo@2809: ingo@2809: public void setUncertainty(BigDecimal uncertainty) { ingo@2809: this.uncertainty = uncertainty; ingo@2809: } ingo@2809: ingo@2809: @Column(name="data_gap") ingo@2809: public BigDecimal getDataGap() { ingo@2809: return dataGap; ingo@2809: } ingo@2809: ingo@2809: public void setDataGap(BigDecimal 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") ingo@2809: public BigDecimal getWidth() { ingo@2809: return width; ingo@2809: } ingo@2809: ingo@2809: public void setWidth(BigDecimal 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); ingo@2873: query.setParameter("kmLo", new BigDecimal(kmLo)); ingo@2873: query.setParameter("kmHi", new BigDecimal(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 :