annotate flys-backend/src/main/java/de/intevation/flys/model/FlowVelocityModel.java @ 5745:ed9d7e360658

Merged.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 17 Apr 2013 15:00:38 +0200
parents c7ce7c9e405e
children
rev   line source
2825
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.model;
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
5323
c7ce7c9e405e Removed river dependency from flow velocity model.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 2871
diff changeset
3 import de.intevation.flys.backend.SessionHolder;
c7ce7c9e405e Removed river dependency from flow velocity model.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 2871
diff changeset
4
2825
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
5 import java.io.Serializable;
5323
c7ce7c9e405e Removed river dependency from flow velocity model.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 2871
diff changeset
6
2825
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
7 import java.util.List;
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
8
5323
c7ce7c9e405e Removed river dependency from flow velocity model.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 2871
diff changeset
9 import javax.persistence.Column;
2825
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10 import javax.persistence.Entity;
5323
c7ce7c9e405e Removed river dependency from flow velocity model.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 2871
diff changeset
11 import javax.persistence.GeneratedValue;
c7ce7c9e405e Removed river dependency from flow velocity model.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 2871
diff changeset
12 import javax.persistence.GenerationType;
2825
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13 import javax.persistence.Id;
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14 import javax.persistence.JoinColumn;
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
15 import javax.persistence.OneToOne;
5323
c7ce7c9e405e Removed river dependency from flow velocity model.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 2871
diff changeset
16 import javax.persistence.SequenceGenerator;
c7ce7c9e405e Removed river dependency from flow velocity model.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 2871
diff changeset
17 import javax.persistence.Table;
2871
5a89c2b05e6d Added functions to retrieve data from database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2825
diff changeset
18
2825
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19 import org.apache.log4j.Logger;
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20
5323
c7ce7c9e405e Removed river dependency from flow velocity model.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 2871
diff changeset
21 import org.hibernate.Query;
c7ce7c9e405e Removed river dependency from flow velocity model.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 2871
diff changeset
22 import org.hibernate.Session;
2871
5a89c2b05e6d Added functions to retrieve data from database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2825
diff changeset
23
2825
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25 @Entity
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26 @Table(name = "flow_velocity_model")
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
27 public class FlowVelocityModel
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28 implements Serializable
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29 {
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30 private static Logger logger = Logger.getLogger(FlowVelocityModel.class);
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
33 private Integer id;
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
34
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
35 private DischargeZone dischargeZone;
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
36
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
37 private String description;
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
39
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40 public FlowVelocityModel() {
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
41 }
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
42
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
43
5323
c7ce7c9e405e Removed river dependency from flow velocity model.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 2871
diff changeset
44 public FlowVelocityModel(DischargeZone dischargeZone) {
c7ce7c9e405e Removed river dependency from flow velocity model.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 2871
diff changeset
45 this(dischargeZone, null);
2825
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
46 }
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
48
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
49 public FlowVelocityModel(
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
50 DischargeZone dischargeZone,
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
51 String description
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
52 ) {
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
53 this.dischargeZone = dischargeZone;
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
54 this.description = description;
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
55 }
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
56
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
57 @Id
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
58 @SequenceGenerator(
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
59 name = "SEQUENCE_FLOW_VELOCITY_MODEL_ID_SEQ",
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
60 sequenceName = "FLOW_VELOCITY_MODEL_ID_SEQ",
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
61 allocationSize = 1)
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
62 @GeneratedValue(
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
63 strategy = GenerationType.SEQUENCE,
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
64 generator = "SEQUENCE_FLOW_VELOCITY_MODEL_ID_SEQ")
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
65 @Column(name = "id")
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
66 public Integer getId() {
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
67 return id;
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
68 }
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
69
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
70 public void setId(Integer id) {
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
71 this.id = id;
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
72 }
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
73
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
74 @OneToOne
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
75 @JoinColumn(name = "discharge_zone_id")
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
76 public DischargeZone getDischargeZone() {
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
77 return dischargeZone;
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
78 }
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
79
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
80 public void setDischargeZone(DischargeZone dischargeZone) {
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
81 this.dischargeZone = dischargeZone;
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
82 }
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
83
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
84 @Column(name = "description")
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
85 public String getDescription() {
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
86 return description;
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
87 }
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
88
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
89 public void setDescription(String description) {
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
90 this.description = description;
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
91 }
2871
5a89c2b05e6d Added functions to retrieve data from database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2825
diff changeset
92
5a89c2b05e6d Added functions to retrieve data from database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2825
diff changeset
93
5323
c7ce7c9e405e Removed river dependency from flow velocity model.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 2871
diff changeset
94 public static List<FlowVelocityModel> getModels(DischargeZone zone) {
c7ce7c9e405e Removed river dependency from flow velocity model.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 2871
diff changeset
95
2871
5a89c2b05e6d Added functions to retrieve data from database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2825
diff changeset
96 Session session = SessionHolder.HOLDER.get();
5a89c2b05e6d Added functions to retrieve data from database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2825
diff changeset
97
5a89c2b05e6d Added functions to retrieve data from database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2825
diff changeset
98 Query query = session.createQuery(
5323
c7ce7c9e405e Removed river dependency from flow velocity model.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 2871
diff changeset
99 "from FlowVelocityModel where dischargeZone=:zone");
2871
5a89c2b05e6d Added functions to retrieve data from database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2825
diff changeset
100
5a89c2b05e6d Added functions to retrieve data from database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2825
diff changeset
101 query.setParameter("zone", zone);
5a89c2b05e6d Added functions to retrieve data from database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2825
diff changeset
102
5a89c2b05e6d Added functions to retrieve data from database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2825
diff changeset
103 return query.list();
5a89c2b05e6d Added functions to retrieve data from database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2825
diff changeset
104 }
2825
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
105 }
a948366d8ac5 Added new model classes for MINFO specific flow velocity.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
106 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org