ingo@2869: package de.intevation.flys.model; ingo@2869: sascha@3320: import com.vividsolutions.jts.geom.Point; sascha@3320: sascha@3320: import de.intevation.flys.backend.SessionHolder; sascha@3320: ingo@2869: import java.io.Serializable; sascha@3320: ingo@2869: import java.util.List; ingo@2869: ingo@2869: import javax.persistence.Column; ingo@2869: import javax.persistence.Entity; ingo@2869: import javax.persistence.Id; ingo@2869: import javax.persistence.JoinColumn; ingo@2869: import javax.persistence.OneToOne; ingo@2869: import javax.persistence.Table; ingo@2869: sascha@3320: import org.hibernate.Query; ingo@2869: import org.hibernate.Session; sascha@3320: ingo@2869: import org.hibernate.annotations.Type; ingo@2869: ingo@2869: ingo@2869: @Entity ingo@2869: @Table(name = "gauge_location") ingo@2869: public class GaugeLocation ingo@2869: implements Serializable ingo@2869: { ingo@2869: private Integer id; ingo@2869: private River river; ingo@2869: private String name; ingo@2869: private Point geom; ingo@2869: ingo@2869: ingo@2869: public GaugeLocation() { ingo@2869: } ingo@2869: ingo@2869: ingo@2869: @Id ingo@2869: @Column(name = "id") ingo@2869: public Integer getId() { ingo@2869: return id; ingo@2869: } ingo@2869: ingo@2869: ingo@2869: public void setId(Integer id) { ingo@2869: this.id = id; ingo@2869: } ingo@2869: ingo@2869: ingo@2869: @OneToOne ingo@2869: @JoinColumn(name = "river_id") ingo@2869: public River getRiver() { ingo@2869: return river; ingo@2869: } ingo@2869: ingo@2869: ingo@2869: public void setRiver(River river) { ingo@2869: this.river = river; ingo@2869: } ingo@2869: ingo@2869: ingo@2869: @Column(name = "name") ingo@2869: public String getName() { ingo@2869: return name; ingo@2869: } ingo@2869: ingo@2869: ingo@2869: public void setName(String name) { ingo@2869: this.name = name; ingo@2869: } ingo@2869: ingo@2869: ingo@2869: @Column(name = "geom") ingo@2869: @Type(type = "org.hibernatespatial.GeometryUserType") ingo@2869: public Point getGeom() { ingo@2869: return geom; ingo@2869: } ingo@2869: ingo@2869: ingo@2869: public void setGeom(Point geom) { ingo@2869: this.geom = geom; ingo@2869: } ingo@2869: ingo@2869: ingo@2869: /** ingo@2869: * Returns a list of RiverAxisKm objects for a given river. ingo@2869: * ingo@2869: * @param riverid The ID of a river in the database. ingo@2869: * ingo@2869: * @return a list of RiverAxisKm objects. ingo@2869: */ ingo@2869: public static List getGaugeLocations(int riverid, String name) { ingo@2869: Session session = SessionHolder.HOLDER.get(); ingo@2869: ingo@2869: Query query = session.createQuery( ingo@2869: "from GaugeLocation where river.id =:riverid and name=:name"); ingo@2869: query.setParameter("riverid", riverid); ingo@2869: query.setParameter("name", name); ingo@2869: ingo@2869: List list = query.list(); ingo@2869: ingo@2869: return list; ingo@2869: } ingo@2869: } ingo@2869: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :