# HG changeset patch # User Tom Gottfried # Date 1370949438 -7200 # Node ID 3d8f9e3bbf2e294f78360518fcc0a758dbeb0267 # Parent e7526a074c0d5c692186c30444826e3d34730645# Parent 24be0cc1c67cf11ee1fd66023dcb041b9c77f752 merged changes from default into double-precision branch diff -r 24be0cc1c67c -r 3d8f9e3bbf2e backend/doc/schema/oracle-minfo.sql --- a/backend/doc/schema/oracle-minfo.sql Tue Jun 11 12:57:51 2013 +0200 +++ b/backend/doc/schema/oracle-minfo.sql Tue Jun 11 13:17:18 2013 +0200 @@ -85,12 +85,12 @@ CREATE TABLE bed_height_single_values ( id NUMBER(38,0) NOT NULL, bed_height_single_id NUMBER(38,0) NOT NULL, - station NUMBER(38,2) NOT NULL, - height NUMBER(38,2), - uncertainty NUMBER(38,2), - data_gap NUMBER(38,2), - sounding_width NUMBER(38,2), - width NUMBER(38,2), + station DOUBLE PRECISION NOT NULL, + height DOUBLE PRECISION, + uncertainty DOUBLE PRECISION, + data_gap DOUBLE PRECISION, + sounding_width DOUBLE PRECISION, + width DOUBLE PRECISION, PRIMARY KEY(id), UNIQUE (station, bed_height_single_id), CONSTRAINT fk_bed_single_values_parent FOREIGN KEY (bed_height_single_id) REFERENCES bed_height_single(id) ON DELETE CASCADE diff -r 24be0cc1c67c -r 3d8f9e3bbf2e backend/src/main/java/org/dive4elements/river/importer/ImportBedHeightSingleValue.java --- a/backend/src/main/java/org/dive4elements/river/importer/ImportBedHeightSingleValue.java Tue Jun 11 12:57:51 2013 +0200 +++ b/backend/src/main/java/org/dive4elements/river/importer/ImportBedHeightSingleValue.java Tue Jun 11 13:17:18 2013 +0200 @@ -29,24 +29,24 @@ protected ImportBedHeightSingle bedHeight; - protected BigDecimal station; - protected BigDecimal height; - protected BigDecimal uncertainty; - protected BigDecimal dataGap; + protected Double station; + protected Double height; + protected Double uncertainty; + protected Double dataGap; protected BigDecimal soundingWidth; - protected BigDecimal width; + protected Double width; protected BedHeightSingleValue peer; public ImportBedHeightSingleValue( ImportBedHeightSingle bedHeight, - BigDecimal station, - BigDecimal height, - BigDecimal uncertainty, - BigDecimal dataGap, + Double station, + Double height, + Double uncertainty, + Double dataGap, BigDecimal soundingWidth, - BigDecimal width + Double width ) { this.bedHeight = bedHeight; this.station = station; diff -r 24be0cc1c67c -r 3d8f9e3bbf2e backend/src/main/java/org/dive4elements/river/importer/parsers/BedHeightParser.java --- a/backend/src/main/java/org/dive4elements/river/importer/parsers/BedHeightParser.java Tue Jun 11 12:57:51 2013 +0200 +++ b/backend/src/main/java/org/dive4elements/river/importer/parsers/BedHeightParser.java Tue Jun 11 13:17:18 2013 +0200 @@ -19,6 +19,7 @@ import java.util.Calendar; import java.util.Date; import java.util.List; +import java.util.TreeSet; import java.util.Locale; import java.util.regex.Matcher; @@ -40,6 +41,7 @@ import org.dive4elements.river.importer.ImportUnit; import org.dive4elements.river.model.BedHeightType; import org.dive4elements.river.importer.ImporterSession; +import org.dive4elements.river.utils.EpsilonComparator; public abstract class BedHeightParser { @@ -98,10 +100,12 @@ String line ); + protected TreeSet kmExists; public BedHeightParser() { - this.bedHeights = new ArrayList(); + bedHeights = new ArrayList(); + kmExists = new TreeSet(EpsilonComparator.CMP); } @@ -115,6 +119,8 @@ ImportBedHeight obj = newImportBedHeight(file.getName().replaceAll("\\.csv", "")); + kmExists.clear(); + LineNumberReader in = null; try { in = diff -r 24be0cc1c67c -r 3d8f9e3bbf2e backend/src/main/java/org/dive4elements/river/importer/parsers/BedHeightSingleParser.java --- a/backend/src/main/java/org/dive4elements/river/importer/parsers/BedHeightSingleParser.java Tue Jun 11 12:57:51 2013 +0200 +++ b/backend/src/main/java/org/dive4elements/river/importer/parsers/BedHeightSingleParser.java Tue Jun 11 13:17:18 2013 +0200 @@ -46,11 +46,21 @@ return; } - BigDecimal km; + Double km; try { - km = new BigDecimal(nf.parse(values[0]).doubleValue()); - } + km = new Double(nf.parse(values[0]).doubleValue()); + + Double key = Double.valueOf(km); + + if (kmExists.contains(key)) { + log.warn("duplicate station '" + km + "': -> ignored"); + return; + } + + kmExists.add(key); + } + catch (ParseException e) { // We expect a lot of ";;;;;;" lines. //log.warn("BSP: Error while parsing km of data row.", e); @@ -76,11 +86,11 @@ ImportBedHeightSingleValue value = new ImportBedHeightSingleValue( (ImportBedHeightSingle) obj, km, - new BigDecimal(nf.parse(values[1]).doubleValue()), - new BigDecimal(nf.parse(values[2]).doubleValue()), - new BigDecimal(nf.parse(values[3]).doubleValue()), + new Double(nf.parse(values[1]).doubleValue()), + new Double(nf.parse(values[2]).doubleValue()), + new Double(nf.parse(values[3]).doubleValue()), parseBigDecimal(values[4], line), - new BigDecimal(nf.parse(values[5]).doubleValue()) + new Double(nf.parse(values[5]).doubleValue()) ); obj.addValue(value); diff -r 24be0cc1c67c -r 3d8f9e3bbf2e backend/src/main/java/org/dive4elements/river/model/BedHeightSingleValue.java --- a/backend/src/main/java/org/dive4elements/river/model/BedHeightSingleValue.java Tue Jun 11 12:57:51 2013 +0200 +++ b/backend/src/main/java/org/dive4elements/river/model/BedHeightSingleValue.java Tue Jun 11 13:17:18 2013 +0200 @@ -43,12 +43,12 @@ private BedHeightSingle bedHeight; - private BigDecimal station; - private BigDecimal height; - private BigDecimal uncertainty; - private BigDecimal dataGap; + private Double station; + private Double height; + private Double uncertainty; + private Double dataGap; private BigDecimal soundingWidth; - private BigDecimal width; + private Double width; public BedHeightSingleValue() { @@ -56,12 +56,12 @@ public BedHeightSingleValue( BedHeightSingle bedHeight, - BigDecimal station, - BigDecimal height, - BigDecimal uncertainty, - BigDecimal dataGap, + Double station, + Double height, + Double uncertainty, + Double dataGap, BigDecimal soundingWidth, - BigDecimal width + Double width ) { this.bedHeight = bedHeight; this.station = station; @@ -100,38 +100,38 @@ } @Column(name = "station") - public BigDecimal getStation() { + public Double getStation() { return station; } - public void setStation(BigDecimal station) { + public void setStation(Double station) { this.station = station; } @Column(name = "height") - public BigDecimal getHeight() { + public Double getHeight() { return height; } - public void setHeight(BigDecimal height) { + public void setHeight(Double height) { this.height = height; } @Column(name="uncertainty") - public BigDecimal getUncertainty() { + public Double getUncertainty() { return uncertainty; } - public void setUncertainty(BigDecimal uncertainty) { + public void setUncertainty(Double uncertainty) { this.uncertainty = uncertainty; } @Column(name="data_gap") - public BigDecimal getDataGap() { + public Double getDataGap() { return dataGap; } - public void setDataGap(BigDecimal dataGap) { + public void setDataGap(Double dataGap) { this.dataGap = dataGap; } @@ -145,11 +145,11 @@ } @Column(name="width") - public BigDecimal getWidth() { + public Double getWidth() { return width; } - public void setWidth(BigDecimal width) { + public void setWidth(Double width) { this.width = width; } @@ -166,8 +166,8 @@ " and station >= :kmLo and station <= :kmHi"); query.setParameter("single", single); - query.setParameter("kmLo", new BigDecimal(kmLo)); - query.setParameter("kmHi", new BigDecimal(kmHi)); + query.setParameter("kmLo", new Double(kmLo)); + query.setParameter("kmHi", new Double(kmHi)); return query.list(); }