Mercurial > dive4elements > river
changeset 5689:a3f7da9bf0d1
Set description when importing flow velocity models
author | Tom Gottfried <tom.gottfried@intevation.de> |
---|---|
date | Fri, 12 Apr 2013 19:51:44 +0200 |
parents | 545a6ace9a19 |
children | b85df73edef0 |
files | flys-backend/src/main/java/de/intevation/flys/importer/ImportFlowVelocityModel.java flys-backend/src/main/java/de/intevation/flys/importer/parsers/FlowVelocityModelParser.java |
diffstat | 2 files changed, 22 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportFlowVelocityModel.java Fri Apr 12 15:08:14 2013 +0200 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportFlowVelocityModel.java Fri Apr 12 19:51:44 2013 +0200 @@ -30,6 +30,12 @@ values = new ArrayList<ImportFlowVelocityModelValue>(); } + public ImportFlowVelocityModel(String description) { + this(); + + this.description = description; + } + public ImportFlowVelocityModel(ImportDischargeZone dischargeZone, String description) { this(); @@ -84,14 +90,12 @@ Query query = session.createQuery("from FlowVelocityModel where " + " dischargeZone=:dischargeZone"); - //query.setParameter("river", river); query.setParameter("dischargeZone", zone); List<FlowVelocityModel> model = query.list(); if (model.isEmpty()) { - //peer = new FlowVelocityModel(river, zone); - peer = new FlowVelocityModel(zone); + peer = new FlowVelocityModel(zone, description); session.save(peer); } else {
--- a/flys-backend/src/main/java/de/intevation/flys/importer/parsers/FlowVelocityModelParser.java Fri Apr 12 15:08:14 2013 +0200 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/parsers/FlowVelocityModelParser.java Fri Apr 12 19:51:44 2013 +0200 @@ -1,5 +1,8 @@ package de.intevation.flys.importer.parsers; +import java.io.File; +import java.io.IOException; + import java.math.BigDecimal; import java.text.NumberFormat; import java.text.ParseException; @@ -49,6 +52,8 @@ private ImportFlowVelocityModel current; + protected String description; + public FlowVelocityModelParser() { models = new ArrayList<ImportFlowVelocityModel>(); @@ -60,14 +65,23 @@ } @Override + public void parse(File file) throws IOException { + description = file.getName(); + + super.parse(file); + } + + @Override protected void reset() { - current = new ImportFlowVelocityModel(); + current = new ImportFlowVelocityModel(description); } @Override protected void finish() { models.add(current); + + // description = null; }