Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/datacage/templating/FixAnalysisYearXPathFunction.java @ 9232:5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
Needs to provide the ArtifactDatabase to the builder implementation.
author | gernotbelger |
---|---|
date | Fri, 06 Jul 2018 13:09:54 +0200 |
parents | |
children | 2d4750874c57 |
rev | line source |
---|---|
9232
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
1 /** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
2 * Software engineering by |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
3 * Björnsen Beratende Ingenieure GmbH |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
5 * |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
6 * This file is Free Software under the GNU AGPL (>=v3) |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
8 * documentation coming with Dive4Elements River for details. |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
9 */ |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
10 package org.dive4elements.river.artifacts.datacage.templating; |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
11 |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
12 import java.util.List; |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
13 import java.util.UUID; |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
14 |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
15 import javax.xml.xpath.XPathFunction; |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
16 import javax.xml.xpath.XPathFunctionException; |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
17 |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
18 import org.apache.log4j.Logger; |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
19 import org.dive4elements.artifacts.CallContext; |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
20 import org.dive4elements.river.artifacts.FixationArtifact; |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
21 import org.dive4elements.river.artifacts.access.FixRealizingAccess; |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
22 import org.dive4elements.river.artifacts.model.fixings.FixRealizingCalculationExtended; |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
23 import org.dive4elements.river.utils.RiverUtils; |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
24 |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
25 /** |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
26 * Very specialized function the resolves the 'year' (als middle of all used events) from a fix-analysis-vollmer |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
27 * artifact). |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
28 * |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
29 * @author Gernot Belger |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
30 */ |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
31 public class FixAnalysisYearXPathFunction implements XPathFunction { |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
32 |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
33 public static final String ID = "fix_analysis_year"; |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
34 |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
35 public static final int ARITY = 1; |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
36 |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
37 private static Logger log = Logger.getLogger(FixAnalysisYearXPathFunction.class); |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
38 |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
39 private final CallContext context; |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
40 |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
41 public FixAnalysisYearXPathFunction(final CallContext context) { |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
42 this.context = context; |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
43 } |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
44 |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
45 @Override |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
46 public Object evaluate(final List args) throws XPathFunctionException { |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
47 |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
48 // FIXME: get artifact id |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
49 final UUID uuid = (UUID) args.get(0); |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
50 |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
51 final FixationArtifact fixation = (FixationArtifact) RiverUtils.getArtifact(uuid.toString(), this.context); |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
52 |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
53 // FIXME: fetch year |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
54 // final CalculationResult r = (CalculationResult) fixation.compute(this.context, ComputeType.ADVANCE, false); |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
55 // final FixRealizingResult frR = (FixRealizingResult) r.getData(); |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
56 |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
57 // Get W/Q input per gauge for this case. |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
58 final FixRealizingAccess fixAccess = new FixRealizingAccess(fixation); |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
59 // final List<Segment> segments = fixAccess.getSegments(); |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
60 // final boolean isFixRealize = (segments != null && !segments.isEmpty()); |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
61 |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
62 /* ugly but necessary to keep this logic at least a bit inside the FixRealizing stuff */ |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
63 final FixRealizingCalculationExtended calculation = new FixRealizingCalculationExtended(fixAccess); |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
64 return calculation.determineMeanYear(); |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
65 } |
5030c46d8cb4
Implemented xpath function that selectes the 'mean year' of a fixation-artifact.
gernotbelger
parents:
diff
changeset
|
66 } |