# HG changeset patch # User Ingo Weinzierl # Date 1350889346 -7200 # Node ID f63b39799d2d7032fe343074215f860977e15993 # Parent 34337e357a5498293804e82f7f9fd4be16d78759 Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations. diff -r 34337e357a54 -r f63b39799d2d flys-backend/doc/schema/postgresql-minfo.sql --- a/flys-backend/doc/schema/postgresql-minfo.sql Fri Oct 19 13:59:51 2012 +0200 +++ b/flys-backend/doc/schema/postgresql-minfo.sql Mon Oct 22 09:02:26 2012 +0200 @@ -352,6 +352,28 @@ ); +CREATE SEQUENCE MEASUREMENT_STATION_ID_SEQ; +CREATE TABLE measurement_station ( + id int NOT NULL, + name VARCHAR(256) NOT NULL, + river_id int NOT NULL, + station NUMERIC NOT NULL, + range_id int NOT NULL, + measurement_type VARCHAR(64) NOT NULL, + riverside VARCHAR(16), + reference_gauge_id int, + observation_timerange_id int, + operator VARCHAR(64), + comment VARCHAR(512), + PRIMARY KEY (id), + CONSTRAINT fk_ms_river_id FOREIGN KEY (river_id) REFERENCES rivers(id), + CONSTRAINT fk_ms_range_id FOREIGN KEY (range_id) REFERENCES ranges(id), + CONSTRAINT fk_ms_reference_gauge_id FOREIGN KEY (reference_gauge_id) REFERENCES gauges(id), + CONSTRAINT fk_ms_observation_timerange_id FOREIGN KEY (observation_timerange_id) REFERENCES time_intervals(id), + UNIQUE (river_id, station) +); + + CREATE SEQUENCE SQ_RELATION_ID_SEQ; CREATE TABLE sq_relation ( diff -r 34337e357a54 -r f63b39799d2d flys-backend/src/main/java/de/intevation/flys/backend/FLYSCredentials.java --- a/flys-backend/src/main/java/de/intevation/flys/backend/FLYSCredentials.java Fri Oct 19 13:59:51 2012 +0200 +++ b/flys-backend/src/main/java/de/intevation/flys/backend/FLYSCredentials.java Mon Oct 22 09:02:26 2012 +0200 @@ -45,6 +45,7 @@ import de.intevation.flys.model.LocationSystem; import de.intevation.flys.model.MainValue; import de.intevation.flys.model.MainValueType; +import de.intevation.flys.model.MeasurementStation; import de.intevation.flys.model.MorphologicalWidth; import de.intevation.flys.model.MorphologicalWidthValue; import de.intevation.flys.model.NamedMainValue; @@ -155,6 +156,7 @@ Line.class, LocationSystem.class, MainValueType.class, + MeasurementStation.class, MorphologicalWidth.class, MorphologicalWidthValue.class, NamedMainValue.class, diff -r 34337e357a54 -r f63b39799d2d flys-backend/src/main/java/de/intevation/flys/importer/Config.java --- a/flys-backend/src/main/java/de/intevation/flys/importer/Config.java Fri Oct 19 13:59:51 2012 +0200 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/Config.java Mon Oct 22 09:02:26 2012 +0200 @@ -71,6 +71,9 @@ public static final String SKIP_WATERLEVEL_DIFFERENCES = "flys.backend.importer.skip.waterlevel.differences"; + public static final String SKIP_MEASUREMENT_STATIONS = + "flys.backend.importer.skip.measurement.stations"; + public static final String SKIP_SQ_RELATION = "flys.backend.importer.skip.sq.relation"; @@ -175,6 +178,10 @@ return getFlag(SKIP_WATERLEVEL_DIFFERENCES); } + public boolean skipMeasurementStations() { + return getFlag(SKIP_MEASUREMENT_STATIONS); + } + public boolean skipSQRelation() { return getFlag(SKIP_SQ_RELATION); } diff -r 34337e357a54 -r f63b39799d2d flys-backend/src/main/java/de/intevation/flys/importer/ImportMeasurementStation.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportMeasurementStation.java Mon Oct 22 09:02:26 2012 +0200 @@ -0,0 +1,112 @@ +package de.intevation.flys.importer; + +import java.sql.SQLException; +import java.util.List; + +import org.apache.log4j.Logger; +import org.hibernate.Session; +import org.hibernate.exception.ConstraintViolationException; + +import de.intevation.flys.model.Gauge; +import de.intevation.flys.model.MeasurementStation; +import de.intevation.flys.model.Range; +import de.intevation.flys.model.River; +import de.intevation.flys.model.TimeInterval; + + +public class ImportMeasurementStation { + + private static final Logger log = Logger + .getLogger(ImportMeasurementStation.class); + + private MeasurementStation peer; + + public String name; + public Double station; + public ImportRange range; + public String measurementType; + public String riverside; + public String gauge; + public ImportTimeInterval observationTimerange; + public String operator; + public String comment; + + public ImportMeasurementStation() { + } + + private Gauge getGaugeFromDB() { + Session session = ImporterSession.getInstance().getDatabaseSession(); + + org.hibernate.Query query = session + .createQuery("FROM Gauge WHERE name=:name"); + + query.setParameter("name", gauge); + List gauges = query.list(); + + return gauges.isEmpty() ? null : gauges.get(0); + } + + public boolean storeDependencies(River river) throws SQLException, + ConstraintViolationException { + getPeer(river); + + return peer != null; + } + + public Object getPeer(River river) { + if (peer == null) { + Gauge gauge = null; + try { + gauge = getGaugeFromDB(); + if (gauge == null) { + log.warn("Skip measurement station '" + name + + "': unable to find gauge with name '" + this.gauge + + "'"); + return null; + } + } + catch (Exception e) { + log.error("Exception: " + e.getMessage()); + } + + Range range = this.range.getPeer(river); + if (range == null) { + log.warn("Skip measurement station '" + name + + "': unable to get range"); + return null; + } + + TimeInterval observationTimerange = this.observationTimerange + .getPeer(); + if (observationTimerange == null) { + log.warn("Skip measurement station '" + name + + "': unable to get time interval for observation time"); + return null; + } + + Session session = ImporterSession.getInstance() + .getDatabaseSession(); + + org.hibernate.Query query = session + .createQuery("FROM MeasurementStation " + + " WHERE river=:river AND station=:station"); + + query.setParameter("river", river); + query.setParameter("station", station); + + List stations = query.list(); + + if (stations.isEmpty()) { + log.info("create new measurement station '" + name + "'"); + + peer = new MeasurementStation(river, name, measurementType, + riverside, station, range, gauge, observationTimerange, + operator, comment); + + session.save(peer); + } + } + + return peer; + } +} diff -r 34337e357a54 -r f63b39799d2d flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java --- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java Fri Oct 19 13:59:51 2012 +0200 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java Mon Oct 22 09:02:26 2012 +0200 @@ -1,34 +1,8 @@ package de.intevation.flys.importer; -import de.intevation.artifacts.common.utils.FileTools.HashedFile; - -import de.intevation.artifacts.common.utils.FileTools; - -import de.intevation.flys.importer.parsers.AnnotationClassifier; -import de.intevation.flys.importer.parsers.AnnotationsParser; -import de.intevation.flys.importer.parsers.BedHeightEpochParser; -import de.intevation.flys.importer.parsers.BedHeightSingleParser; -import de.intevation.flys.importer.parsers.FlowVelocityMeasurementParser; -import de.intevation.flys.importer.parsers.FlowVelocityModelParser; -import de.intevation.flys.importer.parsers.HYKParser; -import de.intevation.flys.importer.parsers.MorphologicalWidthParser; -import de.intevation.flys.importer.parsers.PRFParser; -import de.intevation.flys.importer.parsers.PegelGltParser; -import de.intevation.flys.importer.parsers.SedimentDensityParser; -import de.intevation.flys.importer.parsers.SedimentYieldParser; -import de.intevation.flys.importer.parsers.SQRelationParser; -import de.intevation.flys.importer.parsers.WaterlevelDifferencesParser; -import de.intevation.flys.importer.parsers.WaterlevelParser; -import de.intevation.flys.importer.parsers.WstParser; - -import de.intevation.flys.model.River; -import de.intevation.flys.model.Unit; - import java.io.File; import java.io.IOException; - import java.sql.SQLException; - import java.util.ArrayList; import java.util.Calendar; import java.util.Date; @@ -38,11 +12,31 @@ import java.util.Set; import org.apache.log4j.Logger; - import org.hibernate.Query; import org.hibernate.Session; +import org.hibernate.exception.ConstraintViolationException; -import org.hibernate.exception.ConstraintViolationException; +import de.intevation.artifacts.common.utils.FileTools; +import de.intevation.artifacts.common.utils.FileTools.HashedFile; +import de.intevation.flys.importer.parsers.AnnotationClassifier; +import de.intevation.flys.importer.parsers.AnnotationsParser; +import de.intevation.flys.importer.parsers.BedHeightEpochParser; +import de.intevation.flys.importer.parsers.BedHeightSingleParser; +import de.intevation.flys.importer.parsers.FlowVelocityMeasurementParser; +import de.intevation.flys.importer.parsers.FlowVelocityModelParser; +import de.intevation.flys.importer.parsers.HYKParser; +import de.intevation.flys.importer.parsers.MeasurementStationsParser; +import de.intevation.flys.importer.parsers.MorphologicalWidthParser; +import de.intevation.flys.importer.parsers.PRFParser; +import de.intevation.flys.importer.parsers.PegelGltParser; +import de.intevation.flys.importer.parsers.SQRelationParser; +import de.intevation.flys.importer.parsers.SedimentDensityParser; +import de.intevation.flys.importer.parsers.SedimentYieldParser; +import de.intevation.flys.importer.parsers.WaterlevelDifferencesParser; +import de.intevation.flys.importer.parsers.WaterlevelParser; +import de.intevation.flys.importer.parsers.WstParser; +import de.intevation.flys.model.River; +import de.intevation.flys.model.Unit; public class ImportRiver { @@ -97,6 +91,10 @@ public static final String MINFO_WATERLEVEL_DIFF_DIR = "Wasserspiegeldifferenzen"; + public static final String MINFO_BASE_DIR = "Basisdaten"; + + public static final String MINFO_CORE_DATA_FILE = "Stammdaten_Messstellen.csv"; + public static final String MINFO_SQ_DIR = "Feststofftransport-Abfluss-Beziehung"; @@ -142,6 +140,8 @@ protected List waterlevelDiffs; + protected List measurementStations; + protected List sqRelations; protected ImportWst wst; @@ -167,6 +167,7 @@ sedimentYields = new ArrayList(); waterlevels = new ArrayList(); waterlevelDiffs = new ArrayList(); + measurementStations = new ArrayList(); sqRelations = new ArrayList(); } @@ -238,6 +239,7 @@ parseSedimentYield(); parseWaterlevels(); parseWaterlevelDifferences(); + parseMeasurementStations(); parseSQRelation(); } @@ -498,6 +500,36 @@ waterlevels = parser.getWaterlevels(); } + protected void parseMeasurementStations() throws IOException { + if (Config.INSTANCE.skipMeasurementStations()) { + log.info("skip parsing measurement stations"); + return; + } + + log.info("Parse measurement stations"); + + File minfo = getMinfoDir(); + File minfoBaseDir = new File(minfo, MINFO_BASE_DIR); + File coredataFile = new File(minfoBaseDir, MINFO_CORE_DATA_FILE); + + if (coredataFile == null || !coredataFile.exists()) { + log.warn("No core data file '" + MINFO_CORE_DATA_FILE + "' found"); + return; + } + + MeasurementStationsParser parser = new MeasurementStationsParser(); + try { + parser.parse(coredataFile); + measurementStations = parser.getMeasurementStations(); + + log.info("Successfully parsed " + measurementStations.size() + " measurement stations."); + } + catch (IOException ioe) { + log.error("unable to parse file '" + coredataFile.getName() + + ": " + ioe.getMessage()); + } + } + protected void parseWaterlevelDifferences() throws IOException { if (Config.INSTANCE.skipWaterlevelDifferences()) { @@ -929,6 +961,7 @@ storeSedimentYield(); storeWaterlevels(); storeWaterlevelDifferences(); + storeMeasurementStations(); storeSQRelations(); } @@ -1224,6 +1257,34 @@ } + public void storeMeasurementStations() { + if (!Config.INSTANCE.skipMeasurementStations()) { + log.info("store measurement stations"); + + River river = getPeer(); + + int count = 0; + + for (ImportMeasurementStation station: measurementStations) { + try { + boolean success = station.storeDependencies(river); + if (success) { + count++; + } + } + catch (SQLException sqle) { + log.error("Error while storing measurement station.", sqle); + } + catch (ConstraintViolationException cve) { + log.error("Error while storing measurement station.", cve); + } + } + + log.info("stored " + count + " measurement stations."); + } + } + + public void storeSQRelations() { if (!Config.INSTANCE.skipSQRelation()) { log.info("store sq relations"); diff -r 34337e357a54 -r f63b39799d2d flys-backend/src/main/java/de/intevation/flys/importer/parsers/FlowVelocityMeasurementParser.java --- a/flys-backend/src/main/java/de/intevation/flys/importer/parsers/FlowVelocityMeasurementParser.java Fri Oct 19 13:59:51 2012 +0200 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/parsers/FlowVelocityMeasurementParser.java Mon Oct 22 09:02:26 2012 +0200 @@ -53,7 +53,7 @@ @Override - protected void handleLine(String line) { + protected void handleLine(int lineNum, String line) { if (line.startsWith(START_META_CHAR)) { handleMetaLine(stripMetaLine(line)); } diff -r 34337e357a54 -r f63b39799d2d flys-backend/src/main/java/de/intevation/flys/importer/parsers/FlowVelocityModelParser.java --- a/flys-backend/src/main/java/de/intevation/flys/importer/parsers/FlowVelocityModelParser.java Fri Oct 19 13:59:51 2012 +0200 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/parsers/FlowVelocityModelParser.java Mon Oct 22 09:02:26 2012 +0200 @@ -72,7 +72,7 @@ @Override - protected void handleLine(String line) { + protected void handleLine(int lineNum, String line) { if (line.startsWith(START_META_CHAR)) { handleMetaLine(stripMetaLine(line)); } diff -r 34337e357a54 -r f63b39799d2d flys-backend/src/main/java/de/intevation/flys/importer/parsers/LineParser.java --- a/flys-backend/src/main/java/de/intevation/flys/importer/parsers/LineParser.java Fri Oct 19 13:59:51 2012 +0200 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/parsers/LineParser.java Mon Oct 22 09:02:26 2012 +0200 @@ -2,6 +2,10 @@ import java.io.File; +import java.text.DateFormat; +import java.text.NumberFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.Locale; @@ -26,7 +30,7 @@ public static final String SEPERATOR_CHAR = ";"; - protected abstract void handleLine(String line); + protected abstract void handleLine(int lineNum, String line); protected abstract void reset(); @@ -52,13 +56,15 @@ new InputStreamReader( new FileInputStream(file), ENCODING)); - String line = null; + String line = null; + int lineNum = 1; while ((line = in.readLine()) != null) { if ((line = line.trim()).length() == 0) { + lineNum++; continue; } - handleLine(line); + handleLine(lineNum++, line); } } finally { @@ -82,6 +88,20 @@ } } + public static double getDouble(String doubleString) throws ParseException { + NumberFormat nf = NumberFormat.getInstance(DEFAULT_LOCALE); + Number value = nf.parse(doubleString); + + return value.doubleValue(); + } + + public static Date getDate(String dateString) throws ParseException { + DateFormat df = SimpleDateFormat.getDateInstance( + SimpleDateFormat.MEDIUM, DEFAULT_LOCALE); + + return df.parse(dateString); + } + public static Date getDateFromYear(int year) { Calendar cal = Calendar.getInstance(); diff -r 34337e357a54 -r f63b39799d2d flys-backend/src/main/java/de/intevation/flys/importer/parsers/MeasurementStationsParser.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/parsers/MeasurementStationsParser.java Mon Oct 22 09:02:26 2012 +0200 @@ -0,0 +1,192 @@ +package de.intevation.flys.importer.parsers; + +import java.math.BigDecimal; +import java.text.ParseException; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import org.apache.log4j.Logger; + +import de.intevation.flys.importer.ImportMeasurementStation; +import de.intevation.flys.importer.ImportRange; +import de.intevation.flys.importer.ImportTimeInterval; + + +public class MeasurementStationsParser extends LineParser { + + public static class MeasurementStationParserException extends Exception { + + private static final long serialVersionUID = 1L; + + public MeasurementStationParserException(String msg) { + super(msg); + } + } + + public static final int MIN_COLUMNS = 10; + + private static final Logger log = Logger + .getLogger(MeasurementStationsParser.class); + + private List measurementStations; + private ImportMeasurementStation current; + + @Override + protected void reset() { + this.measurementStations = new ArrayList(); + } + + @Override + protected void finish() { + } + + @Override + protected void handleLine(int lineNum, String line) { + if (line == null || line.startsWith(START_META_CHAR)) { + log.info("skip meta information at line " + lineNum); + return; + } + + try { + current = new ImportMeasurementStation(); + handleDataLine(line); + measurementStations.add(current); + } + catch (MeasurementStationParserException e) { + log.warn("Problem in line " + lineNum + ": " + e.getMessage()); + } + } + + public List getMeasurementStations() { + return measurementStations; + } + + protected void handleDataLine(String line) + throws MeasurementStationParserException { + String[] cols = line.split(SEPERATOR_CHAR); + + if (cols == null || cols.length < MIN_COLUMNS) { + int num = cols != null ? cols.length : 0; + throw new MeasurementStationParserException("Not enough columns: " + + num); + } + + current.name = getName(cols); + current.station = getStation(cols); + current.range = getRange(cols); + current.measurementType = getMeasurementType(cols); + current.riverside = getRiverside(cols); + current.gauge = getGauge(cols); + current.observationTimerange = getObservationTimerange(cols); + current.operator = getOperator(cols); + current.comment = getComment(cols); + + log.debug("Found new measurement station '" + current.name + "' at km " + + current.station); + } + + protected String getName(String[] cols) + throws MeasurementStationParserException { + if (cols[0] == null || cols[0].length() == 0) { + throw new MeasurementStationParserException("invalid name '" + + cols[0] + "'"); + } + + return cols[0]; + } + + protected double getStation(String[] cols) + throws MeasurementStationParserException { + if (cols[1] == null || cols[1].length() == 0) { + throw new MeasurementStationParserException("invalid station '" + + cols[1] + "'"); + } + + try { + return getDouble(cols[1]); + } + catch (ParseException e) { + throw new MeasurementStationParserException( + "unable to parse station: " + e.getMessage()); + } + } + + protected ImportRange getRange(String[] cols) + throws MeasurementStationParserException { + if (cols[4] == null || cols[4].length() == 0) { + throw new MeasurementStationParserException("invalid lower range '" + + cols[4] + "'"); + } + + if (cols[5] == null || cols[5].length() == 0) { + throw new MeasurementStationParserException("invalid lower range '" + + cols[5] + "'"); + } + + try { + double lower = getDouble(cols[4]); + double upper = getDouble(cols[5]); + + return new ImportRange(new BigDecimal(lower), new BigDecimal(upper)); + } + catch (ParseException e) { + throw new MeasurementStationParserException( + "unable to parse range: " + e.getMessage()); + } + } + + protected String getMeasurementType(String[] cols) + throws MeasurementStationParserException { + if (cols[2] == null || cols[2].length() == 0) { + throw new MeasurementStationParserException( + "invalid measurement type '" + cols[2] + "'"); + } + + return cols[2]; + } + + protected String getRiverside(String[] cols) { + return cols[3]; + } + + protected String getGauge(String[] cols) + throws MeasurementStationParserException { + if (cols[6] == null || cols[6].length() == 0) { + throw new MeasurementStationParserException("invalid gauge '" + + cols[6] + "'"); + } + + return cols[6]; + } + + protected ImportTimeInterval getObservationTimerange(String[] cols) + throws MeasurementStationParserException { + if (cols[8] == null || cols[8].length() == 0) { + throw new MeasurementStationParserException( + "invalid observation time '" + cols[8] + "'"); + } + + try { + Date date = getDate(cols[8]); + + if (date != null) { + return new ImportTimeInterval(date); + } + + throw new MeasurementStationParserException( + "invalid observation time '" + cols[8] + "'"); + } + catch (ParseException pe) { + throw new MeasurementStationParserException(pe.getMessage()); + } + } + + protected String getOperator(String[] cols) { + return cols[9]; + } + + protected String getComment(String[] cols) { + return cols.length > 10 ? cols[10] : null; + } +} diff -r 34337e357a54 -r f63b39799d2d flys-backend/src/main/java/de/intevation/flys/importer/parsers/MorphologicalWidthParser.java --- a/flys-backend/src/main/java/de/intevation/flys/importer/parsers/MorphologicalWidthParser.java Fri Oct 19 13:59:51 2012 +0200 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/parsers/MorphologicalWidthParser.java Mon Oct 22 09:02:26 2012 +0200 @@ -55,7 +55,7 @@ @Override - protected void handleLine(String line) { + protected void handleLine(int lineNum, String line) { if (line.startsWith(START_META_CHAR)) { handleMetaLine(stripMetaLine(line)); } diff -r 34337e357a54 -r f63b39799d2d flys-backend/src/main/java/de/intevation/flys/importer/parsers/SQRelationParser.java --- a/flys-backend/src/main/java/de/intevation/flys/importer/parsers/SQRelationParser.java Fri Oct 19 13:59:51 2012 +0200 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/parsers/SQRelationParser.java Mon Oct 22 09:02:26 2012 +0200 @@ -67,7 +67,7 @@ @Override - protected void handleLine(String line) { + protected void handleLine(int lineNum, String line) { if (line.startsWith(START_META_CHAR)) { handleMetaLine(stripMetaLine(line)); } diff -r 34337e357a54 -r f63b39799d2d flys-backend/src/main/java/de/intevation/flys/importer/parsers/SedimentDensityParser.java --- a/flys-backend/src/main/java/de/intevation/flys/importer/parsers/SedimentDensityParser.java Fri Oct 19 13:59:51 2012 +0200 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/parsers/SedimentDensityParser.java Mon Oct 22 09:02:26 2012 +0200 @@ -72,7 +72,7 @@ @Override - protected void handleLine(String line) { + protected void handleLine(int lineNum, String line) { if (line.startsWith(START_META_CHAR)) { handleMetaLine(stripMetaLine(line)); } diff -r 34337e357a54 -r f63b39799d2d flys-backend/src/main/java/de/intevation/flys/importer/parsers/SedimentYieldParser.java --- a/flys-backend/src/main/java/de/intevation/flys/importer/parsers/SedimentYieldParser.java Fri Oct 19 13:59:51 2012 +0200 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/parsers/SedimentYieldParser.java Mon Oct 22 09:02:26 2012 +0200 @@ -126,7 +126,7 @@ @Override - protected void handleLine(String line) { + protected void handleLine(int lineNum, String line) { if (line.startsWith(START_META_CHAR)) { handleMetaLine(stripMetaLine(line)); } diff -r 34337e357a54 -r f63b39799d2d flys-backend/src/main/java/de/intevation/flys/importer/parsers/WaterlevelDifferencesParser.java --- a/flys-backend/src/main/java/de/intevation/flys/importer/parsers/WaterlevelDifferencesParser.java Fri Oct 19 13:59:51 2012 +0200 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/parsers/WaterlevelDifferencesParser.java Mon Oct 22 09:02:26 2012 +0200 @@ -74,7 +74,7 @@ } @Override - protected void handleLine(String line) { + protected void handleLine(int lineNum, String line) { if (line.startsWith(START_META_CHAR)) { handleMetaLine(stripMetaLine(line)); } diff -r 34337e357a54 -r f63b39799d2d flys-backend/src/main/java/de/intevation/flys/importer/parsers/WaterlevelParser.java --- a/flys-backend/src/main/java/de/intevation/flys/importer/parsers/WaterlevelParser.java Fri Oct 19 13:59:51 2012 +0200 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/parsers/WaterlevelParser.java Mon Oct 22 09:02:26 2012 +0200 @@ -77,7 +77,7 @@ } @Override - protected void handleLine(String line) { + protected void handleLine(int lineNum, String line) { if (line.startsWith(START_META_CHAR)) { handleMetaLine(stripMetaLine(line)); return; diff -r 34337e357a54 -r f63b39799d2d flys-backend/src/main/java/de/intevation/flys/model/MeasurementStation.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/model/MeasurementStation.java Mon Oct 22 09:02:26 2012 +0200 @@ -0,0 +1,156 @@ +package de.intevation.flys.model; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.OneToOne; +import javax.persistence.SequenceGenerator; +import javax.persistence.Table; + + +@Entity +@Table(name = "measurement_station") +public class MeasurementStation { + + private Integer id; + + private String name; + private String measurementType; + private String riverside; + private String operator; + private String comment; + + private Double station; + private Range range; + + private River river; + + private Gauge gauge; + + private TimeInterval observationTimerange; + + public MeasurementStation(River river, String name, String measurementType, + String riverside, Double station, Range range, Gauge gauge, + TimeInterval observationTimerange, String operator, String comment) { + this.river = river; + this.name = name; + this.measurementType = measurementType; + this.riverside = riverside; + this.station = station; + this.range = range; + this.gauge = gauge; + this.observationTimerange = observationTimerange; + this.operator = operator; + this.comment = comment; + } + + @Id + @SequenceGenerator(name = "SEQ_MEASUREMENT_STATION_ID_SEQ", sequenceName = "MEASUREMENT_STATION_ID_SEQ", allocationSize = 1) + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_MEASUREMENT_STATION_ID_SEQ") + @Column(name = "id") + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + @Column(name = "name") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Column(name = "measurement_type") + public String getMeasurementType() { + return measurementType; + } + + public void setMeasurementType(String measurementType) { + this.measurementType = measurementType; + } + + @Column(name = "riverside") + public String getRiverside() { + return riverside; + } + + public void setRiverside(String riverside) { + this.riverside = riverside; + } + + @OneToOne + @JoinColumn(name = "river_id") + public River getRiver() { + return river; + } + + public void setRiver(River river) { + this.river = river; + } + + @OneToOne + @JoinColumn(name = "reference_gauge_id") + public Gauge getGauge() { + return gauge; + } + + public void setGauge(Gauge gauge) { + this.gauge = gauge; + } + + @Column(name = "station") + public Double getStation() { + return station; + } + + public void setStation(Double station) { + this.station = station; + } + + @OneToOne + @JoinColumn(name = "range_id") + public Range getRange() { + return range; + } + + public void setRange(Range range) { + this.range = range; + } + + @OneToOne + @JoinColumn(name = "observation_timerange_id") + public TimeInterval getObservationTimerange() { + return observationTimerange; + } + + public void setObservationTimerange(TimeInterval observationTimerange) { + this.observationTimerange = observationTimerange; + } + + @Column(name = "operator") + public String getOperator() { + return operator; + } + + public void setOperator(String operator) { + this.operator = operator; + } + + @Column(name = "comment") + public String getComment() { + return comment; + } + + public void setComment(String comment) { + this.comment = comment; + } + +}