ingo@2364: package de.intevation.flys.model; ingo@2364: ingo@2364: import java.io.Serializable; ingo@2364: import java.math.BigDecimal; ingo@2364: import java.util.List; ingo@2364: ingo@2364: import javax.persistence.Column; ingo@2364: import javax.persistence.Entity; ingo@2364: import javax.persistence.Id; ingo@2364: import javax.persistence.JoinColumn; ingo@2364: import javax.persistence.OneToOne; ingo@2364: import javax.persistence.Table; ingo@2364: ingo@2364: import org.hibernate.Session; ingo@2364: import org.hibernate.Query; ingo@2364: import org.hibernate.annotations.Type; ingo@2364: ingo@2364: import com.vividsolutions.jts.geom.Polygon; ingo@2364: ingo@2364: import de.intevation.flys.backend.SessionHolder; ingo@2364: ingo@2364: ingo@2364: @Entity ingo@2364: @Table(name = "catchment") ingo@2364: public class Catchment ingo@2364: implements Serializable ingo@2364: { ingo@2364: private Integer id; ingo@2364: private BigDecimal area; ingo@2364: private String name; ingo@2364: private River river; ingo@2364: private Polygon geom; ingo@2364: ingo@2364: public Catchment() { ingo@2364: } ingo@2364: ingo@2364: ingo@2364: @Id ingo@2364: @Column(name = "id") ingo@2364: public Integer getId() { ingo@2364: return id; ingo@2364: } ingo@2364: ingo@2364: ingo@2364: public void setId(Integer id) { ingo@2364: this.id = id; ingo@2364: } ingo@2364: ingo@2364: ingo@2364: @OneToOne ingo@2364: @JoinColumn(name = "river_id") ingo@2364: public River getRiver() { ingo@2364: return river; ingo@2364: } ingo@2364: ingo@2364: ingo@2364: public void setRiver(River river) { ingo@2364: this.river = river; ingo@2364: } ingo@2364: ingo@2364: ingo@2364: @Column(name = "name") ingo@2364: public String getName() { ingo@2364: return name; ingo@2364: } ingo@2364: ingo@2364: ingo@2364: public void setName(String name) { ingo@2364: this.name = name; ingo@2364: } ingo@2364: ingo@2364: ingo@2364: @Column(name = "area") ingo@2364: public BigDecimal getArea() { ingo@2364: return area; ingo@2364: } ingo@2364: ingo@2364: ingo@2364: public void setArea(BigDecimal area) { ingo@2364: this.area = area; ingo@2364: } ingo@2364: ingo@2364: ingo@2364: @Column(name = "geom") ingo@2364: @Type(type = "org.hibernatespatial.GeometryUserType") ingo@2364: public Polygon getGeom() { ingo@2364: return geom; ingo@2364: } ingo@2364: ingo@2364: ingo@2364: public void setGeom(Polygon geom) { ingo@2364: this.geom = geom; ingo@2364: } ingo@2364: ingo@2364: ingo@2364: public static List getCatchments(int riverId) { ingo@2364: Session session = SessionHolder.HOLDER.get(); ingo@2364: ingo@2364: Query query = session.createQuery( ingo@2364: "from Catchment where river.id =:river_id"); ingo@2364: query.setParameter("river_id", riverId); ingo@2364: ingo@2364: return query.list(); ingo@2364: } ingo@2364: } ingo@2364: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :