# HG changeset patch # User Ingo Weinzierl # Date 1337344286 0 # Node ID 444e522229418b2313d5863e25ead46493e6a701 # Parent 3bca80af6918954798800ceab9699abe9d25d59e Added lower and upper km to functions that return bed height singles and epochs for a given river. flys-backend/trunk@4442 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 3bca80af6918 -r 444e52222941 flys-backend/ChangeLog --- a/flys-backend/ChangeLog Fri May 18 11:34:17 2012 +0000 +++ b/flys-backend/ChangeLog Fri May 18 12:31:26 2012 +0000 @@ -1,3 +1,10 @@ +2012-05-18 Ingo Weinzierl + + * src/main/java/de/intevation/flys/model/BedHeightEpoch.java, + src/main/java/de/intevation/flys/model/BedHeightSingle.java: Added lower + and upper km to function that returns all singles and epochs for a given + river. + 2012-05-18 Ingo Weinzierl * src/main/java/de/intevation/flys/model/BedHeightSingleValue.java: Fixed diff -r 3bca80af6918 -r 444e52222941 flys-backend/src/main/java/de/intevation/flys/model/BedHeightEpoch.java --- a/flys-backend/src/main/java/de/intevation/flys/model/BedHeightEpoch.java Fri May 18 11:34:17 2012 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/model/BedHeightEpoch.java Fri May 18 12:31:26 2012 +0000 @@ -163,7 +163,11 @@ } - public static List getBedHeightEpochs(River river) { + public static List getBedHeightEpochs( + River river, + double kmLo, + double kmHi + ) { Session session = SessionHolder.HOLDER.get(); Query query = session.createQuery( @@ -171,7 +175,24 @@ query.setParameter("river", river); - return query.list(); + // TODO Do km range filtering in SQL statement + + List epochs = query.list(); + List good = new ArrayList(); + + for (BedHeightEpoch e: epochs) { + OUTER: + for (BedHeightEpochValue value: e.getValues()) { + double station = value.getStation().doubleValue(); + + if (station >= kmLo && station <= kmHi) { + good.add(e); + continue OUTER; + } + } + } + + return good; } diff -r 3bca80af6918 -r 444e52222941 flys-backend/src/main/java/de/intevation/flys/model/BedHeightSingle.java --- a/flys-backend/src/main/java/de/intevation/flys/model/BedHeightSingle.java Fri May 18 11:34:17 2012 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/model/BedHeightSingle.java Fri May 18 12:31:26 2012 +0000 @@ -2,6 +2,7 @@ import java.io.Serializable; +import java.util.ArrayList; import java.util.List; import javax.persistence.Entity; @@ -223,7 +224,11 @@ } - public static List getBedHeightSingles(River river) { + public static List getBedHeightSingles( + River river, + double kmLo, + double kmHi + ) { Session session = SessionHolder.HOLDER.get(); Query query = session.createQuery( @@ -231,7 +236,24 @@ query.setParameter("river", river); - return query.list(); + // TODO Do km range filtering in SQL statement + + List singles = query.list(); + List good = new ArrayList(); + + for (BedHeightSingle s: singles) { + OUTER: + for (BedHeightSingleValue value: s.getValues()) { + double station = value.getStation().doubleValue(); + + if (station >= kmLo && station <= kmHi) { + good.add(s); + continue OUTER; + } + } + } + + return good; }