Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/WstColumnFactory.java @ 8962:708f210ff242
Fetching year informations for waterlevels used in sinfo
author | gernotbelger |
---|---|
date | Wed, 28 Mar 2018 17:03:11 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
8961:8a1c6e2ad48b | 8962:708f210ff242 |
---|---|
1 /** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde | |
2 * Software engineering by | |
3 * Björnsen Beratende Ingenieure GmbH | |
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt | |
5 * | |
6 * This file is Free Software under the GNU AGPL (>=v3) | |
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the | |
8 * documentation coming with Dive4Elements River for details. | |
9 */ | |
10 package org.dive4elements.river.artifacts.model; | |
11 | |
12 import java.util.List; | |
13 | |
14 import org.dive4elements.river.backend.SessionHolder; | |
15 import org.dive4elements.river.model.Wst; | |
16 import org.dive4elements.river.model.WstColumn; | |
17 import org.hibernate.Query; | |
18 import org.hibernate.Session; | |
19 | |
20 /** | |
21 * @author Gernot Belger | |
22 */ | |
23 public final class WstColumnFactory { | |
24 private WstColumnFactory() { | |
25 throw new UnsupportedOperationException("helper class"); | |
26 } | |
27 | |
28 public static WstColumn getWstColumn(final int wst_id, final int columnPosition) { | |
29 final Session session = SessionHolder.HOLDER.get(); | |
30 | |
31 final Wst wst = WstFactory.getWst(wst_id); | |
32 | |
33 final Query query = session.createQuery("from WstColumn where wst=:wst_id and position = :position"); | |
34 query.setParameter("wst_id", wst); | |
35 query.setInteger("position", columnPosition); | |
36 | |
37 final List<WstColumn> columns = query.list(); | |
38 | |
39 return columns.isEmpty() ? null : columns.get(0); | |
40 } | |
41 } |