Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixChartGenerator.java @ 9268:ae9dee74e43e
Fixed: current station of duration chart was not changed
author | gernotbelger |
---|---|
date | Wed, 18 Jul 2018 18:53:15 +0200 |
parents | 5e38e2924c07 |
children |
comparison
equal
deleted
inserted
replaced
9267:c7e5285d434f | 9268:ae9dee74e43e |
---|---|
39 OutputStream out, | 39 OutputStream out, |
40 CallContext context | 40 CallContext context |
41 ) { | 41 ) { |
42 super.init(outName, request, out, context); | 42 super.init(outName, request, out, context); |
43 | 43 |
44 Double currentKm = getCurrentKmFromRequest(request); | 44 initCurrentKm(request, context); |
45 | |
46 if (log.isDebugEnabled()) { | |
47 log.debug("currentKm = " + currentKm); | |
48 } | |
49 | |
50 if (currentKm != INVALID_KM) { | |
51 context.putContextValue(CURRENT_KM, currentKm); | |
52 } | |
53 } | 45 } |
54 | 46 |
55 public static final Double getCurrentKmFromRequest(Document request) { | 47 public static final Double getCurrentKmFromRequest(Document request) { |
56 | 48 |
57 String km = XMLUtils.xpathString( | 49 String km = XMLUtils.xpathString( |
68 } | 60 } |
69 catch (NumberFormatException nfe) { | 61 catch (NumberFormatException nfe) { |
70 return INVALID_KM; | 62 return INVALID_KM; |
71 } | 63 } |
72 } | 64 } |
65 | |
66 /** | |
67 * Returns the current km from the context. | |
68 * If the context is null or doesn't contain a currentKm | |
69 * then a double value of -1 will be returned. | |
70 * | |
71 * @param context | |
72 * The CallContext instance | |
73 * @return the current km as double | |
74 */ | |
75 // FIXME: copied from org.dive4elements.river.artifacts.model.fixings.FixingsFacet | |
76 public static final double getCurrentKm(final CallContext context) { | |
77 if (context == null) | |
78 return Double.NaN; | |
79 | |
80 final Double dkm = (Double) context.getContextValue(CURRENT_KM); | |
81 if (dkm == null) | |
82 return Double.NaN; | |
83 | |
84 return dkm.doubleValue(); | |
85 } | |
86 | |
87 public static void initCurrentKm(Document request, CallContext context) { | |
88 | |
89 Double currentKm = getCurrentKmFromRequest(request); | |
90 | |
91 if (log.isDebugEnabled()) { | |
92 log.debug("currentKm = " + currentKm); | |
93 } | |
94 | |
95 if (currentKm != INVALID_KM) { | |
96 context.putContextValue(CURRENT_KM, currentKm); | |
97 } | |
98 } | |
73 } | 99 } |
74 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 100 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |