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; ingo@2868: import javax.persistence.Id; ingo@2868: import javax.persistence.JoinColumn; ingo@2868: import javax.persistence.OneToOne; ingo@2868: import javax.persistence.Table; 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.LineString; ingo@2868: ingo@2868: import de.intevation.flys.backend.SessionHolder; ingo@2868: ingo@2868: ingo@2868: @Entity ingo@2868: @Table(name = "hydr_boundaries") ingo@2868: public class HydrBoundary ingo@2868: implements Serializable ingo@2868: { ingo@2868: private Integer id; aheinecke@5062: private SectieKind sectie; aheinecke@5062: private SobekKind sobek; ingo@2868: private String name; ingo@2868: private River river; ingo@2868: private LineString geom; aheinecke@5062: private BoundaryKind kind; ingo@2868: ingo@2868: public HydrBoundary() { ingo@2868: } ingo@2868: ingo@2868: ingo@2868: @Id 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: @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 LineString getGeom() { ingo@2868: return geom; ingo@2868: } ingo@2868: ingo@2868: ingo@2868: public void setGeom(LineString 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 HydrBoundary 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@5062: @Column(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 :