# HG changeset patch # User gernotbelger # Date 1525443190 -7200 # Node ID d3bef221b7d924e38be9adaf48933cda49a77b2f # Parent 2be202a8cb893034ba1b0d7ab41db423aad8314d# Parent ddebd4c2fe933495eb2f1b1b0a6e949e930b9c8b sinfo.collision states diff -r 2be202a8cb89 -r d3bef221b7d9 artifacts/doc/conf/artifacts/sinfo.xml --- a/artifacts/doc/conf/artifacts/sinfo.xml Fri May 04 14:50:13 2018 +0200 +++ b/artifacts/doc/conf/artifacts/sinfo.xml Fri May 04 16:13:10 2018 +0200 @@ -3,84 +3,85 @@ - + - - + + - + - - - + + + - - + + - - - + + + - + - - - + + + - + - - - + + + - - - + + + - - + + - + - + - - + + - + @@ -88,50 +89,50 @@ - - - + + + - - - + + + - + - - - + + + - - - - + + + + - + - - + + - + @@ -139,75 +140,75 @@ - - - + + + - - - + + + - + - - - + + + - + - - - + + + - - - - - + + - - - - + + - + + + + + + - - + + - + - - + + - + @@ -217,260 +218,256 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - - + + + + + + - - - - - + + + + + - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + - - + + - + - + - - + + - + - - - - - - - + + + + + + + - - - - - + + + + + - + - - - - - + - - - - - - - - - - - - + + + + + + + + + - + + - - - + + + - + - - - + + + - - - + + + + + + + + + - - - + + + - - + + - + - + - - + + - + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + - - - + + + + + + + + + + + + + + + + + + - - - - - - - + + + + + + + - + - - - + + + - + - + - - - + - - - - - - + + + + + + + + - + - - + + - + - + diff -r 2be202a8cb89 -r d3bef221b7d9 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/collision/CollisionLoadYearEpochAccess.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/collision/CollisionLoadYearEpochAccess.java Fri May 04 16:13:10 2018 +0200 @@ -0,0 +1,34 @@ +/** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde + * Software engineering by + * Björnsen Beratende Ingenieure GmbH + * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt + * + * This file is Free Software under the GNU AGPL (>=v3) + * and comes with ABSOLUTELY NO WARRANTY! Check out the + * documentation coming with Dive4Elements River for details. + */ +package org.dive4elements.river.artifacts.sinfo.collision; + +import org.dive4elements.river.artifacts.D4EArtifact; +import org.dive4elements.river.artifacts.access.RangeAccess; + +/** + * @author Domenico Nardi Tironi + * + */ +public class CollisionLoadYearEpochAccess extends RangeAccess { + + private int[][] epochs; + + private int[] years; + + public CollisionLoadYearEpochAccess(final D4EArtifact artifact) { + // TODO Auto-generated constructor stub + } + + public int[] getYears() { + // TODO Auto-generated method stub + return null; + } + +} diff -r 2be202a8cb89 -r d3bef221b7d9 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/collision/LoadYearSelect.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/collision/LoadYearSelect.java Fri May 04 16:13:10 2018 +0200 @@ -0,0 +1,46 @@ +/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde + * Software engineering by Intevation GmbH + * + * This file is Free Software under the GNU AGPL (>=v3) + * and comes with ABSOLUTELY NO WARRANTY! Check out the + * documentation coming with Dive4Elements River for details. + */ + +package org.dive4elements.river.artifacts.sinfo.collision; + +import org.apache.log4j.Logger; +import org.dive4elements.artifacts.Artifact; +import org.dive4elements.river.artifacts.D4EArtifact; +import org.dive4elements.river.artifacts.states.DefaultState; + +/** State in which to fetch years for sedminent load calculation. */ +public class LoadYearSelect extends DefaultState { + private static final long serialVersionUID = 1L; + /** The log used in this class. */ + private static Logger log = Logger.getLogger(LoadYearSelect.class); + + /** + * The default constructor that initializes an empty State object. + */ + public LoadYearSelect() { + } + + /** Year Select Widget. */ + @Override + protected String getUIProvider() { + return "minfo.sedimentload_year_select"; + } + + @Override + public boolean validate(final Artifact artifact) throws IllegalArgumentException { + final CollisionLoadYearEpochAccess access = new CollisionLoadYearEpochAccess((D4EArtifact) artifact); + + // Second year should be later than first. + if (access.getYears() == null || access.getYears().length == 0) + return true; // TODO: richtig in CollisionLoadYear... implementieren + // throw new IllegalArgumentException("error_years_wrong"); + + return true; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : diff -r 2be202a8cb89 -r d3bef221b7d9 backend/src/main/java/org/dive4elements/river/backend/utils/DateGuesser.java --- a/backend/src/main/java/org/dive4elements/river/backend/utils/DateGuesser.java Fri May 04 14:50:13 2018 +0200 +++ b/backend/src/main/java/org/dive4elements/river/backend/utils/DateGuesser.java Fri May 04 16:13:10 2018 +0200 @@ -13,6 +13,8 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.dive4elements.river.model.TimeInterval; + public final class DateGuesser { public static final String [] MONTH = { "jan", "feb", "mrz", "apr", "mai", "jun", @@ -250,11 +252,12 @@ final Calendar cal = Calendar.getInstance(); final String year = m.group(1); cal.clear(); - cal.set( - Integer.parseInt(year) + (year.length() == 2 ? 1900 : 0), - 5, // month - 15, // day - 12, 0, 0); + cal.set(Integer.parseInt(year) + (year.length() == 2 ? 1900 : 0), + TimeInterval.YEAR_ONLY_DATE.get(Calendar.MONTH), + TimeInterval.YEAR_ONLY_DATE.get(Calendar.DAY_OF_MONTH), + TimeInterval.YEAR_ONLY_DATE.get(Calendar.HOUR_OF_DAY), + TimeInterval.YEAR_ONLY_DATE.get(Calendar.MINUTE), + TimeInterval.YEAR_ONLY_DATE.get(Calendar.SECOND)); return cal.getTime(); } diff -r 2be202a8cb89 -r d3bef221b7d9 backend/src/main/java/org/dive4elements/river/importer/common/AbstractKmLineImport.java --- a/backend/src/main/java/org/dive4elements/river/importer/common/AbstractKmLineImport.java Fri May 04 14:50:13 2018 +0200 +++ b/backend/src/main/java/org/dive4elements/river/importer/common/AbstractKmLineImport.java Fri May 04 16:13:10 2018 +0200 @@ -48,6 +48,9 @@ return this.storeMode; } + public double getStation() { + return this.station; + } /** * Gets the station value record from the database if existing, or creates a database record from this object and adds diff -r 2be202a8cb89 -r d3bef221b7d9 backend/src/main/java/org/dive4elements/river/importer/common/AbstractParser.java --- a/backend/src/main/java/org/dive4elements/river/importer/common/AbstractParser.java Fri May 04 14:50:13 2018 +0200 +++ b/backend/src/main/java/org/dive4elements/river/importer/common/AbstractParser.java Fri May 04 16:13:10 2018 +0200 @@ -304,6 +304,27 @@ } /** + * Logs an info message, appending the relative file path + */ + protected void logInfo(final String message) { + getLog().info(message + ";" + this.rootRelativePath); + } + + /** + * Logs a debug message, appending the relative file path + */ + protected void logDebug(final String message) { + getLog().debug(message + ";" + this.rootRelativePath); + } + + /** + * Logs a trace message, appending the relative file path + */ + protected void logTrace(final String message) { + getLog().trace(message + ";" + this.rootRelativePath); + } + + /** * Creates a new series import object */ protected abstract HEADER createSeriesImport(final String filename); diff -r 2be202a8cb89 -r d3bef221b7d9 backend/src/main/java/org/dive4elements/river/importer/sinfo/parsers/InfrastructureParser.java --- a/backend/src/main/java/org/dive4elements/river/importer/sinfo/parsers/InfrastructureParser.java Fri May 04 14:50:13 2018 +0200 +++ b/backend/src/main/java/org/dive4elements/river/importer/sinfo/parsers/InfrastructureParser.java Fri May 04 16:13:10 2018 +0200 @@ -111,7 +111,7 @@ @Override protected KmMode kmMode() { - return KmMode.NONE; + return KmMode.DUPLICATES; } @Override @@ -205,9 +205,12 @@ logError("Invalid height value in line " + this.in.getLineNumber()); return null; } - if ((this.bankColIndex >= 0) && this.bankAttributes.containsKey(values[this.bankColIndex].trim().toLowerCase())) - return new InfrastructureKmLineImport(km, parseDoubleWithNull(values[this.heightColIndex]).doubleValue(), + if ((this.bankColIndex >= 0) && this.bankAttributes.containsKey(values[this.bankColIndex].trim().toLowerCase())) { + final InfrastructureKmLineImport kmLine = new InfrastructureKmLineImport(km, parseDoubleWithNull(values[this.heightColIndex]).doubleValue(), this.bankAttributes.get(values[this.bankColIndex].trim().toLowerCase())); + logTrace("createKmLineImport(" + km.toString() + ") => " + kmLine.getStation()); + return kmLine; + } else { logError("Invalid bank value in line " + this.in.getLineNumber()); return null; diff -r 2be202a8cb89 -r d3bef221b7d9 backend/src/main/java/org/dive4elements/river/model/TimeInterval.java --- a/backend/src/main/java/org/dive4elements/river/model/TimeInterval.java Fri May 04 14:50:13 2018 +0200 +++ b/backend/src/main/java/org/dive4elements/river/model/TimeInterval.java Fri May 04 16:13:10 2018 +0200 @@ -9,22 +9,33 @@ package org.dive4elements.river.model; import java.io.Serializable; - +import java.util.Calendar; import java.util.Date; +import javax.persistence.Column; import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; import javax.persistence.Id; +import javax.persistence.SequenceGenerator; import javax.persistence.Table; -import javax.persistence.GeneratedValue; -import javax.persistence.Column; -import javax.persistence.SequenceGenerator; -import javax.persistence.GenerationType; @Entity @Table(name = "time_intervals") public class TimeInterval implements Serializable { + /** + * Pseudo-date for Date values where only the year field is significant + * (in Flys 3.2.1 June-15 12:00 had been used) + */ + public final static Calendar YEAR_ONLY_DATE; + static { + YEAR_ONLY_DATE = Calendar.getInstance(); + YEAR_ONLY_DATE.clear(); + YEAR_ONLY_DATE.set(0, Calendar.DECEMBER, 31, 3, 5, 6); + } + private Integer id; private Date startTime; private Date stopTime; @@ -32,43 +43,43 @@ public TimeInterval() { } - public TimeInterval(Date startTime, Date stopTime) { + public TimeInterval(final Date startTime, final Date stopTime) { this.startTime = startTime; this.stopTime = stopTime; } @Id @SequenceGenerator( - name = "SEQUENCE_TIME_INTERVALS_ID_SEQ", - sequenceName = "TIME_INTERVALS_ID_SEQ", - allocationSize = 1) + name = "SEQUENCE_TIME_INTERVALS_ID_SEQ", + sequenceName = "TIME_INTERVALS_ID_SEQ", + allocationSize = 1) @GeneratedValue( - strategy = GenerationType.SEQUENCE, - generator = "SEQUENCE_TIME_INTERVALS_ID_SEQ") + strategy = GenerationType.SEQUENCE, + generator = "SEQUENCE_TIME_INTERVALS_ID_SEQ") @Column(name = "id") public Integer getId() { - return id; + return this.id; } - public void setId(Integer id) { + public void setId(final Integer id) { this.id = id; } @Column(name = "start_time") // FIXME: type mapping needed? public Date getStartTime() { - return startTime; + return this.startTime; } - public void setStartTime(Date startTime) { + public void setStartTime(final Date startTime) { this.startTime = startTime; } @Column(name = "stop_time") // FIXME: type mapping needed? public Date getStopTime() { - return stopTime; + return this.stopTime; } - public void setStopTime(Date stopTime) { + public void setStopTime(final Date stopTime) { this.stopTime = stopTime; } }