[PATCH 4 of 6] Correctly handle not creating facets and error reports
Wald Commits
scm-commit at wald.intevation.org
Mon Aug 25 20:03:43 CEST 2014
# HG changeset patch
# User Andre Heinecke <andre.heinecke at intevation.de>
# Date 1408989704 -7200
# Node ID 45b1d71110c3b37f1e58646c663ac7f4f799bb2e
# Parent 58e3fed51e9edd29b2470329cbf142dea09a1323
Correctly handle not creating facets and error reports.
diff -r 58e3fed51e9e -r 45b1d71110c3 artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/SedimentLoadDataCalculate.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/SedimentLoadDataCalculate.java Mon Aug 25 20:00:45 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/SedimentLoadDataCalculate.java Mon Aug 25 20:01:44 2014 +0200
@@ -138,8 +138,6 @@
CallContext context, List<Facet> facets, Object old) {
logger.debug("SedimentLoadDataCalculate.computeAdvance");
- List<Facet> newFacets = new ArrayList<Facet>();
-
SedimentLoadAccess access = new SedimentLoadAccess(artifact);
CalculationResult res = old instanceof CalculationResult
@@ -151,13 +149,21 @@
logger.error ("No calculation result.");
}
+ if (facets == null) {
+ /* No need to create facets as they already exist in this case. */
+ return res;
+ }
+
+ Calculation report = res.getReport();
+
+ if (report != null && report.hasProblems()) {
+ facets.add(new ReportFacet(ComputeType.ADVANCE, hash, id));
+ logger.warn ("Problems : " + report.problemsToString());
+ }
+
Object raw = res.getData();
if (raw == null) {
logger.warn("No result data.");
- Calculation report = res.getReport();
- if (report != null) {
- logger.warn ("Problems : " + report.problemsToString());
- }
return res;
}
@@ -168,23 +174,18 @@
logger.error ("Unknown result");
return null;
}
+ String unit = access.getUnit().replace("_per_","/");
int i = 0;
for (Fraction fract: sdRes.getFractions()) {
logger.debug("Adding facet for fraction: " + fract.getName());
- newFacets.add(new SedimentLoadDataFacet(i++, fract.getName(),
- fract.getUnit(), ComputeType.ADVANCE, id, hash, context));
+ facets.add(new SedimentLoadDataFacet(i++, fract.getName(),
+ unit, ComputeType.ADVANCE, id, hash, context));
}
- newFacets.add(
+ facets.add(
new DataFacet(CSV, "CSV data", ComputeType.ADVANCE, hash, id));
- if (facets != null) {
- facets.addAll(newFacets);
- } else {
- facets = newFacets;
- }
-
/* XXX: THIS IS ALL BROKEN
SedimentLoadResult[] results = (SedimentLoadResult[]) res.getData();
More information about the Dive4Elements-commits
mailing list