Mercurial > dive4elements > river
diff backend/src/main/java/org/dive4elements/river/model/sinfo/Infrastructure.java @ 9625:07f02019065e
Nachtrag Pos. 20: infrastructure query added, calculation updated for extended access class
author | mschaefer |
---|---|
date | Mon, 14 Oct 2019 08:14:58 +0200 |
parents | 02ca823ec9c6 |
children |
line wrap: on
line diff
--- a/backend/src/main/java/org/dive4elements/river/model/sinfo/Infrastructure.java Fri Oct 11 18:30:36 2019 +0200 +++ b/backend/src/main/java/org/dive4elements/river/model/sinfo/Infrastructure.java Mon Oct 14 08:14:58 2019 +0200 @@ -71,11 +71,13 @@ private List<InfrastructureValue> values; + /***** CONSTRUCTORS *****/ public Infrastructure() { } + public Infrastructure(final River river, final String filename, final String kmrange_info, final String notes, final AnnotationType type, final AnnotationType group, final Integer year, final String dataprovider, final String evaluation_by) { this.river = river; @@ -90,6 +92,7 @@ this.values = new ArrayList<>(); } + /***** METHODS *****/ @Id @@ -230,8 +233,8 @@ * Fetches from the database the infrastructure groups and types of a river's km range and river side(s) * as tab-separated strings ordered by the infrastructure group, then the type */ - @Deprecated - public static Set<String> fetchInfrastructureTypes(final River river, final double kmLo, final double kmHi, final AttributeKey riverside) { + public static Set<String> fetchInfrastructureTypes(final River river, final double kmLo, final double kmHi, + final AttributeKey riverside) { final Set<String> groupTypes = new HashSet<>(); for (final Infrastructure ifs : fetchInfrastructureTypeList(river, kmLo, kmHi, riverside)) groupTypes.add(ifs.getGroup().getName() + "\t" + ifs.getType().getName()); @@ -242,13 +245,18 @@ * Fetches from the database the list of infrastructure types of a river's km range and river side(s) * ordered by type group */ - private static List<Infrastructure> fetchInfrastructureTypeList(final River river, final double kmLo, final double kmHi, final AttributeKey riverside) { + private static List<Infrastructure> fetchInfrastructureTypeList(final River river, final double kmLo, final double kmHi, + final AttributeKey riverside) { final Session session = SessionHolder.HOLDER.get(); - final Query query = session.createQuery("FROM Infrastructure" + " WHERE (river=:river)" - + " AND (id IN (SELECT v.infrastructure.id FROM InfrastructureValue v" + " WHERE (v.station BETWEEN (:kmLo - 0.0001) AND (:kmHi + 0.0001))" - + InfrastructureValue.getRiversideClause(riverside, "v.", "attr_id") + "))" + " ORDER BY group, type"); + final Query query = session.createQuery("FROM Infrastructure" + + " WHERE (river=:river)" + + " AND (id IN (SELECT v.infrastructure.id FROM InfrastructureValue v" + + " WHERE (v.station BETWEEN (:kmLo - 0.0001) AND (:kmHi + 0.0001))" + + InfrastructureValue.getRiversideClause(riverside, "v.", "attr_id") + + "))" + + " ORDER BY group, type"); query.setParameter("river", river); query.setParameter("kmLo", new Double(kmLo)); query.setParameter("kmHi", new Double(kmHi));