Mercurial > dive4elements > river
comparison backend/src/main/java/org/dive4elements/river/model/sinfo/FlowDepthColumn.java @ 9035:c16e90a0baf7
Added datacage select and chart display for modelled flow depth series loaded from database
author | mschaefer |
---|---|
date | Mon, 30 Apr 2018 16:00:12 +0200 |
parents | 50416a0df385 |
children | 32dd7e761e4e |
comparison
equal
deleted
inserted
replaced
9034:8aa7d9eaaa21 | 9035:c16e90a0baf7 |
---|---|
21 import javax.persistence.JoinColumn; | 21 import javax.persistence.JoinColumn; |
22 import javax.persistence.OneToMany; | 22 import javax.persistence.OneToMany; |
23 import javax.persistence.OneToOne; | 23 import javax.persistence.OneToOne; |
24 import javax.persistence.SequenceGenerator; | 24 import javax.persistence.SequenceGenerator; |
25 import javax.persistence.Table; | 25 import javax.persistence.Table; |
26 import javax.persistence.Transient; | |
27 | |
28 import org.dive4elements.river.backend.SessionHolder; | |
29 import org.hibernate.Query; | |
30 import org.hibernate.Session; | |
26 | 31 |
27 /** | 32 /** |
28 * Hibernate binding for the DB table flow_depth_column | 33 * Hibernate binding for the DB table flow_depth_column |
29 * | 34 * |
30 * @author Matthias Schäfer | 35 * @author Matthias Schäfer |
75 @JoinColumn(name = "flow_depth_id") | 80 @JoinColumn(name = "flow_depth_id") |
76 public FlowDepth getFlowDepth() { | 81 public FlowDepth getFlowDepth() { |
77 return this.parent; | 82 return this.parent; |
78 } | 83 } |
79 | 84 |
85 @Transient | |
86 public FlowDepth getSeries() { | |
87 return getFlowDepth(); | |
88 } | |
89 | |
80 public void setFlowDepth(final FlowDepth flow_depth) { | 90 public void setFlowDepth(final FlowDepth flow_depth) { |
81 this.parent = flow_depth; | 91 this.parent = flow_depth; |
82 } | 92 } |
83 | 93 |
84 @Column(name = "name") | 94 @Column(name = "name") |
101 } | 111 } |
102 | 112 |
103 public void addValue(final FlowDepthValue value) { | 113 public void addValue(final FlowDepthValue value) { |
104 this.values.add(value); | 114 this.values.add(value); |
105 } | 115 } |
116 | |
117 /** | |
118 * Selects a flow depth series column by id from the database | |
119 */ | |
120 public static FlowDepthColumn getColumnById(final int id) { | |
121 final Session session = SessionHolder.HOLDER.get(); | |
122 final Query query = session.createQuery("FROM FlowDepthColumn WHERE id=:id"); | |
123 query.setParameter("id", id); | |
124 final List<FlowDepthColumn> rows = query.list(); | |
125 return (rows != null) ? rows.get(0) : null; | |
126 } | |
106 } | 127 } |