Mercurial > dive4elements > river
changeset 8683:cfafe5764509
(issue 1796) Scheme change! Add model for seddb_name lookup table.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Mon, 13 Apr 2015 11:24:32 +0200 |
parents | 5102733c4567 |
children | 2e11fc7f5d35 |
files | backend/doc/schema/oracle-drop.sql backend/doc/schema/oracle.sql backend/doc/schema/postgresql.sql backend/src/main/java/org/dive4elements/river/backend/FLYSCredentials.java backend/src/main/java/org/dive4elements/river/model/River.java backend/src/main/java/org/dive4elements/river/model/SeddbName.java |
diffstat | 6 files changed, 94 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/backend/doc/schema/oracle-drop.sql Mon Apr 13 11:03:00 2015 +0200 +++ b/backend/doc/schema/oracle-drop.sql Mon Apr 13 11:24:32 2015 +0200 @@ -24,6 +24,7 @@ ALTER TABLE official_lines DROP CONSTRAINT cOffLinesWstColumns; ALTER TABLE ranges DROP CONSTRAINT cRangesRivers; ALTER TABLE rivers DROP CONSTRAINT cRiversUnits; +ALTER TABLE rivers DROP CONSTRAINT cRiversSeddbNames; ALTER TABLE wst_column_q_ranges DROP CONSTRAINT cWstColumnQRangesWstColums; ALTER TABLE wst_column_q_ranges DROP CONSTRAINT cWstColumnQRangesWstQRanges; ALTER TABLE wst_column_values DROP CONSTRAINT cWstColumnValuesWstColumns; @@ -62,6 +63,7 @@ DROP TABLE official_lines PURGE; DROP TABLE wsts PURGE; DROP TABLE wst_kinds PURGE; +DROP TABLE seddb_names PURGE; DROP SEQUENCE ANNOTATION_TYPES_ID_SEQ; DROP SEQUENCE ANNOTATIONS_ID_SEQ; DROP SEQUENCE ATTRIBUTES_ID_SEQ;
--- a/backend/doc/schema/oracle.sql Mon Apr 13 11:03:00 2015 +0200 +++ b/backend/doc/schema/oracle.sql Mon Apr 13 11:24:32 2015 +0200 @@ -255,6 +255,14 @@ CHECK (a < b) ); +-- SEDDB_NAME +-- Lookup table for seddb river names +CREATE TABLE seddb_name ( + id NUMBER(38,0) NOT NULL, + name VARCHAR2(255) NOT NULL, + PRIMARY KEY (id) +); +INSERT INTO seddb_name (id, name) VALUES (0, 'Rhein'); -- RIVERS @@ -267,6 +275,7 @@ km_up int DEFAULT 0 NOT NULL, name VARCHAR2(255) NOT NULL UNIQUE, wst_unit_id NUMBER(38,0) NOT NULL, + seddb_name_id NUMBER(38,0), PRIMARY KEY (id), CHECK(km_up IN(0,1)) ); @@ -398,6 +407,7 @@ ALTER TABLE main_values ADD CONSTRAINT cMainValuesTimeIntervals FOREIGN KEY (time_interval_id) REFERENCES time_intervals; ALTER TABLE named_main_values ADD CONSTRAINT cNamedMainValuesMainValueTypes FOREIGN KEY (type_id) REFERENCES main_value_types; ALTER TABLE rivers ADD CONSTRAINT cRiversUnits FOREIGN KEY (wst_unit_id) REFERENCES units; +ALTER TABLE rivers ADD CONSTRAINT cRiversSeddbNames FOREIGN KEY (seddb_name_id) REFERENCES seddb_name; ALTER TABLE wst_columns ADD CONSTRAINT cWstColumnsTime_intervals FOREIGN KEY (time_interval_id) REFERENCES time_intervals; -- Cascading references
--- a/backend/doc/schema/postgresql.sql Mon Apr 13 11:03:00 2015 +0200 +++ b/backend/doc/schema/postgresql.sql Mon Apr 13 11:24:32 2015 +0200 @@ -7,6 +7,15 @@ name VARCHAR(32) NOT NULL UNIQUE ); +-- SEDDB_NAME +-- Lookup table for seddb river names + +CREATE TABLE seddb_name ( + id int PRIMARY KEY NOT NULL, + name VARCHAR(256) NOT NULL +); +INSERT INTO seddb_name (id, name) VALUES (0, 'Rhein'); + -- Gewaesser CREATE SEQUENCE RIVERS_ID_SEQ; @@ -17,6 +26,7 @@ name VARCHAR(256) NOT NULL UNIQUE, km_up int DEFAULT 0 NOT NULL, wst_unit_id int NOT NULL REFERENCES units(id), + seddb_name_id int REFERENCES seddb_name(id), CHECK(km_up IN(0,1)) );
--- a/backend/src/main/java/org/dive4elements/river/backend/FLYSCredentials.java Mon Apr 13 11:03:00 2015 +0200 +++ b/backend/src/main/java/org/dive4elements/river/backend/FLYSCredentials.java Mon Apr 13 11:24:32 2015 +0200 @@ -72,6 +72,7 @@ import org.dive4elements.river.model.SQRelationValue; import org.dive4elements.river.model.SectieKind; import org.dive4elements.river.model.SobekKind; +import org.dive4elements.river.model.SeddbName; import org.dive4elements.river.model.SedimentDensity; import org.dive4elements.river.model.SedimentDensityValue; import org.dive4elements.river.model.SedimentLoad; @@ -207,6 +208,7 @@ PorosityValue.class, SectieKind.class, SobekKind.class, + SeddbName.class, SedimentDensity.class, SedimentDensityValue.class, SedimentLoad.class,
--- a/backend/src/main/java/org/dive4elements/river/model/River.java Mon Apr 13 11:03:00 2015 +0200 +++ b/backend/src/main/java/org/dive4elements/river/model/River.java Mon Apr 13 11:24:32 2015 +0200 @@ -66,6 +66,8 @@ private Unit wstUnit; + private SeddbName seddbName; + @Id @SequenceGenerator( name = "SEQUENCE_RIVERS_ID_SEQ", @@ -149,6 +151,32 @@ } + /** + * Get alternative seddb name. + * + * This is the name should be used in seddb queries + * and might differ from "our" backend db name. + * + * @return The name River in the seddb. + */ + public String nameForSeddb() { + SeddbName alt = getSeddbName(); + if (alt == null) { + return getName(); + } + return alt.getName(); + } + + + @OneToOne + @JoinColumn(name = "seddb_name_id" ) + public SeddbName getSeddbName() { + return seddbName; + } + + public void setSeddbName(SeddbName name) { + this.seddbName = name; + } @Override public String toString() {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/backend/src/main/java/org/dive4elements/river/model/SeddbName.java Mon Apr 13 11:24:32 2015 +0200 @@ -0,0 +1,42 @@ +/* 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 javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; + +@Entity +@Table(name = "seddb_name") +public class SeddbName implements Serializable { + private Integer id; + private String name; + + @Id + @Column(name = "id") + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + @Column(name = "name") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +}