# HG changeset patch # User Ingo Weinzierl # Date 1337324507 0 # Node ID bcfdaa3a5bfc500b7ca61335d432eeb0a25deffd # Parent 5a89c2b05e6da13ffecc55ab2bf1e9523b878ea0 Added functions to BedHeightSingle and BedHeightEpoch to get instances from db by id or river. flys-backend/trunk@4434 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 5a89c2b05e6d -r bcfdaa3a5bfc flys-backend/ChangeLog --- a/flys-backend/ChangeLog Tue May 15 14:19:55 2012 +0000 +++ b/flys-backend/ChangeLog Fri May 18 07:01:47 2012 +0000 @@ -1,3 +1,9 @@ +2012-05-18 Ingo Weinzierl + + * src/main/java/de/intevation/flys/model/BedHeightEpoch.java, + src/main/java/de/intevation/flys/model/BedHeightSingle.java: Added + functions to get singles and epochs by river and by id. + 2012-05-15 Ingo Weinzierl * src/main/java/de/intevation/flys/model/FlowVelocityModel.java, diff -r 5a89c2b05e6d -r bcfdaa3a5bfc flys-backend/src/main/java/de/intevation/flys/model/BedHeightEpoch.java --- a/flys-backend/src/main/java/de/intevation/flys/model/BedHeightEpoch.java Tue May 15 14:19:55 2012 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/model/BedHeightEpoch.java Fri May 18 07:01:47 2012 +0000 @@ -16,6 +16,11 @@ import javax.persistence.OneToOne; import javax.persistence.OneToMany; +import org.hibernate.Session; +import org.hibernate.Query; + +import de.intevation.flys.backend.SessionHolder; + @Entity @Table(name = "bed_height_epoch") @@ -156,5 +161,31 @@ public void setValues(List values) { this.values = values; } + + + public static List getBedHeightEpochs(River river) { + Session session = SessionHolder.HOLDER.get(); + + Query query = session.createQuery( + "from BedHeightEpoch where river=:river"); + + query.setParameter("river", river); + + return query.list(); + } + + + public static BedHeightEpoch getBedHeightEpochById(int id) { + Session session = SessionHolder.HOLDER.get(); + + Query query = session.createQuery( + "from BedHeightEpoch where id=:id"); + + query.setParameter("id", id); + + List singles = query.list(); + + return singles != null ? singles.get(0) : null; + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 5a89c2b05e6d -r bcfdaa3a5bfc flys-backend/src/main/java/de/intevation/flys/model/BedHeightSingle.java --- a/flys-backend/src/main/java/de/intevation/flys/model/BedHeightSingle.java Tue May 15 14:19:55 2012 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/model/BedHeightSingle.java Fri May 18 07:01:47 2012 +0000 @@ -15,6 +15,11 @@ import javax.persistence.OneToOne; import javax.persistence.OneToMany; +import org.hibernate.Session; +import org.hibernate.Query; + +import de.intevation.flys.backend.SessionHolder; + @Entity @Table(name = "bed_height_single") @@ -216,5 +221,31 @@ public void setValues(List values) { this.values = values; } + + + public static List getBedHeightSingles(River river) { + Session session = SessionHolder.HOLDER.get(); + + Query query = session.createQuery( + "from BedHeightSingle where river=:river"); + + query.setParameter("river", river); + + return query.list(); + } + + + public static BedHeightSingle getBedHeightSingleById(int id) { + Session session = SessionHolder.HOLDER.get(); + + Query query = session.createQuery( + "from BedHeightSingle where id=:id"); + + query.setParameter("id", id); + + List singles = query.list(); + + return singles != null ? singles.get(0) : null; + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :