# HG changeset patch # User Raimund Renkert # Date 1347543780 0 # Node ID 75bc96dd9d82e6a83e1aca83c1fa96ebc4afcff9 # Parent e8a90a5ce62457b7bad02dce744acdd169699401 Added depth parameter to bed quality data. flys-artifacts/trunk@5456 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r e8a90a5ce624 -r 75bc96dd9d82 flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Thu Sep 13 12:08:50 2012 +0000 +++ b/flys-artifacts/ChangeLog Thu Sep 13 13:43:00 2012 +0000 @@ -1,3 +1,9 @@ +2012-09-13 Raimund Renkert + + * src/main/java/de/intevation/flys/artifacts/model/minfo/QualityMeasurementFactory.java, + src/main/java/de/intevation/flys/artifacts/model/minfo/QualityMeasurement.java: + Added depth parameter to bed quality data. + 2012-09-13 Ingo Weinzierl * doc/conf/conf.xml: Registered new OutGenerators BedQualityGenerator and diff -r e8a90a5ce624 -r 75bc96dd9d82 flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/QualityMeasurement.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/QualityMeasurement.java Thu Sep 13 12:08:50 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/QualityMeasurement.java Thu Sep 13 13:43:00 2012 +0000 @@ -3,10 +3,13 @@ import java.util.Date; import java.util.Map; + public class QualityMeasurement { - private double km; - private Date date; + private double km; + private Date date; + private double depth1; + private double depth2; private Map charDiameter; public QualityMeasurement() { @@ -16,10 +19,13 @@ public QualityMeasurement( double km, Date date, - Map diameter) - { + double depth1, + double depth2, + Map diameter) { this.setKm(km); this.setDate(date); + this.depth1 = depth1; + this.depth2 = depth2; this.setDiameter(diameter); } @@ -54,4 +60,21 @@ public void setDiameter(String key, double value) { charDiameter.put(key, value); } + + public double getDepth1() { + return depth1; + } + + public void setDepth1(double depth1) { + this.depth1 = depth1; + } + + public double getDepth2() { + return depth2; + } + + public void setDepth2(double depth2) { + this.depth2 = depth2; + } + } diff -r e8a90a5ce624 -r 75bc96dd9d82 flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/QualityMeasurementFactory.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/QualityMeasurementFactory.java Thu Sep 13 12:08:50 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/QualityMeasurementFactory.java Thu Sep 13 13:43:00 2012 +0000 @@ -11,39 +11,42 @@ import de.intevation.flys.backend.SedDBSessionHolder; + public class QualityMeasurementFactory { - private static final String SQL_BED_MEASUREMENT = - "SELECT st.km as km," + - " st.datum as date,"+ - " sa.d10 as d10," + - " sa.d16 as d16," + - " sa.d20 as d20," + - " sa.d25 as d25," + - " sa.d30 as d30," + - " sa.d40 as d40," + - " sa.d50 as d50," + - " sa.d60 as d60," + - " sa.d70 as d70," + - " sa.d75 as d75," + - " sa.d80 as d80," + - " sa.d84 as d84," + - " sa.d90 as d90," + - " sa.dmin as dmin," + - " sa.dmax as dmax " + + private static final String SQL_BED_MEASUREMENT = + "SELECT st.km as km," + + " st.datum as date," + + " sp.tiefevon as depth1" + + " sp.tiefebis as depth2" + + " sa.d10 as d10," + + " sa.d16 as d16," + + " sa.d20 as d20," + + " sa.d25 as d25," + + " sa.d30 as d30," + + " sa.d40 as d40," + + " sa.d50 as d50," + + " sa.d60 as d60," + + " sa.d70 as d70," + + " sa.d75 as d75," + + " sa.d80 as d80," + + " sa.d84 as d84," + + " sa.d90 as d90," + + " sa.dmin as dmin," + + " sa.dmax as dmax " + "FROM sohltest st" + " JOIN station sn ON sn.stationid = st.stationid" + " JOIN gewaesser gw ON gw.gewaesserid = sn.gewaesserid" + " JOIN sohlprobe sp ON sp.sohltestid = st.sohltestid" + - " JOIN siebanalyse sa ON sa.sohlprobeid = sp.sohlprobeid" + + " JOIN siebanalyse sa ON sa.sohlprobeid = sp.sohlprobeid " + "WHERE gw.name = :name AND " + " st.km IS NOT NULL AND " + " st.km BETWEEN :from - 0.001 AND :to + 0.001 AND" + " st.datum BETWEEN :start AND :end"; - private static final String SQL_BEDLOAD_MEASUREMENT = + private static final String SQL_BEDLOAD_MEASUREMENT = "SELECT m.km as km," + - " m.datum as date,"+ + " m.datum as date," + " m.d10 as d10," + " m.d16 as d16," + " m.d20 as d20," + @@ -61,40 +64,47 @@ " m.dmax as dmax " + "FROM messung m" + " JOIN station sn ON sn.stationid = m.stationid" + - " JOIN gewaesser gw ON gw.gewaesserid = sn.gewaesserid" + + " JOIN gewaesser gw ON gw.gewaesserid = sn.gewaesserid " + "WHERE gw.name = :name AND " + " m.km IS NOT NULL AND " + " m.km BETWEEN :from - 0.001 AND :to + 0.001 AND" + " m.datum BETWEEN :start AND :end"; public static final class QualityMeasurementResultTransformer - extends BasicTransformerAdapter - { - public static QualityMeasurementResultTransformer INSTANCE = - new QualityMeasurementResultTransformer(); + extends BasicTransformerAdapter { + + public static QualityMeasurementResultTransformer INSTANCE = new QualityMeasurementResultTransformer(); public QualityMeasurementResultTransformer() { } @Override - public Object transformTuple(Object [] tuple, String [] aliases) { + public Object transformTuple(Object[] tuple, String[] aliases) { Map map = new HashMap(); double km = 0; Date d = null; + double depth1 = 0; + double depth2 = 0; for (int i = 0; i < tuple.length; ++i) { if (tuple[i] != null) { if (aliases[i].equals("km")) { - km = ((Number)tuple[i]).doubleValue(); + km = ((Number) tuple[i]).doubleValue(); } else if (aliases[i].equals("date")) { - d = (Date)tuple[i]; + d = (Date) tuple[i]; + } + else if (aliases[i].equals("depth1")) { + depth1 = ((Number) tuple[i]).doubleValue(); + } + else if (aliases[i].equals("depth2")) { + depth2 = ((Number) tuple[i]).doubleValue(); } else { - map.put(aliases[i], (Double)tuple[i]); + map.put(aliases[i], (Double) tuple[i]); } } } - return new QualityMeasurement(km, d, map); + return new QualityMeasurement(km, d, depth1, depth2, map); } } // class BasicTransformerAdapter @@ -111,27 +121,32 @@ String statement ) { SQLQuery query = session.createSQLQuery(statement) - .addScalar("km", StandardBasicTypes.DOUBLE) - .addScalar("date", StandardBasicTypes.DATE) - .addScalar("d10", StandardBasicTypes.DOUBLE) - .addScalar("d16", StandardBasicTypes.DOUBLE) - .addScalar("d20", StandardBasicTypes.DOUBLE) - .addScalar("d25", StandardBasicTypes.DOUBLE) - .addScalar("d30", StandardBasicTypes.DOUBLE) - .addScalar("d40", StandardBasicTypes.DOUBLE) - .addScalar("d50", StandardBasicTypes.DOUBLE) - .addScalar("d60", StandardBasicTypes.DOUBLE) - .addScalar("d70", StandardBasicTypes.DOUBLE) - .addScalar("d75", StandardBasicTypes.DOUBLE) - .addScalar("d80", StandardBasicTypes.DOUBLE) - .addScalar("d84", StandardBasicTypes.DOUBLE) - .addScalar("d90", StandardBasicTypes.DOUBLE) - .addScalar("dmin", StandardBasicTypes.DOUBLE) - .addScalar("dmax", StandardBasicTypes.DOUBLE); + .addScalar("km", StandardBasicTypes.DOUBLE) + .addScalar("date", StandardBasicTypes.DATE) + .addScalar("d10", StandardBasicTypes.DOUBLE) + .addScalar("d16", StandardBasicTypes.DOUBLE) + .addScalar("d20", StandardBasicTypes.DOUBLE) + .addScalar("d25", StandardBasicTypes.DOUBLE) + .addScalar("d30", StandardBasicTypes.DOUBLE) + .addScalar("d40", StandardBasicTypes.DOUBLE) + .addScalar("d50", StandardBasicTypes.DOUBLE) + .addScalar("d60", StandardBasicTypes.DOUBLE) + .addScalar("d70", StandardBasicTypes.DOUBLE) + .addScalar("d75", StandardBasicTypes.DOUBLE) + .addScalar("d80", StandardBasicTypes.DOUBLE) + .addScalar("d84", StandardBasicTypes.DOUBLE) + .addScalar("d90", StandardBasicTypes.DOUBLE) + .addScalar("dmin", StandardBasicTypes.DOUBLE) + .addScalar("dmax", StandardBasicTypes.DOUBLE); + + if (statement.equals(SQL_BED_MEASUREMENT)) { + query.addScalar("depth1", StandardBasicTypes.DOUBLE); + query.addScalar("depth2", StandardBasicTypes.DOUBLE); + } query.setString("name", river); query.setDouble("from", from); - query.setDouble("to", to); + query.setDouble("to", to); query.setDate("start", start); query.setDate("end", end); @@ -146,18 +161,11 @@ double from, double to, Date start, - Date end - ) { + Date end) { Session session = SedDBSessionHolder.HOLDER.get(); try { - return load( - session, - river, - from, - to, - start, - end, - SQL_BED_MEASUREMENT); + return load(session, river, from, to, start, end, + SQL_BED_MEASUREMENT); } finally { session.close(); @@ -170,7 +178,7 @@ double to, Date start, Date end - ){ + ) { Session session = SedDBSessionHolder.HOLDER.get(); try { return load(