Mercurial > dive4elements > river
comparison flys-backend/src/main/java/de/intevation/flys/importer/ImportBedHeightSingleValue.java @ 2809:f283212966e8
Finished work on MINFO bed heights (single).
flys-backend/trunk@4221 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 12 Apr 2012 10:42:46 +0000 |
parents | b57c95094b68 |
children | 8926571e47fb |
comparison
equal
deleted
inserted
replaced
2808:b57c95094b68 | 2809:f283212966e8 |
---|---|
1 package de.intevation.flys.importer; | 1 package de.intevation.flys.importer; |
2 | |
3 import java.util.List; | |
2 | 4 |
3 import java.math.BigDecimal; | 5 import java.math.BigDecimal; |
4 | 6 |
7 import org.apache.log4j.Logger; | |
8 | |
9 import org.hibernate.Session; | |
10 import org.hibernate.Query; | |
11 | |
12 import de.intevation.flys.model.BedHeightSingle; | |
13 import de.intevation.flys.model.BedHeightSingleValue; | |
14 | |
5 | 15 |
6 public class ImportBedHeightSingleValue { | 16 public class ImportBedHeightSingleValue { |
17 | |
18 private static final Logger log = | |
19 Logger.getLogger(ImportBedHeightSingleValue.class); | |
20 | |
7 | 21 |
8 protected ImportBedHeightSingle bedHeight; | 22 protected ImportBedHeightSingle bedHeight; |
9 | 23 |
10 protected BigDecimal station; | 24 protected BigDecimal station; |
11 protected BigDecimal height; | 25 protected BigDecimal height; |
12 protected BigDecimal uncertainty; | 26 protected BigDecimal uncertainty; |
13 protected BigDecimal dataGap; | 27 protected BigDecimal dataGap; |
14 protected BigDecimal soundingWidth; | 28 protected BigDecimal soundingWidth; |
15 protected BigDecimal width; | 29 protected BigDecimal width; |
30 | |
31 protected BedHeightSingleValue peer; | |
16 | 32 |
17 | 33 |
18 public ImportBedHeightSingleValue( | 34 public ImportBedHeightSingleValue( |
19 ImportBedHeightSingle bedHeight, | 35 ImportBedHeightSingle bedHeight, |
20 BigDecimal station, | 36 BigDecimal station, |
30 this.uncertainty = uncertainty; | 46 this.uncertainty = uncertainty; |
31 this.dataGap = dataGap; | 47 this.dataGap = dataGap; |
32 this.soundingWidth = soundingWidth; | 48 this.soundingWidth = soundingWidth; |
33 this.width = width; | 49 this.width = width; |
34 } | 50 } |
51 | |
52 | |
53 public void storeDependencies(BedHeightSingle bedHeight) { | |
54 getPeer(bedHeight); | |
55 } | |
56 | |
57 | |
58 public BedHeightSingleValue getPeer(BedHeightSingle bedHeight) { | |
59 if (peer == null) { | |
60 Session session = ImporterSession.getInstance().getDatabaseSession(); | |
61 | |
62 Query query = session.createQuery( | |
63 "from BedHeightSingleValue where " + | |
64 " bedHeight=:bedHeight and " + | |
65 " station=:station and " + | |
66 " height=:height and " + | |
67 " uncertainty=:uncertainty and " + | |
68 " dataGap=:dataGap and " + | |
69 " soundingWidth=:soundingWidth and " + | |
70 " width=:width"); | |
71 | |
72 query.setParameter("bedHeight", bedHeight); | |
73 query.setParameter("station", station); | |
74 query.setParameter("height", height); | |
75 query.setParameter("uncertainty", uncertainty); | |
76 query.setParameter("dataGap", dataGap); | |
77 query.setParameter("soundingWidth", soundingWidth); | |
78 query.setParameter("width", width); | |
79 | |
80 List<BedHeightSingleValue> values = query.list(); | |
81 if (values.isEmpty()) { | |
82 peer = new BedHeightSingleValue( | |
83 bedHeight, | |
84 station, | |
85 height, | |
86 uncertainty, | |
87 dataGap, | |
88 soundingWidth, | |
89 width | |
90 ); | |
91 session.save(peer); | |
92 } | |
93 else { | |
94 peer = values.get(0); | |
95 } | |
96 } | |
97 | |
98 return peer; | |
99 } | |
35 } | 100 } |
36 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 101 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |