changeset 5811:67e07c29dd29

ImportTimeInterval: Verbosity increased and fixed bug in getPeer when stoptime is null.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 24 Apr 2013 14:49:00 +0200
parents dba9e1fa233e
children c24820c235d9
files flys-backend/src/main/java/de/intevation/flys/importer/ImportTimeInterval.java
diffstat 1 files changed, 14 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportTimeInterval.java	Wed Apr 24 12:07:03 2013 +0200
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportTimeInterval.java	Wed Apr 24 14:49:00 2013 +0200
@@ -24,6 +24,7 @@
 
     public ImportTimeInterval(Date startTime) {
         this.startTime = startTime;
+        this.stopTime = null;
     }
 
     public ImportTimeInterval(Date startTime, Date stopTime) {
@@ -67,8 +68,19 @@
     public TimeInterval getPeer() {
         if (peer == null) {
             Session session = ImporterSession.getInstance().getDatabaseSession();
-            Query query = session.createQuery(
-                "from TimeInterval where startTime=:a and stopTime=:b");
+            if (startTime == null) {
+                log.error("Null Start time will be ignored.");
+            }
+            Query query;
+            if (stopTime == null) {
+                query = session.createQuery(
+                    "from TimeInterval where startTime=:a and stopTime is null");
+            }
+            else {
+                query = session.createQuery(
+                    "from TimeInterval where startTime=:a and stopTime=:b");
+                query.setParameter("b", stopTime);
+            }
             query.setParameter("a", startTime);
             query.setParameter("b",  stopTime);
             List<TimeInterval> intervals = query.list();

http://dive4elements.wald.intevation.org