Mercurial > dive4elements > river
diff flys-backend/src/main/java/de/intevation/flys/importer/ImportSedimentYield.java @ 3943:a5b003595d6c
Store minfo values into database only if their peer has been successfully stored.
flys-backend/trunk@5520 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 19 Sep 2012 10:05:36 +0000 |
parents | 71175502d868 |
children | 4ee97d914501 |
line wrap: on
line diff
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportSedimentYield.java Tue Sep 18 15:58:28 2012 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportSedimentYield.java Wed Sep 19 10:05:36 2012 +0000 @@ -33,36 +33,29 @@ private SedimentYield peer; - public ImportSedimentYield(String description) { - this.values = new ArrayList<ImportSedimentYieldValue>(); + this.values = new ArrayList<ImportSedimentYieldValue>(); this.description = description; } - public void setTimeInterval(ImportTimeInterval timeInterval) { this.timeInterval = timeInterval; } - public void setUnit(ImportUnit unit) { this.unit = unit; } - public void setGrainFraction(ImportGrainFraction grainFraction) { this.grainFraction = grainFraction; } - public void addValue(ImportSedimentYieldValue value) { this.values.add(value); } - - public void storeDependencies(River river) - throws SQLException, ConstraintViolationException - { + public void storeDependencies(River river) throws SQLException, + ConstraintViolationException { log.debug("store dependencies"); if (grainFraction != null) { @@ -71,22 +64,22 @@ SedimentYield peer = getPeer(river); - int i = 0; + if (peer != null) { + int i = 0; - for (ImportSedimentYieldValue value: values) { - value.storeDependencies(peer); - i++; + for (ImportSedimentYieldValue value : values) { + value.storeDependencies(peer); + i++; + } + + log.info("stored " + i + " sediment yield values."); } - - log.info("stored " + i + " sediment yield values."); } - public SedimentYield getPeer(River river) { log.debug("get peer"); - GrainFraction gf = grainFraction != null - ? grainFraction.getPeer() + GrainFraction gf = grainFraction != null ? grainFraction.getPeer() : null; Unit u = unit != null ? unit.getPeer() : null; @@ -99,15 +92,13 @@ } if (peer == null) { - Session session = ImporterSession.getInstance().getDatabaseSession(); - Query query = session.createQuery( - "from SedimentYield where " + - " river=:river and " + - " grainFraction=:grainFraction and " + - " unit=:unit and " + - " timeInterval=:timeInterval and " + - " description=:description" - ); + Session session = ImporterSession.getInstance() + .getDatabaseSession(); + Query query = session.createQuery("from SedimentYield where " + + " river=:river and " + + " grainFraction=:grainFraction and " + " unit=:unit and " + + " timeInterval=:timeInterval and " + + " description=:description"); query.setParameter("river", river); query.setParameter("grainFraction", gf);