Mercurial > dive4elements > river
comparison backend/src/main/java/org/dive4elements/river/importer/ImportSedimentLoadLS.java @ 8032:fd3a24336e6a
SCHEMA CHANGE and Importer (only longitudinal section data so far): only grain fractions given now in schema are valid. We are handling sediment loads, not yields.
author | "Tom Gottfried <tom@intevation.de>" |
---|---|
date | Mon, 14 Jul 2014 15:36:44 +0200 |
parents | 6954ac9b7591 |
children | d86cc6a17b7a |
comparison
equal
deleted
inserted
replaced
8031:6954ac9b7591 | 8032:fd3a24336e6a |
---|---|
81 for (ImportSedimentLoadLSValue value : values) { | 81 for (ImportSedimentLoadLSValue value : values) { |
82 value.storeDependencies(peer); | 82 value.storeDependencies(peer); |
83 i++; | 83 i++; |
84 } | 84 } |
85 | 85 |
86 log.info("stored " + i + " sediment yield values."); | 86 log.info("stored " + i + " sediment load values."); |
87 } | 87 } |
88 } | 88 } |
89 | 89 |
90 public SedimentLoadLS getPeer(River river) { | 90 public SedimentLoadLS getPeer(River river) { |
91 log.debug("get peer"); | 91 log.debug("get peer"); |
96 Unit u = unit != null ? unit.getPeer() : null; | 96 Unit u = unit != null ? unit.getPeer() : null; |
97 | 97 |
98 TimeInterval ti = timeInterval != null ? timeInterval.getPeer() : null; | 98 TimeInterval ti = timeInterval != null ? timeInterval.getPeer() : null; |
99 | 99 |
100 if (ti == null || u == null) { | 100 if (ti == null || u == null) { |
101 log.warn("Skip invalid SedimentYield: time interval or unit null!"); | 101 log.warn("Skip invalid SedimentLoadLS: time interval or unit null!"); |
102 return null; | 102 return null; |
103 } | 103 } |
104 | 104 |
105 if (peer == null) { | 105 if (peer == null) { |
106 Session session = ImporterSession.getInstance() | 106 Session session = ImporterSession.getInstance() |
107 .getDatabaseSession(); | 107 .getDatabaseSession(); |
108 Query query = session.createQuery("from SedimentYield where " | 108 Query query = session.createQuery("from SedimentLoadLS where " |
109 + " river=:river and " | 109 + " river=:river and " |
110 + " grainFraction=:grainFraction and " + " unit=:unit and " | 110 + " grainFraction=:grainFraction and " + " unit=:unit and " |
111 + " timeInterval=:timeInterval and " | 111 + " timeInterval=:timeInterval and " |
112 + " description=:description"); | 112 + " description=:description"); |
113 | 113 |
115 query.setParameter("grainFraction", gf); | 115 query.setParameter("grainFraction", gf); |
116 query.setParameter("unit", u); | 116 query.setParameter("unit", u); |
117 query.setParameter("timeInterval", ti); | 117 query.setParameter("timeInterval", ti); |
118 query.setParameter("description", description); | 118 query.setParameter("description", description); |
119 | 119 |
120 List<SedimentLoadLS> yields = query.list(); | 120 List<SedimentLoadLS> loads = query.list(); |
121 if (yields.isEmpty()) { | 121 if (loads.isEmpty()) { |
122 log.debug("create new SedimentYield"); | 122 log.debug("create new SedimentLoadLS"); |
123 | 123 |
124 peer = new SedimentLoadLS(river, u, ti, gf, description); | 124 peer = new SedimentLoadLS(river, u, ti, gf, description); |
125 peer.setKind(this.kind); | 125 peer.setKind(this.kind); |
126 session.save(peer); | 126 session.save(peer); |
127 } | 127 } |
128 else { | 128 else { |
129 peer = yields.get(0); | 129 peer = loads.get(0); |
130 } | 130 } |
131 } | 131 } |
132 | 132 |
133 return peer; | 133 return peer; |
134 } | 134 } |