Mercurial > dive4elements > river
view backend/src/main/java/org/dive4elements/river/importer/ImportElevationModel.java @ 9269:83ebeb620b5a
Station specific main value annotations in S-Info flood duration curve, corrected infrastructure flood duration calculation
author | mschaefer |
---|---|
date | Thu, 19 Jul 2018 08:07:03 +0200 |
parents | a275ddf7a3a1 |
children |
line wrap: on
line source
/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde * Software engineering by Intevation GmbH * * 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; import java.util.List; import org.apache.log4j.Logger; import org.dive4elements.river.model.ElevationModel; import org.hibernate.Query; import org.hibernate.Session; public class ImportElevationModel { private static final Logger log = Logger.getLogger(ImportElevationModel.class); protected String name; protected ImportUnit unit; protected ElevationModel peer; public ImportElevationModel(final String name, final ImportUnit unit) { this.name = name; this.unit = unit; } public void storeDependencies() { final ElevationModel model = getPeer(); } public ElevationModel getPeer() { if (this.unit == null) { log.warn("No elevation model specified."); return null; } if (this.peer != null) return this.peer; final Session session = ImporterSession.getInstance().getDatabaseSession(); final Query query = session.createQuery("FROM ElevationModel WHERE (trim(name)=:name) AND (unit=:unit)"); query.setParameter("name", this.name); query.setParameter("unit", this.unit.getPeer()); final List<ElevationModel> models = query.list(); if (models.isEmpty()) { log.info("Create new ElevationModel DB instance."); this.peer = new ElevationModel(this.name, this.unit.getPeer()); session.save(this.peer); } else { this.peer = models.get(0); } return this.peer; } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :