annotate flys-backend/src/main/java/de/intevation/flys/model/BedHeightEpochValue.java @ 4846:298d540f7b70

WINFOArtifact: Use RangeAccess.getLocations instead of FLYSUtils.getLocations.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 23 Jan 2013 10:40:35 +0100
parents 1894e0471eac
children
rev   line source
2810
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.model;
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
2873
1894e0471eac Added functions to retrieve bed height single and epoch values based on its owner and km range.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2810
diff changeset
3 import java.util.List;
1894e0471eac Added functions to retrieve bed height single and epoch values based on its owner and km range.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2810
diff changeset
4
2810
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
5 import java.io.Serializable;
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
6 import java.math.BigDecimal;
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
7
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
8 import javax.persistence.Entity;
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
9 import javax.persistence.Id;
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10 import javax.persistence.Table;
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11 import javax.persistence.GeneratedValue;
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12 import javax.persistence.Column;
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13 import javax.persistence.SequenceGenerator;
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14 import javax.persistence.GenerationType;
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
15 import javax.persistence.JoinColumn;
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
16 import javax.persistence.OneToOne;
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
17
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18 import org.apache.log4j.Logger;
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19
2873
1894e0471eac Added functions to retrieve bed height single and epoch values based on its owner and km range.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2810
diff changeset
20 import org.hibernate.Session;
1894e0471eac Added functions to retrieve bed height single and epoch values based on its owner and km range.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2810
diff changeset
21 import org.hibernate.Query;
1894e0471eac Added functions to retrieve bed height single and epoch values based on its owner and km range.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2810
diff changeset
22
1894e0471eac Added functions to retrieve bed height single and epoch values based on its owner and km range.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2810
diff changeset
23 import de.intevation.flys.backend.SessionHolder;
1894e0471eac Added functions to retrieve bed height single and epoch values based on its owner and km range.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2810
diff changeset
24
2810
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26 @Entity
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
27 @Table(name = "bed_height_epoch_values")
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28 public class BedHeightEpochValue
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29 implements Serializable
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30 {
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31 private static Logger logger =
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32 Logger.getLogger(BedHeightEpochValue.class);
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
33
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
34 private Integer id;
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
35
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
36 private BedHeightEpoch bedHeight;
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
37
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38 private BigDecimal station;
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
39 private BigDecimal height;
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
41
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
42 public BedHeightEpochValue() {
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
43 }
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
44
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45 public BedHeightEpochValue(
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
46 BedHeightEpoch bedHeight,
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47 BigDecimal station,
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
48 BigDecimal height
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
49 ) {
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
50 this.bedHeight = bedHeight;
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
51 this.station = station;
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
52 this.height = height;
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
53 }
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
54
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
55 @Id
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
56 @SequenceGenerator(
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
57 name = "SEQUENCE_BED_EPOCH_VALUE_ID_SEQ",
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
58 sequenceName = "BED_EPOCH_VALUES_ID_SEQ",
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
59 allocationSize = 1)
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
60 @GeneratedValue(
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
61 strategy = GenerationType.SEQUENCE,
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
62 generator = "SEQUENCE_BED_EPOCH_VALUE_ID_SEQ")
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
63 @Column(name = "id")
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
64 public Integer getId() {
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
65 return id;
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
66 }
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
67
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
68 public void setId(Integer id) {
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
69 this.id = id;
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
70 }
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
71
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
72 @OneToOne
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
73 @JoinColumn(name = "bed_height_epoch_id" )
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
74 public BedHeightEpoch getBedHeight() {
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
75 return bedHeight;
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
76 }
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
77
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
78 public void setBedHeight(BedHeightEpoch bedHeight) {
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
79 this.bedHeight = bedHeight;
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
80 }
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
81
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
82 @Column(name = "station")
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
83 public BigDecimal getStation() {
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
84 return station;
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
85 }
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
86
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
87 public void setStation(BigDecimal station) {
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
88 this.station = station;
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
89 }
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
90
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
91 @Column(name = "height")
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
92 public BigDecimal getHeight() {
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
93 return height;
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
94 }
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
95
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
96 public void setHeight(BigDecimal height) {
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
97 this.height = height;
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
98 }
2873
1894e0471eac Added functions to retrieve bed height single and epoch values based on its owner and km range.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2810
diff changeset
99
1894e0471eac Added functions to retrieve bed height single and epoch values based on its owner and km range.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2810
diff changeset
100
1894e0471eac Added functions to retrieve bed height single and epoch values based on its owner and km range.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2810
diff changeset
101 public static List<BedHeightEpochValue> getBedHeightEpochValues(
1894e0471eac Added functions to retrieve bed height single and epoch values based on its owner and km range.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2810
diff changeset
102 BedHeightEpoch epoch,
1894e0471eac Added functions to retrieve bed height single and epoch values based on its owner and km range.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2810
diff changeset
103 double kmLo,
1894e0471eac Added functions to retrieve bed height single and epoch values based on its owner and km range.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2810
diff changeset
104 double kmHi
1894e0471eac Added functions to retrieve bed height single and epoch values based on its owner and km range.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2810
diff changeset
105 ) {
1894e0471eac Added functions to retrieve bed height single and epoch values based on its owner and km range.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2810
diff changeset
106 Session session = SessionHolder.HOLDER.get();
1894e0471eac Added functions to retrieve bed height single and epoch values based on its owner and km range.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2810
diff changeset
107
1894e0471eac Added functions to retrieve bed height single and epoch values based on its owner and km range.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2810
diff changeset
108 Query query = session.createQuery(
1894e0471eac Added functions to retrieve bed height single and epoch values based on its owner and km range.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2810
diff changeset
109 "from BedHeightEpochValue where bedHeight=:epoch " +
1894e0471eac Added functions to retrieve bed height single and epoch values based on its owner and km range.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2810
diff changeset
110 " and station >= :kmLo and station <= :kmHi");
1894e0471eac Added functions to retrieve bed height single and epoch values based on its owner and km range.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2810
diff changeset
111
1894e0471eac Added functions to retrieve bed height single and epoch values based on its owner and km range.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2810
diff changeset
112 query.setParameter("epoch", epoch);
1894e0471eac Added functions to retrieve bed height single and epoch values based on its owner and km range.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2810
diff changeset
113 query.setParameter("kmLo", new BigDecimal(kmLo));
1894e0471eac Added functions to retrieve bed height single and epoch values based on its owner and km range.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2810
diff changeset
114 query.setParameter("kmHi", new BigDecimal(kmHi));
1894e0471eac Added functions to retrieve bed height single and epoch values based on its owner and km range.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2810
diff changeset
115
1894e0471eac Added functions to retrieve bed height single and epoch values based on its owner and km range.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2810
diff changeset
116 return query.list();
1894e0471eac Added functions to retrieve bed height single and epoch values based on its owner and km range.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2810
diff changeset
117 }
2810
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
118 }
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
119 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org