# HG changeset patch # User "Tom Gottfried " # Date 1424081313 -3600 # Node ID 6d8d7425a6b5b1bb4f67962755c0e4aa3e448d30 # Parent d0ea092a32f51730c5399fbcdcabcfc7488f15a2 Bed heights are just bed heights since a while ('single' is obsolete). diff -r d0ea092a32f5 -r 6d8d7425a6b5 artifacts/src/main/java/org/dive4elements/river/artifacts/access/BedHeightAccess.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/access/BedHeightAccess.java Mon Feb 16 10:12:12 2015 +0100 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/access/BedHeightAccess.java Mon Feb 16 11:08:33 2015 +0100 @@ -49,7 +49,7 @@ } - public int[] getBedHeightSingleIDs() { + public int[] getBedHeightIDs() { if (singleIDs == null) { String data = getString("soundings"); @@ -58,7 +58,7 @@ return null; } else { - log.debug("getBedHeightSingleIDs(): data=" + data); + log.debug("getBedHeightIDs(): data=" + data); } String[] parts = data.split(";"); diff -r d0ea092a32f5 -r 6d8d7425a6b5 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffHeightMinFacet.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffHeightMinFacet.java Mon Feb 16 10:12:12 2015 +0100 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffHeightMinFacet.java Mon Feb 16 11:08:33 2015 +0100 @@ -5,7 +5,7 @@ import org.dive4elements.artifacts.Artifact; import org.dive4elements.artifacts.CallContext; -import org.dive4elements.river.model.BedHeightSingle; +import org.dive4elements.river.model.BedHeight; import org.dive4elements.river.artifacts.D4EArtifact; import org.dive4elements.river.artifacts.access.RiverAccess; @@ -46,7 +46,7 @@ if (resultData != null && resultData.length > index) { BedDiffYearResult data = resultData[index]; - BedHeightSingle first = BedHeightSingle.getBedHeightSingleById( + BedHeight first = BedHeight.getBedHeightById( data.getIdFirst()); this.addMetaData(Resources.getMsg( context.getMeta(), diff -r d0ea092a32f5 -r 6d8d7425a6b5 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffHeightMinFilterFacet.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffHeightMinFilterFacet.java Mon Feb 16 10:12:12 2015 +0100 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffHeightMinFilterFacet.java Mon Feb 16 11:08:33 2015 +0100 @@ -14,7 +14,7 @@ import org.dive4elements.artifacts.Artifact; import org.dive4elements.artifacts.CallContext; -import org.dive4elements.river.model.BedHeightSingle; +import org.dive4elements.river.model.BedHeight; import org.dive4elements.river.artifacts.D4EArtifact; import org.dive4elements.river.artifacts.access.RiverAccess; @@ -68,7 +68,7 @@ Resources.getMsg(context.getMeta(), "chart.subtitle.radius", new Object[] { radius }), ""); - BedHeightSingle first = BedHeightSingle.getBedHeightSingleById( + BedHeight first = BedHeight.getBedHeightById( oldData.getIdFirst()); this.addMetaData(Resources.getMsg( context.getMeta(), diff -r d0ea092a32f5 -r 6d8d7425a6b5 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffHeightSubFacet.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffHeightSubFacet.java Mon Feb 16 10:12:12 2015 +0100 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffHeightSubFacet.java Mon Feb 16 11:08:33 2015 +0100 @@ -5,7 +5,7 @@ import org.dive4elements.artifacts.Artifact; import org.dive4elements.artifacts.CallContext; -import org.dive4elements.river.model.BedHeightSingle; +import org.dive4elements.river.model.BedHeight; import org.dive4elements.river.artifacts.D4EArtifact; import org.dive4elements.river.artifacts.access.RiverAccess; @@ -46,7 +46,7 @@ if (resultData != null && resultData.length > index) { BedDiffYearResult data = resultData[index]; - BedHeightSingle second = BedHeightSingle.getBedHeightSingleById( + BedHeight second = BedHeight.getBedHeightById( data.getIdSecond()); this.addMetaData(Resources.getMsg( context.getMeta(), diff -r d0ea092a32f5 -r 6d8d7425a6b5 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffHeightSubFilterFacet.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffHeightSubFilterFacet.java Mon Feb 16 10:12:12 2015 +0100 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffHeightSubFilterFacet.java Mon Feb 16 11:08:33 2015 +0100 @@ -14,7 +14,7 @@ import org.dive4elements.artifacts.Artifact; import org.dive4elements.artifacts.CallContext; -import org.dive4elements.river.model.BedHeightSingle; +import org.dive4elements.river.model.BedHeight; import org.dive4elements.river.artifacts.D4EArtifact; import org.dive4elements.river.artifacts.access.RiverAccess; @@ -68,7 +68,7 @@ Resources.getMsg(context.getMeta(), "chart.subtitle.radius", new Object[] { radius }), ""); - BedHeightSingle second = BedHeightSingle.getBedHeightSingleById( + BedHeight second = BedHeight.getBedHeightById( oldData.getIdSecond()); this.addMetaData(Resources.getMsg( context.getMeta(), diff -r d0ea092a32f5 -r 6d8d7425a6b5 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedHeightFacet.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedHeightFacet.java Mon Feb 16 10:12:12 2015 +0100 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedHeightFacet.java Mon Feb 16 11:08:33 2015 +0100 @@ -19,8 +19,8 @@ import org.dive4elements.river.artifacts.access.BedHeightAccess; import org.dive4elements.river.artifacts.model.BlackboardDataFacet; import org.dive4elements.river.artifacts.model.FacetTypes; -import org.dive4elements.river.model.BedHeightSingle; -import org.dive4elements.river.model.BedHeightSingleValue; +import org.dive4elements.river.model.BedHeight; +import org.dive4elements.river.model.BedHeightValue; public class BedHeightFacet extends BlackboardDataFacet @@ -52,19 +52,19 @@ BedHeightAccess access = new BedHeightAccess((D4EArtifact)artifact); if (type.equals("singlevalues")) { /* Former doc (from BedHeightAccess): - * Return a {@link List} of {@link BedHeightSingleValue}s + * Return a {@link List} of {@link BedHeightValue}s * at the range of the artifact - * @return List of {@link BedHeightSingleValue}s */ - BedHeightSingle single = BedHeightSingle.getBedHeightSingleById( + * @return List of {@link BedHeightValue}s */ + BedHeight single = BedHeight.getBedHeightById( access.getHeightId()); - List bedheightValues = - BedHeightSingleValue.getBedHeightSingleValues( + List bedheightValues = + BedHeightValue.getBedHeightValues( single, access.getFrom(), access.getTo()); double[][] values = new double[2][bedheightValues.size()]; int i = 0; - for (BedHeightSingleValue bedheightValue : bedheightValues) { + for (BedHeightValue bedheightValue : bedheightValues) { values[0][i] = bedheightValue.getStation(); values[1][i] = bedheightValue.getHeight(); i++; diff -r d0ea092a32f5 -r 6d8d7425a6b5 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedHeightSoundingWidthFacet.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedHeightSoundingWidthFacet.java Mon Feb 16 10:12:12 2015 +0100 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedHeightSoundingWidthFacet.java Mon Feb 16 11:08:33 2015 +0100 @@ -8,8 +8,8 @@ import org.dive4elements.river.artifacts.access.BedHeightAccess; import org.dive4elements.river.artifacts.model.BlackboardDataFacet; import org.dive4elements.river.artifacts.model.FacetTypes; -import org.dive4elements.river.model.BedHeightSingle; -import org.dive4elements.river.model.BedHeightSingleValue; +import org.dive4elements.river.model.BedHeight; +import org.dive4elements.river.model.BedHeightValue; public class BedHeightSoundingWidthFacet @@ -36,19 +36,19 @@ public Object getData(Artifact artifact, CallContext context) { BedHeightAccess access = new BedHeightAccess((D4EArtifact)artifact); /* Former doc (from BedHeightAccess): - * Return a {@link List} of {@link BedHeightSingleValue}s + * Return a {@link List} of {@link BedHeightValue}s * at the range of the artifact - * @return List of {@link BedHeightSingleValue}s */ - BedHeightSingle single = BedHeightSingle.getBedHeightSingleById( + * @return List of {@link BedHeightValue}s */ + BedHeight single = BedHeight.getBedHeightById( access.getHeightId()); - List bedheightValues = - BedHeightSingleValue.getBedHeightSingleValues( + List bedheightValues = + BedHeightValue.getBedHeightValues( single, access.getFrom(), access.getTo()); double[][] values = new double[2][bedheightValues.size()]; int i = 0; - for (BedHeightSingleValue bedheightValue : bedheightValues) { + for (BedHeightValue bedheightValue : bedheightValues) { values[0][i] = bedheightValue.getStation(); values[1][i] = bedheightValue.getSoundingWidth() != null ? bedheightValue.getSoundingWidth() : Double.NaN; diff -r d0ea092a32f5 -r 6d8d7425a6b5 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/MiddleBedHeightCalculation.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/MiddleBedHeightCalculation.java Mon Feb 16 10:12:12 2015 +0100 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/MiddleBedHeightCalculation.java Mon Feb 16 11:08:33 2015 +0100 @@ -14,8 +14,8 @@ import org.apache.log4j.Logger; import org.dive4elements.artifacts.Artifact; -import org.dive4elements.river.model.BedHeightSingle; -import org.dive4elements.river.model.BedHeightSingleValue; +import org.dive4elements.river.model.BedHeight; +import org.dive4elements.river.model.BedHeightValue; import org.dive4elements.river.artifacts.access.BedHeightAccess; import org.dive4elements.river.artifacts.model.Calculation; import org.dive4elements.river.artifacts.model.CalculationResult; @@ -30,7 +30,7 @@ public CalculationResult calculate(BedHeightAccess access) { log.info("MiddleBedHeightCalculation.calculate"); - int[] singleIds = access.getBedHeightSingleIDs(); + int[] singleIds = access.getBedHeightIDs(); if (log.isDebugEnabled()) { @@ -42,20 +42,20 @@ } } - List singles = getSingles(access, singleIds); + List singles = getSingles(access, singleIds); return buildCalculationResult(access, singles); } - protected List getSingles( + protected List getSingles( BedHeightAccess access, int[] ids ) { - List singles = new ArrayList(); + List singles = new ArrayList(); for (int id: ids) { - BedHeightSingle s = BedHeightSingle.getBedHeightSingleById(id); + BedHeight s = BedHeight.getBedHeightById(id); if (s != null) { singles.add(s); @@ -72,7 +72,7 @@ protected CalculationResult buildCalculationResult( BedHeightAccess access, - List singles + List singles ) { log.info("MiddleBedHeightCalculation.buildCalculationResult"); @@ -81,7 +81,7 @@ List data = new ArrayList(); - for (BedHeightSingle single: singles) { + for (BedHeight single: singles) { MiddleBedHeightData d = prepareSingleData(single, kmLo, kmHi); if (d != null) { @@ -97,14 +97,14 @@ protected MiddleBedHeightData prepareSingleData( - BedHeightSingle single, + BedHeight single, double kmLo, double kmHi ) { log.debug("Prepare data for single: " + single.getDescription()); - List values = - BedHeightSingleValue.getBedHeightSingleValues(single, kmLo, kmHi); + List values = + BedHeightValue.getBedHeightValues(single, kmLo, kmHi); int year = single.getYear() != null ? single.getYear() : 0; @@ -130,7 +130,7 @@ locationSystem, single.getSoundingWidth()); - for (BedHeightSingleValue value: values) { + for (BedHeightValue value: values) { if (value.getHeight() != null) { double uncert = value.getUncertainty() != null ? value.getUncertainty().doubleValue() : Double.NaN; diff -r d0ea092a32f5 -r 6d8d7425a6b5 artifacts/src/main/java/org/dive4elements/river/artifacts/states/SoundingsSelect.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/SoundingsSelect.java Mon Feb 16 10:12:12 2015 +0100 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/SoundingsSelect.java Mon Feb 16 11:08:33 2015 +0100 @@ -18,7 +18,7 @@ import org.dive4elements.artifacts.common.model.KVP; import org.dive4elements.artifacts.common.utils.XMLUtils; import org.dive4elements.artifacts.common.utils.XMLUtils.ElementCreator; -import org.dive4elements.river.model.BedHeightSingle; +import org.dive4elements.river.model.BedHeight; import org.dive4elements.river.model.River; import org.dive4elements.river.artifacts.D4EArtifact; import org.dive4elements.river.artifacts.resources.Resources; @@ -120,8 +120,8 @@ Element select, CallContext context ) { - List singles = - BedHeightSingle.getBedHeightSingles(river, kmLo, kmHi); + List singles = + BedHeight.getBedHeights(river, kmLo, kmHi); if (singles != null) { int size = singles.size(); @@ -130,7 +130,7 @@ NumberFormat nf = Formatter.getCalculationKm(context.getMeta()); for (int i = 0; i < size; i++) { - BedHeightSingle s = singles.get(i); + BedHeight s = singles.get(i); String id = PREFIX_SINGLE + s.getId(); String value = s.getDescription(); @@ -204,7 +204,7 @@ protected String getLabelForSingle(CallContext cc, String value) { String id = value.replace(PREFIX_SINGLE, ""); try { - BedHeightSingle s = BedHeightSingle.getBedHeightSingleById( + BedHeight s = BedHeight.getBedHeightById( Integer.parseInt(id)); if (s != null) { diff -r d0ea092a32f5 -r 6d8d7425a6b5 backend/doc/documentation/de/importer-hydr-morph.tex --- a/backend/doc/documentation/de/importer-hydr-morph.tex Mon Feb 16 10:12:12 2015 +0100 +++ b/backend/doc/documentation/de/importer-hydr-morph.tex Mon Feb 16 11:08:33 2015 +0100 @@ -181,7 +181,7 @@ unterdrückt werden. \subsubsection{Sohlhöhen (Peilungen)} -Mit \textbf{-Dflys.backend.importer.skip.bed.height.single=true} +Mit \textbf{-Dflys.backend.importer.skip.bed.height=true} kann der Import von Sohlhöhen-Peilungen unterdrückt werden. Es werden die CSV-Dateien aus dem Verzeichnis \textit{Morphologie/Sohlhoehen/Einzeljahre} geladen. diff -r d0ea092a32f5 -r 6d8d7425a6b5 backend/doc/schema/oracle-minfo.sql --- a/backend/doc/schema/oracle-minfo.sql Mon Feb 16 10:12:12 2015 +0100 +++ b/backend/doc/schema/oracle-minfo.sql Mon Feb 16 11:08:33 2015 +0100 @@ -35,9 +35,9 @@ INSERT INTO bed_height_type VALUES (6, 'Modell'); -CREATE SEQUENCE BED_HEIGHT_SINGLE_ID_SEQ; +CREATE SEQUENCE BED_HEIGHT_ID_SEQ; -CREATE TABLE bed_height_single ( +CREATE TABLE bed_height ( id NUMBER(38,0) NOT NULL, river_id NUMBER(38,0) NOT NULL, year NUMBER(38,0), @@ -50,28 +50,34 @@ evaluation_by VARCHAR(255), description VARCHAR(255), PRIMARY KEY(id), - CONSTRAINT fk_bed_single_river_id FOREIGN KEY (river_id) REFERENCES rivers(id) ON DELETE CASCADE, + CONSTRAINT fk_bed_river_id FOREIGN KEY (river_id) + REFERENCES rivers(id) ON DELETE CASCADE, CONSTRAINT fk_type FOREIGN KEY (type_id) REFERENCES bed_height_type(id), - CONSTRAINT fk_location_system FOREIGN KEY (location_system_id) REFERENCES location_system(id), - CONSTRAINT fk_cur_elevation_model FOREIGN KEY (cur_elevation_model_id) REFERENCES elevation_model(id), - CONSTRAINT fk_old_elevation_model FOREIGN KEY (old_elevation_model_id) REFERENCES elevation_model(id), - CONSTRAINT fk_range FOREIGN KEY (range_id) REFERENCES ranges(id) ON DELETE CASCADE + CONSTRAINT fk_location_system FOREIGN KEY (location_system_id) + REFERENCES location_system(id), + CONSTRAINT fk_cur_elevation_model FOREIGN KEY (cur_elevation_model_id) + REFERENCES elevation_model(id), + CONSTRAINT fk_old_elevation_model FOREIGN KEY (old_elevation_model_id) + REFERENCES elevation_model(id), + CONSTRAINT fk_range FOREIGN KEY (range_id) + REFERENCES ranges(id) ON DELETE CASCADE ); -CREATE SEQUENCE BED_SINGLE_VALUES_ID_SEQ; +CREATE SEQUENCE BED_HEIGHT_VALUES_ID_SEQ; -CREATE TABLE bed_height_single_values ( +CREATE TABLE bed_height_values ( id NUMBER(38,0) NOT NULL, - bed_height_single_id NUMBER(38,0) NOT NULL, + bed_height_id NUMBER(38,0) NOT NULL, station DOUBLE PRECISION NOT NULL, height DOUBLE PRECISION, uncertainty DOUBLE PRECISION, data_gap DOUBLE PRECISION, sounding_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 + UNIQUE (station, bed_height_id), + CONSTRAINT fk_bed_values_parent FOREIGN KEY (bed_height_id) + REFERENCES bed_height(id) ON DELETE CASCADE ); diff -r d0ea092a32f5 -r 6d8d7425a6b5 backend/doc/schema/postgresql-minfo.sql --- a/backend/doc/schema/postgresql-minfo.sql Mon Feb 16 10:12:12 2015 +0100 +++ b/backend/doc/schema/postgresql-minfo.sql Mon Feb 16 11:08:33 2015 +0100 @@ -35,9 +35,9 @@ INSERT INTO bed_height_type VALUES (6, 'Modell'); -CREATE SEQUENCE BED_HEIGHT_SINGLE_ID_SEQ; +CREATE SEQUENCE BED_HEIGHT_ID_SEQ; -CREATE TABLE bed_height_single ( +CREATE TABLE bed_height ( id int NOT NULL, river_id int NOT NULL, year int, @@ -50,28 +50,34 @@ evaluation_by VARCHAR(255), description VARCHAR(255), PRIMARY KEY(id), - CONSTRAINT fk_bed_single_river_id FOREIGN KEY (river_id) REFERENCES rivers(id) ON DELETE CASCADE, + CONSTRAINT fk_bed_river_id FOREIGN KEY (river_id) + REFERENCES rivers(id) ON DELETE CASCADE, CONSTRAINT fk_type FOREIGN KEY (type_id) REFERENCES bed_height_type(id), - CONSTRAINT fk_location_system FOREIGN KEY (location_system_id) REFERENCES location_system(id), - CONSTRAINT fk_cur_elevation_model FOREIGN KEY (cur_elevation_model_id) REFERENCES elevation_model(id), - CONSTRAINT fk_old_elevation_model FOREIGN KEY (old_elevation_model_id) REFERENCES elevation_model(id), - CONSTRAINT fk_range FOREIGN KEY (range_id) REFERENCES ranges(id) ON DELETE CASCADE + CONSTRAINT fk_location_system FOREIGN KEY (location_system_id) + REFERENCES location_system(id), + CONSTRAINT fk_cur_elevation_model FOREIGN KEY (cur_elevation_model_id) + REFERENCES elevation_model(id), + CONSTRAINT fk_old_elevation_model FOREIGN KEY (old_elevation_model_id) + REFERENCES elevation_model(id), + CONSTRAINT fk_range FOREIGN KEY (range_id) + REFERENCES ranges(id) ON DELETE CASCADE ); -CREATE SEQUENCE BED_SINGLE_VALUES_ID_SEQ; +CREATE SEQUENCE BED_HEIGHT_VALUES_ID_SEQ; -CREATE TABLE bed_height_single_values ( +CREATE TABLE bed_height_values ( id int NOT NULL, - bed_height_single_id int NOT NULL, + bed_height_id int NOT NULL, station NUMERIC NOT NULL, height NUMERIC, uncertainty NUMERIC, data_gap NUMERIC, sounding_width NUMERIC, 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 + UNIQUE (station, bed_height_id), + CONSTRAINT fk_bed_values_parent FOREIGN KEY (bed_height_id) + REFERENCES bed_height(id) ON DELETE CASCADE ); diff -r d0ea092a32f5 -r 6d8d7425a6b5 backend/src/main/java/org/dive4elements/river/backend/FLYSCredentials.java --- a/backend/src/main/java/org/dive4elements/river/backend/FLYSCredentials.java Mon Feb 16 10:12:12 2015 +0100 +++ b/backend/src/main/java/org/dive4elements/river/backend/FLYSCredentials.java Mon Feb 16 11:08:33 2015 +0100 @@ -14,8 +14,8 @@ import org.dive4elements.river.model.AnnotationType; import org.dive4elements.river.model.Attribute; import org.dive4elements.river.model.AxisKind; -import org.dive4elements.river.model.BedHeightSingle; -import org.dive4elements.river.model.BedHeightSingleValue; +import org.dive4elements.river.model.BedHeight; +import org.dive4elements.river.model.BedHeightValue; import org.dive4elements.river.model.BedHeightType; import org.dive4elements.river.model.Building; import org.dive4elements.river.model.BoundaryKind; @@ -151,8 +151,8 @@ AnnotationType.class, Attribute.class, AxisKind.class, - BedHeightSingle.class, - BedHeightSingleValue.class, + BedHeight.class, + BedHeightValue.class, BedHeightType.class, Building.class, BoundaryKind.class, diff -r d0ea092a32f5 -r 6d8d7425a6b5 backend/src/main/java/org/dive4elements/river/importer/Config.java --- a/backend/src/main/java/org/dive4elements/river/importer/Config.java Mon Feb 16 10:12:12 2015 +0100 +++ b/backend/src/main/java/org/dive4elements/river/importer/Config.java Mon Feb 16 11:08:33 2015 +0100 @@ -67,8 +67,8 @@ public static final String SKIP_FLOOD_PROTECTION = "flys.backend.importer.skip.flood.protection"; - public static final String SKIP_BED_HEIGHT_SINGLE = - "flys.backend.importer.skip.bed.height.single"; + public static final String SKIP_BED_HEIGHT = + "flys.backend.importer.skip.bed.height"; public static final String SKIP_DA66S = "flys.backend.importer.skip.da66s"; @@ -210,8 +210,8 @@ return getFlag(SKIP_DA66S); } - public boolean skipBedHeightSingle() { - return getFlag(SKIP_BED_HEIGHT_SINGLE); + public boolean skipBedHeight() { + return getFlag(SKIP_BED_HEIGHT); } public boolean skipSedimentDensity() { diff -r d0ea092a32f5 -r 6d8d7425a6b5 backend/src/main/java/org/dive4elements/river/importer/ImportBedHeight.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/backend/src/main/java/org/dive4elements/river/importer/ImportBedHeight.java Mon Feb 16 11:08:33 2015 +0100 @@ -0,0 +1,203 @@ +/* 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.importer; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.log4j.Logger; + +import org.hibernate.Session; +import org.hibernate.Query; + +import org.dive4elements.river.model.BedHeight; +import org.dive4elements.river.model.BedHeightType; +import org.dive4elements.river.model.ElevationModel; +import org.dive4elements.river.model.Range; +import org.dive4elements.river.model.River; + + +public class ImportBedHeight +{ + private static Logger log = Logger.getLogger(ImportBedHeight.class); + + protected Integer year; + protected int soundingWidth; + + protected String evaluationBy; + protected String description; + + protected ImportRange range; + protected ImportBedHeightType type; + protected ImportLocationSystem locationSystem; + protected ImportElevationModel curElevationModel; + protected ImportElevationModel oldElevationModel; + + protected List values; + + protected BedHeight peer; + + + public ImportBedHeight(String description) { + this.description = description; + this.values = new ArrayList(); + } + + + public String getDescription() { + return description; + } + + public int getValueCount() { + return values.size(); + } + + + public void setYear(int year) { + this.year = year; + } + + public void setTimeInterval(ImportTimeInterval timeInterval) { + // do nothing + } + + public void setSoundingWidth(int soundingWidth) { + this.soundingWidth = soundingWidth; + } + + public void setEvaluationBy(String evaluationBy) { + this.evaluationBy = evaluationBy; + } + + public void setDescription(String description) { + this.description = description; + } + + public void setRange(ImportRange range) { + this.range = range; + } + + public void setType(ImportBedHeightType type) { + this.type = type; + } + + public void setLocationSystem(ImportLocationSystem locationSystem) { + this.locationSystem = locationSystem; + } + + public void setCurElevationModel(ImportElevationModel curElevationModel) { + this.curElevationModel = curElevationModel; + } + + public void setOldElevationModel(ImportElevationModel oldElevationModel) { + this.oldElevationModel = oldElevationModel; + } + + public void addValue(ImportBedHeightValue value) { + values.add((ImportBedHeightValue) value); + } + + public void storeDependencies(River river) { + log.info("Store dependencies for single: '" + getDescription() + "'"); + + if (type != null) { + type.storeDependencies(); + } + + if (locationSystem != null) { + locationSystem.storeDependencies(); + } + + if (curElevationModel != null) { + curElevationModel.storeDependencies(); + } + + if (oldElevationModel != null) { + oldElevationModel.storeDependencies(); + } + + BedHeight peer = getPeer(river); + + if (peer != null) { + for (ImportBedHeightValue value: values) { + value.storeDependencies(peer); + } + } + + Session session = ImporterSession.getInstance().getDatabaseSession(); + session.flush(); + } + + public BedHeight getPeer(River river) { + if (peer == null) { + BedHeightType theType = type != null ? type.getPeer() : null; + ElevationModel theCurModel = curElevationModel.getPeer(); + Range theRange = range != null ? range.getPeer(river) : null; + + if (theType == null) { + log.warn("BHS: No bed height type given. Skip file '" + + description + "'"); + return null; + } + + if (theCurModel == null) { + log.warn("BHS: No elevation model given. Skip file '" + + description + "'"); + return null; + } + + if (theRange == null) { + log.warn("BHS: No km-range given: '" + + description + "'"); + } + + Session session = ImporterSession.getInstance().getDatabaseSession(); + + Query query = session.createQuery( + "from BedHeight where " + + "river=:river and year=:year and soundingWidth=:soundingWidth " + + "and type=:type and locationSystem=:locationSystem and " + + "curElevationModel=:curElevationModel and range=:range"); + + query.setParameter("river", river); + query.setParameter("year", year); + query.setParameter("soundingWidth", soundingWidth); + query.setParameter("type", theType); + query.setParameter("locationSystem", locationSystem.getPeer()); + query.setParameter("curElevationModel", theCurModel); + query.setParameter("range", range.getPeer(river)); + + List bedHeights = query.list(); + if (bedHeights.isEmpty()) { + log.info("Create new BedHeight DB instance."); + + peer = new BedHeight( + river, + year, + soundingWidth, + theType, + locationSystem.getPeer(), + theCurModel, + oldElevationModel != null ? oldElevationModel.getPeer() : null, + range.getPeer(river), + evaluationBy, + description + ); + + session.save(peer); + } + else { + peer = bedHeights.get(0); + } + } + + return peer; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r d0ea092a32f5 -r 6d8d7425a6b5 backend/src/main/java/org/dive4elements/river/importer/ImportBedHeightSingle.java --- a/backend/src/main/java/org/dive4elements/river/importer/ImportBedHeightSingle.java Mon Feb 16 10:12:12 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,203 +0,0 @@ -/* 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.importer; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.log4j.Logger; - -import org.hibernate.Session; -import org.hibernate.Query; - -import org.dive4elements.river.model.BedHeightSingle; -import org.dive4elements.river.model.BedHeightType; -import org.dive4elements.river.model.ElevationModel; -import org.dive4elements.river.model.Range; -import org.dive4elements.river.model.River; - - -public class ImportBedHeightSingle -{ - private static Logger log = Logger.getLogger(ImportBedHeightSingle.class); - - protected Integer year; - protected int soundingWidth; - - protected String evaluationBy; - protected String description; - - protected ImportRange range; - protected ImportBedHeightType type; - protected ImportLocationSystem locationSystem; - protected ImportElevationModel curElevationModel; - protected ImportElevationModel oldElevationModel; - - protected List values; - - protected BedHeightSingle peer; - - - public ImportBedHeightSingle(String description) { - this.description = description; - this.values = new ArrayList(); - } - - - public String getDescription() { - return description; - } - - public int getValueCount() { - return values.size(); - } - - - public void setYear(int year) { - this.year = year; - } - - public void setTimeInterval(ImportTimeInterval timeInterval) { - // do nothing - } - - public void setSoundingWidth(int soundingWidth) { - this.soundingWidth = soundingWidth; - } - - public void setEvaluationBy(String evaluationBy) { - this.evaluationBy = evaluationBy; - } - - public void setDescription(String description) { - this.description = description; - } - - public void setRange(ImportRange range) { - this.range = range; - } - - public void setType(ImportBedHeightType type) { - this.type = type; - } - - public void setLocationSystem(ImportLocationSystem locationSystem) { - this.locationSystem = locationSystem; - } - - public void setCurElevationModel(ImportElevationModel curElevationModel) { - this.curElevationModel = curElevationModel; - } - - public void setOldElevationModel(ImportElevationModel oldElevationModel) { - this.oldElevationModel = oldElevationModel; - } - - public void addValue(ImportBedHeightSingleValue value) { - values.add((ImportBedHeightSingleValue) value); - } - - public void storeDependencies(River river) { - log.info("Store dependencies for single: '" + getDescription() + "'"); - - if (type != null) { - type.storeDependencies(); - } - - if (locationSystem != null) { - locationSystem.storeDependencies(); - } - - if (curElevationModel != null) { - curElevationModel.storeDependencies(); - } - - if (oldElevationModel != null) { - oldElevationModel.storeDependencies(); - } - - BedHeightSingle peer = getPeer(river); - - if (peer != null) { - for (ImportBedHeightSingleValue value: values) { - value.storeDependencies(peer); - } - } - - Session session = ImporterSession.getInstance().getDatabaseSession(); - session.flush(); - } - - public BedHeightSingle getPeer(River river) { - if (peer == null) { - BedHeightType theType = type != null ? type.getPeer() : null; - ElevationModel theCurModel = curElevationModel.getPeer(); - Range theRange = range != null ? range.getPeer(river) : null; - - if (theType == null) { - log.warn("BHS: No bed height type given. Skip file '" + - description + "'"); - return null; - } - - if (theCurModel == null) { - log.warn("BHS: No elevation model given. Skip file '" + - description + "'"); - return null; - } - - if (theRange == null) { - log.warn("BHS: No km-range given: '" + - description + "'"); - } - - Session session = ImporterSession.getInstance().getDatabaseSession(); - - Query query = session.createQuery( - "from BedHeightSingle where " + - "river=:river and year=:year and soundingWidth=:soundingWidth " + - "and type=:type and locationSystem=:locationSystem and " + - "curElevationModel=:curElevationModel and range=:range"); - - query.setParameter("river", river); - query.setParameter("year", year); - query.setParameter("soundingWidth", soundingWidth); - query.setParameter("type", theType); - query.setParameter("locationSystem", locationSystem.getPeer()); - query.setParameter("curElevationModel", theCurModel); - query.setParameter("range", range.getPeer(river)); - - List bedHeights = query.list(); - if (bedHeights.isEmpty()) { - log.info("Create new BedHeightSingle DB instance."); - - peer = new BedHeightSingle( - river, - year, - soundingWidth, - theType, - locationSystem.getPeer(), - theCurModel, - oldElevationModel != null ? oldElevationModel.getPeer() : null, - range.getPeer(river), - evaluationBy, - description - ); - - session.save(peer); - } - else { - peer = bedHeights.get(0); - } - } - - return peer; - } -} -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r d0ea092a32f5 -r 6d8d7425a6b5 backend/src/main/java/org/dive4elements/river/importer/ImportBedHeightSingleValue.java --- a/backend/src/main/java/org/dive4elements/river/importer/ImportBedHeightSingleValue.java Mon Feb 16 10:12:12 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,105 +0,0 @@ -/* 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.importer; - -import java.util.List; - -import org.apache.log4j.Logger; - -import org.hibernate.Session; -import org.hibernate.Query; - -import org.dive4elements.river.model.BedHeightSingle; -import org.dive4elements.river.model.BedHeightSingleValue; - - -public class ImportBedHeightSingleValue { - - private static final Logger log = - Logger.getLogger(ImportBedHeightSingleValue.class); - - - protected ImportBedHeightSingle bedHeight; - - protected Double station; - protected Double height; - protected Double uncertainty; - protected Double dataGap; - protected Double soundingWidth; - - protected BedHeightSingleValue peer; - - - public ImportBedHeightSingleValue( - ImportBedHeightSingle bedHeight, - Double station, - Double height, - Double uncertainty, - Double dataGap, - Double soundingWidth - ) { - this.bedHeight = bedHeight; - this.station = station; - this.height = height; - this.uncertainty = uncertainty; - this.dataGap = dataGap; - this.soundingWidth = soundingWidth; - } - - - public void storeDependencies(BedHeightSingle bedHeight) { - getPeer(bedHeight); - } - - - /** - * Add this value to database or return database bound Value, assuring - * that the BedHeightSingle exists in db already. - */ - public BedHeightSingleValue getPeer(BedHeightSingle bedHeight) { - if (peer == null) { - Session session = ImporterSession.getInstance().getDatabaseSession(); - - Query query = session.createQuery( - "from BedHeightSingleValue where " + - " bedHeight=:bedHeight and " + - " station=:station and " + - " height=:height and " + - " uncertainty=:uncertainty and " + - " dataGap=:dataGap and " + - " soundingWidth=:soundingWidth"); - - query.setParameter("bedHeight", bedHeight); - query.setParameter("station", station); - query.setParameter("height", height); - query.setParameter("uncertainty", uncertainty); - query.setParameter("dataGap", dataGap); - query.setParameter("soundingWidth", soundingWidth); - - List values = query.list(); - if (values.isEmpty()) { - peer = new BedHeightSingleValue( - bedHeight, - station, - height, - uncertainty, - dataGap, - soundingWidth - ); - session.save(peer); - } - else { - peer = values.get(0); - } - } - - return peer; - } -} -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r d0ea092a32f5 -r 6d8d7425a6b5 backend/src/main/java/org/dive4elements/river/importer/ImportBedHeightValue.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/backend/src/main/java/org/dive4elements/river/importer/ImportBedHeightValue.java Mon Feb 16 11:08:33 2015 +0100 @@ -0,0 +1,105 @@ +/* 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.importer; + +import java.util.List; + +import org.apache.log4j.Logger; + +import org.hibernate.Session; +import org.hibernate.Query; + +import org.dive4elements.river.model.BedHeight; +import org.dive4elements.river.model.BedHeightValue; + + +public class ImportBedHeightValue { + + private static final Logger log = + Logger.getLogger(ImportBedHeightValue.class); + + + protected ImportBedHeight bedHeight; + + protected Double station; + protected Double height; + protected Double uncertainty; + protected Double dataGap; + protected Double soundingWidth; + + protected BedHeightValue peer; + + + public ImportBedHeightValue( + ImportBedHeight bedHeight, + Double station, + Double height, + Double uncertainty, + Double dataGap, + Double soundingWidth + ) { + this.bedHeight = bedHeight; + this.station = station; + this.height = height; + this.uncertainty = uncertainty; + this.dataGap = dataGap; + this.soundingWidth = soundingWidth; + } + + + public void storeDependencies(BedHeight bedHeight) { + getPeer(bedHeight); + } + + + /** + * Add this value to database or return database bound Value, assuring + * that the BedHeight exists in db already. + */ + public BedHeightValue getPeer(BedHeight bedHeight) { + if (peer == null) { + Session session = ImporterSession.getInstance().getDatabaseSession(); + + Query query = session.createQuery( + "from BedHeightValue where " + + " bedHeight=:bedHeight and " + + " station=:station and " + + " height=:height and " + + " uncertainty=:uncertainty and " + + " dataGap=:dataGap and " + + " soundingWidth=:soundingWidth"); + + query.setParameter("bedHeight", bedHeight); + query.setParameter("station", station); + query.setParameter("height", height); + query.setParameter("uncertainty", uncertainty); + query.setParameter("dataGap", dataGap); + query.setParameter("soundingWidth", soundingWidth); + + List values = query.list(); + if (values.isEmpty()) { + peer = new BedHeightValue( + bedHeight, + station, + height, + uncertainty, + dataGap, + soundingWidth + ); + session.save(peer); + } + else { + peer = values.get(0); + } + } + + return peer; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r d0ea092a32f5 -r 6d8d7425a6b5 backend/src/main/java/org/dive4elements/river/importer/ImportRiver.java --- a/backend/src/main/java/org/dive4elements/river/importer/ImportRiver.java Mon Feb 16 10:12:12 2015 +0100 +++ b/backend/src/main/java/org/dive4elements/river/importer/ImportRiver.java Mon Feb 16 11:08:33 2015 +0100 @@ -164,7 +164,7 @@ /** Wst-structures from waterlevel-difference-csv files. */ protected List waterlevelDifferences; - protected List bedHeightSingles; + protected List bedHeights; protected List sedimentDensities; @@ -456,12 +456,12 @@ File bedHeightDir = new File(minfoDir, BED_HEIGHT_DIR); File singlesDir = new File(bedHeightDir, BED_HEIGHT_SINGLE_DIR); - if (Config.INSTANCE.skipBedHeightSingle()) { + if (Config.INSTANCE.skipBedHeight()) { log.info("skip parsing bed height single."); } else { log.info("Parse bed height single."); - parseBedHeightSingles(singlesDir); + parseBedHeights(singlesDir); } } @@ -816,7 +816,7 @@ } - protected void parseBedHeightSingles(File dir) throws IOException { + protected void parseBedHeights(File dir) throws IOException { log.debug("Parse bed height singles"); File[] files = dir.listFiles(); @@ -832,7 +832,7 @@ parser.parse(file); } - bedHeightSingles = parser.getBedHeights(); + bedHeights = parser.getBedHeights(); } public void parseFloodWater() throws IOException { @@ -1440,29 +1440,24 @@ public void storeBedHeight() { - if (!Config.INSTANCE.skipBedHeightSingle()) { - log.info("store bed heights single"); - storeBedHeightSingle(); - } - } - - - private void storeBedHeightSingle() { - River river = getPeer(); + if (!Config.INSTANCE.skipBedHeight()) { + log.info("store bed heights"); + River river = getPeer(); - if (bedHeightSingles != null) { - for (ImportBedHeightSingle tmp: bedHeightSingles) { - ImportBedHeightSingle single = (ImportBedHeightSingle) tmp; - - String desc = single.getDescription(); + if (bedHeights != null) { + for (ImportBedHeight tmp: bedHeights) { + ImportBedHeight single = (ImportBedHeight) tmp; - log.debug("name: " + desc); + String desc = single.getDescription(); - single.storeDependencies(river); + log.debug("name: " + desc); + + single.storeDependencies(river); + } } - } - else { - log.info("No single bed heights to store."); + else { + log.info("No bed heights to store."); + } } } diff -r d0ea092a32f5 -r 6d8d7425a6b5 backend/src/main/java/org/dive4elements/river/importer/parsers/BedHeightParser.java --- a/backend/src/main/java/org/dive4elements/river/importer/parsers/BedHeightParser.java Mon Feb 16 10:12:12 2015 +0100 +++ b/backend/src/main/java/org/dive4elements/river/importer/parsers/BedHeightParser.java Mon Feb 16 11:08:33 2015 +0100 @@ -31,8 +31,8 @@ import org.apache.log4j.Logger; -import org.dive4elements.river.importer.ImportBedHeightSingle; -import org.dive4elements.river.importer.ImportBedHeightSingleValue; +import org.dive4elements.river.importer.ImportBedHeight; +import org.dive4elements.river.importer.ImportBedHeightValue; import org.dive4elements.river.importer.ImportBedHeightType; import org.dive4elements.river.importer.ImportElevationModel; import org.dive4elements.river.importer.ImportLocationSystem; @@ -90,23 +90,23 @@ protected static NumberFormat nf = NumberFormat.getInstance(DEFAULT_LOCALE); - protected List bedHeights; + protected List bedHeights; - protected ImportBedHeightSingle newImportBedHeight(String description) { - return new ImportBedHeightSingle(description); + protected ImportBedHeight newImportBedHeight(String description) { + return new ImportBedHeight(description); } protected TreeSet kmExists; public BedHeightParser() { - bedHeights = new ArrayList(); + bedHeights = new ArrayList(); kmExists = new TreeSet(EpsilonComparator.CMP); } - public List getBedHeights() { + public List getBedHeights() { return bedHeights; } @@ -114,7 +114,7 @@ public void parse(File file) throws IOException { log.info("Parsing bed height single file '" + file + "'"); - ImportBedHeightSingle obj = newImportBedHeight(file.getName().replaceAll("\\.csv", "")); + ImportBedHeight obj = newImportBedHeight(file.getName().replaceAll("\\.csv", "")); kmExists.clear(); @@ -162,7 +162,7 @@ } - protected void handleMetaLine(ImportBedHeightSingle obj, String line) { + protected void handleMetaLine(ImportBedHeight obj, String line) { String meta = stripMetaLine(line); if (handleMetaYear(obj, meta)) { @@ -201,7 +201,7 @@ } - protected boolean handleMetaYear(ImportBedHeightSingle obj, String line) { + protected boolean handleMetaYear(ImportBedHeight obj, String line) { Matcher m = META_YEAR.matcher(line); if (m.matches()) { @@ -219,7 +219,7 @@ } - protected boolean handleMetaTimeInterval(ImportBedHeightSingle obj, String line) { + protected boolean handleMetaTimeInterval(ImportBedHeight obj, String line) { Matcher m = META_TIMEINTERVAL.matcher(line); if (m.matches()) { @@ -248,7 +248,7 @@ } - protected boolean handleMetaSoundingWidth(ImportBedHeightSingle obj, String line) { + protected boolean handleMetaSoundingWidth(ImportBedHeight obj, String line) { Matcher m = META_SOUNDING_WIDTH.matcher(line); if (m.matches()) { @@ -270,7 +270,7 @@ } - protected boolean handleMetaComment(ImportBedHeightSingle obj, String line) { + protected boolean handleMetaComment(ImportBedHeight obj, String line) { Matcher m = META_COMMENTS.matcher(line); if (m.matches()) { @@ -286,7 +286,7 @@ protected boolean handleMetaEvaluationBy( - ImportBedHeightSingle obj, + ImportBedHeight obj, String line ) { Matcher m = META_EVALUATION_BY.matcher(line); @@ -304,7 +304,7 @@ } - protected boolean handleMetaRange(ImportBedHeightSingle obj, String line) { + protected boolean handleMetaRange(ImportBedHeight obj, String line) { Matcher m = META_RANGE.matcher(line); if (m.matches() && m.groupCount() >= 2) { @@ -328,7 +328,7 @@ } - protected boolean handleMetaType(ImportBedHeightSingle obj, String line) { + protected boolean handleMetaType(ImportBedHeight obj, String line) { Matcher m = META_TYPE.matcher(line); if (m.matches()) { @@ -351,7 +351,7 @@ protected boolean handleMetaLocationSystem( - ImportBedHeightSingle obj, + ImportBedHeight obj, String line ) { Matcher m = META_LOCATION_SYSTEM.matcher(line); @@ -369,7 +369,7 @@ protected boolean handleMetaCurElevationModel( - ImportBedHeightSingle obj, + ImportBedHeight obj, String line ) { Matcher m = META_CUR_ELEVATION_SYSTEM.matcher(line); @@ -392,7 +392,7 @@ protected boolean handleMetaOldElevationModel( - ImportBedHeightSingle obj, + ImportBedHeight obj, String line ) { Matcher m = META_OLD_ELEVATION_SYSTEM.matcher(line); @@ -413,7 +413,7 @@ return false; } - protected void handleDataLine(ImportBedHeightSingle obj, String line) { + protected void handleDataLine(ImportBedHeight obj, String line) { String[] values = line.split(SEPERATOR_CHAR, -1); if (values == null) { @@ -491,8 +491,8 @@ } } - ImportBedHeightSingleValue value = new ImportBedHeightSingleValue( - (ImportBedHeightSingle) obj, + ImportBedHeightValue value = new ImportBedHeightValue( + (ImportBedHeight) obj, km, height, uncertainty, diff -r d0ea092a32f5 -r 6d8d7425a6b5 backend/src/main/java/org/dive4elements/river/model/BedHeight.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/backend/src/main/java/org/dive4elements/river/model/BedHeight.java Mon Feb 16 11:08:33 2015 +0100 @@ -0,0 +1,280 @@ +/* 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.model; + +import java.io.Serializable; + +import java.util.ArrayList; +import java.util.List; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; +import javax.persistence.GeneratedValue; +import javax.persistence.Column; +import javax.persistence.SequenceGenerator; +import javax.persistence.GenerationType; +import javax.persistence.JoinColumn; +import javax.persistence.OneToOne; +import javax.persistence.OneToMany; + +import org.hibernate.Session; +import org.hibernate.Query; + +import org.dive4elements.river.backend.SessionHolder; + + +@Entity +@Table(name = "bed_height") +public class BedHeight implements Serializable { + + private Integer id; + private Integer year; + private Integer soundingWidth; + + private String evaluationBy; + private String description; + + private River river; + + private BedHeightType type; + + private LocationSystem locationSystem; + + private ElevationModel curElevationModel; + + private ElevationModel oldElevationModel; + + private Range range; + + private List values; + + + public BedHeight() { + } + + + public BedHeight( + River river, + Integer year, + Integer soundingWidth, + BedHeightType type, + LocationSystem locationSystem, + ElevationModel curElevationModel, + Range range + ) { + this( + river, + year, + soundingWidth, + type, + locationSystem, + curElevationModel, + null, + range, + null, + null); + } + + + public BedHeight( + River river, + Integer year, + Integer soundingWidth, + BedHeightType type, + LocationSystem locationSystem, + ElevationModel curElevationModel, + ElevationModel oldElevationModel, + Range range, + String evaluationBy, + String description + ) { + this.river = river; + this.year = year; + this.soundingWidth = soundingWidth; + this.type = type; + this.locationSystem = locationSystem; + this.curElevationModel = curElevationModel; + this.oldElevationModel = oldElevationModel; + this.range = range; + this.evaluationBy = evaluationBy; + this.description = description; + } + + + @Id + @SequenceGenerator( + name = "SEQUENCE_BED_HEIGHT_ID_SEQ", + sequenceName = "BED_HEIGHT_ID_SEQ", + allocationSize = 1) + @GeneratedValue( + strategy = GenerationType.SEQUENCE, + generator = "SEQUENCE_BED_HEIGHT_ID_SEQ") + @Column(name = "id") + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + @OneToOne + @JoinColumn(name = "river_id" ) + public River getRiver() { + return river; + } + + public void setRiver(River river) { + this.river = river; + } + + @Column(name = "year") + public Integer getYear() { + return year; + } + + public void setYear(Integer year) { + this.year = year; + } + + @Column(name = "sounding_width") + public Integer getSoundingWidth() { + return soundingWidth; + } + + public void setSoundingWidth(Integer soundingWidth) { + this.soundingWidth = soundingWidth; + } + + @OneToOne + @JoinColumn(name = "type_id") + public BedHeightType getType() { + return type; + } + + public void setType(BedHeightType type) { + this.type = type; + } + + @OneToOne + @JoinColumn(name = "location_system_id") + public LocationSystem getLocationSystem() { + return locationSystem; + } + + public void setLocationSystem(LocationSystem locationSystem) { + this.locationSystem = locationSystem; + } + + @OneToOne + @JoinColumn(name = "cur_elevation_model_id") + public ElevationModel getCurElevationModel() { + return curElevationModel; + } + + public void setCurElevationModel(ElevationModel curElevationModel) { + this.curElevationModel = curElevationModel; + } + + @OneToOne + @JoinColumn(name = "old_elevation_model_id") + public ElevationModel getOldElevationModel() { + return oldElevationModel; + } + + public void setOldElevationModel(ElevationModel oldElevationModel) { + this.oldElevationModel = oldElevationModel; + } + + @OneToOne + @JoinColumn(name = "range_id") + public Range getRange() { + return range; + } + + public void setRange(Range range) { + this.range = range; + } + + @Column(name = "evaluation_by") + public String getEvaluationBy() { + return evaluationBy; + } + + public void setEvaluationBy(String evaluationBy) { + this.evaluationBy = evaluationBy; + } + + @Column(name = "description") + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + @OneToMany + @JoinColumn(name = "bed_height_id") + public List getValues() { + return values; + } + + public void setValues(List values) { + this.values = values; + } + + + public static List getBedHeights( + River river, + double kmLo, + double kmHi + ) { + Session session = SessionHolder.HOLDER.get(); + + Query query = session.createQuery( + "from BedHeight where river=:river"); + + query.setParameter("river", river); + + // TODO Do km range filtering in SQL statement + + List singles = query.list(); + List good = new ArrayList(); + + for (BedHeight s: singles) { + for (BedHeightValue value: s.getValues()) { + double station = value.getStation().doubleValue(); + + if (station >= kmLo && station <= kmHi) { + good.add(s); + break; + } + } + } + + return good; + } + + + public static BedHeight getBedHeightById(int id) { + Session session = SessionHolder.HOLDER.get(); + + Query query = session.createQuery( + "from BedHeight where id=:id"); + + query.setParameter("id", id); + + List singles = query.list(); + + return singles != null ? singles.get(0) : null; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r d0ea092a32f5 -r 6d8d7425a6b5 backend/src/main/java/org/dive4elements/river/model/BedHeightSingle.java --- a/backend/src/main/java/org/dive4elements/river/model/BedHeightSingle.java Mon Feb 16 10:12:12 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,280 +0,0 @@ -/* 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.model; - -import java.io.Serializable; - -import java.util.ArrayList; -import java.util.List; - -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; -import javax.persistence.GeneratedValue; -import javax.persistence.Column; -import javax.persistence.SequenceGenerator; -import javax.persistence.GenerationType; -import javax.persistence.JoinColumn; -import javax.persistence.OneToOne; -import javax.persistence.OneToMany; - -import org.hibernate.Session; -import org.hibernate.Query; - -import org.dive4elements.river.backend.SessionHolder; - - -@Entity -@Table(name = "bed_height_single") -public class BedHeightSingle implements Serializable { - - private Integer id; - private Integer year; - private Integer soundingWidth; - - private String evaluationBy; - private String description; - - private River river; - - private BedHeightType type; - - private LocationSystem locationSystem; - - private ElevationModel curElevationModel; - - private ElevationModel oldElevationModel; - - private Range range; - - private List values; - - - public BedHeightSingle() { - } - - - public BedHeightSingle( - River river, - Integer year, - Integer soundingWidth, - BedHeightType type, - LocationSystem locationSystem, - ElevationModel curElevationModel, - Range range - ) { - this( - river, - year, - soundingWidth, - type, - locationSystem, - curElevationModel, - null, - range, - null, - null); - } - - - public BedHeightSingle( - River river, - Integer year, - Integer soundingWidth, - BedHeightType type, - LocationSystem locationSystem, - ElevationModel curElevationModel, - ElevationModel oldElevationModel, - Range range, - String evaluationBy, - String description - ) { - this.river = river; - this.year = year; - this.soundingWidth = soundingWidth; - this.type = type; - this.locationSystem = locationSystem; - this.curElevationModel = curElevationModel; - this.oldElevationModel = oldElevationModel; - this.range = range; - this.evaluationBy = evaluationBy; - this.description = description; - } - - - @Id - @SequenceGenerator( - name = "SEQUENCE_BED_HEIGHT_SINGLE_ID_SEQ", - sequenceName = "BED_HEIGHT_SINGLE_ID_SEQ", - allocationSize = 1) - @GeneratedValue( - strategy = GenerationType.SEQUENCE, - generator = "SEQUENCE_BED_HEIGHT_SINGLE_ID_SEQ") - @Column(name = "id") - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - @OneToOne - @JoinColumn(name = "river_id" ) - public River getRiver() { - return river; - } - - public void setRiver(River river) { - this.river = river; - } - - @Column(name = "year") - public Integer getYear() { - return year; - } - - public void setYear(Integer year) { - this.year = year; - } - - @Column(name = "sounding_width") - public Integer getSoundingWidth() { - return soundingWidth; - } - - public void setSoundingWidth(Integer soundingWidth) { - this.soundingWidth = soundingWidth; - } - - @OneToOne - @JoinColumn(name = "type_id") - public BedHeightType getType() { - return type; - } - - public void setType(BedHeightType type) { - this.type = type; - } - - @OneToOne - @JoinColumn(name = "location_system_id") - public LocationSystem getLocationSystem() { - return locationSystem; - } - - public void setLocationSystem(LocationSystem locationSystem) { - this.locationSystem = locationSystem; - } - - @OneToOne - @JoinColumn(name = "cur_elevation_model_id") - public ElevationModel getCurElevationModel() { - return curElevationModel; - } - - public void setCurElevationModel(ElevationModel curElevationModel) { - this.curElevationModel = curElevationModel; - } - - @OneToOne - @JoinColumn(name = "old_elevation_model_id") - public ElevationModel getOldElevationModel() { - return oldElevationModel; - } - - public void setOldElevationModel(ElevationModel oldElevationModel) { - this.oldElevationModel = oldElevationModel; - } - - @OneToOne - @JoinColumn(name = "range_id") - public Range getRange() { - return range; - } - - public void setRange(Range range) { - this.range = range; - } - - @Column(name = "evaluation_by") - public String getEvaluationBy() { - return evaluationBy; - } - - public void setEvaluationBy(String evaluationBy) { - this.evaluationBy = evaluationBy; - } - - @Column(name = "description") - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - @OneToMany - @JoinColumn(name = "bed_height_single_id") - public List getValues() { - return values; - } - - public void setValues(List values) { - this.values = values; - } - - - public static List getBedHeightSingles( - River river, - double kmLo, - double kmHi - ) { - Session session = SessionHolder.HOLDER.get(); - - Query query = session.createQuery( - "from BedHeightSingle where river=:river"); - - query.setParameter("river", river); - - // TODO Do km range filtering in SQL statement - - List singles = query.list(); - List good = new ArrayList(); - - for (BedHeightSingle s: singles) { - for (BedHeightSingleValue value: s.getValues()) { - double station = value.getStation().doubleValue(); - - if (station >= kmLo && station <= kmHi) { - good.add(s); - break; - } - } - } - - return good; - } - - - public static BedHeightSingle getBedHeightSingleById(int id) { - Session session = SessionHolder.HOLDER.get(); - - Query query = session.createQuery( - "from BedHeightSingle where id=:id"); - - query.setParameter("id", id); - - List singles = query.list(); - - return singles != null ? singles.get(0) : null; - } -} -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r d0ea092a32f5 -r 6d8d7425a6b5 backend/src/main/java/org/dive4elements/river/model/BedHeightSingleValue.java --- a/backend/src/main/java/org/dive4elements/river/model/BedHeightSingleValue.java Mon Feb 16 10:12:12 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,162 +0,0 @@ -/* 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.model; - -import java.util.List; - -import java.io.Serializable; - -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; -import javax.persistence.GeneratedValue; -import javax.persistence.Column; -import javax.persistence.SequenceGenerator; -import javax.persistence.GenerationType; -import javax.persistence.JoinColumn; -import javax.persistence.OneToOne; - -import org.apache.log4j.Logger; - -import org.hibernate.Session; -import org.hibernate.Query; - -import org.dive4elements.river.backend.SessionHolder; - - -@Entity -@Table(name = "bed_height_single_values") -public class BedHeightSingleValue -implements Serializable -{ - private static Logger log = - Logger.getLogger(BedHeightSingleValue.class); - - private Integer id; - - private BedHeightSingle bedHeight; - - private Double station; - private Double height; - private Double uncertainty; - private Double dataGap; - private Double soundingWidth; - - - public BedHeightSingleValue() { - } - - public BedHeightSingleValue( - BedHeightSingle bedHeight, - Double station, - Double height, - Double uncertainty, - Double dataGap, - Double soundingWidth - ) { - this.bedHeight = bedHeight; - this.station = station; - this.height = height; - this.uncertainty = uncertainty; - this.dataGap = dataGap; - this.soundingWidth = soundingWidth; - } - - @Id - @SequenceGenerator( - name = "SEQUENCE_BED_SINGLE_VALUE_ID_SEQ", - sequenceName = "BED_SINGLE_VALUES_ID_SEQ", - allocationSize = 1) - @GeneratedValue( - strategy = GenerationType.SEQUENCE, - generator = "SEQUENCE_BED_SINGLE_VALUE_ID_SEQ") - @Column(name = "id") - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - @OneToOne - @JoinColumn(name = "bed_height_single_id" ) - public BedHeightSingle getBedHeight() { - return bedHeight; - } - - public void setBedHeight(BedHeightSingle bedHeight) { - this.bedHeight = bedHeight; - } - - @Column(name = "station") - public Double getStation() { - return station; - } - - public void setStation(Double station) { - this.station = station; - } - - @Column(name = "height") - public Double getHeight() { - return height; - } - - public void setHeight(Double height) { - this.height = height; - } - - @Column(name="uncertainty") - public Double getUncertainty() { - return uncertainty; - } - - public void setUncertainty(Double uncertainty) { - this.uncertainty = uncertainty; - } - - @Column(name="data_gap") - public Double getDataGap() { - return dataGap; - } - - public void setDataGap(Double dataGap) { - this.dataGap = dataGap; - } - - @Column(name="sounding_width") - public Double getSoundingWidth() { - return soundingWidth; - } - - public void setSoundingWidth(Double soundingWidth) { - this.soundingWidth = soundingWidth; - } - - - public static List getBedHeightSingleValues( - BedHeightSingle single, - double kmLo, - double kmHi - ) { - Session session = SessionHolder.HOLDER.get(); - - Query query = session.createQuery( - "from BedHeightSingleValue where bedHeight=:single " + - " and station >= :kmLo and station <= :kmHi"); - - query.setParameter("single", single); - query.setParameter("kmLo", new Double(kmLo)); - query.setParameter("kmHi", new Double(kmHi)); - - return query.list(); - } -} -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r d0ea092a32f5 -r 6d8d7425a6b5 backend/src/main/java/org/dive4elements/river/model/BedHeightValue.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/backend/src/main/java/org/dive4elements/river/model/BedHeightValue.java Mon Feb 16 11:08:33 2015 +0100 @@ -0,0 +1,162 @@ +/* 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.model; + +import java.util.List; + +import java.io.Serializable; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; +import javax.persistence.GeneratedValue; +import javax.persistence.Column; +import javax.persistence.SequenceGenerator; +import javax.persistence.GenerationType; +import javax.persistence.JoinColumn; +import javax.persistence.OneToOne; + +import org.apache.log4j.Logger; + +import org.hibernate.Session; +import org.hibernate.Query; + +import org.dive4elements.river.backend.SessionHolder; + + +@Entity +@Table(name = "bed_height_values") +public class BedHeightValue +implements Serializable +{ + private static Logger log = + Logger.getLogger(BedHeightValue.class); + + private Integer id; + + private BedHeight bedHeight; + + private Double station; + private Double height; + private Double uncertainty; + private Double dataGap; + private Double soundingWidth; + + + public BedHeightValue() { + } + + public BedHeightValue( + BedHeight bedHeight, + Double station, + Double height, + Double uncertainty, + Double dataGap, + Double soundingWidth + ) { + this.bedHeight = bedHeight; + this.station = station; + this.height = height; + this.uncertainty = uncertainty; + this.dataGap = dataGap; + this.soundingWidth = soundingWidth; + } + + @Id + @SequenceGenerator( + name = "SEQUENCE_BED_HEIGHT_VALUE_ID_SEQ", + sequenceName = "BED_HEIGHT_VALUES_ID_SEQ", + allocationSize = 1) + @GeneratedValue( + strategy = GenerationType.SEQUENCE, + generator = "SEQUENCE_BED_HEIGHT_VALUE_ID_SEQ") + @Column(name = "id") + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + @OneToOne + @JoinColumn(name = "bed_height_id" ) + public BedHeight getBedHeight() { + return bedHeight; + } + + public void setBedHeight(BedHeight bedHeight) { + this.bedHeight = bedHeight; + } + + @Column(name = "station") + public Double getStation() { + return station; + } + + public void setStation(Double station) { + this.station = station; + } + + @Column(name = "height") + public Double getHeight() { + return height; + } + + public void setHeight(Double height) { + this.height = height; + } + + @Column(name="uncertainty") + public Double getUncertainty() { + return uncertainty; + } + + public void setUncertainty(Double uncertainty) { + this.uncertainty = uncertainty; + } + + @Column(name="data_gap") + public Double getDataGap() { + return dataGap; + } + + public void setDataGap(Double dataGap) { + this.dataGap = dataGap; + } + + @Column(name="sounding_width") + public Double getSoundingWidth() { + return soundingWidth; + } + + public void setSoundingWidth(Double soundingWidth) { + this.soundingWidth = soundingWidth; + } + + + public static List getBedHeightValues( + BedHeight single, + double kmLo, + double kmHi + ) { + Session session = SessionHolder.HOLDER.get(); + + Query query = session.createQuery( + "from BedHeightValue where bedHeight=:single " + + " and station >= :kmLo and station <= :kmHi"); + + query.setParameter("single", single); + query.setParameter("kmLo", new Double(kmLo)); + query.setParameter("kmHi", new Double(kmHi)); + + return query.list(); + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :