Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BunduWstWQFixing.java @ 9288:82c67b859aa7
bundu.bezugswst worklflow incl. service impl for mainValues to be calculated
author | gernotbelger |
---|---|
date | Tue, 24 Jul 2018 10:39:03 +0200 |
parents | 2323d005f9a5 |
children |
comparison
equal
deleted
inserted
replaced
9287:6c88ad449c83 | 9288:82c67b859aa7 |
---|---|
10 import org.apache.log4j.Logger; | 10 import org.apache.log4j.Logger; |
11 import org.dive4elements.artifacts.Artifact; | 11 import org.dive4elements.artifacts.Artifact; |
12 import org.dive4elements.artifacts.CallContext; | 12 import org.dive4elements.artifacts.CallContext; |
13 import org.dive4elements.artifacts.common.utils.XMLUtils; | 13 import org.dive4elements.artifacts.common.utils.XMLUtils; |
14 import org.dive4elements.river.artifacts.D4EArtifact; | 14 import org.dive4elements.river.artifacts.D4EArtifact; |
15 import org.dive4elements.river.artifacts.model.RangeWithValues; | |
16 import org.dive4elements.river.artifacts.states.WQAdapted; | 15 import org.dive4elements.river.artifacts.states.WQAdapted; |
17 import org.w3c.dom.Element; | 16 import org.w3c.dom.Element; |
18 | 17 |
19 /** | 18 /** |
20 * State to input W/Q data for fixings | 19 * State to input W/Q data for fixings |
21 * | 20 * |
22 * @author <a href="mailto:aheinecke@intevation.de">Andre Heinecke</a> | 21 * @author <a href="mailto:aheinecke@intevation.de">Andre Heinecke</a> |
23 */ | 22 */ |
24 public class BunduWstWQFixing extends WQAdapted { | 23 public class BunduWstWQFixing extends WQAdapted { |
25 | 24 |
25 private static final long serialVersionUID = 1L; | |
26 | |
26 /** The log used in this state. */ | 27 /** The log used in this state. */ |
27 private static Logger log = Logger.getLogger(BunduWstWQFixing.class); | 28 private static Logger log = Logger.getLogger(BunduWstWQFixing.class); |
28 | 29 |
29 @Override | 30 @Override |
30 protected String getUIProvider() { | 31 protected String getUIProvider() { |
31 return "bundu_wst_wq_panel"; | 32 return "bundu_wst_wq_panel"; |
32 } | 33 } |
33 | 34 |
34 /** Simple sanity check if values are positive numbers **/ | |
35 @Override | 35 @Override |
36 public boolean validate(final Artifact artifact) throws IllegalArgumentException { | 36 public boolean validate(final Artifact artifact) throws IllegalArgumentException { |
37 log.debug("BunduWstWQFixing.validate"); | |
38 | 37 |
39 final RangeWithValues[] rwvs = extractInput(getData((D4EArtifact) artifact, "wq_values")); | 38 // Validation is done on client side. No wrong inputs should arrive here. |
40 | 39 // Validation in Super is not suitable for this case |
41 if (rwvs == null) { | |
42 throw new IllegalArgumentException("error_missing_wq_data"); | |
43 } | |
44 | |
45 for (final RangeWithValues rwv : rwvs) { | |
46 final double[] values = rwv.getValues(); | |
47 for (final double val : values) { | |
48 if (val <= 0) { | |
49 throw new IllegalArgumentException("error_validate_positive"); | |
50 } | |
51 } | |
52 } | |
53 | |
54 return true; | 40 return true; |
55 } | 41 } |
56 | 42 |
57 // adding bezugsjahr and dauer to client | 43 // adding bezugsjahr and dauer to client |
58 | |
59 @Override | 44 @Override |
60 protected Element[] createItems(final XMLUtils.ElementCreator ec, final Artifact artifact, final String name, final CallContext context) { | 45 protected Element[] createItems(final XMLUtils.ElementCreator ec, final Artifact artifact, final String name, final CallContext context) { |
61 | 46 |
62 final Element[] defaultElements = super.createItems(ec, artifact, name, context); | 47 final Element[] defaultElements = super.createItems(ec, artifact, name, context); |
48 if (name.equals("bundu.wst.mode")) { // random-name eines DataItems vom state (s. bundu.xml), sodass verhindert wird, dass an alle DataItems | |
49 // length+bezugsjahr drangehÃĪngt werden | |
50 final BunduAccess access = new BunduAccess((D4EArtifact) artifact); | |
63 | 51 |
64 final BunduAccess access = new BunduAccess((D4EArtifact) artifact); | 52 final int bezugsjahr = access.getBezugsJahr(); |
53 final int qSeriesLength = access.getQSeriesLength(); | |
54 final String[] keys = new String[] { "ignore_q_series_length", "ignore_bezugsjahr" }; | |
55 final String[] values = new String[] { String.valueOf(qSeriesLength), String.valueOf(bezugsjahr) }; | |
65 | 56 |
66 final int bezugsjahr = access.getBezugsJahr(); | 57 return FixationChoice.appendElements(ec, defaultElements, keys, values); |
67 final int qSeriesLength = access.getQSeriesLength(); | 58 } else |
68 final String[] keys = new String[] { "ignore_q_series_length", "ignore_bezugsjahr" }; | 59 return defaultElements; |
69 final String[] values = new String[] { String.valueOf(qSeriesLength), String.valueOf(bezugsjahr) }; | |
70 | |
71 return FixationChoice.appendElements(ec, defaultElements, keys, values); | |
72 | |
73 } | 60 } |
74 | |
75 } | 61 } |