changeset 2812:a36a5407acbf

Improved the MINFO db schema and added model classes for storing sediment density values specific to a river and depth. flys-backend/trunk@4228 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 13 Apr 2012 08:16:55 +0000
parents 8926571e47fb
children f121c0f456ab
files flys-backend/ChangeLog flys-backend/doc/schema/oracle-drop-minfo.sql flys-backend/doc/schema/oracle-minfo.sql flys-backend/src/main/java/de/intevation/flys/model/Depth.java flys-backend/src/main/java/de/intevation/flys/model/SedimentDensity.java flys-backend/src/main/java/de/intevation/flys/model/SedimentDensityValue.java
diffstat 6 files changed, 314 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/flys-backend/ChangeLog	Fri Apr 13 07:24:55 2012 +0000
+++ b/flys-backend/ChangeLog	Fri Apr 13 08:16:55 2012 +0000
@@ -1,3 +1,14 @@
+2012-04-13  Ingo Weinzierl <ingo@intevation.de>
+
+	* doc/schema/oracle-minfo.sql,
+	  doc/schema/oracle-drop-minfo.sql: Improved the MINFO schema to store
+	  sediment density values specific to a river and depth.
+
+	* src/main/java/de/intevation/flys/model/SedimentDensityValue.java,
+	  src/main/java/de/intevation/flys/model/SedimentDensity.java,
+	  src/main/java/de/intevation/flys/model/Depth.java: New model classes
+	  used to store sediment density values specific to a river and depth.
+
 2012-04-13  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/importer/parsers/BedHeightParser.java:
--- a/flys-backend/doc/schema/oracle-drop-minfo.sql	Fri Apr 13 07:24:55 2012 +0000
+++ b/flys-backend/doc/schema/oracle-drop-minfo.sql	Fri Apr 13 08:16:55 2012 +0000
@@ -12,6 +12,10 @@
 ALTER TABLE bed_height_epoch DROP CONSTRAINT fk_epoch_cur_elevation_model;
 ALTER TABLE bed_height_epoch DROP CONSTRAINT fk_epoch_old_elevation_model;
 ALTER TABLE bed_height_epoch DROP CONSTRAINT fk_epoch_range;
+ALTER TABLE depths DROP CONSTRAINT fk_depths_unit_id;
+ALTER TABLE sediment_density DROP CONSTRAINT fk_sd_depth_id;
+ALTER TABLE sediment_density_values DROP CONSTRAINT fk_sdv_sediment_density_id;
+ALTER TABLE sediment_density_values DROP CONSTRAINT fk_sdv_station_id;
 
 DROP TABLE bed_height_type;
 DROP TABLE location_system;
@@ -20,6 +24,9 @@
 DROP TABLE bed_height_single_values;
 DROP TABLE bed_height_epoch_values;
 DROP TABLE bed_height_epoch;
+DROP TABLE depths;
+DROP TABLE sediment_density;
+DROP TABLE sediment_density_values;
 
 DROP SEQUENCE BED_HEIGHT_TYPE_SEQ;
 DROP SEQUENCE LOCATION_SYSTEM_SEQ;
@@ -28,4 +35,7 @@
 DROP SEQUENCE BED_SINGLE_VALUES_ID_SEQ;
 DROP SEQUENCE BED_EPOCH_VALUES_ID_SEQ;
 DROP SEQUENCE BED_HEIGHT_EPOCH_ID_SEQ;
+DROP SEQUENCE DEPTHS_ID_SEQ;
+DROP SEQUENCE SEDIMENT_DENSITY_ID_SEQ;
+DROP SEQUENCE SEDIMENT_DENSITY_VALUES_ID_SEQ;
 
--- a/flys-backend/doc/schema/oracle-minfo.sql	Fri Apr 13 07:24:55 2012 +0000
+++ b/flys-backend/doc/schema/oracle-minfo.sql	Fri Apr 13 08:16:55 2012 +0000
@@ -103,3 +103,40 @@
     CONSTRAINT fk_bed_epoch_values_parent FOREIGN KEY (bed_height_epoch_id) REFERENCES bed_height_epoch(id)
 );
 
