view artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/KMRangeLoader.java @ 9415:9744ce3c3853

Rework of fixanalysis computation and dWt and WQ facets. Got rid of strange remapping and bitshifting code by explicitely saving the column information and using it in the facets. The facets also put the valid station range into their xml-metadata
author gernotbelger
date Thu, 16 Aug 2018 16:27:53 +0200
parents
children
line wrap: on
line source
/** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde
 * Software engineering by
 *  Björnsen Beratende Ingenieure GmbH
 *  Dr. Schumacher Ingenieurbüro für Wasser und Umwelt
 *
 * This file is Free Software under the GNU AGPL (>=v3)
 * and comes with ABSOLUTELY NO WARRANTY! Check out the
 * documentation coming with Dive4Elements River for details.
 */
package org.dive4elements.river.artifacts.model.fixings;

import java.util.List;

import org.dive4elements.river.utils.BatchLoader;
import org.hibernate.SQLQuery;
import org.hibernate.Session;
import org.hibernate.type.StandardBasicTypes;

final class KMRangeLoader extends BatchLoader<double[]> {

    private static final String SQL_FIXING_COLUMN_KM_RANGE_BATCH = "SELECT " + "wst_column_id," + "MIN(position) AS start_km," + "MAX(position) AS stop_km "
            + "FROM " + "wst_column_values " + "WHERE " + "wst_column_id IN ($IDS) " + "GROUP BY wst_column_id";

    public KMRangeLoader(final List<Integer> columns, final Session session) {
        super(columns, session, SQL_FIXING_COLUMN_KM_RANGE_BATCH);
    }

    @Override
    protected void fill(final SQLQuery query) {
        query.addScalar("wst_column_id", StandardBasicTypes.INTEGER).addScalar("start_km", StandardBasicTypes.DOUBLE).addScalar("stop_km",
                StandardBasicTypes.DOUBLE);

        final List<Object[]> ranges = query.list();
        for (final Object[] r : ranges) {
            final Integer cid = (Integer) r[0];
            final double[] vs = new double[] { (Double) r[1], (Double) r[2] };
            cache(cid, vs);
        }
    }
}

http://dive4elements.wald.intevation.org