Mercurial > dive4elements > river
comparison flys-backend/src/main/java/de/intevation/flys/importer/ImportSedimentDensity.java @ 5441:7c1dd9c3f6bd
remove unit from sediment density and depths (always t/m3 respectively cm, otherwise a typo)
author | Tom Gottfried <tom.gottfried@intevation.de> |
---|---|
date | Tue, 26 Mar 2013 19:29:39 +0100 |
parents | 4ee97d914501 |
children | 3bd786772798 |
comparison
equal
deleted
inserted
replaced
5440:765013c837b1 | 5441:7c1dd9c3f6bd |
---|---|
19 | 19 |
20 protected SedimentDensity peer; | 20 protected SedimentDensity peer; |
21 | 21 |
22 protected ImportDepth depth; | 22 protected ImportDepth depth; |
23 | 23 |
24 protected ImportUnit unit; | |
25 | |
26 protected String description; | 24 protected String description; |
27 | 25 |
28 protected List<ImportSedimentDensityValue> values; | 26 protected List<ImportSedimentDensityValue> values; |
29 | 27 |
30 public ImportSedimentDensity(String description) { | 28 public ImportSedimentDensity(String description) { |
36 return description; | 34 return description; |
37 } | 35 } |
38 | 36 |
39 public void setDepth(ImportDepth depth) { | 37 public void setDepth(ImportDepth depth) { |
40 this.depth = depth; | 38 this.depth = depth; |
41 } | |
42 | |
43 public void setUnit(ImportUnit unit) { | |
44 this.unit = unit; | |
45 } | 39 } |
46 | 40 |
47 public void addValue(ImportSedimentDensityValue value) { | 41 public void addValue(ImportSedimentDensityValue value) { |
48 values.add(value); | 42 values.add(value); |
49 } | 43 } |
72 log.warn("cannot store sediment density '" + description | 66 log.warn("cannot store sediment density '" + description |
73 + "': no depth"); | 67 + "': no depth"); |
74 return null; | 68 return null; |
75 } | 69 } |
76 | 70 |
77 if (unit == null) { | |
78 log.warn("cannot store sediment density '" + description | |
79 + "': no unit"); | |
80 return null; | |
81 } | |
82 | |
83 if (peer == null) { | 71 if (peer == null) { |
84 Session session = ImporterSession.getInstance() | 72 Session session = ImporterSession.getInstance() |
85 .getDatabaseSession(); | 73 .getDatabaseSession(); |
86 | 74 |
87 Query query = session.createQuery("from SedimentDensity where " | 75 Query query = session.createQuery("from SedimentDensity where " |
88 + " river=:river and " + " depth=:depth and " | 76 + " river=:river and " + " depth=:depth"); |
89 + " unit=:unit"); | |
90 | 77 |
91 query.setParameter("river", river); | 78 query.setParameter("river", river); |
92 query.setParameter("depth", depth.getPeer()); | 79 query.setParameter("depth", depth.getPeer()); |
93 query.setParameter("unit", unit.getPeer()); | |
94 | 80 |
95 List<SedimentDensity> density = query.list(); | 81 List<SedimentDensity> density = query.list(); |
96 | 82 |
97 if (density.isEmpty()) { | 83 if (density.isEmpty()) { |
98 log.debug("Create new SedimentDensity DB instance."); | 84 log.debug("Create new SedimentDensity DB instance."); |
99 | 85 |
100 peer = new SedimentDensity(river, depth.getPeer(), | 86 peer = new SedimentDensity(river, depth.getPeer(), |
101 unit.getPeer(), description); | 87 description); |
102 | 88 |
103 session.save(peer); | 89 session.save(peer); |
104 } | 90 } |
105 else { | 91 else { |
106 peer = density.get(0); | 92 peer = density.get(0); |