Mercurial > dive4elements > river
view artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/vegetationzones/VegetationZonesCalculation.java @ 9118:431f1c269be5
Veg-Zone Table improved, State change data recovery;
author | gernotbelger |
---|---|
date | Mon, 04 Jun 2018 19:38:59 +0200 |
parents | 41f4bc83aa7a |
children | b570b6fcc052 |
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.uinfo.vegetationzones; import java.util.ArrayList; import java.util.Collection; import java.util.List; import org.apache.commons.lang.math.DoubleRange; import org.dive4elements.artifacts.CallContext; import org.dive4elements.river.artifacts.common.ResultRow; import org.dive4elements.river.artifacts.model.Calculation; import org.dive4elements.river.artifacts.model.CalculationResult; import org.dive4elements.river.artifacts.resources.Resources; import org.dive4elements.river.artifacts.sinfo.util.CalculationUtils; import org.dive4elements.river.artifacts.sinfo.util.RiverInfo; import org.dive4elements.river.artifacts.uinfo.UINFOArtifact; import org.dive4elements.river.artifacts.uinfo.commons.UInfoResultType; import org.dive4elements.river.model.River; /** * @author Domenico Nardi Tironi * */ final class VegetationZonesCalculation { private final CallContext context; public VegetationZonesCalculation(final CallContext context) { this.context = context; } public CalculationResult calculate(final UINFOArtifact uinfo) { final Calculation problems = new Calculation(); final String calcModeLabel = Resources.getMsg(this.context.getMeta(), uinfo.getCalculationMode().name()); final String user = CalculationUtils.findArtifactUser(this.context, uinfo); final VegetationzonesAccess vAccess = new VegetationzonesAccess(uinfo); final River river = vAccess.getRiver(); final DoubleRange calcRange = vAccess.getRange(); final RiverInfo riverInfo = new RiverInfo(river); final String zonesRaw = vAccess.getVegZones(); final List<VegetationZone> helpers = VegetationZone.parse(zonesRaw); final VegetationZonesCalculationResults results = new VegetationZonesCalculationResults(calcModeLabel, user, riverInfo, calcRange); final Collection<ResultRow> rows = new ArrayList<>(); for (final VegetationZone zone : helpers) { final ResultRow row2 = ResultRow.create().// putValue(UInfoResultType.vegname, zone.getZoneName()).// putValue(UInfoResultType.vegdauervon, zone.getMin_day_overflow()).// putValue(UInfoResultType.vegdauerbis, zone.getMax_day_overflow()); rows.add(row2); } final VegetationZonesCalculationResult result = new VegetationZonesCalculationResult("Ergebnis 1", rows); results.addResult(result, problems); return new CalculationResult(results, problems); } }