Mercurial > dive4elements > river
view flys-backend/src/main/java/de/intevation/flys/model/RiverAxis.java @ 5152:b26465581abf
Add a configurable path prefix to relative DGM path to allways have an absolute path.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Fri, 01 Mar 2013 10:35:38 +0100 |
parents | d4fdd98a04f7 |
children | c1b60f8c3390 |
line wrap: on
line source
package de.intevation.flys.model; import java.io.Serializable; import java.util.List; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.OneToOne; import javax.persistence.Table; import org.hibernate.Session; import org.hibernate.Query; import org.hibernate.annotations.Type; import com.vividsolutions.jts.geom.MultiLineString; import de.intevation.flys.backend.SessionHolder; import de.intevation.flys.model.AxisKind; /** * A river has one axis that is used for calculation. * Additional axes of a river can be used to be painted int maps etc. * which one is the main river axis can be determined over the axis kind. */ @Entity @Table(name = "river_axes") public class RiverAxis implements Serializable { private Integer id; private AxisKind kind; private River river; private MultiLineString geom; public static final int KIND_UNKOWN = 0; public static final int KIND_CURRENT = 1; public static final int KIND_OTHER = 2; public RiverAxis() { } @Id @Column(name = "id") public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } @OneToOne @JoinColumn(name = "river_id") public River getRiver() { return river; } public void setRiver(River river) { this.river = river; } /** * Get kind. * * @return kind as AxisKind. */ @OneToOne @JoinColumn(name = "kind_id") public AxisKind getKind() { return kind; } /** * Set kind. * * @param kind the value to set. */ public void setKind(AxisKind kind) { this.kind = kind; } @Column(name = "geom") @Type(type = "org.hibernatespatial.GeometryUserType") public MultiLineString getGeom() { return geom; } public void setGeom(MultiLineString geom) { this.geom = geom; } public static List<RiverAxis> getRiverAxis(String river) { return getRiverAxis(river, KIND_CURRENT); } public static List<RiverAxis> getRiverAxis(String river, int kind) { Session session = SessionHolder.HOLDER.get(); Query query = session.createQuery( "from RiverAxis where river.name =:river AND kind.id =:kind"); query.setParameter("river", river); query.setParameter("kind", kind); List<RiverAxis> list = query.list(); return list.isEmpty() ? null : list; } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :