# HG changeset patch # User Andre Heinecke # Date 1376575074 -7200 # Node ID a895eb07a7dc8c8b47a7386b1c28388d22862650 # Parent 9da2298ae38081336bfb890841272099ee06f9a1 (issue1353) Add method to model to gauge by number and river name diff -r 9da2298ae380 -r a895eb07a7dc backend/src/main/java/org/dive4elements/river/model/Gauge.java --- a/backend/src/main/java/org/dive4elements/river/model/Gauge.java Thu Aug 15 15:57:13 2013 +0200 +++ b/backend/src/main/java/org/dive4elements/river/model/Gauge.java Thu Aug 15 15:57:54 2013 +0200 @@ -223,7 +223,6 @@ this.mainValues = mainValues; } - public static Gauge getGaugeByOfficialNumber(long number) { Session session = SessionHolder.HOLDER.get(); @@ -237,6 +236,21 @@ return results.isEmpty() ? null : results.get(0); } + public static Gauge getGaugeByOfficialNumber(long number, String river_name) { + Session session = SessionHolder.HOLDER.get(); + + Query query = session.createQuery( + "from Gauge as gau " + + "where gau.officialNumber=:number and gau.river.name=:river_name"); + + query.setParameter("number", number); + query.setParameter("river_name", river_name); + + List results = query.list(); + + return results.isEmpty() ? null : results.get(0); + } + public DischargeTable fetchMasterDischargeTable() { for (DischargeTable dt: dischargeTables) {