ingo@2868: package de.intevation.flys.model; ingo@2868: ingo@2868: import java.io.Serializable; ingo@2868: import java.util.List; ingo@2868: ingo@2868: import javax.persistence.Column; ingo@2868: import javax.persistence.Entity; aheinecke@5098: import javax.persistence.GeneratedValue; aheinecke@5098: import javax.persistence.GenerationType; ingo@2868: import javax.persistence.Id; ingo@2868: import javax.persistence.JoinColumn; ingo@2868: import javax.persistence.OneToOne; ingo@2868: import javax.persistence.Table; aheinecke@5098: import javax.persistence.SequenceGenerator; ingo@2868: ingo@2868: import org.hibernate.Session; ingo@2868: import org.hibernate.Query; ingo@2868: import org.hibernate.annotations.Type; ingo@2868: ingo@2868: import com.vividsolutions.jts.geom.Geometry; ingo@2868: ingo@2868: import de.intevation.flys.backend.SessionHolder; ingo@2868: ingo@2868: ingo@2868: @Entity ingo@2868: @Table(name = "hydr_boundaries_poly") ingo@2868: public class HydrBoundaryPoly ingo@2868: implements Serializable ingo@2868: { ingo@2868: private Integer id; ingo@2868: private String name; ingo@2868: private River river; ingo@2868: private Geometry geom; aheinecke@5062: private SectieKind sectie; aheinecke@5062: private SobekKind sobek; aheinecke@5062: private BoundaryKind kind; ingo@2868: ingo@2868: public HydrBoundaryPoly() { ingo@2868: } ingo@2868: ingo@2868: ingo@2868: @Id aheinecke@5098: @SequenceGenerator( aheinecke@5098: name = "SEQUENCE_HYDR_BOUNDARIES_POLY_ID_SEQ", aheinecke@5098: sequenceName = "HYDR_BOUNDARIES_POLY_ID_SEQ", aheinecke@5098: allocationSize = 1) aheinecke@5098: @GeneratedValue( aheinecke@5098: strategy = GenerationType.SEQUENCE, aheinecke@5098: generator = "SEQUENCE_HYDR_BOUNDARIES_POLY_ID_SEQ") ingo@2868: @Column(name = "id") ingo@2868: public Integer getId() { ingo@2868: return id; ingo@2868: } ingo@2868: ingo@2868: ingo@2868: public void setId(Integer id) { ingo@2868: this.id = id; ingo@2868: } ingo@2868: ingo@2868: ingo@2868: @OneToOne ingo@2868: @JoinColumn(name = "river_id") ingo@2868: public River getRiver() { ingo@2868: return river; ingo@2868: } ingo@2868: ingo@2868: ingo@2868: public void setRiver(River river) { ingo@2868: this.river = river; ingo@2868: } ingo@2868: ingo@2868: ingo@2868: @Column(name = "name") ingo@2868: public String getName() { ingo@2868: return name; ingo@2868: } ingo@2868: ingo@2868: ingo@2868: public void setName(String name) { ingo@2868: this.name = name; ingo@2868: } ingo@2868: ingo@2868: ingo@2868: @Column(name = "geom") ingo@2868: @Type(type = "org.hibernatespatial.GeometryUserType") ingo@2868: public Geometry getGeom() { ingo@2868: return geom; ingo@2868: } ingo@2868: ingo@2868: ingo@2868: public void setGeom(Geometry geom) { ingo@2868: this.geom = geom; ingo@2868: } ingo@2868: ingo@2868: ingo@2868: public static List getHydrBoundaries(int riverId, String name) { ingo@2868: Session session = SessionHolder.HOLDER.get(); ingo@2868: ingo@2868: Query query = session.createQuery( ingo@2868: "from HydrBoundaryPoly where river.id =:river_id and name=:name"); ingo@2868: query.setParameter("river_id", riverId); ingo@2868: query.setParameter("name", name); ingo@2868: ingo@2868: return query.list(); ingo@2868: } aheinecke@5062: aheinecke@5062: /** aheinecke@5062: * Get sectie. aheinecke@5062: * aheinecke@5062: * @return sectie as SectieKind. aheinecke@5062: */ aheinecke@5062: @OneToOne aheinecke@5089: @JoinColumn(name = "sectie") aheinecke@5062: public SectieKind getSectie() aheinecke@5062: { aheinecke@5062: return sectie; aheinecke@5062: } aheinecke@5062: aheinecke@5062: /** aheinecke@5062: * Set sectie. aheinecke@5062: * aheinecke@5062: * @param sectie the value to set. aheinecke@5062: */ aheinecke@5062: public void setSectie(SectieKind sectie) aheinecke@5062: { aheinecke@5062: this.sectie = sectie; aheinecke@5062: } aheinecke@5062: aheinecke@5062: /** aheinecke@5062: * Get sobek. aheinecke@5062: * aheinecke@5062: * @return sobek as SobekKind. aheinecke@5062: */ aheinecke@5062: @OneToOne aheinecke@5062: @JoinColumn(name = "sobek") aheinecke@5062: public SobekKind getSobek() aheinecke@5062: { aheinecke@5062: return sobek; aheinecke@5062: } aheinecke@5062: aheinecke@5062: /** aheinecke@5062: * Set sobek. aheinecke@5062: * aheinecke@5062: * @param sobek the value to set. aheinecke@5062: */ aheinecke@5062: public void setSobek(SobekKind sobek) aheinecke@5062: { aheinecke@5062: this.sobek = sobek; aheinecke@5062: } aheinecke@5062: aheinecke@5062: /** aheinecke@5062: * Get kind. aheinecke@5062: * aheinecke@5062: * @return kind as BoundaryKind. aheinecke@5062: */ aheinecke@5062: @OneToOne aheinecke@5062: @JoinColumn(name = "kind") aheinecke@5062: public BoundaryKind getKind() aheinecke@5062: { aheinecke@5062: return kind; aheinecke@5062: } aheinecke@5062: aheinecke@5062: /** aheinecke@5062: * Set kind. aheinecke@5062: * aheinecke@5062: * @param kind the value to set. aheinecke@5062: */ aheinecke@5062: public void setKind(BoundaryKind kind) aheinecke@5062: { aheinecke@5062: this.kind = kind; aheinecke@5062: } ingo@2868: } ingo@2868: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :