diff 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
line wrap: on
line diff
--- a/backend/src/main/java/org/dive4elements/river/model/sinfo/FlowDepthColumn.java	Mon Apr 30 10:13:15 2018 +0200
+++ b/backend/src/main/java/org/dive4elements/river/model/sinfo/FlowDepthColumn.java	Mon Apr 30 16:00:12 2018 +0200
@@ -23,6 +23,11 @@
 import javax.persistence.OneToOne;
 import javax.persistence.SequenceGenerator;
 import javax.persistence.Table;
+import javax.persistence.Transient;
+
+import org.dive4elements.river.backend.SessionHolder;
+import org.hibernate.Query;
+import org.hibernate.Session;
 
 /**
  * Hibernate binding for the DB table flow_depth_column
@@ -77,6 +82,11 @@
         return this.parent;
     }
 
+    @Transient
+    public FlowDepth getSeries() {
+        return getFlowDepth();
+    }
+
     public void setFlowDepth(final FlowDepth flow_depth) {
         this.parent = flow_depth;
     }
@@ -103,4 +113,15 @@
     public void addValue(final FlowDepthValue value) {
         this.values.add(value);
     }
+
+    /**
+     * Selects a flow depth series column by id from the database
+     */
+    public static FlowDepthColumn getColumnById(final int id) {
+        final Session session = SessionHolder.HOLDER.get();
+        final Query query = session.createQuery("FROM FlowDepthColumn WHERE id=:id");
+        query.setParameter("id", id);
+        final List<FlowDepthColumn> rows = query.list();
+        return (rows != null) ? rows.get(0) : null;
+    }
 }

http://dive4elements.wald.intevation.org