ingo@2810: package de.intevation.flys.model; ingo@2810: ingo@2873: import java.util.List; ingo@2873: ingo@2810: import java.io.Serializable; ingo@2810: import java.math.BigDecimal; ingo@2810: ingo@2810: import javax.persistence.Entity; ingo@2810: import javax.persistence.Id; ingo@2810: import javax.persistence.Table; ingo@2810: import javax.persistence.GeneratedValue; ingo@2810: import javax.persistence.Column; ingo@2810: import javax.persistence.SequenceGenerator; ingo@2810: import javax.persistence.GenerationType; ingo@2810: import javax.persistence.JoinColumn; ingo@2810: import javax.persistence.OneToOne; ingo@2810: ingo@2810: import org.apache.log4j.Logger; ingo@2810: 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@2810: ingo@2810: @Entity ingo@2810: @Table(name = "bed_height_epoch_values") ingo@2810: public class BedHeightEpochValue ingo@2810: implements Serializable ingo@2810: { ingo@2810: private static Logger logger = ingo@2810: Logger.getLogger(BedHeightEpochValue.class); ingo@2810: ingo@2810: private Integer id; ingo@2810: ingo@2810: private BedHeightEpoch bedHeight; ingo@2810: ingo@2810: private BigDecimal station; ingo@2810: private BigDecimal height; ingo@2810: ingo@2810: ingo@2810: public BedHeightEpochValue() { ingo@2810: } ingo@2810: ingo@2810: public BedHeightEpochValue( ingo@2810: BedHeightEpoch bedHeight, ingo@2810: BigDecimal station, ingo@2810: BigDecimal height ingo@2810: ) { ingo@2810: this.bedHeight = bedHeight; ingo@2810: this.station = station; ingo@2810: this.height = height; ingo@2810: } ingo@2810: ingo@2810: @Id ingo@2810: @SequenceGenerator( ingo@2810: name = "SEQUENCE_BED_EPOCH_VALUE_ID_SEQ", ingo@2810: sequenceName = "BED_EPOCH_VALUES_ID_SEQ", ingo@2810: allocationSize = 1) ingo@2810: @GeneratedValue( ingo@2810: strategy = GenerationType.SEQUENCE, ingo@2810: generator = "SEQUENCE_BED_EPOCH_VALUE_ID_SEQ") ingo@2810: @Column(name = "id") ingo@2810: public Integer getId() { ingo@2810: return id; ingo@2810: } ingo@2810: ingo@2810: public void setId(Integer id) { ingo@2810: this.id = id; ingo@2810: } ingo@2810: ingo@2810: @OneToOne ingo@2810: @JoinColumn(name = "bed_height_epoch_id" ) ingo@2810: public BedHeightEpoch getBedHeight() { ingo@2810: return bedHeight; ingo@2810: } ingo@2810: ingo@2810: public void setBedHeight(BedHeightEpoch bedHeight) { ingo@2810: this.bedHeight = bedHeight; ingo@2810: } ingo@2810: ingo@2810: @Column(name = "station") ingo@2810: public BigDecimal getStation() { ingo@2810: return station; ingo@2810: } ingo@2810: ingo@2810: public void setStation(BigDecimal station) { ingo@2810: this.station = station; ingo@2810: } ingo@2810: ingo@2810: @Column(name = "height") ingo@2810: public BigDecimal getHeight() { ingo@2810: return height; ingo@2810: } ingo@2810: ingo@2810: public void setHeight(BigDecimal height) { ingo@2810: this.height = height; ingo@2810: } ingo@2873: ingo@2873: ingo@2873: public static List<BedHeightEpochValue> getBedHeightEpochValues( ingo@2873: BedHeightEpoch epoch, 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 BedHeightEpochValue where bedHeight=:epoch " + ingo@2873: " and station >= :kmLo and station <= :kmHi"); ingo@2873: ingo@2873: query.setParameter("epoch", epoch); 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@2810: } ingo@2810: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :