Mercurial > dive4elements > river
diff flys-backend/src/main/java/de/intevation/flys/importer/ImportFlowVelocityMeasurement.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 | ac5bd90697c1 |
children | 4ee97d914501 |
line wrap: on
line diff
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportFlowVelocityMeasurement.java Tue Sep 18 15:58:28 2012 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportFlowVelocityMeasurement.java Wed Sep 19 10:05:36 2012 +0000 @@ -16,9 +16,8 @@ public class ImportFlowVelocityMeasurement { - private static final Logger log = - Logger.getLogger(ImportFlowVelocityMeasurement.class); - + private static final Logger log = Logger + .getLogger(ImportFlowVelocityMeasurement.class); private String description; @@ -26,50 +25,44 @@ private FlowVelocityMeasurement peer; - public ImportFlowVelocityMeasurement() { this(null); } - public ImportFlowVelocityMeasurement(String description) { this.description = description; - this.values = new ArrayList<ImportFlowVelocityMeasurementValue>(); + this.values = new ArrayList<ImportFlowVelocityMeasurementValue>(); } - public void setDescription(String description) { this.description = description; } - public void addValue(ImportFlowVelocityMeasurementValue 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"); FlowVelocityMeasurement peer = getPeer(river); - for (ImportFlowVelocityMeasurementValue value: values) { - value.storeDependencies(peer); + if (peer != null) { + for (ImportFlowVelocityMeasurementValue value : values) { + value.storeDependencies(peer); + } } } - public FlowVelocityMeasurement getPeer(River river) { if (peer == null) { - Session session = ImporterSession.getInstance().getDatabaseSession(); + Session session = ImporterSession.getInstance() + .getDatabaseSession(); - Query query = session.createQuery( - "from FlowVelocityMeasurement where " + - " river=:river and " + - " description=:description" - ); + Query query = session + .createQuery("from FlowVelocityMeasurement where " + + " river=:river and " + " description=:description"); query.setParameter("river", river); query.setParameter("description", description);