Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/vegetationzones/VegetationZonesState.java @ 9195:a4121ec450d6
'ca.'-issue
ExportContextCSV+PDF separated
uinfo.inundationduration url export
author | gernotbelger |
---|---|
date | Fri, 29 Jun 2018 14:52:54 +0200 |
parents | 23945061daec |
children | 853f2dafc16e |
rev | line source |
---|---|
8996 | 1 /** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde |
9024 | 2 * Software engineering by |
3 * Björnsen Beratende Ingenieure GmbH | |
8996 | 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.uinfo.vegetationzones; | |
11 | |
12 import java.util.List; | |
13 | |
14 import org.dive4elements.artifactdatabase.state.Facet; | |
15 import org.dive4elements.artifacts.CallContext; | |
16 import org.dive4elements.river.artifacts.ChartArtifact; | |
17 import org.dive4elements.river.artifacts.D4EArtifact; | |
18 import org.dive4elements.river.artifacts.model.Calculation; | |
19 import org.dive4elements.river.artifacts.model.CalculationResult; | |
20 import org.dive4elements.river.artifacts.model.DataFacet; | |
21 import org.dive4elements.river.artifacts.model.EmptyFacet; | |
22 import org.dive4elements.river.artifacts.model.FacetTypes; | |
23 import org.dive4elements.river.artifacts.model.ReportFacet; | |
24 import org.dive4elements.river.artifacts.states.DefaultState; | |
25 import org.dive4elements.river.artifacts.uinfo.UINFOArtifact; | |
26 | |
27 /** | |
28 * @author Domenico Nardi Tironi | |
29 */ | |
30 public class VegetationZonesState extends DefaultState { | |
31 | |
32 /// ** The log that is used in this state. */ | |
33 // private static Logger log = Logger.getLogger(FlowDepthState.class); | |
34 | |
35 private static final long serialVersionUID = 1L; | |
36 | |
37 /** | |
38 * From this state can only be continued trivially. | |
39 */ | |
40 @Override | |
41 protected String getUIProvider() { | |
42 return "continue"; | |
43 } | |
44 | |
45 @Override | |
46 public Object computeFeed(final D4EArtifact artifact, final String hash, final CallContext context, final List<Facet> facets, final Object old) { | |
47 // FIXME: why is this necessary? | |
48 if (artifact instanceof ChartArtifact) { | |
49 facets.add(new EmptyFacet()); | |
50 return null; | |
51 } | |
52 return compute((UINFOArtifact) artifact, context, hash, facets, old); | |
53 } | |
54 | |
55 @Override | |
56 public Object computeAdvance(final D4EArtifact artifact, final String hash, final CallContext context, final List<Facet> facets, final Object old) { | |
57 if (artifact instanceof ChartArtifact) { | |
58 facets.add(new EmptyFacet()); | |
59 return null; | |
60 } | |
61 return compute((UINFOArtifact) artifact, context, hash, facets, old); | |
62 } | |
63 | |
64 /** | |
65 * Compute result or returned object from cache, create facets. | |
66 * | |
67 * @param old | |
68 * Object that was cached. | |
69 */ | |
70 private Object compute(final UINFOArtifact sinfo, final CallContext context, final String hash, final List<Facet> facets, final Object old) { | |
71 | |
72 final CalculationResult res = doCompute(sinfo, context, old); | |
73 | |
74 if (facets == null) | |
75 return res; | |
76 | |
77 final VegetationZonesCalculationResults results = (VegetationZonesCalculationResults) res.getData(); | |
78 | |
9195 | 79 final List<VegetationZonesCalculationResult> resultList = results.getResults(); |
8996 | 80 |
81 if (!resultList.isEmpty()) { | |
82 final Facet csv = new DataFacet(FacetTypes.CSV, "CSV data", ComputeType.ADVANCE, hash, this.id); | |
83 final Facet pdf = new DataFacet(FacetTypes.PDF, "PDF data", ComputeType.ADVANCE, hash, this.id); | |
84 | |
85 facets.add(csv); | |
86 facets.add(pdf); | |
87 } | |
88 | |
89 final Calculation report = res.getReport(); | |
90 | |
91 if (report.hasProblems()) | |
92 facets.add(new ReportFacet(ComputeType.ADVANCE, hash, this.id)); | |
93 | |
94 return res; | |
95 } | |
96 | |
9069
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
9024
diff
changeset
|
97 private CalculationResult doCompute(final UINFOArtifact uinfo, final CallContext context, final Object old) { |
8996 | 98 if (old instanceof CalculationResult) |
99 return (CalculationResult) old; | |
100 | |
9069
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
9024
diff
changeset
|
101 return new VegetationZonesCalculation(context).calculate(uinfo); |
8996 | 102 } |
103 } |