Mercurial > dive4elements > river
comparison flys-backend/src/main/java/de/intevation/flys/importer/ImportTimeInterval.java @ 486:8ea09ec7f0c8
Importer: Attach a time interval to a discharge table if we find one during import.
flys-backend/trunk@1813 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 03 May 2011 17:34:52 +0000 |
parents | |
children | cf513cbe88c3 |
comparison
equal
deleted
inserted
replaced
485:6b231041dc18 | 486:8ea09ec7f0c8 |
---|---|
1 package de.intevation.flys.importer; | |
2 | |
3 import de.intevation.flys.model.TimeInterval; | |
4 | |
5 import org.hibernate.Session; | |
6 import org.hibernate.Query; | |
7 | |
8 import java.util.List; | |
9 import java.util.Date; | |
10 | |
11 public class ImportTimeInterval | |
12 { | |
13 protected Date startTime; | |
14 protected Date stopTime; | |
15 | |
16 protected TimeInterval peer; | |
17 | |
18 public ImportTimeInterval() { | |
19 } | |
20 | |
21 public ImportTimeInterval(Date startTime, Date stopTime) { | |
22 this.startTime = startTime; | |
23 this.stopTime = stopTime; | |
24 } | |
25 | |
26 public Date getStartTime() { | |
27 return startTime; | |
28 } | |
29 | |
30 public void setStartTime(Date startTime) { | |
31 this.startTime = startTime; | |
32 } | |
33 | |
34 public Date getStopTime() { | |
35 return stopTime; | |
36 } | |
37 | |
38 public void setStopTime(Date stopTime) { | |
39 this.stopTime = stopTime; | |
40 } | |
41 | |
42 public TimeInterval getPeer() { | |
43 if (peer != null) { | |
44 Session session = Importer.sessionHolder.get(); | |
45 Query query = session.createQuery( | |
46 "from TimeInterval where startTime=:a and stopTime=:b"); | |
47 query.setParameter("a", startTime); | |
48 query.setParameter("b", stopTime); | |
49 List<TimeInterval> intervals = query.list(); | |
50 if (intervals.isEmpty()) { | |
51 peer = new TimeInterval(startTime, stopTime); | |
52 session.save(peer); | |
53 } | |
54 } | |
55 return peer; | |
56 } | |
57 } | |
58 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |