comparison backend/src/main/java/org/dive4elements/river/importer/ImportHYKFlowZone.java @ 5838:5aa05a7a34b7

Rename modules to more fitting names.
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 25 Apr 2013 15:23:37 +0200
parents flys-backend/src/main/java/org/dive4elements/river/importer/ImportHYKFlowZone.java@18619c1e7c2a
children 4dd33b86dc61
comparison
equal deleted inserted replaced
5837:d9901a08d0a6 5838:5aa05a7a34b7
1 package org.dive4elements.river.importer;
2
3 import org.dive4elements.river.model.HYKFormation;
4 import org.dive4elements.river.model.HYKFlowZone;
5 import org.dive4elements.river.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 void storeDependencies() {
47 getPeer();
48 }
49
50 public HYKFlowZone getPeer() {
51 if (peer == null) {
52 HYKFormation f = formation.getPeer();
53 HYKFlowZoneType t = type.getPeer();
54 Session session = ImporterSession.getInstance()
55 .getDatabaseSession();
56 Query query = session.createQuery(
57 "from HYKFlowZone where formation=:formation " +
58 "and type=:type and a=:a and b=:b");
59 query.setParameter("formation", f);
60 query.setParameter("type", t);
61 query.setParameter("a", a);
62 query.setParameter("b", b);
63 List<HYKFlowZone> zones = query.list();
64 if (zones.isEmpty()) {
65 peer = new HYKFlowZone(f, t, a, b);
66 session.save(peer);
67 }
68 else {
69 peer = zones.get(0);
70 }
71
72 }
73 return peer;
74 }
75 }
76 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org