# HG changeset patch # User gernotbelger # Date 1530875524 -7200 # Node ID 2d4750874c57e30212562b8c58b8e6f2ec74b177 # Parent 03427b89ba62a812af8867410674c17b454f3755 Cleanup and more fail safe diff -r 03427b89ba62 -r 2d4750874c57 artifacts/src/main/java/org/dive4elements/river/artifacts/datacage/templating/FixAnalysisYearXPathFunction.java --- 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 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);