comparison artifacts/src/main/java/org/dive4elements/river/artifacts/states/WaterlevelInfoState.java @ 9425:3f49835a00c3

Extended CrossSectionFacet so it may fetch different data from within the artifact result. Also allows to have acces to the potentially already computed artifact result via its normal computation cache.
author gernotbelger
date Fri, 17 Aug 2018 15:31:02 +0200
parents 5e38e2924c07
children
comparison
equal deleted inserted replaced
9424:da19f1f58d72 9425:3f49835a00c3
49 String hash, 49 String hash,
50 Object context, 50 Object context,
51 CallMeta meta, 51 CallMeta meta,
52 List<Facet> facets 52 List<Facet> facets
53 ) { 53 ) {
54 return compute((WINFOArtifact) artifact, hash, facets, null); 54 return compute((WINFOArtifact) artifact, ComputeType.INIT, hash, facets, null);
55 } 55 }
56 56
57 57
58 protected Object compute( 58 private Object compute(
59 WINFOArtifact winfo, 59 WINFOArtifact winfo,
60 ComputeType type,
60 String hash, 61 String hash,
61 List<Facet> facets, 62 List<Facet> facets,
62 Object old 63 Object old
63 ) { 64 ) {
64 log.debug("WaterlevelInfoState.compute"); 65 log.debug("WaterlevelInfoState.compute");
65 String id = getID(); 66 String stateId = getID();
66 67
67 CalculationResult res = old instanceof CalculationResult 68 CalculationResult res = old instanceof CalculationResult
68 ? (CalculationResult)old 69 ? (CalculationResult)old
69 : winfo.getWaterlevelData(); 70 : winfo.getWaterlevelData();
70 71
89 90
90 log.debug("WaterlevelInfoState Create facet: " + nameW); 91 log.debug("WaterlevelInfoState Create facet: " + nameW);
91 log.debug("WaterlevelInfoState Create facet: " + nameQ); 92 log.debug("WaterlevelInfoState Create facet: " + nameQ);
92 93
93 Facet w = new WaterlevelFacet( 94 Facet w = new WaterlevelFacet(
94 i, LONGITUDINAL_W, nameW, ComputeType.ADVANCE, id, hash); 95 i, LONGITUDINAL_W, nameW, ComputeType.ADVANCE, stateId, hash);
95 Facet q = new WaterlevelFacet( 96 Facet q = new WaterlevelFacet(
96 i, LONGITUDINAL_Q, nameQ, ComputeType.ADVANCE, id, hash); 97 i, LONGITUDINAL_Q, nameQ, ComputeType.ADVANCE, stateId, hash);
97 98
98 facets.add(w); 99 facets.add(w);
99 facets.add(q); 100 facets.add(q);
100 } 101 }
101 102
102 if (wqkms.length > 0) { 103 if (wqkms.length > 0) {
103 Facet wst = new DataFacet( 104 Facet wst = new DataFacet(
104 WST, "WST data", ComputeType.ADVANCE, hash, id); 105 WST, "WST data", ComputeType.ADVANCE, hash, stateId);
105 Facet csv = new DataFacet( 106 Facet csv = new DataFacet(
106 CSV, "CSV data", ComputeType.ADVANCE, hash, id); 107 CSV, "CSV data", ComputeType.ADVANCE, hash, stateId);
107 108
108 facets.add(wst); 109 facets.add(wst);
109 facets.add(csv); 110 facets.add(csv);
110 } 111 }
111 112
112 if (res.getReport().hasProblems()) { 113 if (res.getReport().hasProblems()) {
113 facets.add(new ReportFacet(ComputeType.ADVANCE, hash, id)); 114 facets.add(new ReportFacet(ComputeType.ADVANCE, hash, stateId));
114 } 115 }
115 116
116 // TODO Adjust to WaterlevelState - implementation. 117 // TODO Adjust to WaterlevelState - implementation.
117 facets.add(new CrossSectionWaterLineFacet(0, 118 facets.add(new CrossSectionWaterLineFacet(0, "Q=" + winfo.getDataAsString("wq_single"), type, hash, stateId, null));
118 "Q=" + winfo.getDataAsString("wq_single")));
119 119
120 // Assume to be in wq_single mode. 120 // Assume to be in wq_single mode.
121 return res; 121 return res;
122 } 122 }
123 123
131 String hash, 131 String hash,
132 CallContext context, 132 CallContext context,
133 List<Facet> facets, 133 List<Facet> facets,
134 Object old 134 Object old
135 ) { 135 ) {
136 return compute((WINFOArtifact) artifact, hash, facets, old); 136 return compute((WINFOArtifact) artifact, ComputeType.FEED, hash, facets, old);
137 } 137 }
138 138
139 139
140 /** 140 /**
141 * @param context Ignored. 141 * @param context Ignored.
146 String hash, 146 String hash,
147 CallContext context, 147 CallContext context,
148 List<Facet> facets, 148 List<Facet> facets,
149 Object old 149 Object old
150 ) { 150 ) {
151 return compute((WINFOArtifact) artifact, hash, facets, old); 151 return compute((WINFOArtifact) artifact, ComputeType.ADVANCE, hash, facets, old);
152 } 152 }
153 } 153 }
154 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : 154 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org