comparison artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/inundationduration/InundationDurationState.java @ 9190:0633f963c5be

uinfo.inundationduration workflow
author gernotbelger
date Thu, 28 Jun 2018 15:10:04 +0200
parents 2f5052835b76
children 787fc085459b
comparison
equal deleted inserted replaced
9189:13a0c4be17ea 9190:0633f963c5be
14 import org.dive4elements.artifactdatabase.state.Facet; 14 import org.dive4elements.artifactdatabase.state.Facet;
15 import org.dive4elements.artifacts.CallContext; 15 import org.dive4elements.artifacts.CallContext;
16 import org.dive4elements.river.artifacts.ChartArtifact; 16 import org.dive4elements.river.artifacts.ChartArtifact;
17 import org.dive4elements.river.artifacts.D4EArtifact; 17 import org.dive4elements.river.artifacts.D4EArtifact;
18 import org.dive4elements.river.artifacts.MapArtifact.MapState; 18 import org.dive4elements.river.artifacts.MapArtifact.MapState;
19 import org.dive4elements.river.artifacts.common.AbstractCalculationExportableResult;
20 import org.dive4elements.river.artifacts.model.Calculation; 19 import org.dive4elements.river.artifacts.model.Calculation;
21 import org.dive4elements.river.artifacts.model.CalculationResult; 20 import org.dive4elements.river.artifacts.model.CalculationResult;
22 import org.dive4elements.river.artifacts.model.DataFacet; 21 import org.dive4elements.river.artifacts.model.DataFacet;
23 import org.dive4elements.river.artifacts.model.EmptyFacet; 22 import org.dive4elements.river.artifacts.model.EmptyFacet;
24 import org.dive4elements.river.artifacts.model.FacetTypes;
25 import org.dive4elements.river.artifacts.model.ReportFacet; 23 import org.dive4elements.river.artifacts.model.ReportFacet;
24 import org.dive4elements.river.artifacts.model.map.WMSLayerFacet;
26 import org.dive4elements.river.artifacts.uinfo.UINFOArtifact; 25 import org.dive4elements.river.artifacts.uinfo.UINFOArtifact;
26 import org.dive4elements.river.artifacts.uinfo.inundationduration.InundationDurationCalculationResult.WmsLayer;
27 27
28 /** 28 /**
29 * @author Domenico Nardi Tironi 29 * @author Domenico Nardi Tironi
30 */ 30 */
31 public class InundationDurationState extends MapState { 31 public class InundationDurationState extends MapState {
32 32
33 /// ** The log that is used in this state. */ 33 /// ** The log that is used in this state. */
34 // private static Logger log = Logger.getLogger(FlowDepthState.class); 34 // private static Logger log = Logger.getLogger(FlowDepthState.class);
35 35
36 private static final long serialVersionUID = 1L; 36 private static final long serialVersionUID = 1L;
37
38 private static final String LABEL_URL_SEPARATOR = ";";// always sync with client (ExportPanel)
37 39
38 /** 40 /**
39 * From this state can only be continued trivially. 41 * From this state can only be continued trivially.
40 */ 42 */
41 @Override 43 @Override
49 if (artifact instanceof ChartArtifact) { 51 if (artifact instanceof ChartArtifact) {
50 facets.add(new EmptyFacet()); 52 facets.add(new EmptyFacet());
51 return null; 53 return null;
52 } 54 }
53 55
54 return compute((UINFOArtifact) artifact, context, hash, facets, old); 56 return compute((UINFOArtifact) artifact, context, ComputeType.FEED, hash, facets, old);
55 } 57 }
56 58
57 @Override 59 @Override
58 public Object computeAdvance(final D4EArtifact artifact, final String hash, final CallContext context, final List<Facet> facets, final Object old) { 60 public Object computeAdvance(final D4EArtifact artifact, final String hash, final CallContext context, final List<Facet> facets, final Object old) {
59 if (artifact instanceof ChartArtifact) { 61 if (artifact instanceof ChartArtifact) {
62 } 64 }
63 65
64 if (facets != null) 66 if (facets != null)
65 super.computeAdvance(artifact, hash, context, facets, old); 67 super.computeAdvance(artifact, hash, context, facets, old);
66 68
67 return compute((UINFOArtifact) artifact, context, hash, facets, old); 69 return compute((UINFOArtifact) artifact, context, ComputeType.ADVANCE, hash, facets, old);
70
68 } 71 }
69 72
70 /** 73 /**
71 * Compute result or returned object from cache, create facets. 74 * Compute result or returned object from cache, create facets.
72 * 75 *
73 * @param old 76 * @param old
74 * Object that was cached. 77 * Object that was cached.
75 */ 78 */
76 private Object compute(final UINFOArtifact sinfo, final CallContext context, final String hash, final List<Facet> facets, final Object old) { 79 private Object compute(final UINFOArtifact sinfo, final CallContext context, final ComputeType type, final String hash, final List<Facet> facets,
80 final Object old) {
77 81
78 final CalculationResult res = doCompute(sinfo, context, old); 82 final CalculationResult res = doCompute(sinfo, context, old);
79 83
80 if (facets == null) 84 if (facets == null)
81 return res; 85 return res;
82 86
83 final InundationDurationCalculationResults results = (InundationDurationCalculationResults) res.getData(); 87 final InundationDurationCalculationResult result = (InundationDurationCalculationResult) res.getData();
88 final List<WmsLayer> layers = result.getLayers();
84 89
85 final List<AbstractCalculationExportableResult<InundationDurationCalculationResults>> resultList = results.getResults(); 90 int index = 1; // 1 because super.computeAdvance adds the river theme with index 0
91 for (final WmsLayer layer : layers) {
86 92
87 if (!resultList.isEmpty()) { 93 final String label = layer.getLabel();
88 final Facet csv = new DataFacet(FacetTypes.CSV, "CSV data", ComputeType.ADVANCE, hash, this.id); 94 final String url = layer.getUrl();
89 final Facet pdf = new DataFacet(FacetTypes.PDF, "PDF data", ComputeType.ADVANCE, hash, this.id);
90 95
91 facets.add(csv); 96 final WMSLayerFacet wmsFacet = new WMSLayerFacet(index, FLOODMAP_EXTERNAL_WMS_INUNDATIONDUR + index, label, type, getID(), hash, url);
92 facets.add(pdf); 97 facets.add(wmsFacet);
98
99 wmsFacet.addLayer("OSM-WMS-Dienst");
100
101 // wmsFacet.setExtent(getExtent(false));
102 // wmsFacet.setOriginalExtent(getExtent(true));
103 wmsFacet.setSrid(getSrid());
104
105 if (layer.isShowLayerLink())
106 facets.add(new DataFacet("wms_url", label + LABEL_URL_SEPARATOR + url, ComputeType.ADVANCE, hash, this.id));
107
108 index++; // because super.computeAdvance adds the river theme with index 0
93 } 109 }
94 110
111 // tODO: create layer links: filter by "showLayerLink"
112
113 // tODO: create layer links: filter by "showLayerLink"
114
95 final Calculation report = res.getReport(); 115 final Calculation report = res.getReport();
96
97 if (report.hasProblems()) 116 if (report.hasProblems())
98 facets.add(new ReportFacet(ComputeType.ADVANCE, hash, this.id)); 117 facets.add(new ReportFacet(ComputeType.ADVANCE, hash, this.id));
99 118
100 return res; 119 return res;
101 } 120 }

http://dive4elements.wald.intevation.org