[PATCH 1 of 2] issue957: Better name for flowvelocity measured values facets

Wald Commits scm-commit at wald.intevation.org
Thu Aug 29 16:40:35 CEST 2013


# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1377786823 -7200
# Node ID 602dac32a996261dc7f665aaf126a48f7e9abe3a
# Parent  61128e4b6f46dd0d16a4fd90555f6972e4e3eedb
issue957: Better name for flowvelocity measured values facets.

diff -r 61128e4b6f46 -r 602dac32a996 artifacts/src/main/java/org/dive4elements/river/artifacts/FlowVelocityMeasurementArtifact.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/FlowVelocityMeasurementArtifact.java	Thu Aug 29 12:15:28 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/FlowVelocityMeasurementArtifact.java	Thu Aug 29 16:33:43 2013 +0200
@@ -8,6 +8,8 @@
 
 package org.dive4elements.river.artifacts;
 
+import java.text.DateFormat;
+
 import java.util.ArrayList;
 import java.util.List;
 
@@ -29,6 +31,8 @@
 
 import org.dive4elements.river.artifacts.model.FacetTypes;
 
+import org.dive4elements.river.utils.Formatter;
+
 
 /** Artefact to access flow velocity measurements. */
 public class FlowVelocityMeasurementArtifact
@@ -111,14 +115,21 @@
 
         List<Facet> fs = new ArrayList<Facet>();
         String code = getDatacageIDValue(data);
+        DateFormat dateFormatter = Formatter.getDateFormatter(
+            callMeta, "dd.MM.yyy HH:mm");
 
         if (code != null) {
             // parse code, interact with factory, add real facets.
             // store relevant parts of code as data.
-            // TODO i18n/Name for facet: Include date with dateformatter.
-            String name =
-                FlowVelocityMeasurementFactory.getFlowVelocityMeasurement(
-                    Integer.parseInt(code)).getDescription();
+            FlowVelocityMeasurementValue.FastFlowVelocityMeasurementValue
+                flowVelocityMeasurement =
+                    FlowVelocityMeasurementFactory.getFlowVelocityMeasurement(
+                        Integer.parseInt(code));
+            String name = flowVelocityMeasurement.getDescription();
+            logger.debug ("datetime " + flowVelocityMeasurement.getDatetime());
+            name += " - " + dateFormatter.format(
+                flowVelocityMeasurement.getDatetime());
+
             Facet facet = new FlowVelocityMeasurementFacet(
                 FLOW_VELOCITY_MEASUREMENT,
                 name);
diff -r 61128e4b6f46 -r 602dac32a996 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/FlowVelocityMeasurementFactory.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/FlowVelocityMeasurementFactory.java	Thu Aug 29 12:15:28 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/FlowVelocityMeasurementFactory.java	Thu Aug 29 16:33:43 2013 +0200
@@ -8,12 +8,15 @@
 
 package org.dive4elements.river.artifacts.model.minfo;
 
+import java.util.Date;
 import java.util.List;
 
 import org.apache.log4j.Logger;
 import org.hibernate.SQLQuery;
 import org.hibernate.Session;
 
+import org.hibernate.type.StandardBasicTypes;
+
 import org.dive4elements.river.model.FlowVelocityMeasurementValue;
 import org.dive4elements.river.backend.SessionHolder;
 
@@ -40,7 +43,13 @@
         log.debug("FlowVelocityMeasurementFactory.getFlowVelocityMeasurementValue");
         Session session = SessionHolder.HOLDER.get();
         SQLQuery sqlQuery = null;
-        sqlQuery = session.createSQLQuery(SQL_SELECT_ONE);
+        sqlQuery = session.createSQLQuery(SQL_SELECT_ONE)
+            .addScalar("station", StandardBasicTypes.DOUBLE)
+            .addScalar("datetime", StandardBasicTypes.DATE)
+            .addScalar("w", StandardBasicTypes.DOUBLE)
+            .addScalar("q", StandardBasicTypes.DOUBLE)
+            .addScalar("v", StandardBasicTypes.DOUBLE)
+            .addScalar("description", StandardBasicTypes.STRING);
         sqlQuery.setParameter("id", id);
 
         List<Object []> results = sqlQuery.list();
@@ -53,7 +62,7 @@
                 Double.parseDouble(row[0].toString()),
                 Double.parseDouble(row[2].toString()),
                 Double.valueOf(row[3].toString()),
-                Double.valueOf(row[4].toString()), null, row[5].toString());
+                Double.valueOf(row[4].toString()), (Date) row[1], row[5].toString());
         }
         return null;
     }


More information about the Dive4elements-commits mailing list