+
+CREATE SEQUENCE DEPTHS_ID_SEQ;
+
+CREATE TABLE depths (
+    id      NUMBER(38,0) NOT NULL,
+    lower   NUMBER(38,2) NOT NULL,
+    upper   NUMBER(38,2) NOT NULL,
+    unit_id NUMBER(38,2) NOT NULL,
+    PRIMARY KEY(id),
+    CONSTRAINT fk_depths_unit_id FOREIGN KEY (unit_id) REFERENCES units(id)
+);
+
+
+CREATE SEQUENCE SEDIMENT_DENSITY_ID_SEQ;
+
+CREATE TABLE sediment_density (
+    id          NUMBER(38,0) NOT NULL,
+    river_id    NUMBER(38,0) NOT NULL,
+    depth_id    NUMBER(38,0) NOT NULL,
+    PRIMARY KEY(id),
+    CONSTRAINT fk_sd_river_id FOREIGN KEY (river_id) REFERENCES rivers(id),
+    CONSTRAINT fk_sd_depth_id FOREIGN KEY (depth_id) REFERENCES depths(id)
+);
+
+
+CREATE SEQUENCE SEDIMENT_DENSITY_VALUES_ID_SEQ;
+
+CREATE TABLE sediment_density_values (
+    id                  NUMBER(38,0) NOT NULL,
+    sediment_density_id NUMBER(38,0) NOT NULL,
+    station_id          NUMBER(38,0) NOT NULL,
+    density             NUMBER(38,2) NOT NULL,
+    description         VARCHAR(256),
+    PRIMARY KEY(id),
+    CONSTRAINT fk_sdv_sediment_density_id FOREIGN KEY(sediment_density_id) REFERENCES sediment_density(id),
+    CONSTRAINT fk_sdv_station_id FOREIGN KEY (station_id) REFERENCES ranges(id)
+);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/model/Depth.java	Fri Apr 13 08:16:55 2012 +0000
@@ -0,0 +1,84 @@
+package de.intevation.flys.model;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+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;
+
+
+@Entity
+@Table(name = "depths")
+public class Depth implements Serializable {
+
+    private Integer id;
+
+    private BigDecimal lower;
+    private BigDecimal upper;
+
+    private Unit unit;
+
+
+    public Depth() {
+    }
+
+
+    public Depth(BigDecimal lower, BigDecimal upper, Unit unit) {
+        this.lower = lower;
+        this.upper = upper;
+        this.unit  = unit;
+    }
+
+    @Id
+    @SequenceGenerator(
+        name           = "SEQUENCE_DEPTHS_ID_SEQ",
+        sequenceName   = "DEPTHS_ID_SEQ",
+        allocationSize = 1)
+    @GeneratedValue(
+        strategy  = GenerationType.SEQUENCE,
+        generator = "SEQUENCE_DEPTHS_ID_SEQ")
+    @Column(name = "id")
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    @Column(name = "lower")
+    public BigDecimal getLower() {
+        return lower;
+    }
+
+    public void setLower(BigDecimal lower) {
+        this.lower = lower;
+    }
+
+    @Column(name = "upper")
+    public BigDecimal getUpper() {
+        return upper;
+    }
+
+    public void setUpper(BigDecimal upper) {
+        this.upper = upper;
+    }
+
+    @OneToOne
+    @JoinColumn(name = "unit_id")
+    public Unit getUnit() {
+        return unit;
+    }
+
+    public void setUnit(Unit unit) {
+        this.unit = unit;
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/model/SedimentDensity.java	Fri Apr 13 08:16:55 2012 +0000
@@ -0,0 +1,87 @@
+package de.intevation.flys.model;
+
+import java.io.Serializable;
+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;
+
+
+@Entity
+@Table(name = "sediment_density")
+public class SedimentDensity implements Serializable {
+
+    private Integer id;
+
+    private River river;
+
+    private Depth depth;
+
+    private List<SedimentDensityValue> values;
+
+
+    public SedimentDensity() {
+    }
+
+
+    public SedimentDensity(River river, Depth depth) {
+        this.river = river;
+        this.depth = depth;
+    }
+
+    @Id
+    @SequenceGenerator(
+        name           = "SEQUENCE_SEDIMENT_DENSITY_ID_SEQ",
+        sequenceName   = "SEDIMENT_DENSITY_ID_SEQ",
+        allocationSize = 1)
+    @GeneratedValue(
+        strategy  = GenerationType.SEQUENCE,
+        generator = "SEQUENCE_SEDIMENT_DENSITY_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;
+    }
+
+    @OneToOne
+    @JoinColumn(name = "depth_id")
+    public Depth getDepth() {
+        return depth;
+    }
+
+    public void setDepth(Depth depth) {
+        this.depth = depth;
+    }
+
+    @OneToMany
+    @JoinColumn(name="sediment_density_id")
+    public List<SedimentDensityValue> getValues() {
+        return values;
+    }
+
+    public void addValue(SedimentDensityValue value) {
+        this.values.add(value);
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/model/SedimentDensityValue.java	Fri Apr 13 08:16:55 2012 +0000
@@ -0,0 +1,85 @@
+package de.intevation.flys.model;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+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;
+
+
+@Entity
+@Table(name = "sediment_density_values")
+public class SedimentDensityValue implements Serializable {
+
+    private Integer id;
+
+    private Range station;
+
+    private BigDecimal density;
+
+    private String description;
+
+
+    public SedimentDensityValue() {
+    }
+
+
+    public SedimentDensityValue(Range station, BigDecimal density, String desc) {
+        this.station     = station;
+        this.density     = density;
+        this.description = desc;
+    }
+
+    @Id
+    @SequenceGenerator(
+        name           = "SEQUENCE_SEDIMENT_DENSITY_VALUES_ID_SEQ",
+        sequenceName   = "SEDIMENT_DENSITY_VALUES_ID_SEQ",
+        allocationSize = 1)
+    @GeneratedValue(
+        strategy  = GenerationType.SEQUENCE,
+        generator = "SEQUENCE_SEDIMENT_DENSITY_VALUES_ID_SEQ")
+    @Column(name = "id")
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    @OneToOne
+    @JoinColumn(name = "station_id")
+    public Range getStation() {
+        return station;
+    }
+
+    public void setStation(Range station) {
+        this.station = station;
+    }
+
+    @Column(name = "density")
+    public BigDecimal getDensity() {
+        return density;
+    }
+
+    public void setDensity(BigDecimal density) {
+        this.density = density;
+    }
+
+    @Column(name = "description")
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org