# HG changeset patch # User Ingo Weinzierl # Date 1320933513 0 # Node ID 2246348ff90e9fe0e7c3223a247fcc92513c95f5 # Parent 60532f75396b566d5200e2df999734ec5b972d17 Added functions that return lists of Buildings/Fixpoints to according classes. flys-backend/trunk@3223 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 60532f75396b -r 2246348ff90e flys-backend/ChangeLog --- 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 + + * 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 * doc/schema/oracle-spatial.sql, diff -r 60532f75396b -r 2246348ff90e flys-backend/src/main/java/de/intevation/flys/model/Building.java --- 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 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 : diff -r 60532f75396b -r 2246348ff90e flys-backend/src/main/java/de/intevation/flys/model/Fixpoint.java --- 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 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 :