ingo@1237: package de.intevation.flys.model; ingo@1237: ingo@1237: import java.io.Serializable; ingo@1237: import java.util.List; ingo@1237: ingo@1237: import javax.persistence.Column; ingo@1237: import javax.persistence.Entity; ingo@1237: import javax.persistence.Id; ingo@1237: import javax.persistence.JoinColumn; ingo@1237: import javax.persistence.OneToOne; ingo@1237: import javax.persistence.Table; ingo@1237: ingo@1237: import org.hibernate.Query; ingo@1237: import org.hibernate.Session; ingo@1237: import org.hibernate.annotations.Type; ingo@1237: ingo@1237: import com.vividsolutions.jts.geom.MultiPolygon; ingo@1237: ingo@1237: import de.intevation.flys.backend.SessionHolder; ingo@1237: ingo@1237: ingo@1237: @Entity ingo@1237: @Table(name = "floodplain") ingo@1237: public class Floodplain ingo@1237: implements Serializable ingo@1237: { ingo@1237: private Integer id; ingo@1237: ingo@1237: private River river; ingo@1237: ingo@1237: private MultiPolygon geom; ingo@1237: ingo@1237: ingo@1237: public Floodplain() { ingo@1237: } ingo@1237: ingo@1237: ingo@1237: @Id ingo@1237: @Column(name = "id") ingo@1237: public Integer getId() { ingo@1237: return id; ingo@1237: } ingo@1237: ingo@1237: public void setId(Integer id) { ingo@1237: this.id = id; ingo@1237: } ingo@1237: ingo@1237: @OneToOne ingo@1237: @JoinColumn(name = "river_id") ingo@1237: public River getRiver() { ingo@1237: return river; ingo@1237: } ingo@1237: ingo@1237: public void setRiver(River river) { ingo@1237: this.river = river; ingo@1237: } ingo@1237: ingo@1237: @Column(name = "geom") ingo@1237: @Type(type = "org.hibernatespatial.GeometryUserType") ingo@1237: public MultiPolygon getGeom() { ingo@1237: return geom; ingo@1237: } ingo@1237: ingo@1237: public void setGeom(MultiPolygon geom) { ingo@1237: this.geom = geom; ingo@1237: } ingo@1237: ingo@1237: ingo@1237: public static Floodplain getFloodplain(String river) { ingo@1237: Session session = SessionHolder.HOLDER.get(); ingo@1237: ingo@1237: Query query = session.createQuery( ingo@1237: "from Floodplain where river.name =:river"); ingo@1237: query.setParameter("river", river); ingo@1237: ingo@1237: List result = query.list(); ingo@1237: ingo@1237: return result.isEmpty() ? null : result.get(0); ingo@1237: } ingo@1237: } ingo@1237: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :