ingo@2825: package de.intevation.flys.model; ingo@2825: ingo@2825: import java.io.Serializable; ingo@2825: import java.math.BigDecimal; ingo@2871: import java.util.List; ingo@2825: ingo@2825: import javax.persistence.Entity; ingo@2825: import javax.persistence.Id; ingo@2825: import javax.persistence.Table; ingo@2825: import javax.persistence.GeneratedValue; ingo@2825: import javax.persistence.Column; ingo@2825: import javax.persistence.SequenceGenerator; ingo@2825: import javax.persistence.GenerationType; ingo@2825: import javax.persistence.JoinColumn; ingo@2825: import javax.persistence.OneToOne; ingo@2825: ingo@2871: import org.hibernate.Session; ingo@2871: import org.hibernate.Query; ingo@2871: ingo@2825: import org.apache.log4j.Logger; ingo@2825: ingo@2871: import de.intevation.flys.backend.SessionHolder; ingo@2871: ingo@2825: ingo@2825: @Entity ingo@2825: @Table(name = "flow_velocity_model_values") ingo@2825: public class FlowVelocityModelValue ingo@2825: implements Serializable ingo@2825: { ingo@2825: private static Logger logger = ingo@2825: Logger.getLogger(FlowVelocityModelValue.class); ingo@2825: ingo@2825: ingo@2825: private Integer id; ingo@2825: ingo@2825: private FlowVelocityModel flowVelocity; ingo@2825: ingo@2825: private BigDecimal station; ingo@2828: private BigDecimal q; ingo@2825: private BigDecimal totalChannel; ingo@2825: private BigDecimal mainChannel; ingo@2825: private BigDecimal shearStress; ingo@2825: ingo@2825: ingo@2825: public FlowVelocityModelValue() { ingo@2825: } ingo@2825: ingo@2825: ingo@2825: public FlowVelocityModelValue( ingo@2825: FlowVelocityModel flowVelocity, ingo@2825: BigDecimal station, ingo@2828: BigDecimal q, ingo@2825: BigDecimal totalChannel, ingo@2825: BigDecimal mainChannel, ingo@2825: BigDecimal shearStress ingo@2825: ) { ingo@2825: this.flowVelocity = flowVelocity; ingo@2825: this.station = station; ingo@2828: this.q = q; ingo@2825: this.totalChannel = totalChannel; ingo@2825: this.mainChannel = mainChannel; ingo@2825: this.shearStress = shearStress; ingo@2825: } ingo@2825: ingo@2825: @Id ingo@2825: @SequenceGenerator( ingo@2825: name = "SEQUENCE_FLOW_VELOCITY_M_VALUES_ID_SEQ", ingo@2825: sequenceName = "FLOW_VELOCITY_M_VALUES_ID_SEQ", ingo@2825: allocationSize = 1) ingo@2825: @GeneratedValue( ingo@2825: strategy = GenerationType.SEQUENCE, ingo@2825: generator = "SEQUENCE_FLOW_VELOCITY_M_VALUES_ID_SEQ") ingo@2825: @Column(name = "id") ingo@2825: public Integer getId() { ingo@2825: return id; ingo@2825: } ingo@2825: ingo@2825: public void setId(Integer id) { ingo@2825: this.id = id; ingo@2825: } ingo@2825: ingo@2825: @OneToOne ingo@2825: @JoinColumn(name = "flow_velocity_model_id") ingo@2825: public FlowVelocityModel getFlowVelocity() { ingo@2825: return flowVelocity; ingo@2825: } ingo@2825: ingo@2825: public void setFlowVelocity(FlowVelocityModel flowVelocity) { ingo@2825: this.flowVelocity = flowVelocity; ingo@2825: } ingo@2825: ingo@2825: @Column(name = "station") ingo@2825: public BigDecimal getStation() { ingo@2825: return station; ingo@2825: } ingo@2825: ingo@2825: public void setStation(BigDecimal station) { ingo@2825: this.station = station; ingo@2825: } ingo@2825: ingo@2828: @Column(name = "q") ingo@2828: public BigDecimal getQ() { ingo@2828: return q; ingo@2828: } ingo@2828: ingo@2828: public void setQ(BigDecimal q) { ingo@2828: this.q = q; ingo@2828: } ingo@2828: ingo@2825: @Column(name = "total_channel") ingo@2825: public BigDecimal getTotalChannel() { ingo@2825: return totalChannel; ingo@2825: } ingo@2825: ingo@2825: public void setTotalChannel(BigDecimal totalChannel) { ingo@2825: this.totalChannel = totalChannel; ingo@2825: } ingo@2825: ingo@2825: @Column(name = "main_channel") ingo@2825: public BigDecimal getMainChannel() { ingo@2825: return mainChannel; ingo@2825: } ingo@2825: ingo@2825: public void setMainChannel(BigDecimal mainChannel) { ingo@2825: this.mainChannel = mainChannel; ingo@2825: } ingo@2825: ingo@2825: @Column(name = "shear_stress") ingo@2825: public BigDecimal getShearStress() { ingo@2825: return shearStress; ingo@2825: } ingo@2825: ingo@2825: public void setShearStress(BigDecimal shearStress) { ingo@2825: this.shearStress = shearStress; ingo@2825: } ingo@2871: ingo@2871: ingo@2871: public static List getValues( ingo@2871: FlowVelocityModel model, ingo@2871: double kmLo, ingo@2871: double kmHi ingo@2871: ) { ingo@2871: Session session = SessionHolder.HOLDER.get(); ingo@2871: ingo@2871: Query query = session.createQuery( ingo@2871: "from FlowVelocityModelValue where " + ingo@2871: " flowVelocity=:model and" + ingo@2871: " station >= :kmLo and " + ingo@2871: " station <= :kmHi"); ingo@2871: ingo@2871: query.setParameter("model", model); ingo@2871: query.setParameter("kmLo", new BigDecimal(kmLo)); ingo@2871: query.setParameter("kmHi", new BigDecimal(kmHi)); ingo@2871: ingo@2871: return query.list(); ingo@2871: } ingo@2825: } ingo@2825: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :