Mercurial > dive4elements > river
view backend/src/main/java/org/dive4elements/river/importer/sinfo/importitem/InfrastructureSeriesImport.java @ 9709:b74f817435fe
comment removed
author | dnt_bjoernsen <d.tironi@bjoernsen.de> |
---|---|
date | Wed, 27 Jan 2021 11:47:38 +0100 |
parents | 75bd347147ad |
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.importer.sinfo.importitem; import java.util.List; import org.apache.log4j.Logger; import org.dive4elements.river.importer.ImportAnnotationType; import org.dive4elements.river.importer.common.AbstractSeriesImport; import org.dive4elements.river.model.River; import org.dive4elements.river.model.sinfo.Infrastructure; import org.dive4elements.river.model.sinfo.InfrastructureValue; import org.hibernate.Query; import org.hibernate.Session; /** * Imported infrastructure data series of a river and a type * * @author Matthias Schäfer * */ public class InfrastructureSeriesImport extends AbstractSeriesImport<Infrastructure, InfrastructureValue, InfrastructureKmLineImport> { /***** FIELDS *****/ private static Logger log = Logger.getLogger(InfrastructureSeriesImport.class); private ImportAnnotationType type; private ImportAnnotationType group; private String provider; private String evaluation_by; private int year; /***** CONSTRUCTORS *****/ public InfrastructureSeriesImport(final String filename) { super(filename); } /***** METHODS *****/ public void setType(final ImportAnnotationType type) { this.type = type; } public void setGroup(final ImportAnnotationType group) { this.group = group; } public void setProvider(final String provider) { this.provider = provider; } public void setEvaluation_by(final String evaluation_by) { this.evaluation_by = evaluation_by; } public void setYear(final int year) { this.year = year; } @Override public Logger getLog() { return log; } @Override public List<Infrastructure> querySeriesItem(final Session session, final River river, final boolean doQueryParent) { final Query query = session.createQuery("FROM Infrastructure WHERE river=:river AND lower(filename)=:filename"); query.setParameter("river", river); query.setParameter("filename", this.filename.toLowerCase()); return query.list(); } @Override public Infrastructure createSeriesItem(final River river) { return new Infrastructure(river, this.filename, this.kmrange_info, this.notes, this.type.getPeer(), this.group.getPeer(), this.year, this.provider, this.evaluation_by); } @Override public boolean addValue(final InfrastructureKmLineImport value) { for (final InfrastructureKmLineImport item : this.values) { if (item.getStation() != value.getStation()) continue; if (item.getBankAttribute() == value.getBankAttribute()) return false; } return super.addValue(value); } }