view artifacts/src/main/java/org/dive4elements/river/artifacts/model/WstColumnFactory.java @ 9425:3f49835a00c3

Extended CrossSectionFacet so it may fetch different data from within the artifact result. Also allows to have acces to the potentially already computed artifact result via its normal computation cache.
author gernotbelger
date Fri, 17 Aug 2018 15:31:02 +0200
parents 708f210ff242
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;

import java.util.List;

import org.dive4elements.river.backend.SessionHolder;
import org.dive4elements.river.model.Wst;
import org.dive4elements.river.model.WstColumn;
import org.hibernate.Query;
import org.hibernate.Session;

/**
 * @author Gernot Belger
 */
public final class WstColumnFactory {
    private WstColumnFactory() {
        throw new UnsupportedOperationException("helper class");
    }

    public static WstColumn getWstColumn(final int wst_id, final int columnPosition) {
        final Session session = SessionHolder.HOLDER.get();

        final Wst wst = WstFactory.getWst(wst_id);

        final Query query = session.createQuery("from WstColumn where wst=:wst_id and position = :position");
        query.setParameter("wst_id", wst);
        query.setInteger("position", columnPosition);

        final List<WstColumn> columns = query.list();

        return columns.isEmpty() ? null : columns.get(0);
    }
}

http://dive4elements.wald.intevation.org