Mercurial > dive4elements > river
changeset 2366:2246348ff90e
Added functions that return lists of Buildings/Fixpoints to according classes.
flys-backend/trunk@3223 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 10 Nov 2011 13:58:33 +0000 |
parents | 60532f75396b |
children | 418a0918863b |
files | flys-backend/ChangeLog flys-backend/src/main/java/de/intevation/flys/model/Building.java flys-backend/src/main/java/de/intevation/flys/model/Fixpoint.java |
diffstat | 3 files changed, 38 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-backend/ChangeLog Thu Nov 10 13:35:31 2011 +0000 +++ b/flys-backend/ChangeLog Thu Nov 10 13:58:33 2011 +0000 @@ -1,3 +1,9 @@ +2011-11-10 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/model/Building.java, + src/main/java/de/intevation/flys/model/Fixpoint.java: Added functions + that return a list of Buildings/Fixpoints for a given river. + 2011-11-10 Ingo Weinzierl <ingo@intevation.de> * doc/schema/oracle-spatial.sql,
--- a/flys-backend/src/main/java/de/intevation/flys/model/Building.java Thu Nov 10 13:35:31 2011 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/model/Building.java Thu Nov 10 13:58:33 2011 +0000 @@ -1,6 +1,7 @@ package de.intevation.flys.model; import java.io.Serializable; +import java.util.List; import javax.persistence.Column; import javax.persistence.Entity; @@ -9,10 +10,14 @@ 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.LineString; +import de.intevation.flys.backend.SessionHolder; + @Entity @Table(name = "buildings") @@ -73,5 +78,16 @@ public void setGeom(LineString geom) { this.geom = geom; } + + + public static List<Building> getBuildings(int riverId) { + Session session = SessionHolder.HOLDER.get(); + + Query query = session.createQuery( + "from Building where river.id =:river_id"); + query.setParameter("river_id", riverId); + + return query.list(); + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-backend/src/main/java/de/intevation/flys/model/Fixpoint.java Thu Nov 10 13:35:31 2011 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/model/Fixpoint.java Thu Nov 10 13:58:33 2011 +0000 @@ -2,6 +2,7 @@ import java.io.Serializable; import java.math.BigDecimal; +import java.util.List; import javax.persistence.Column; import javax.persistence.Entity; @@ -10,10 +11,14 @@ 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.Point; +import de.intevation.flys.backend.SessionHolder; + @Entity @Table(name = "fixpoints") @@ -110,5 +115,16 @@ public void setGeom(Point geom) { this.geom = geom; } + + + public static List<Fixpoint> getFixpoints(int riverId) { + Session session = SessionHolder.HOLDER.get(); + + Query query = session.createQuery( + "from Fixpoint where river.id =:river_id"); + query.setParameter("river_id", riverId); + + return query.list(); + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :