comparison flys-backend/src/main/java/de/intevation/flys/importer/ImportTimeInterval.java @ 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 5e3c9027e09c
children c24820c235d9
comparison
equal deleted inserted replaced
5810:dba9e1fa233e 5811:67e07c29dd29
22 public ImportTimeInterval() { 22 public ImportTimeInterval() {
23 } 23 }
24 24
25 public ImportTimeInterval(Date startTime) { 25 public ImportTimeInterval(Date startTime) {
26 this.startTime = startTime; 26 this.startTime = startTime;
27 this.stopTime = null;
27 } 28 }
28 29
29 public ImportTimeInterval(Date startTime, Date stopTime) { 30 public ImportTimeInterval(Date startTime, Date stopTime) {
30 Date start; 31 Date start;
31 Date stop; 32 Date stop;
65 } 66 }
66 67
67 public TimeInterval getPeer() { 68 public TimeInterval getPeer() {
68 if (peer == null) { 69 if (peer == null) {
69 Session session = ImporterSession.getInstance().getDatabaseSession(); 70 Session session = ImporterSession.getInstance().getDatabaseSession();
70 Query query = session.createQuery( 71 if (startTime == null) {
71 "from TimeInterval where startTime=:a and stopTime=:b"); 72 log.error("Null Start time will be ignored.");
73 }
74 Query query;
75 if (stopTime == null) {
76 query = session.createQuery(
77 "from TimeInterval where startTime=:a and stopTime is null");
78 }
79 else {
80 query = session.createQuery(
81 "from TimeInterval where startTime=:a and stopTime=:b");
82 query.setParameter("b", stopTime);
83 }
72 query.setParameter("a", startTime); 84 query.setParameter("a", startTime);
73 query.setParameter("b", stopTime); 85 query.setParameter("b", stopTime);
74 List<TimeInterval> intervals = query.list(); 86 List<TimeInterval> intervals = query.list();
75 if (intervals.isEmpty()) { 87 if (intervals.isEmpty()) {
76 peer = new TimeInterval(startTime, stopTime); 88 peer = new TimeInterval(startTime, stopTime);

http://dive4elements.wald.intevation.org