Mercurial > dive4elements > river
changeset 5888:a763fb7aa2e5
Backend: Fixed indentation.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 02 May 2013 17:58:16 +0200 |
parents | 88fca576e9e6 |
children | 65ebae00fb76 6ea004d51203 |
files | backend/src/main/java/org/dive4elements/river/importer/ImportDischargeTable.java |
diffstat | 1 files changed, 28 insertions(+), 30 deletions(-) [+] |
line wrap: on
line diff
--- a/backend/src/main/java/org/dive4elements/river/importer/ImportDischargeTable.java Thu May 02 17:55:01 2013 +0200 +++ b/backend/src/main/java/org/dive4elements/river/importer/ImportDischargeTable.java Thu May 02 17:58:16 2013 +0200 @@ -76,41 +76,39 @@ this.timeInterval = timeInterval; } - public DischargeTable getPeer(Gauge gauge) { - if (peer == null) { - TimeInterval ti = timeInterval != null - ? timeInterval.getPeer() - : null; - Session session = ImporterSession.getInstance().getDatabaseSession(); - - String timeIntervalQuery = ti != null - ? "timeInterval=:interval" - : "timeInterval is null"; - - Query query = session.createQuery( + if (peer == null) { + TimeInterval ti = timeInterval != null + ? timeInterval.getPeer() + : null; + Session session = ImporterSession.getInstance().getDatabaseSession(); + + String timeIntervalQuery = ti != null + ? "timeInterval=:interval" + : "timeInterval is null"; + + Query query = session.createQuery( "from DischargeTable where " + "gauge.id=:gauge and kind=:kind and " + "description=:description and " + timeIntervalQuery); - query.setParameter("gauge", gauge.getId()); - query.setParameter("description", description); - query.setParameter("kind", kind); - if (ti != null) { - query.setParameter("interval", ti); - } - - List<DischargeTable> dischargeTables = query.list(); - if (dischargeTables.isEmpty()) { - peer = new DischargeTable(gauge, description, null, kind, ti); - session.save(peer); - } - else { - peer = dischargeTables.get(0); - } - } - - return peer; + query.setParameter("gauge", gauge.getId()); + query.setParameter("description", description); + query.setParameter("kind", kind); + if (ti != null) { + query.setParameter("interval", ti); + } + + List<DischargeTable> dischargeTables = query.list(); + if (dischargeTables.isEmpty()) { + peer = new DischargeTable(gauge, description, null, kind, ti); + session.save(peer); + } + else { + peer = dischargeTables.get(0); + } + } + return peer; }