# HG changeset patch # User Sascha L. Teichmann # Date 1310728334 0 # Node ID 31d8638760b196051499341953fe185a34980d82 # Parent c12b5fbd33e8fe0a2c1c873c3a195d4784ba6b2b New. The hibernate models for the HYK structures. flys-backend/trunk@2336 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r c12b5fbd33e8 -r 31d8638760b1 flys-backend/ChangeLog --- a/flys-backend/ChangeLog Fri Jul 15 09:36:23 2011 +0000 +++ b/flys-backend/ChangeLog Fri Jul 15 11:12:14 2011 +0000 @@ -1,3 +1,18 @@ +2011-07-15 Sascha L. Teichmann + + * src/main/java/de/intevation/flys/model/HYKFormation.java, + src/main/java/de/intevation/flys/model/HYKEntry.java, + src/main/java/de/intevation/flys/model/HYKFlowZone.java, + src/main/java/de/intevation/flys/model/HYKFlowZoneType.java, + src/main/java/de/intevation/flys/model/HYK.java: New. The hibernate models + for the HYK structures. + + * src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java: + Registered new models. + + * src/main/java/de/intevation/flys/model/CrossSection.java: Added + 'order by' annotation for fetching the cross section lines. + 2011-07-15 Sascha L. Teichmann * doc/schema/postgresql.sql: Added structures for HYKs "Hydraulische Kenngroessen" @@ -5,7 +20,6 @@ BEGIN; CREATE SEQUENCE HYKS_ID_SEQ; - CREATE TABLE hyks ( id int PRIMARY KEY NOT NULL, river_id int NOT NULL, @@ -13,7 +27,6 @@ ); CREATE SEQUENCE HYK_ENTRIES_ID_SEQ; - CREATE TABLE hyk_entries ( id int PRIMARY KEY NOT NULL, hyk_id int NOT NULL REFERENCES hyks(id), @@ -22,7 +35,6 @@ ); CREATE SEQUENCE HYK_FORMATIONS_ID_SEQ; - CREATE TABLE hyk_formations ( id int PRIMARY KEY NOT NULL, formation_num int NOT NULL DEFAULT 0, @@ -33,7 +45,6 @@ ); CREATE SEQUENCE HYK_FLOW_ZONE_TYPES_ID_SEQ; - CREATE TABLE hyk_flow_zone_types ( id int PRIMARY KEY NOT NULL, name VARCHAR(50) NOT NULL UNIQUE, @@ -41,7 +52,6 @@ ); CREATE SEQUENCE HYK_FLOW_ZONES_ID_SEQ; - CREATE TABLE hyk_flow_zones ( id int PRIMARY KEY NOT NULL, formation_id int NOT NULL REFERENCES hyk_formations(id), diff -r c12b5fbd33e8 -r 31d8638760b1 flys-backend/src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java --- a/flys-backend/src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java Fri Jul 15 09:36:23 2011 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java Fri Jul 15 11:12:14 2011 +0000 @@ -19,6 +19,11 @@ import de.intevation.flys.model.DischargeTableValue; import de.intevation.flys.model.Edge; import de.intevation.flys.model.Gauge; +import de.intevation.flys.model.HYK; +import de.intevation.flys.model.HYKEntry; +import de.intevation.flys.model.HYKFormation; +import de.intevation.flys.model.HYKFlowZoneType; +import de.intevation.flys.model.HYKFlowZone; import de.intevation.flys.model.MainValueType; import de.intevation.flys.model.NamedMainValue; import de.intevation.flys.model.MainValue; @@ -127,6 +132,11 @@ cfg.addAnnotatedClass(DischargeTableValue.class); cfg.addAnnotatedClass(Edge.class); cfg.addAnnotatedClass(Gauge.class); + cfg.addAnnotatedClass(HYK.class); + cfg.addAnnotatedClass(HYKEntry.class); + cfg.addAnnotatedClass(HYKFormation.class); + cfg.addAnnotatedClass(HYKFlowZoneType.class); + cfg.addAnnotatedClass(HYKFlowZone.class); cfg.addAnnotatedClass(MainValueType.class); cfg.addAnnotatedClass(NamedMainValue.class); cfg.addAnnotatedClass(MainValue.class); diff -r c12b5fbd33e8 -r 31d8638760b1 flys-backend/src/main/java/de/intevation/flys/model/CrossSection.java --- a/flys-backend/src/main/java/de/intevation/flys/model/CrossSection.java Fri Jul 15 09:36:23 2011 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/model/CrossSection.java Fri Jul 15 11:12:14 2011 +0000 @@ -13,6 +13,7 @@ import javax.persistence.GenerationType; import javax.persistence.OneToOne; import javax.persistence.OneToMany; +import javax.persistence.OrderBy; import javax.persistence.JoinColumn; @Entity @@ -86,6 +87,7 @@ } @OneToMany + @OrderBy("km") @JoinColumn(name="cross_section_id") public List getLines() { return lines; diff -r c12b5fbd33e8 -r 31d8638760b1 flys-backend/src/main/java/de/intevation/flys/model/HYK.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/model/HYK.java Fri Jul 15 11:12:14 2011 +0000 @@ -0,0 +1,85 @@ +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.OneToOne; +import javax.persistence.OneToMany; +import javax.persistence.OrderBy; +import javax.persistence.JoinColumn; + +@Entity +@Table(name = "hyks") +public class HYK +implements Serializable +{ + private Integer id; + private River river; + private String description; + + private List entries; + + public HYK() { + } + + public HYK(River river, String description) { + this.river = river; + this.description = description; + } + + @Id + @SequenceGenerator( + name = "SEQUENCE_HYKS_ID_SEQ", + sequenceName = "HYKS_ID_SEQ", + allocationSize = 1) + @GeneratedValue( + strategy = GenerationType.SEQUENCE, + generator = "SEQUENCE_HYKS_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 = "name") + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + @OneToMany + @OrderBy("km") + @JoinColumn(name="hyk_id") + public List getEntries() { + return entries; + } + + public void setEntries(List entries) { + this.entries = entries; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r c12b5fbd33e8 -r 31d8638760b1 flys-backend/src/main/java/de/intevation/flys/model/HYKEntry.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/model/HYKEntry.java Fri Jul 15 11:12:14 2011 +0000 @@ -0,0 +1,87 @@ +package de.intevation.flys.model; + +import java.io.Serializable; + +import java.math.BigDecimal; + +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.OneToOne; +import javax.persistence.OneToMany; +import javax.persistence.OrderBy; +import javax.persistence.JoinColumn; + +@Entity +@Table(name = "hyk_entries") +public class HYKEntry +implements Serializable +{ + private Integer id; + private HYK hyk; + private BigDecimal km; + + private List formations; + + public HYKEntry() { + } + + public HYKEntry(HYK hyk, BigDecimal km) { + this.hyk = hyk; + this.km = km; + } + + @Id + @SequenceGenerator( + name = "SEQUENCE_HYK_ENTRIES_ID_SEQ", + sequenceName = "HYK_ENTRIES_ID_SEQ", + allocationSize = 1) + @GeneratedValue( + strategy = GenerationType.SEQUENCE, + generator = "SEQUENCE_HYK_ENTRIES_ID_SEQ") + @Column(name = "id") + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + @OneToOne + @JoinColumn(name = "hyk_id") + public HYK getHYK() { + return hyk; + } + + public void setHYK(HYK hyk) { + this.hyk = hyk; + } + + @Column(name = "km") + public BigDecimal getKm() { + return km; + } + + public void setKm(BigDecimal km) { + this.km = km; + } + + @OneToMany + @OrderBy("formation_num") + @JoinColumn(name="hyk_entry_id") + public List getFormations() { + return formations; + } + + public void setFormations(List formations) { + this.formations = formations; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r c12b5fbd33e8 -r 31d8638760b1 flys-backend/src/main/java/de/intevation/flys/model/HYKFlowZone.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/model/HYKFlowZone.java Fri Jul 15 11:12:14 2011 +0000 @@ -0,0 +1,98 @@ +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.OneToOne; +import javax.persistence.JoinColumn; + +@Entity +@Table(name = "hyk_flow_zones") +public class HYKFlowZone +implements Serializable +{ + private Integer id; + private HYKFormation formation; + private HYKFlowZoneType type; + private BigDecimal a; + private BigDecimal b; + + public HYKFlowZone() { + } + + public HYKFlowZone( + HYKFormation formation, + HYKFlowZoneType type, + BigDecimal a, + BigDecimal b + ) { + this.formation = formation; + this.type = type; + this.a = a; + this.b = b; + } + + @Id + @SequenceGenerator( + name = "SEQUENCE_HYK_FLOW_ZONES_ID_SEQ", + sequenceName = "HYK_FLOW_ZONES_ID_SEQ", + allocationSize = 1) + @GeneratedValue( + strategy = GenerationType.SEQUENCE, + generator = "SEQUENCE_HYK_FLOW_ZONES_ID_SEQ") + @Column(name = "id") + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + @OneToOne + @JoinColumn(name = "formation_id") + public HYKFormation getFormation() { + return formation; + } + + public void setFormation(HYKFormation formation) { + this.formation = formation; + } + + @OneToOne + @JoinColumn(name = "type_id") + public HYKFlowZoneType getType() { + return type; + } + + public void setType(HYKFlowZoneType type) { + this.type = type; + } + + @Column(name = "a") + public BigDecimal getA() { + return a; + } + + public void setA(BigDecimal a) { + this.a = a; + } + + @Column(name = "b") + public BigDecimal getB() { + return b; + } + + public void setB(BigDecimal b) { + this.b = b; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r c12b5fbd33e8 -r 31d8638760b1 flys-backend/src/main/java/de/intevation/flys/model/HYKFlowZoneType.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/model/HYKFlowZoneType.java Fri Jul 15 11:12:14 2011 +0000 @@ -0,0 +1,69 @@ +package de.intevation.flys.model; + +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; + +@Entity +@Table(name = "hyk_flow_zone_types") +public class HYKFlowZoneType +implements Serializable +{ + private Integer id; + private String name; + private String description; + + public HYKFlowZoneType() { + } + + public HYKFlowZoneType(String name) { + this.name = name; + } + + public HYKFlowZoneType(String name, String description) { + this.name = name; + this.description = description; + } + + @Id + @SequenceGenerator( + name = "SEQUENCE_HYK_FLOW_ZONE_TYPES_ID_SEQ", + sequenceName = "HYK_FLOW_ZONE_TYPES_ID_SEQ", + allocationSize = 1) + @GeneratedValue( + strategy = GenerationType.SEQUENCE, + generator = "SEQUENCE_HYK_FLOW_ZONE_TYPES_ID_SEQ") + @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; + } + + @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 : diff -r c12b5fbd33e8 -r 31d8638760b1 flys-backend/src/main/java/de/intevation/flys/model/HYKFormation.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/model/HYKFormation.java Fri Jul 15 11:12:14 2011 +0000 @@ -0,0 +1,114 @@ +package de.intevation.flys.model; + +import java.io.Serializable; + +import java.util.List; + +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.OneToOne; +import javax.persistence.OneToMany; +import javax.persistence.OrderBy; +import javax.persistence.JoinColumn; + +@Entity +@Table(name = "hyk_formations") +public class HYKFormation +implements Serializable +{ + private Integer id; + private Integer formationNum; + private HYKEntry entry; + private BigDecimal top; + private BigDecimal bottom; + + private List zones; + + public HYKFormation() { + } + + public HYKFormation( + Integer formationNum, + HYKEntry entry, + BigDecimal top, + BigDecimal bottom + ) { + this.formationNum = formationNum; + this.entry = entry; + this.top = top; + this.bottom = bottom; + } + + @Id + @SequenceGenerator( + name = "SEQUENCE_HYK_FORMATIONS_ID_SEQ", + sequenceName = "HYK_FORMATIONS_ID_SEQ", + allocationSize = 1) + @GeneratedValue( + strategy = GenerationType.SEQUENCE, + generator = "SEQUENCE_HYK_FORMATIONS_ID_SEQ") + @Column(name = "id") + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + @Column(name = "formation_num") + public Integer getFormationNum() { + return formationNum; + } + + public void setFormationNum(Integer formationNum) { + this.formationNum = formationNum; + } + + @OneToOne + @JoinColumn(name = "hyk_entry_id") + public HYKEntry getEntry() { + return entry; + } + + public void setEntry(HYKEntry entry) { + this.entry = entry; + } + + @Column(name = "top") + public BigDecimal getTop() { + return top; + } + + public void setTop(BigDecimal top) { + this.top = top; + } + + @Column(name = "bottom") + public BigDecimal getBottom() { + return bottom; + } + + public void setBottom(BigDecimal bottom) { + this.bottom = bottom; + } + + @OneToMany + @OrderBy("a") + @JoinColumn(name="formation_id") + public List getZones() { + return zones; + } + + public void setZones(List zones) { + this.zones = zones; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :