Mercurial > dive4elements > river
changeset 9234:2d4750874c57
Cleanup and more fail safe
author | gernotbelger |
---|---|
date | Fri, 06 Jul 2018 13:12:04 +0200 |
parents | 03427b89ba62 |
children | d47f6641f597 eedb0bcf226b |
files | artifacts/src/main/java/org/dive4elements/river/artifacts/datacage/templating/FixAnalysisYearXPathFunction.java |
diffstat | 1 files changed, 7 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/datacage/templating/FixAnalysisYearXPathFunction.java Fri Jul 06 13:10:31 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/datacage/templating/FixAnalysisYearXPathFunction.java Fri Jul 06 13:12:04 2018 +0200 @@ -15,8 +15,8 @@ import javax.xml.xpath.XPathFunction; import javax.xml.xpath.XPathFunctionException; -import org.apache.log4j.Logger; import org.dive4elements.artifacts.CallContext; +import org.dive4elements.river.artifacts.D4EArtifact; import org.dive4elements.river.artifacts.FixationArtifact; import org.dive4elements.river.artifacts.access.FixRealizingAccess; import org.dive4elements.river.artifacts.model.fixings.FixRealizingCalculationExtended; @@ -34,8 +34,6 @@ public static final int ARITY = 1; - private static Logger log = Logger.getLogger(FixAnalysisYearXPathFunction.class); - private final CallContext context; public FixAnalysisYearXPathFunction(final CallContext context) { @@ -45,19 +43,18 @@ @Override public Object evaluate(final List args) throws XPathFunctionException { - // FIXME: get artifact id final UUID uuid = (UUID) args.get(0); + if (uuid == null) + return null; - final FixationArtifact fixation = (FixationArtifact) RiverUtils.getArtifact(uuid.toString(), this.context); + final D4EArtifact artifact = RiverUtils.getArtifact(uuid.toString(), this.context); + if (!(artifact instanceof FixationArtifact)) + return null; - // FIXME: fetch year - // final CalculationResult r = (CalculationResult) fixation.compute(this.context, ComputeType.ADVANCE, false); - // final FixRealizingResult frR = (FixRealizingResult) r.getData(); + final FixationArtifact fixation = (FixationArtifact) artifact; // Get W/Q input per gauge for this case. final FixRealizingAccess fixAccess = new FixRealizingAccess(fixation); - // final List<Segment> segments = fixAccess.getSegments(); - // final boolean isFixRealize = (segments != null && !segments.isEmpty()); /* ugly but necessary to keep this logic at least a bit inside the FixRealizing stuff */ final FixRealizingCalculationExtended calculation = new FixRealizingCalculationExtended(fixAccess);