Mercurial > dive4elements > river
comparison flys-backend/src/main/java/de/intevation/flys/importer/ImportHYKFlowZone.java @ 1218:00e37d22a589
Added importer models for HYKs.
flys-backend/trunk@2344 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Sun, 17 Jul 2011 19:03:33 +0000 |
parents | |
children | 979ff070e368 |
comparison
equal
deleted
inserted
replaced
1217:d5e39c16fd2a | 1218:00e37d22a589 |
---|---|
1 package de.intevation.flys.importer; | |
2 | |
3 import de.intevation.flys.model.HYKFormation; | |
4 import de.intevation.flys.model.HYKFlowZone; | |
5 import de.intevation.flys.model.HYKFlowZoneType; | |
6 | |
7 import org.hibernate.Session; | |
8 import org.hibernate.Query; | |
9 | |
10 import java.util.List; | |
11 | |
12 import java.math.BigDecimal; | |
13 | |
14 public class ImportHYKFlowZone | |
15 { | |
16 protected ImportHYKFormation formation; | |
17 protected ImportHYKFlowZoneType type; | |
18 protected BigDecimal a; | |
19 protected BigDecimal b; | |
20 | |
21 protected HYKFlowZone peer; | |
22 | |
23 public ImportHYKFlowZone() { | |
24 } | |
25 | |
26 public ImportHYKFlowZone( | |
27 ImportHYKFormation formation, | |
28 ImportHYKFlowZoneType type, | |
29 BigDecimal a, | |
30 BigDecimal b | |
31 ) { | |
32 this.formation = formation; | |
33 this.type = type; | |
34 this.a = a; | |
35 this.b = b; | |
36 } | |
37 | |
38 public ImportHYKFormation getFormation() { | |
39 return formation; | |
40 } | |
41 | |
42 public void setFormation(ImportHYKFormation formation) { | |
43 this.formation = formation; | |
44 } | |
45 | |
46 public HYKFlowZone getPeer() { | |
47 if (peer == null) { | |
48 HYKFormation f = formation.getPeer(); | |
49 HYKFlowZoneType t = type.getPeer(); | |
50 Session session = ImporterSession.getInstance() | |
51 .getDatabaseSession(); | |
52 Query query = session.createQuery( | |
53 "from HYKFlowZone where formation=:formation " + | |
54 "and type=:type and a=:a and b=:b"); | |
55 query.setParameter("formation", f); | |
56 query.setParameter("type", t); | |
57 query.setParameter("a", a); | |
58 query.setParameter("b", b); | |
59 List<HYKFlowZone> zones = query.list(); | |
60 if (zones.isEmpty()) { | |
61 peer = new HYKFlowZone(f, t, a, b); | |
62 session.save(peer); | |
63 } | |
64 else { | |
65 peer = zones.get(0); | |
66 } | |
67 | |
68 } | |
69 return peer; | |
70 } | |
71 } | |
72 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |