# HG changeset patch
# User gernotbelger
# Date 1532075942 -7200
# Node ID 2323d005f9a5a6df7d40f7a00544079e1a055d35
# Parent 3141f0e7314ef249f5600733c5431f5f41c49e13
compile error fix
diff -r 3141f0e7314e -r 2323d005f9a5 artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BunduAccess.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BunduAccess.java Thu Jul 19 17:54:10 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BunduAccess.java Fri Jul 20 10:39:02 2018 +0200
@@ -43,6 +43,10 @@
return getIntArray("events_temp");
}
+ public int getQSeriesLength() {
+ return this.artifact.getDataAsInteger("year_input_q_series");
+ }
+
// /** Access the reference date period, return null in case of 'errors'. */
// public DateRange getReferencePeriod() {
// if (this.referencePeriod == null) {
diff -r 3141f0e7314e -r 2323d005f9a5 artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BunduWstWQFixing.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BunduWstWQFixing.java Thu Jul 19 17:54:10 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BunduWstWQFixing.java Fri Jul 20 10:39:02 2018 +0200
@@ -9,13 +9,16 @@
import org.apache.log4j.Logger;
import org.dive4elements.artifacts.Artifact;
+import org.dive4elements.artifacts.CallContext;
+import org.dive4elements.artifacts.common.utils.XMLUtils;
import org.dive4elements.river.artifacts.D4EArtifact;
import org.dive4elements.river.artifacts.model.RangeWithValues;
import org.dive4elements.river.artifacts.states.WQAdapted;
+import org.w3c.dom.Element;
/**
* State to input W/Q data for fixings
- *
+ *
* @author Andre Heinecke
*/
public class BunduWstWQFixing extends WQAdapted {
@@ -23,6 +26,11 @@
/** The log used in this state. */
private static Logger log = Logger.getLogger(BunduWstWQFixing.class);
+ @Override
+ protected String getUIProvider() {
+ return "bundu_wst_wq_panel";
+ }
+
/** Simple sanity check if values are positive numbers **/
@Override
public boolean validate(final Artifact artifact) throws IllegalArgumentException {
@@ -46,8 +54,22 @@
return true;
}
+ // adding bezugsjahr and dauer to client
+
@Override
- protected String getUIProvider() {
- return "bundu_wst_wq_panel";
+ protected Element[] createItems(final XMLUtils.ElementCreator ec, final Artifact artifact, final String name, final CallContext context) {
+
+ final Element[] defaultElements = super.createItems(ec, artifact, name, context);
+
+ final BunduAccess access = new BunduAccess((D4EArtifact) artifact);
+
+ final int bezugsjahr = access.getBezugsJahr();
+ final int qSeriesLength = access.getQSeriesLength();
+ final String[] keys = new String[] { "ignore_q_series_length", "ignore_bezugsjahr" };
+ final String[] values = new String[] { String.valueOf(qSeriesLength), String.valueOf(bezugsjahr) };
+
+ return FixationChoice.appendElements(ec, defaultElements, keys, values);
+
}
+
}
diff -r 3141f0e7314e -r 2323d005f9a5 artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/FixationChoice.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/FixationChoice.java Thu Jul 19 17:54:10 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/FixationChoice.java Fri Jul 20 10:39:02 2018 +0200
@@ -43,11 +43,6 @@
protected Element[] createItems(final XMLUtils.ElementCreator ec, final Artifact artifact, final String name, final CallContext context) {
final Element[] elements = super.createItems(ec, artifact, name, context);
- final Element[] elementsAndYear = new Element[elements.length + 2];
-
- for (int i = 0; i < elements.length; i++) {
- elementsAndYear[i] = elements[i];
- }
final BunduAccess access = new BunduAccess((D4EArtifact) artifact);
final int[] eventsTemp = access.getEventsTemp();
@@ -59,14 +54,27 @@
} else {
builder.append("");// no values
}
- elementsAndYear[elements.length] = createItem(ec, new String[] { "ignore_events_temp", builder.toString() });
-
final int year = access.getBezugsJahr();
+ final String[] values = new String[] { builder.toString(), String.valueOf(year) };
+ final String[] keys = new String[] { "ignore_events_temp", "ignore_singleyear" };
- elementsAndYear[elements.length + 1] = createItem(ec, new String[] { "ignore_singleyear", String.valueOf(year) });
+ return appendElements(ec, elements, keys, values);
- return elementsAndYear;
+ }
+ public static final Element[] appendElements(final ElementCreator ec, final Element[] defaultElements, final String[] keys, final String[] values) {
+ assert (values.length == keys.length);
+ // make bigger array
+ final Element[] defaultAndAddedElements = new Element[defaultElements.length + values.length];
+
+ for (int i = 0; i < defaultElements.length; i++) {
+ defaultAndAddedElements[i] = defaultElements[i];
+ }
+ // add the new values:
+ for (int j = 0; j < keys.length; j++) {
+ defaultAndAddedElements[defaultElements.length + j] = createItem(ec, new String[] { keys[j], values[j] });
+ }
+ return defaultAndAddedElements;
}
@Override
diff -r 3141f0e7314e -r 2323d005f9a5 artifacts/src/main/java/org/dive4elements/river/artifacts/states/BooleanChoiceState.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/BooleanChoiceState.java Thu Jul 19 17:54:10 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/BooleanChoiceState.java Fri Jul 20 10:39:02 2018 +0200
@@ -7,40 +7,34 @@
*/
package org.dive4elements.river.artifacts.states;
-import org.w3c.dom.Element;
-
import org.apache.log4j.Logger;
-
+import org.dive4elements.artifactdatabase.ProtocolUtils;
import org.dive4elements.artifacts.Artifact;
import org.dive4elements.artifacts.CallContext;
import org.dive4elements.artifacts.CallMeta;
-
import org.dive4elements.artifacts.common.utils.XMLUtils;
-
-import org.dive4elements.artifactdatabase.ProtocolUtils;
-
import org.dive4elements.river.artifacts.resources.Resources;
+import org.w3c.dom.Element;
/**
* Generic state for a boolean choice. Only difference between real implementations are the human readable labels.
- *
+ *
* @author Ingo Weinzierl
* @author Gernot Belger
*/
public abstract class BooleanChoiceState extends DefaultState {
- private String optionMsg;
- private String activeMsg;
- private String inactiveMsg;
+ private final String optionMsg;
+ private final String activeMsg;
+ private final String inactiveMsg;
- public BooleanChoiceState( String optionMsg, String activeMsg, String inactiveMsg ) {
- this.optionMsg = optionMsg;
- this.activeMsg = activeMsg;
- this.inactiveMsg = inactiveMsg;
- }
-
- private static final Logger log =
- Logger.getLogger(BooleanChoiceState.class);
+ public BooleanChoiceState(final String optionMsg, final String activeMsg, final String inactiveMsg) {
+ this.optionMsg = optionMsg;
+ this.activeMsg = activeMsg;
+ this.inactiveMsg = inactiveMsg;
+ }
+
+ private static final Logger log = Logger.getLogger(BooleanChoiceState.class);
@Override
protected String getUIProvider() {
@@ -48,45 +42,30 @@
}
@Override
- protected Element[] createItems(
- XMLUtils.ElementCreator cr,
- Artifact artifact,
- String name,
- CallContext context)
- {
- CallMeta meta = context.getMeta();
+ protected Element[] createItems(final XMLUtils.ElementCreator cr, final Artifact artifact, final String name, final CallContext context) {
+ final CallMeta meta = context.getMeta();
- Element option = createItem(
- cr,
- new String[] { Resources.getMsg(meta, optionMsg, optionMsg), "true" });
+ final Element option = createItem(cr, new String[] { Resources.getMsg(meta, this.optionMsg, this.optionMsg), "true" });
return new Element[] { option };
}
-
@Override
- protected String getLabelFor(
- CallContext cc,
- String name,
- String value,
- String type
- ) {
+ protected String getLabelFor(final CallContext cc, final String name, final String value, final String type) {
log.debug("GET LABEL FOR '" + name + "' / '" + value + "'");
if (value != null && value.equals("true")) {
- return Resources.getMsg(cc.getMeta(), activeMsg, activeMsg);
- }
- else {
- return Resources.getMsg(cc.getMeta(), inactiveMsg, inactiveMsg);
+ return Resources.getMsg(cc.getMeta(), this.activeMsg, this.activeMsg);
+ } else {
+ return Resources.getMsg(cc.getMeta(), this.inactiveMsg, this.inactiveMsg);
}
}
+ protected static Element createItem(final XMLUtils.ElementCreator cr, final Object obj) {
+ final Element item = ProtocolUtils.createArtNode(cr, "item", null, null);
+ final Element label = ProtocolUtils.createArtNode(cr, "label", null, null);
+ final Element value = ProtocolUtils.createArtNode(cr, "value", null, null);
- protected Element createItem(XMLUtils.ElementCreator cr, Object obj) {
- Element item = ProtocolUtils.createArtNode(cr, "item", null, null);
- Element label = ProtocolUtils.createArtNode(cr, "label", null, null);
- Element value = ProtocolUtils.createArtNode(cr, "value", null, null);
-
- String[] arr = (String[]) obj;
+ final String[] arr = (String[]) obj;
label.setTextContent(arr[0]);
value.setTextContent(arr[1]);
diff -r 3141f0e7314e -r 2323d005f9a5 artifacts/src/main/java/org/dive4elements/river/artifacts/states/DefaultState.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/DefaultState.java Thu Jul 19 17:54:10 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/DefaultState.java Fri Jul 20 10:39:02 2018 +0200
@@ -9,35 +9,26 @@
package org.dive4elements.river.artifacts.states;
import java.text.NumberFormat;
+import java.util.List;
import java.util.Locale;
import java.util.Map;
-import java.util.List;
import org.apache.log4j.Logger;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
+import org.dive4elements.artifactdatabase.ProtocolUtils;
+import org.dive4elements.artifactdatabase.data.StateData;
+import org.dive4elements.artifactdatabase.state.AbstractState;
+import org.dive4elements.artifactdatabase.state.Facet;
import org.dive4elements.artifacts.Artifact;
import org.dive4elements.artifacts.ArtifactNamespaceContext;
import org.dive4elements.artifacts.CallContext;
import org.dive4elements.artifacts.CallMeta;
-
import org.dive4elements.artifacts.common.utils.XMLUtils;
import org.dive4elements.artifacts.common.utils.XMLUtils.ElementCreator;
-
-import org.dive4elements.artifactdatabase.ProtocolUtils;
-
-import org.dive4elements.artifactdatabase.data.StateData;
-
-import org.dive4elements.artifactdatabase.state.AbstractState;
-import org.dive4elements.artifactdatabase.state.Facet;
-
import org.dive4elements.river.artifacts.D4EArtifact;
-
import org.dive4elements.river.artifacts.resources.Resources;
-
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
/**
* @author Ingo Weinzierl
@@ -47,129 +38,97 @@
/** The log that is used in this class. */
private static Logger log = Logger.getLogger(DefaultState.class);
-
/** The three possible compute types. */
public static enum ComputeType {
FEED, ADVANCE, INIT
}
-
- protected StateData getData(D4EArtifact artifact, String name) {
+ protected StateData getData(final D4EArtifact artifact, final String name) {
return artifact.getData(name);
}
-
/**
* Append to a node and return xml description relevant for gui.
*/
- public Element describeStatic(
- Artifact artifact,
- Document document,
- Node root,
- CallContext context,
- String uuid)
- {
- ElementCreator creator = new ElementCreator(
- document,
- ArtifactNamespaceContext.NAMESPACE_URI,
- ArtifactNamespaceContext.NAMESPACE_PREFIX);
+ public Element describeStatic(final Artifact artifact, final Document document, final Node root, final CallContext context, final String uuid) {
+ final ElementCreator creator = new ElementCreator(document, ArtifactNamespaceContext.NAMESPACE_URI, ArtifactNamespaceContext.NAMESPACE_PREFIX);
- CallMeta meta = context.getMeta();
+ final CallMeta meta = context.getMeta();
String helpText = getHelpText();
if (helpText != null) {
- helpText = replaceHelpUrl(
- Resources.getMsg(meta, helpText, helpText));
+ helpText = replaceHelpUrl(Resources.getMsg(meta, helpText, helpText));
}
- String label = Resources.getMsg(meta, getID(), getID());
- Element ui = ProtocolUtils.createArtNode(
- creator, "state",
- new String[] { "name", "uiprovider", "label", "helpText"},
- new String[] { getID(), getUIProvider(), label, helpText });
+ final String label = Resources.getMsg(meta, getID(), getID());
+ final Element ui = ProtocolUtils.createArtNode(creator, "state", new String[] { "name", "uiprovider", "label", "helpText" },
+ new String[] { getID(), getUIProvider(), label, helpText });
- Map theData = getData();
+ final Map theData = getData();
if (theData == null) {
return ui;
}
- D4EArtifact flys = (D4EArtifact)artifact;
+ final D4EArtifact flys = (D4EArtifact) artifact;
- for (String name: theData.keySet()) {
+ for (final String name : theData.keySet()) {
appendStaticData(flys, context, creator, ui, name);
}
return ui;
}
-
- protected void appendStaticData(
- D4EArtifact flys,
- CallContext context,
- ElementCreator cr,
- Element ui,
- String name
- ) {
- StateData data = getData(flys, name);
- String value = (data != null) ? (String) data.getValue() : null;
+ protected void appendStaticData(final D4EArtifact flys, final CallContext context, final ElementCreator cr, final Element ui, final String name) {
+ final StateData data = getData(flys, name);
+ final String value = (data != null) ? (String) data.getValue() : null;
if (value == null) {
return;
}
- String type = data.getType();
+ final String type = data.getType();
if (log.isDebugEnabled()) {
- log.debug(
- "Append element " + type + "'" +
- name + "' (" + value + ")");
+ log.debug("Append element " + type + "'" + name + "' (" + value + ")");
}
- Element e = createStaticData(flys, cr, context, name, value, type);
+ final Element e = createStaticData(flys, cr, context, name, value, type);
ui.appendChild(e);
}
-
/**
* Creates a data element used in the static part of the DESCRIBE
* document.
*
- * @param creator The ElementCreator that is used to build new Elements.
- * @param cc The CallContext object used for nested i18n retrieval.
- * @param name The name of the data item.
- * @param value The value as string.
+ * @param creator
+ * The ElementCreator that is used to build new Elements.
+ * @param cc
+ * The CallContext object used for nested i18n retrieval.
+ * @param name
+ * The name of the data item.
+ * @param value
+ * The value as string.
*
* @return an Element.
*/
- protected Element createStaticData(
- D4EArtifact flys,
- ElementCreator creator,
- CallContext cc,
- String name,
- String value,
- String type
- ) {
- Element dataElement = creator.create("data");
+ protected Element createStaticData(final D4EArtifact flys, final ElementCreator creator, final CallContext cc, final String name, final String value,
+ final String type) {
+ final Element dataElement = creator.create("data");
creator.addAttr(dataElement, "name", name, true);
creator.addAttr(dataElement, "type", type, true);
- Element itemElement = creator.create("item");
+ final Element itemElement = creator.create("item");
creator.addAttr(itemElement, "value", value, true);
- creator.addAttr(
- itemElement,
- "label",
- getLabelFor(cc, name, value, type),
- true);
+ creator.addAttr(itemElement, "label", getLabelFor(cc, name, value, type), true);
dataElement.appendChild(itemElement);
return dataElement;
}
-
/**
* @param cc
* @param name
@@ -178,29 +137,23 @@
*
* @return
*/
- protected String getLabelFor(
- CallContext cc,
- String name,
- String value,
- String type
- ) {
- CallMeta meta = cc.getMeta();
+ protected String getLabelFor(final CallContext cc, final String name, final String value, final String type) {
+ final CallMeta meta = cc.getMeta();
try {
// XXX A better way to format the output would be to use the
// 'type' value of the data objects.
- double doubleVal = Double.parseDouble(value);
- Locale l = Resources.getLocale(meta);
- NumberFormat nf = NumberFormat.getInstance(l);
+ final double doubleVal = Double.parseDouble(value);
+ final Locale l = Resources.getLocale(meta);
+ final NumberFormat nf = NumberFormat.getInstance(l);
return nf.format(doubleVal);
}
- catch (NumberFormatException nfe) {
+ catch (final NumberFormatException nfe) {
return Resources.getMsg(meta, value, value);
}
}
-
/**
* This method returns the default value and label for data.
*
@@ -210,69 +163,54 @@
* but shall not be null.
*
* Example implementation:
- * if (data != null && data.getName().equals("the_answer")) {
- * return new String[] {"42", "the_answer"};
- * }
+ * if (data != null && data.getName().equals("the_answer")) {
+ * return new String[] {"42", "the_answer"};
+ * }
*
- * @param context The CallContext used for i18n.
- * @param data The data objects that the defaults are for.
+ * @param context
+ * The CallContext used for i18n.
+ * @param data
+ * The data objects that the defaults are for.
* @return a String[] with [default value, default label].
*/
- protected String[] getDefaultsFor(CallContext context, StateData data) {
+ protected String[] getDefaultsFor(final CallContext context, final StateData data) {
return null;
}
-
- public Element describe(
- Artifact artifact,
- Document document,
- Node root,
- CallContext context,
- String uuid)
- {
- ElementCreator creator = new ElementCreator(
- document,
- ArtifactNamespaceContext.NAMESPACE_URI,
- ArtifactNamespaceContext.NAMESPACE_PREFIX);
+ @Override
+ public Element describe(final Artifact artifact, final Document document, final Node root, final CallContext context, final String uuid) {
+ final ElementCreator creator = new ElementCreator(document, ArtifactNamespaceContext.NAMESPACE_URI, ArtifactNamespaceContext.NAMESPACE_PREFIX);
String helpText = getHelpText();
if (helpText != null) {
- helpText = replaceHelpUrl(
- Resources.getMsg(context.getMeta(), helpText, helpText));
+ helpText = replaceHelpUrl(Resources.getMsg(context.getMeta(), helpText, helpText));
}
- Element ui = null;
- String uiprovider = getUIProvider();
+ Element ui = null;
+ final String uiprovider = getUIProvider();
if (uiprovider != null) {
- ui = ProtocolUtils.createArtNode(
- creator, "dynamic",
- new String[] { "uiprovider", "helpText" },
- new String[] { uiprovider, helpText });
- }
- else {
- ui = ProtocolUtils.createArtNode(
- creator, "dynamic",
- new String[] { "helpText" },
- new String[] { helpText });
+ ui = ProtocolUtils.createArtNode(creator, "dynamic", new String[] { "uiprovider", "helpText" }, new String[] { uiprovider, helpText });
+ } else {
+ ui = ProtocolUtils.createArtNode(creator, "dynamic", new String[] { "helpText" }, new String[] { helpText });
}
- Map theData = getData();
+ final Map theData = getData();
if (theData == null) {
return ui;
}
- D4EArtifact flys = (D4EArtifact)artifact;
+ final D4EArtifact flys = (D4EArtifact) artifact;
- for (String name: theData.keySet()) {
+ for (final String name : theData.keySet()) {
StateData data = getData(flys, name);
if (data == null) {
data = getData(name);
}
- Element select = createData(creator, artifact, data, context);
+ final Element select = createData(creator, artifact, data, context);
- String[] defaults = getDefaultsFor(context, data);
+ final String[] defaults = getDefaultsFor(context, data);
if (defaults != null && defaults.length > 1) {
creator.addAttr(select, "defaultValue", defaults[0], true);
creator.addAttr(select, "defaultLabel", defaults[1], true);
@@ -285,7 +223,6 @@
return ui;
}
-
/**
* @param artifact
* @param creator
@@ -293,95 +230,75 @@
* @param context
* @param select
*/
- protected void appendItems(
- Artifact artifact,
- ElementCreator creator,
- String name,
- CallContext context,
- Element select
- ) {
- Element choices = ProtocolUtils.createArtNode(
- creator, "choices", null, null);
+ protected void appendItems(final Artifact artifact, final ElementCreator creator, final String name, final CallContext context, final Element select) {
+ final Element choices = ProtocolUtils.createArtNode(creator, "choices", null, null);
select.appendChild(choices);
- Element[] items = createItems(creator, artifact, name, context);
+ final Element[] items = createItems(creator, artifact, name, context);
if (items != null) {
- for (Element item: items) {
+ for (final Element item : items) {
choices.appendChild(item);
}
}
}
-
/**
* This method creates the root node that contains the list of selectable
* items.
*
- * @param cr The ElementCreator.
+ * @param cr
+ * The ElementCreator.
*
* @return the root node of the item list.
*/
- protected Element createData(
- ElementCreator cr,
- Artifact artifact,
- StateData data,
- CallContext context)
- {
- Element select = ProtocolUtils.createArtNode(
- cr, "select", null, null);
+ protected Element createData(final ElementCreator cr, final Artifact artifact, final StateData data, final CallContext context) {
+ final Element select = ProtocolUtils.createArtNode(cr, "select", null, null);
cr.addAttr(select, "name", data.getName(), true);
- Element label = ProtocolUtils.createArtNode(
- cr, "label", null, null);
+ final Element label = ProtocolUtils.createArtNode(cr, "label", null, null);
select.appendChild(label);
- label.setTextContent(Resources.getMsg(
- context.getMeta(),
- getID(),
- getID()));
+ label.setTextContent(Resources.getMsg(context.getMeta(), getID(), getID()));
return select;
}
-
/**
* This method creates a list of items. These items represent the amount of
* input data that is possible for this state.
*
- * @param cr The ElementCreator.
- * @param name The name of the amount of data.
+ * @param cr
+ * The ElementCreator.
+ * @param name
+ * The name of the amount of data.
*
* @return a list of items.
*/
- protected Element[] createItems(
- ElementCreator cr,
- Artifact artifact,
- String name,
- CallContext context
- ) {
+ protected Element[] createItems(final ElementCreator cr, final Artifact artifact, final String name, final CallContext context) {
return null;
}
-
/**
* This method is used to create an item Element that contains two
* further elements label and value. The label and value
* elements both have text nodes.
*
- * @param cr The ElementCreator used to build new Elements.
- * @param obj This implementation awaits a String array with [0] = label and
- * [1] = value.
+ * @param cr
+ * The ElementCreator used to build new Elements.
+ * @param obj
+ * This implementation awaits a String array with [0] = label and
+ * [1] = value.
*
* @return an Element.
*/
- protected Element createItem(XMLUtils.ElementCreator cr, Object obj) {
- Element item = ProtocolUtils.createArtNode(cr, "item", null, null);
- Element label = ProtocolUtils.createArtNode(cr, "label", null, null);
- Element value = ProtocolUtils.createArtNode(cr, "value", null, null);
+ protected static Element createItem(final XMLUtils.ElementCreator cr, final Object obj) {
+ final Element item = ProtocolUtils.createArtNode(cr, "item", null, null);
+ final Element label = ProtocolUtils.createArtNode(cr, "label", null, null);
+ final Element value = ProtocolUtils.createArtNode(cr, "value", null, null);
- String[] arr = (String[]) obj;
+ final String[] arr = (String[]) obj;
label.setTextContent(arr[0]);
value.setTextContent(arr[1]);
@@ -392,23 +309,35 @@
return item;
}
+ // protected static Element createItem(final XMLUtils.ElementCreator cr, final Object obj) {
+ // final Element item = ProtocolUtils.createArtNode(cr, "item", null, null);
+ // final Element label = ProtocolUtils.createArtNode(cr, "label", null, null);
+ // final Element value = ProtocolUtils.createArtNode(cr, "value", null, null);
+ //
+ // final String[] arr = (String[]) obj;
+ //
+ // label.setTextContent(arr[0]);
+ // value.setTextContent(arr[1]);
+ //
+ // item.appendChild(label);
+ // item.appendChild(value);
+ //
+ // return item;
+ // }
/**
* This method transform a given value into a StateData object.
*
- * @param flys The D4EArtifact.
- * @param name The name of the data object.
- * @param val The value of the data object.
+ * @param flys
+ * The D4EArtifact.
+ * @param name
+ * The name of the data object.
+ * @param val
+ * The value of the data object.
*
* @return a StateData object with name and value.
*/
- public StateData transform(
- D4EArtifact flys,
- CallContext cc,
- StateData stateData,
- String name,
- String val
- ) {
+ public StateData transform(final D4EArtifact flys, final CallContext cc, final StateData stateData, final String name, final String val) {
if (log.isDebugEnabled()) {
log.debug("Transform data ('" + name + "','" + val + "')");
}
@@ -418,29 +347,29 @@
return stateData;
}
-
- /** Override this to do validation.
+ /**
+ * Override this to do validation.
*
* Throw an IllegalArgumentException with a localized
* error message that should be presented to the user in case
- * the date provided is invalid. */
- public void validate(Artifact artifact, CallContext context)
- throws IllegalArgumentException {
- validate(artifact); /* For compatibility so that classes that
- override this method still work. */
+ * the date provided is invalid.
+ */
+ public void validate(final Artifact artifact, final CallContext context) throws IllegalArgumentException {
+ validate(artifact); /*
+ * For compatibility so that classes that
+ * override this method still work.
+ */
}
+
/**
* This method is deprecated.
* Override the function with the callcontext instead to do
* localization of error.s
*/
- public boolean validate(Artifact artifact)
- throws IllegalArgumentException
- {
+ public boolean validate(final Artifact artifact) throws IllegalArgumentException {
return true;
}
-
/**
* Returns which UIProvider shall be used to aid user input.
*/
@@ -448,36 +377,15 @@
return null;
}
-
- public Object computeAdvance(
- D4EArtifact artifact,
- String hash,
- CallContext context,
- List facets,
- Object old
- ) {
+ public Object computeAdvance(final D4EArtifact artifact, final String hash, final CallContext context, final List facets, final Object old) {
return null;
}
-
- public Object computeFeed(
- D4EArtifact artifact,
- String hash,
- CallContext context,
- List facets,
- Object old
- ) {
+ public Object computeFeed(final D4EArtifact artifact, final String hash, final CallContext context, final List facets, final Object old) {
return null;
}
-
- public Object computeInit(
- D4EArtifact artifact,
- String hash,
- Object context,
- CallMeta meta,
- List facets)
- {
+ public Object computeInit(final D4EArtifact artifact, final String hash, final Object context, final CallMeta meta, final List facets) {
return null;
}
}
diff -r 3141f0e7314e -r 2323d005f9a5 artifacts/src/main/java/org/dive4elements/river/artifacts/states/FloodplainChoice.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/FloodplainChoice.java Thu Jul 19 17:54:10 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/FloodplainChoice.java Fri Jul 20 10:39:02 2018 +0200
@@ -8,89 +8,66 @@
package org.dive4elements.river.artifacts.states;
-import org.w3c.dom.Element;
-
import org.apache.log4j.Logger;
-
import org.dive4elements.artifacts.Artifact;
import org.dive4elements.artifacts.CallContext;
import org.dive4elements.artifacts.CallMeta;
-
import org.dive4elements.artifacts.common.utils.XMLUtils;
-
-import org.dive4elements.artifactdatabase.ProtocolUtils;
-
import org.dive4elements.river.artifacts.resources.Resources;
-
+import org.w3c.dom.Element;
/**
* @author Ingo Weinzierl
*/
-// FIXME: inherit from BooleanChoiceState instead to remove duplicate code; BUT: this will probably break artifact serialization
+// FIXME: inherit from BooleanChoiceState instead to remove duplicate code; BUT: this will probably break artifact
+// serialization
public class FloodplainChoice extends DefaultState {
- public static final String OPTION = "floodplain.option";
- public static final String ACTIVE = "floodplain.active";
+ public static final String OPTION = "floodplain.option";
+ public static final String ACTIVE = "floodplain.active";
public static final String INACTIVE = "floodplain.inactive";
- private static final Logger log =
- Logger.getLogger(FloodplainChoice.class);
-
+ private static final Logger log = Logger.getLogger(FloodplainChoice.class);
@Override
protected String getUIProvider() {
return "boolean_panel";
}
-
@Override
- protected Element[] createItems(
- XMLUtils.ElementCreator cr,
- Artifact artifact,
- String name,
- CallContext context)
- {
- CallMeta meta = context.getMeta();
+ protected Element[] createItems(final XMLUtils.ElementCreator cr, final Artifact artifact, final String name, final CallContext context) {
+ final CallMeta meta = context.getMeta();
- Element option = createItem(
- cr,
- new String[] { Resources.getMsg(meta, OPTION, OPTION), "true" });
+ final Element option = createItem(cr, new String[] { Resources.getMsg(meta, OPTION, OPTION), "true" });
return new Element[] { option };
}
-
@Override
- protected String getLabelFor(
- CallContext cc,
- String name,
- String value,
- String type
- ) {
+ protected String getLabelFor(final CallContext cc, final String name, final String value, final String type) {
log.debug("GET LABEL FOR '" + name + "' / '" + value + "'");
if (value != null && value.equals("true")) {
return Resources.getMsg(cc.getMeta(), ACTIVE, ACTIVE);
- }
- else {
+ } else {
return Resources.getMsg(cc.getMeta(), INACTIVE, INACTIVE);
}
}
-
- protected Element createItem(XMLUtils.ElementCreator cr, Object obj) {
- Element item = ProtocolUtils.createArtNode(cr, "item", null, null);
- Element label = ProtocolUtils.createArtNode(cr, "label", null, null);
- Element value = ProtocolUtils.createArtNode(cr, "value", null, null);
-
- String[] arr = (String[]) obj;
-
- label.setTextContent(arr[0]);
- value.setTextContent(arr[1]);
-
- item.appendChild(label);
- item.appendChild(value);
-
- return item;
- }
+ // ist mit super identisch!
+ // protected Element createItem(XMLUtils.ElementCreator cr, Object obj) {
+ // Element item = ProtocolUtils.createArtNode(cr, "item", null, null);
+ // Element label = ProtocolUtils.createArtNode(cr, "label", null, null);
+ // Element value = ProtocolUtils.createArtNode(cr, "value", null, null);
+ //
+ // String[] arr = (String[]) obj;
+ //
+ // label.setTextContent(arr[0]);
+ // value.setTextContent(arr[1]);
+ //
+ // item.appendChild(label);
+ // item.appendChild(value);
+ //
+ // return item;
+ // }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
diff -r 3141f0e7314e -r 2323d005f9a5 artifacts/src/main/java/org/dive4elements/river/artifacts/states/ScenarioSelect.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/ScenarioSelect.java Thu Jul 19 17:54:10 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/ScenarioSelect.java Fri Jul 20 10:39:02 2018 +0200
@@ -8,7 +8,9 @@
package org.dive4elements.river.artifacts.states;
-import org.dive4elements.artifactdatabase.ProtocolUtils;
+import java.io.File;
+
+import org.apache.log4j.Logger;
import org.dive4elements.artifacts.Artifact;
import org.dive4elements.artifacts.CallContext;
import org.dive4elements.artifacts.CallMeta;
@@ -17,10 +19,6 @@
import org.dive4elements.river.artifacts.D4EArtifact;
import org.dive4elements.river.artifacts.resources.Resources;
import org.dive4elements.river.utils.RiverUtils;
-
-import java.io.File;
-
-import org.apache.log4j.Logger;
import org.w3c.dom.Element;
/**
@@ -28,21 +26,16 @@
*/
public class ScenarioSelect extends DefaultState {
- /** The log that is used in this class.*/
+ /** The log that is used in this class. */
private static Logger log = Logger.getLogger(ScenarioSelect.class);
+ public static final String FIELD_MODE = "scenario";
- public static final String FIELD_MODE = "scenario";
-
- public static final String SCENARIO_CURRENT = "scenario.current";
+ public static final String SCENARIO_CURRENT = "scenario.current";
public static final String SCENARIO_POTENTIEL = "scenario.potentiel";
- public static final String SCENARIO_SCENRAIO = "scenario.scenario";
+ public static final String SCENARIO_SCENRAIO = "scenario.scenario";
- public static final String[] SCENARIOS = {
- SCENARIO_CURRENT,
- SCENARIO_POTENTIEL,
- SCENARIO_SCENRAIO };
-
+ public static final String[] SCENARIOS = { SCENARIO_CURRENT, SCENARIO_POTENTIEL, SCENARIO_SCENRAIO };
@Override
protected String getUIProvider() {
@@ -50,96 +43,74 @@
}
@Override
- protected Element[] createItems(
- XMLUtils.ElementCreator cr,
- Artifact artifact,
- String name,
- CallContext context)
- {
- CallMeta meta = context.getMeta();
+ protected Element[] createItems(final XMLUtils.ElementCreator cr, final Artifact artifact, final String name, final CallContext context) {
+ final CallMeta meta = context.getMeta();
if (name.equals(FIELD_MODE)) {
- Element[] scenarios = new Element[SCENARIOS.length];
+ final Element[] scenarios = new Element[SCENARIOS.length];
int i = 0;
- for (String scenario: SCENARIOS) {
- scenarios[i++] = createItem(
- cr, new String[] {
- Resources.getMsg(meta, scenario, scenario),
- scenario
- });
+ for (final String scenario : SCENARIOS) {
+ scenarios[i++] = createItem(cr, new String[] { Resources.getMsg(meta, scenario, scenario), scenario });
}
return scenarios;
- }
- else {
- D4EArtifact flys = (D4EArtifact) artifact;
- String data = flys.getDataAsString(name);
+ } else {
+ final D4EArtifact flys = (D4EArtifact) artifact;
+ final String data = flys.getDataAsString(name);
- return new Element[] { createItem(
- cr,
- new String[] {
- Resources.getMsg(meta, name, name),
- data
- }
- )};
+ return new Element[] { createItem(cr, new String[] { Resources.getMsg(meta, name, name), data }) };
}
}
+ // ist mit super identisch
+ // @Override
+ // protected Element createItem(XMLUtils.ElementCreator cr, Object obj) {
+ // Element item = ProtocolUtils.createArtNode(cr, "item", null, null);
+ // Element label = ProtocolUtils.createArtNode(cr, "label", null, null);
+ // Element value = ProtocolUtils.createArtNode(cr, "value", null, null);
+ //
+ // String[] arr = (String[]) obj;
+ //
+ // label.setTextContent(arr[0]);
+ // value.setTextContent(arr[1]);
+ //
+ // item.appendChild(label);
+ // item.appendChild(value);
+ //
+ // return item;
+ // }
@Override
- protected Element createItem(XMLUtils.ElementCreator cr, Object obj) {
- Element item = ProtocolUtils.createArtNode(cr, "item", null, null);
- Element label = ProtocolUtils.createArtNode(cr, "label", null, null);
- Element value = ProtocolUtils.createArtNode(cr, "value", null, null);
-
- String[] arr = (String[]) obj;
-
- label.setTextContent(arr[0]);
- value.setTextContent(arr[1]);
-
- item.appendChild(label);
- item.appendChild(value);
-
- return item;
- }
-
-
-
- @Override
- public void endOfLife(Artifact artifact, Object callContext) {
+ public void endOfLife(final Artifact artifact, final Object callContext) {
super.endOfLife(artifact, callContext);
log.info("ScenarioSelect.endOfLife: " + artifact.identifier());
- D4EArtifact flys = (D4EArtifact) artifact;
+ final D4EArtifact flys = (D4EArtifact) artifact;
removeDirectory(flys);
}
-
/**
* Removes the directory and all its content where the required data and the
* results of WSPLGEN are stored. Should be called in endOfLife().
*/
// FIXME: I've seen this code somewhere else...
- protected void removeDirectory(D4EArtifact artifact) {
- String shapePath = RiverUtils.getXPathString(
- RiverUtils.XPATH_FLOODMAP_SHAPEFILE_DIR);
+ protected void removeDirectory(final D4EArtifact artifact) {
+ final String shapePath = RiverUtils.getXPathString(RiverUtils.XPATH_FLOODMAP_SHAPEFILE_DIR);
- File artifactDir = new File(shapePath, artifact.identifier());
+ final File artifactDir = new File(shapePath, artifact.identifier());
if (artifactDir.exists()) {
log.debug("Delete directory: " + artifactDir.getAbsolutePath());
- boolean success = FileTools.deleteRecursive(artifactDir);
+ final boolean success = FileTools.deleteRecursive(artifactDir);
if (!success) {
log.warn("could not remove dir '" + artifactDir + "'");
}
- }
- else {
+ } else {
log.debug("There is no directory to remove.");
}
}
-
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
diff -r 3141f0e7314e -r 2323d005f9a5 artifacts/src/main/java/org/dive4elements/river/artifacts/states/WQAdapted.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/WQAdapted.java Thu Jul 19 17:54:10 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/WQAdapted.java Fri Jul 20 10:39:02 2018 +0200
@@ -9,43 +9,35 @@
package org.dive4elements.river.artifacts.states;
import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.List;
-import java.util.Comparator;
-import java.util.Collections;
import org.apache.log4j.Logger;
-
-import org.w3c.dom.Element;
-
+import org.dive4elements.artifactdatabase.ProtocolUtils;
+import org.dive4elements.artifactdatabase.data.StateData;
import org.dive4elements.artifacts.Artifact;
import org.dive4elements.artifacts.CallContext;
-
-import org.dive4elements.artifactdatabase.ProtocolUtils;
-import org.dive4elements.artifactdatabase.data.StateData;
-
import org.dive4elements.artifacts.common.utils.XMLUtils;
-
+import org.dive4elements.river.artifacts.D4EArtifact;
import org.dive4elements.river.artifacts.access.RangeAccess;
-
+import org.dive4elements.river.artifacts.model.RangeWithValues;
+import org.dive4elements.river.artifacts.model.WstFactory;
import org.dive4elements.river.model.Gauge;
import org.dive4elements.river.model.Range;
import org.dive4elements.river.model.River;
import org.dive4elements.river.model.Wst;
-
-import org.dive4elements.river.artifacts.D4EArtifact;
-
-import org.dive4elements.river.artifacts.model.RangeWithValues;
-import org.dive4elements.river.artifacts.model.WstFactory;
import org.dive4elements.river.utils.RiverUtils;
-
+import org.w3c.dom.Element;
/**
* State to input W/Q data.
+ *
* @author Ingo Weinzierl
*/
public class WQAdapted extends DefaultState {
- /** The log used in this state.*/
+ /** The log used in this state. */
private static Logger log = Logger.getLogger(WQAdapted.class);
public static final String FIELD_WQ_MODE = "wq_isq";
@@ -53,26 +45,25 @@
public static final String FIELD_WQ_VALUES = "wq_values";
public static final class GaugeOrder implements Comparator {
- private int order;
+ private final int order;
- public GaugeOrder(boolean up) {
- order = up ? 1 : -1;
+ public GaugeOrder(final boolean up) {
+ this.order = up ? 1 : -1;
}
- public int compare(Gauge a, Gauge b) {
- return order * a.getRange().getA().compareTo(b.getRange().getA());
+ @Override
+ public int compare(final Gauge a, final Gauge b) {
+ return this.order * a.getRange().getA().compareTo(b.getRange().getA());
}
} // class GaugeOrder
- public static final GaugeOrder GAUGE_UP = new GaugeOrder(true);
+ public static final GaugeOrder GAUGE_UP = new GaugeOrder(true);
public static final GaugeOrder GAUGE_DOWN = new GaugeOrder(false);
-
/** Trivial, empty constructor. */
public WQAdapted() {
}
-
/**
* This method creates one element for each gauge of selected river that
* is intersected by the given kilometer range. Each element is a tuple of
@@ -81,156 +72,124 @@
* kilometer range. to is the upper bounds of the gauge or the upper
* kilometer range.
*
- * @param cr The ElementCreator.
- * @param artifact The FLYS artifact.
- * @param name The name of the data item.
- * @param context The CallContext.
+ * @param cr
+ * The ElementCreator.
+ * @param artifact
+ * The FLYS artifact.
+ * @param name
+ * The name of the data item.
+ * @param context
+ * The CallContext.
*
* @return a list of elements that consist of tuples of the intersected
- * gauges of the selected river.
+ * gauges of the selected river.
*/
@Override
- protected Element[] createItems(
- XMLUtils.ElementCreator cr,
- Artifact artifact,
- String name,
- CallContext context)
- {
+ protected Element[] createItems(final XMLUtils.ElementCreator cr, final Artifact artifact, final String name, final CallContext context) {
log.debug("WQAdapted.createItems");
if (name != null && name.equals(FIELD_WQ_MODE)) {
return createModeItems(cr, artifact, name, context);
- }
- else if (name != null && name.equals(FIELD_WQ_VALUES)) {
+ } else if (name != null && name.equals(FIELD_WQ_VALUES)) {
return createValueItems(cr, artifact, name, context);
- }
- else {
+ } else {
log.warn("Unknown data object: " + name);
return null;
}
}
-
/** Creates "Q" and "W" items. */
- protected Element[] createModeItems(
- XMLUtils.ElementCreator cr,
- Artifact artifact,
- String name,
- CallContext context)
- {
+ protected Element[] createModeItems(final XMLUtils.ElementCreator cr, final Artifact artifact, final String name, final CallContext context) {
log.debug("WQAdapted.createModeItems");
- Element w = createItem(cr, new String[] { "w", "W" });
- Element q = createItem(cr, new String[] { "q", "Q" });
+ final Element w = createItem(cr, new String[] { "w", "W" });
+ final Element q = createItem(cr, new String[] { "q", "Q" });
return new Element[] { w, q };
}
-
/** Create the items for input to the ranges per mode. */
- protected Element[] createValueItems(
- XMLUtils.ElementCreator cr,
- Artifact artifact,
- String name,
- CallContext context)
- {
+ protected Element[] createValueItems(final XMLUtils.ElementCreator cr, final Artifact artifact, final String name, final CallContext context) {
log.debug("WQAdapted.createValueItems");
- D4EArtifact flysArtifact = (D4EArtifact) artifact;
+ final D4EArtifact flysArtifact = (D4EArtifact) artifact;
- RangeAccess rangeAccess = new RangeAccess(flysArtifact);
- double[] dist = rangeAccess.getKmRange();
+ final RangeAccess rangeAccess = new RangeAccess(flysArtifact);
+ final double[] dist = rangeAccess.getKmRange();
// TODO use Access to get River and gauges.
- River river = RiverUtils.getRiver(flysArtifact);
- Wst wst = WstFactory.getWst(river);
- List gauges = RiverUtils.getGauges(flysArtifact);
+ final River river = RiverUtils.getRiver(flysArtifact);
+ final Wst wst = WstFactory.getWst(river);
+ final List gauges = RiverUtils.getGauges(flysArtifact);
- int num = gauges != null ? gauges.size() : 0;
+ final int num = gauges != null ? gauges.size() : 0;
if (num == 0) {
log.warn("Selected distance matches no gauges.");
return null;
}
- List elements = new ArrayList();
+ final List elements = new ArrayList<>();
double rangeFrom = dist[0];
- double rangeTo = dist[1];
+ double rangeTo = dist[1];
if (rangeFrom < rangeTo) {
Collections.sort(gauges, GAUGE_UP);
- for (Gauge gauge: gauges) {
- Range range = gauge.getRange();
- double lower = range.getA().doubleValue();
- double upper = range.getB().doubleValue();
+ for (final Gauge gauge : gauges) {
+ final Range range = gauge.getRange();
+ final double lower = range.getA().doubleValue();
+ final double upper = range.getB().doubleValue();
// If gauge out of range, skip it.
if (upper <= rangeFrom || lower >= rangeTo) {
continue;
}
- double from = lower < rangeFrom ? rangeFrom : lower;
- double to = upper > rangeTo ? rangeTo : upper;
-
- double[] mmQ = determineMinMaxQ(gauge, wst);
- double[] mmW = gauge.determineMinMaxW();
+ final double from = lower < rangeFrom ? rangeFrom : lower;
+ final double to = upper > rangeTo ? rangeTo : upper;
- elements.add(createItem(
- cr,
- new String[] { from + ";" + to,
- gauge.getName()},
- mmQ,
- mmW));
+ final double[] mmQ = determineMinMaxQ(gauge, wst);
+ final double[] mmW = gauge.determineMinMaxW();
+
+ elements.add(createItem(cr, new String[] { from + ";" + to, gauge.getName() }, mmQ, mmW));
}
- }
- else {
+ } else {
Collections.sort(gauges, GAUGE_DOWN);
rangeFrom = dist[1];
- rangeTo = dist[0];
- for (Gauge gauge: gauges) {
- Range range = gauge.getRange();
- double lower = range.getA().doubleValue();
- double upper = range.getB().doubleValue();
+ rangeTo = dist[0];
+ for (final Gauge gauge : gauges) {
+ final Range range = gauge.getRange();
+ final double lower = range.getA().doubleValue();
+ final double upper = range.getB().doubleValue();
- double from = lower < rangeFrom ? rangeFrom : lower;
- double to = upper > rangeTo ? rangeTo : upper;
+ final double from = lower < rangeFrom ? rangeFrom : lower;
+ final double to = upper > rangeTo ? rangeTo : upper;
// TODO probably need to continue out if oof range (see above).
- double[] mmQ = determineMinMaxQ(gauge, wst);
- double[] mmW = gauge.determineMinMaxW();
+ final double[] mmQ = determineMinMaxQ(gauge, wst);
+ final double[] mmW = gauge.determineMinMaxW();
- elements.add(createItem(
- cr,
- new String[] { to + ";" + from,
- gauge.getName()},
- mmQ,
- mmW));
+ elements.add(createItem(cr, new String[] { to + ";" + from, gauge.getName() }, mmQ, mmW));
}
}
- Element[] els = new Element[elements.size()];
+ final Element[] els = new Element[elements.size()];
return elements.toArray(els);
}
-
- protected Element createItem(XMLUtils.ElementCreator cr, Object obj) {
- return createItem(cr, obj, null, null);
- }
-
+ // dead code!
+ // protected Element createItem(XMLUtils.ElementCreator cr, Object obj) {
+ // return createItem(cr, obj, null, null);
+ // }
/** In obj: 0 is label, 1 is value. */
- protected Element createItem(
- XMLUtils.ElementCreator cr,
- Object obj,
- double[] q,
- double[] w)
- {
- Element item = ProtocolUtils.createArtNode(cr, "item", null, null);
- Element label = ProtocolUtils.createArtNode(cr, "label", null, null);
- Element value = ProtocolUtils.createArtNode(cr, "value", null, null);
+ protected Element createItem(final XMLUtils.ElementCreator cr, final Object obj, final double[] q, final double[] w) {
+ final Element item = ProtocolUtils.createArtNode(cr, "item", null, null);
+ final Element label = ProtocolUtils.createArtNode(cr, "label", null, null);
+ final Element value = ProtocolUtils.createArtNode(cr, "value", null, null);
- String[] arr = (String[]) obj;
+ final String[] arr = (String[]) obj;
label.setTextContent(arr[0]);
value.setTextContent(arr[1]);
@@ -239,33 +198,25 @@
item.appendChild(value);
if (q != null) {
- Element qRange = createRangeElement(cr, q, "Q");
+ final Element qRange = createRangeElement(cr, q, "Q");
item.appendChild(qRange);
}
if (w != null) {
- Element wRange = createRangeElement(cr, w, "W");
+ final Element wRange = createRangeElement(cr, w, "W");
item.appendChild(wRange);
}
return item;
}
+ protected Element createRangeElement(final XMLUtils.ElementCreator cr, final double[] mm, final String type) {
+ final Element range = ProtocolUtils.createArtNode(cr, "range", new String[] { "type" }, new String[] { type });
- protected Element createRangeElement(
- XMLUtils.ElementCreator cr,
- double[] mm,
- String type)
- {
- Element range = ProtocolUtils.createArtNode(
- cr, "range",
- new String[] {"type"},
- new String[] {type});
-
- Element min = ProtocolUtils.createArtNode(cr, "min", null, null);
+ final Element min = ProtocolUtils.createArtNode(cr, "min", null, null);
min.setTextContent(String.valueOf(mm[0]));
- Element max = ProtocolUtils.createArtNode(cr, "max", null, null);
+ final Element max = ProtocolUtils.createArtNode(cr, "max", null, null);
max.setTextContent(String.valueOf(mm[1]));
range.appendChild(min);
@@ -274,7 +225,6 @@
return range;
}
-
/**
* Determines the min and max Q value for the given gauge. If no min and
* max values could be determined, this method will return
@@ -285,74 +235,60 @@
*
* @return the min and max Q values for the given gauge.
*/
- protected double[] determineMinMaxQ(Gauge gauge, Wst wst) {
+ protected double[] determineMinMaxQ(final Gauge gauge, final Wst wst) {
log.debug("WQAdapted.determineMinMaxQ");
- double[] minmaxQ = gauge != null
- ? wst.determineMinMaxQ(gauge.getRange())
- : null;
+ final double[] minmaxQ = gauge != null ? wst.determineMinMaxQ(gauge.getRange()) : null;
- double minQ = minmaxQ != null ? minmaxQ[0] : Double.MIN_VALUE;
- double maxQ = minmaxQ != null ? minmaxQ[1] : Double.MAX_VALUE;
+ final double minQ = minmaxQ != null ? minmaxQ[0] : Double.MIN_VALUE;
+ final double maxQ = minmaxQ != null ? minmaxQ[1] : Double.MAX_VALUE;
return new double[] { minQ, maxQ };
}
-
/** Indicate client which input elements to use. */
@Override
protected String getUIProvider() {
return "wq_panel_adapted";
}
-
@Override
- public boolean validate(Artifact artifact)
- throws IllegalArgumentException
- {
+ public boolean validate(final Artifact artifact) throws IllegalArgumentException {
log.debug("WQAdapted.validate");
- D4EArtifact flys = (D4EArtifact) artifact;
- StateData data = getData(flys, FIELD_WQ_MODE);
+ final D4EArtifact flys = (D4EArtifact) artifact;
+ final StateData data = getData(flys, FIELD_WQ_MODE);
- String mode = data != null ? (String) data.getValue() : null;
- boolean isQ = mode != null
- ? Boolean.valueOf(mode)
- : false;
+ final String mode = data != null ? (String) data.getValue() : null;
+ final boolean isQ = mode != null ? Boolean.valueOf(mode) : false;
if (!isQ) {
return validateW(artifact);
- }
- else if (isQ) {
+ } else if (isQ) {
return validateQ(artifact);
- }
- else {
- throw new IllegalArgumentException(
- "error_feed_no_wq_mode_selected");
+ } else {
+ throw new IllegalArgumentException("error_feed_no_wq_mode_selected");
}
}
+ protected boolean validateW(final Artifact artifact) throws IllegalArgumentException {
+ log.debug("WQAdapted.validateW");
+ final D4EArtifact flys = (D4EArtifact) artifact;
- protected boolean validateW(Artifact artifact)
- throws IllegalArgumentException
- {
- log.debug("WQAdapted.validateW");
- D4EArtifact flys = (D4EArtifact) artifact;
-
- RangeWithValues[] rwvs = extractInput(getData(flys, "wq_values"));
+ final RangeWithValues[] rwvs = extractInput(getData(flys, "wq_values"));
if (rwvs == null) {
throw new IllegalArgumentException("error_missing_wq_data");
}
- List gauges = RiverUtils.getGauges((D4EArtifact) artifact);
+ final List gauges = RiverUtils.getGauges((D4EArtifact) artifact);
- for (Gauge gauge: gauges) {
- Range range = gauge.getRange();
- double lower = range.getA().doubleValue();
- double upper = range.getB().doubleValue();
+ for (final Gauge gauge : gauges) {
+ final Range range = gauge.getRange();
+ final double lower = range.getA().doubleValue();
+ final double upper = range.getB().doubleValue();
- for (RangeWithValues rwv: rwvs) {
+ for (final RangeWithValues rwv : rwvs) {
if (lower <= rwv.getStart() && upper >= rwv.getEnd()) {
compareWsWithGauge(gauge, rwv.getValues());
}
@@ -362,29 +298,26 @@
return true;
}
+ protected boolean validateQ(final Artifact artifact) throws IllegalArgumentException {
+ log.debug("WQAdapted.validateQ");
+ final D4EArtifact flys = (D4EArtifact) artifact;
- protected boolean validateQ(Artifact artifact)
- throws IllegalArgumentException
- {
- log.debug("WQAdapted.validateQ");
- D4EArtifact flys = (D4EArtifact) artifact;
-
- RangeWithValues[] rwvs = extractInput(getData(flys, "wq_values"));
+ final RangeWithValues[] rwvs = extractInput(getData(flys, "wq_values"));
if (rwvs == null) {
throw new IllegalArgumentException("error_missing_wq_data");
}
- List gauges = RiverUtils.getGauges(flys);
- River river = RiverUtils.getRiver(flys);
- Wst wst = WstFactory.getWst(river);
+ final List gauges = RiverUtils.getGauges(flys);
+ final River river = RiverUtils.getRiver(flys);
+ final Wst wst = WstFactory.getWst(river);
- for (Gauge gauge: gauges) {
- Range range = gauge.getRange();
- double lower = range.getA().doubleValue();
- double upper = range.getB().doubleValue();
+ for (final Gauge gauge : gauges) {
+ final Range range = gauge.getRange();
+ final double lower = range.getA().doubleValue();
+ final double upper = range.getB().doubleValue();
- for (RangeWithValues rwv: rwvs) {
+ for (final RangeWithValues rwv : rwvs) {
if (lower <= rwv.getStart() && upper >= rwv.getEnd()) {
compareQsWithGauge(wst, gauge, rwv.getValues());
}
@@ -394,13 +327,8 @@
return true;
}
-
- protected boolean compareQsWithGauge(Wst wst, Gauge gauge, double[] qs)
- throws IllegalArgumentException
- {
- double[] minmax = gauge != null
- ? wst.determineMinMaxQ(gauge.getRange())
- : null;
+ protected boolean compareQsWithGauge(final Wst wst, final Gauge gauge, final double[] qs) throws IllegalArgumentException {
+ final double[] minmax = gauge != null ? wst.determineMinMaxQ(gauge.getRange()) : null;
if (minmax == null) {
log.warn("Could not determine min/max Q of gauge.");
@@ -414,23 +342,17 @@
log.debug("-- Gauge max: " + minmax[1]);
}
- for (double q: qs) {
+ for (final double q : qs) {
if (q < minmax[0] || q > minmax[1]) {
- throw new IllegalArgumentException(
- "error_feed_q_values_invalid");
+ throw new IllegalArgumentException("error_feed_q_values_invalid");
}
}
return true;
}
-
- protected boolean compareWsWithGauge(Gauge gauge, double[] ws)
- throws IllegalArgumentException
- {
- double[] minmax = gauge != null
- ? gauge.determineMinMaxW()
- : null;
+ protected boolean compareWsWithGauge(final Gauge gauge, final double[] ws) throws IllegalArgumentException {
+ final double[] minmax = gauge != null ? gauge.determineMinMaxW() : null;
if (minmax == null) {
log.warn("Could not determine min/max W of gauge.");
@@ -444,43 +366,41 @@
log.debug("-- Gauge max: " + minmax[1]);
}
- for (double w: ws) {
+ for (final double w : ws) {
if (w < minmax[0] || w > minmax[1]) {
- throw new IllegalArgumentException(
- "error_feed_w_values_invalid");
+ throw new IllegalArgumentException("error_feed_w_values_invalid");
}
}
return true;
}
-
- protected RangeWithValues[] extractInput(StateData data) {
+ protected RangeWithValues[] extractInput(final StateData data) {
if (data == null) {
return null;
}
- String dataString = (String) data.getValue();
- String[] ranges = dataString.split(":");
-
- List rwv = new ArrayList();
+ final String dataString = (String) data.getValue();
+ final String[] ranges = dataString.split(":");
- for (String range: ranges) {
- String[] parts = range.split(";");
+ final List rwv = new ArrayList<>();
- double lower = Double.parseDouble(parts[0]);
- double upper = Double.parseDouble(parts[1]);
+ for (final String range : ranges) {
+ final String[] parts = range.split(";");
- String[] values = parts[3].split(",");
+ final double lower = Double.parseDouble(parts[0]);
+ final double upper = Double.parseDouble(parts[1]);
- int num = values.length;
- double[] res = new double[num];
+ final String[] values = parts[3].split(",");
+
+ final int num = values.length;
+ final double[] res = new double[num];
for (int i = 0; i < num; i++) {
try {
res[i] = Double.parseDouble(values[i]);
}
- catch (NumberFormatException nfe) {
+ catch (final NumberFormatException nfe) {
log.warn(nfe, nfe);
}
}
diff -r 3141f0e7314e -r 2323d005f9a5 artifacts/src/main/java/org/dive4elements/river/artifacts/states/WQSelect.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/WQSelect.java Thu Jul 19 17:54:10 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/WQSelect.java Fri Jul 20 10:39:02 2018 +0200
@@ -10,37 +10,28 @@
import java.text.NumberFormat;
-import gnu.trove.TDoubleArrayList;
-
import org.apache.log4j.Logger;
-
-import org.w3c.dom.Element;
-
+import org.dive4elements.artifactdatabase.ProtocolUtils;
+import org.dive4elements.artifactdatabase.data.StateData;
import org.dive4elements.artifacts.Artifact;
import org.dive4elements.artifacts.CallContext;
-
import org.dive4elements.artifacts.common.utils.XMLUtils;
import org.dive4elements.artifacts.common.utils.XMLUtils.ElementCreator;
-
-import org.dive4elements.artifactdatabase.ProtocolUtils;
-import org.dive4elements.artifactdatabase.data.StateData;
-
-import org.dive4elements.river.model.Gauge;
-import org.dive4elements.river.model.River;
-import org.dive4elements.river.model.Wst;
-
import org.dive4elements.river.artifacts.D4EArtifact;
-
+import org.dive4elements.river.artifacts.access.ComputationRangeAccess;
import org.dive4elements.river.artifacts.access.RangeAccess;
import org.dive4elements.river.artifacts.access.RangeAccess.KM_MODE;
-import org.dive4elements.river.artifacts.access.ComputationRangeAccess;
import org.dive4elements.river.artifacts.model.WstFactory;
import org.dive4elements.river.artifacts.model.WstValueTable;
import org.dive4elements.river.artifacts.model.WstValueTableFactory;
import org.dive4elements.river.artifacts.resources.Resources;
+import org.dive4elements.river.model.Gauge;
+import org.dive4elements.river.model.River;
+import org.dive4elements.river.model.Wst;
+import org.dive4elements.river.utils.RiverUtils;
+import org.w3c.dom.Element;
-import org.dive4elements.river.utils.RiverUtils;
-
+import gnu.trove.TDoubleArrayList;
/**
* @author Ingo Weinzierl
@@ -80,43 +71,34 @@
/** The name of the 'single' field. */
public static final String WQ_SINGLE = "wq_single";
-
/**
* The default constructor that initializes an empty State object.
*/
public WQSelect() {
}
-
@Override
- protected Element createStaticData(
- D4EArtifact flys,
- ElementCreator creator,
- CallContext cc,
- String name,
- String value,
- String type
- ) {
+ protected Element createStaticData(final D4EArtifact flys, final ElementCreator creator, final CallContext cc, final String name, final String value,
+ final String type) {
if (!name.equals(WQ_SINGLE)) {
return super.createStaticData(flys, creator, cc, name, value, type);
}
- Boolean isQ = flys.getDataAsBoolean(WQ_MODE);
- Boolean isFree = flys.getDataAsBoolean(WQ_FREE);
+ final Boolean isQ = flys.getDataAsBoolean(WQ_MODE);
+ final Boolean isFree = flys.getDataAsBoolean(WQ_FREE);
- Element dataElement = creator.create("data");
+ final Element dataElement = creator.create("data");
creator.addAttr(dataElement, "name", name, true);
creator.addAttr(dataElement, "type", type, true);
- Element itemElement = creator.create("item");
+ final Element itemElement = creator.create("item");
creator.addAttr(itemElement, "value", value, true);
String label;
if (!isQ || isFree) {
label = getLabel(flys, cc, value);
- }
- else {
+ } else {
label = getSpecialLabel(flys, cc, value);
}
@@ -127,35 +109,29 @@
return dataElement;
}
-
- protected static String getLabel(
- D4EArtifact winfo,
- CallContext cc,
- String raw
- ) {
- String[] values = raw.split(" ");
+ protected static String getLabel(final D4EArtifact winfo, final CallContext cc, final String raw) {
+ final String[] values = raw.split(" ");
if (values.length < 1) {
return null;
}
- StringBuilder label = new StringBuilder();
-
- NumberFormat nf = NumberFormat.getInstance(
- Resources.getLocale(cc.getMeta()));
+ final StringBuilder label = new StringBuilder();
- for (String value: values) {
+ final NumberFormat nf = NumberFormat.getInstance(Resources.getLocale(cc.getMeta()));
+
+ for (final String value : values) {
try {
- double v = Double.parseDouble(value.trim());
+ final double v = Double.parseDouble(value.trim());
- String formatted = nf.format(v);
+ final String formatted = nf.format(v);
if (label.length() > 0) {
label.append(';');
}
label.append(formatted);
}
- catch (NumberFormatException nfe) {
+ catch (final NumberFormatException nfe) {
// do nothing here
}
}
@@ -163,33 +139,26 @@
return label.toString();
}
-
- protected static String getSpecialLabel(
- D4EArtifact winfo,
- CallContext cc,
- String raw
- ) {
- String[] values = raw.split(" ");
+ protected static String getSpecialLabel(final D4EArtifact winfo, final CallContext cc, final String raw) {
+ final String[] values = raw.split(" ");
if (values.length < 1) {
return null;
}
- NumberFormat nf = NumberFormat.getInstance(
- Resources.getLocale(cc.getMeta()));
+ final NumberFormat nf = NumberFormat.getInstance(Resources.getLocale(cc.getMeta()));
- RangeAccess rangeAccess = new RangeAccess(winfo);
- Gauge gauge = rangeAccess.getRiver().determineRefGauge(
- rangeAccess.getKmRange(), rangeAccess.isRange());
+ final RangeAccess rangeAccess = new RangeAccess(winfo);
+ final Gauge gauge = rangeAccess.getRiver().determineRefGauge(rangeAccess.getKmRange(), rangeAccess.isRange());
- StringBuilder label = new StringBuilder();
+ final StringBuilder label = new StringBuilder();
- for (String value: values) {
+ for (final String value : values) {
try {
- double v = Double.parseDouble(value.trim());
+ final double v = Double.parseDouble(value.trim());
String tmp = nf.format(v);
- String mv = RiverUtils.getNamedMainValue(gauge, v);
+ final String mv = RiverUtils.getNamedMainValue(gauge, v);
if (mv != null && mv.length() > 0) {
tmp = mv + ": " + tmp;
@@ -200,7 +169,7 @@
}
label.append(tmp);
}
- catch (NumberFormatException nfe) {
+ catch (final NumberFormatException nfe) {
// do nothing here
}
}
@@ -208,155 +177,99 @@
return label.toString();
}
-
@Override
- protected Element createData(
- XMLUtils.ElementCreator cr,
- Artifact artifact,
- StateData data,
- CallContext context)
- {
- Element select = ProtocolUtils.createArtNode(
- cr, "select", null, null);
+ protected Element createData(final XMLUtils.ElementCreator cr, final Artifact artifact, final StateData data, final CallContext context) {
+ final Element select = ProtocolUtils.createArtNode(cr, "select", null, null);
cr.addAttr(select, "name", data.getName(), true);
- Element label = ProtocolUtils.createArtNode(
- cr, "label", null, null);
+ final Element label = ProtocolUtils.createArtNode(cr, "label", null, null);
// XXX: DEAD CODE
/*
- Element choices = ProtocolUtils.createArtNode(
- cr, "choices", null, null);
- */
+ * Element choices = ProtocolUtils.createArtNode(
+ * cr, "choices", null, null);
+ */
- label.setTextContent(Resources.getMsg(
- context.getMeta(),
- data.getName(),
- data.getName()));
+ label.setTextContent(Resources.getMsg(context.getMeta(), data.getName(), data.getName()));
select.appendChild(label);
return select;
}
-
@Override
- protected Element[] createItems(
- XMLUtils.ElementCreator cr,
- Artifact artifact,
- String name,
- CallContext context
- ){
- D4EArtifact flys = (D4EArtifact) artifact;
+ protected Element[] createItems(final XMLUtils.ElementCreator cr, final Artifact artifact, final String name, final CallContext context) {
+ final D4EArtifact flys = (D4EArtifact) artifact;
- double[] minmaxW = determineMinMaxW(flys);
- double[] minmaxWFree = determineMinMaxWFree(flys);
- double[] minmaxQ = determineMinMaxQAtGauge(flys);
- double[] minmaxQFree = determineMinMaxQ(flys);
+ final double[] minmaxW = determineMinMaxW(flys);
+ final double[] minmaxWFree = determineMinMaxWFree(flys);
+ final double[] minmaxQ = determineMinMaxQAtGauge(flys);
+ final double[] minmaxQFree = determineMinMaxQ(flys);
if (name.equals("wq_from")) {
- Element minW = createItem(cr, new String[] {
- "minW",
- String.valueOf(minmaxW[0])});
+ final Element minW = createItem(cr, new String[] { "minW", String.valueOf(minmaxW[0]) });
- Element minQ = createItem(cr, new String[] {
- "minQ",
- String.valueOf(minmaxQ[0])});
+ final Element minQ = createItem(cr, new String[] { "minQ", String.valueOf(minmaxQ[0]) });
- Element minQFree = createItem(cr, new String[] {
- "minQFree",
- String.valueOf(minmaxQFree[0])});
+ final Element minQFree = createItem(cr, new String[] { "minQFree", String.valueOf(minmaxQFree[0]) });
- Element minWFree = createItem(cr, new String[] {
- "minWFree",
- String.valueOf(minmaxWFree[0])});
+ final Element minWFree = createItem(cr, new String[] { "minWFree", String.valueOf(minmaxWFree[0]) });
return new Element[] { minW, minQ, minQFree, minWFree };
- }
- else if (name.equals("wq_to")) {
- Element maxW = createItem(cr, new String[] {
- "maxW",
- String.valueOf(minmaxW[1])});
+ } else if (name.equals("wq_to")) {
+ final Element maxW = createItem(cr, new String[] { "maxW", String.valueOf(minmaxW[1]) });
- Element maxQ = createItem(cr, new String[] {
- "maxQ",
- String.valueOf(minmaxQ[1])});
+ final Element maxQ = createItem(cr, new String[] { "maxQ", String.valueOf(minmaxQ[1]) });
- Element maxQFree = createItem(cr, new String[] {
- "maxQFree",
- String.valueOf(minmaxQFree[1])});
+ final Element maxQFree = createItem(cr, new String[] { "maxQFree", String.valueOf(minmaxQFree[1]) });
- Element maxWFree = createItem(cr, new String[] {
- "maxWFree",
- String.valueOf(minmaxWFree[1])});
+ final Element maxWFree = createItem(cr, new String[] { "maxWFree", String.valueOf(minmaxWFree[1]) });
return new Element[] { maxW, maxQ, maxQFree, maxWFree };
- }
- else {
- Element stepW = createItem(
- cr, new String[] {
- "stepW",
- String.valueOf(getStepsW(minmaxW[0], minmaxW[1]))});
- Element stepQ = createItem(
- cr, new String[] {
- "stepQ",
- String.valueOf(getStepsQ(minmaxQ[0], minmaxQ[1]))});
- Element stepQFree = createItem(
- cr, new String[] {
- "stepQFree",
- String.valueOf(getStepsQ(minmaxQFree[0], minmaxQFree[1]))});
- Element stepWFree = createItem(
- cr, new String[] {
- "stepWFree",
- String.valueOf(getStepsW(minmaxWFree[0], minmaxWFree[1]))});
+ } else {
+ final Element stepW = createItem(cr, new String[] { "stepW", String.valueOf(getStepsW(minmaxW[0], minmaxW[1])) });
+ final Element stepQ = createItem(cr, new String[] { "stepQ", String.valueOf(getStepsQ(minmaxQ[0], minmaxQ[1])) });
+ final Element stepQFree = createItem(cr, new String[] { "stepQFree", String.valueOf(getStepsQ(minmaxQFree[0], minmaxQFree[1])) });
+ final Element stepWFree = createItem(cr, new String[] { "stepWFree", String.valueOf(getStepsW(minmaxWFree[0], minmaxWFree[1])) });
return new Element[] { stepW, stepQ, stepQFree, stepWFree };
}
}
-
- protected static double getStepsW(double min, double max) {
- double diff = min < max ? max - min : min - max;
- double step = diff / MAX_STEPS;
+ protected static double getStepsW(final double min, final double max) {
+ final double diff = min < max ? max - min : min - max;
+ final double step = diff / MAX_STEPS;
if (step < 10) {
return getSteps(step, 1);
- }
- else if (step < 100) {
+ } else if (step < 100) {
return getSteps(step, 10);
- }
- else if (step < 1000) {
+ } else if (step < 1000) {
return getSteps(step, 100);
- }
- else {
+ } else {
return step;
}
}
-
- protected static double getStepsQ(double min, double max) {
- double diff = min < max ? max - min : min - max;
- double step = diff / MAX_STEPS;
+ protected static double getStepsQ(final double min, final double max) {
+ final double diff = min < max ? max - min : min - max;
+ final double step = diff / MAX_STEPS;
if (step < 10) {
return getSteps(step, 1);
- }
- else if (step < 100) {
+ } else if (step < 100) {
return getSteps(step, 10);
- }
- else if (step < 1000) {
+ } else if (step < 1000) {
return getSteps(step, 100);
- }
- else {
+ } else {
return step;
}
}
-
- protected static double getSteps(double steps, double factor) {
- int fac = (int) (steps / factor);
- double diff = steps - fac * factor;
+ protected static double getSteps(final double steps, final double factor) {
+ final int fac = (int) (steps / factor);
+ final double diff = steps - fac * factor;
if (diff == 0) {
return steps;
@@ -365,141 +278,133 @@
return factor * (fac + 1);
}
-
- protected Element createItem(XMLUtils.ElementCreator cr, Object obj) {
- Element item = ProtocolUtils.createArtNode(cr, "item", null, null);
- Element label = ProtocolUtils.createArtNode(cr, "label", null, null);
- Element value = ProtocolUtils.createArtNode(cr, "value", null, null);
-
- String[] arr = (String[]) obj;
-
- label.setTextContent(arr[0]);
- value.setTextContent(arr[1]);
-
- item.appendChild(label);
- item.appendChild(value);
-
- return item;
- }
-
+ // ist mit super identisch
+ // protected Element createItem(XMLUtils.ElementCreator cr, Object obj) {
+ // Element item = ProtocolUtils.createArtNode(cr, "item", null, null);
+ // Element label = ProtocolUtils.createArtNode(cr, "label", null, null);
+ // Element value = ProtocolUtils.createArtNode(cr, "value", null, null);
+ //
+ // String[] arr = (String[]) obj;
+ //
+ // label.setTextContent(arr[0]);
+ // value.setTextContent(arr[1]);
+ //
+ // item.appendChild(label);
+ // item.appendChild(value);
+ //
+ // return item;
+ // }
@Override
protected String getUIProvider() {
return "wq_panel";
}
-
/**
* Determines the min and max W value for the current gauge. If no min and
* max values could be determined, this method will return
* [Double.MIN_VALUE, Double.MAX_VALUE].
*
- * @param artifact The D4EArtifact.
+ * @param artifact
+ * The D4EArtifact.
*
* @return the min and max W values for the current gauge.
*/
- protected double[] determineMinMaxW(D4EArtifact winfo) {
+ protected double[] determineMinMaxW(final D4EArtifact winfo) {
log.debug("WQSelect.determineCurrentGauge");
- RangeAccess rangeAccess = new RangeAccess(winfo);
- Gauge gauge = rangeAccess.getRiver().determineRefGauge(
- rangeAccess.getKmRange(), rangeAccess.isRange());
+ final RangeAccess rangeAccess = new RangeAccess(winfo);
+ final Gauge gauge = rangeAccess.getRiver().determineRefGauge(rangeAccess.getKmRange(), rangeAccess.isRange());
- double[] minmaxW = gauge != null ? gauge.determineMinMaxW() : null;
+ final double[] minmaxW = gauge != null ? gauge.determineMinMaxW() : null;
- double minW = minmaxW != null ? minmaxW[0] : Double.MIN_VALUE;
- double maxW = minmaxW != null ? minmaxW[1] : Double.MAX_VALUE;
+ final double minW = minmaxW != null ? minmaxW[0] : Double.MIN_VALUE;
+ final double maxW = minmaxW != null ? minmaxW[1] : Double.MAX_VALUE;
return new double[] { minW, maxW };
}
-
/**
* Determines the min and max W value. If no min and
* max values could be determined, this method will return
* [Double.MIN_VALUE, Double.MAX_VALUE].
*
- * @param artifact The D4EArtifact.
+ * @param artifact
+ * The D4EArtifact.
*
* @return the min and max W values.
*/
- protected double[] determineMinMaxWFree(D4EArtifact winfo) {
+ protected double[] determineMinMaxWFree(final D4EArtifact winfo) {
log.debug("WQSelect.determineMinMaxWFree");
- WstValueTable valueTable = WstValueTableFactory.getTable(
- RiverUtils.getRiver(winfo));
+ final WstValueTable valueTable = WstValueTableFactory.getTable(RiverUtils.getRiver(winfo));
- ComputationRangeAccess access = new ComputationRangeAccess(winfo);
-
+ final ComputationRangeAccess access = new ComputationRangeAccess(winfo);
+
double[] minmaxW = null;
- if(valueTable != null) {
+ if (valueTable != null) {
final double startKm = access.getStartKm();
// Use the start km to determine the min max values.
minmaxW = valueTable.getMinMaxW(startKm);
}
- return minmaxW != null
- ? minmaxW
- : new double[] { Double.MIN_VALUE, Double.MAX_VALUE };
+ return minmaxW != null ? minmaxW : new double[] { Double.MIN_VALUE, Double.MAX_VALUE };
}
-
/**
* Determines the min and max Q value for the current gauge. If no min and
* max values could be determined, this method will return
* [Double.MIN_VALUE, Double.MAX_VALUE].
*
- * @param artifact The D4EArtifact.
+ * @param artifact
+ * The D4EArtifact.
*
* @return the min and max Q values for the current gauge.
*/
- protected double[] determineMinMaxQAtGauge(D4EArtifact winfo) {
+ protected double[] determineMinMaxQAtGauge(final D4EArtifact winfo) {
log.debug("WQSelect.determineMinMaxQAtGauge");
- RangeAccess rangeAccess = new RangeAccess(winfo);
- River river = rangeAccess.getRiver();
- Gauge gauge = river.determineRefGauge(
- rangeAccess.getKmRange(), rangeAccess.isRange());
+ final RangeAccess rangeAccess = new RangeAccess(winfo);
+ final River river = rangeAccess.getRiver();
+ final Gauge gauge = river.determineRefGauge(rangeAccess.getKmRange(), rangeAccess.isRange());
- Wst wst = WstFactory.getWst(river);
+ final Wst wst = WstFactory.getWst(river);
- double[] minmaxQ = gauge != null
- ? wst.determineMinMaxQ(gauge.getRange())
- : null;
+ final double[] minmaxQ = gauge != null ? wst.determineMinMaxQ(gauge.getRange()) : null;
- double minQ = minmaxQ != null ? minmaxQ[0] : Double.MIN_VALUE;
- double maxQ = minmaxQ != null ? minmaxQ[1] : Double.MAX_VALUE;
+ final double minQ = minmaxQ != null ? minmaxQ[0] : Double.MIN_VALUE;
+ final double maxQ = minmaxQ != null ? minmaxQ[1] : Double.MAX_VALUE;
return new double[] { minQ, maxQ };
}
-
/**
* Determines the min and max Q value for the current kilometer range. If no
* min and max values could be determined, this method will return
*
- * @param artifact The D4EArtifact.
+ * @param artifact
+ * The D4EArtifact.
*
* @return the min and max Q values for the current kilometer range.
*/
- protected double[] determineMinMaxQ(D4EArtifact winfo) {
+ protected double[] determineMinMaxQ(final D4EArtifact winfo) {
log.debug("WQSelect.determineMinMaxQ");
final WstValueTable valueTable = WstValueTableFactory.getTable(RiverUtils.getRiver(winfo));
final ComputationRangeAccess access = new ComputationRangeAccess(winfo);
-
+
double[] minmaxQ = null;
- if(valueTable != null) {
-
+ if (valueTable != null) {
+
final KM_MODE mode = access.getKmRangeMode();
switch (mode) {
case RANGE: {
- final double[] km = access.getFromToStep();
+ final double[] km = access.getFromToStep();
minmaxQ = valueTable.getMinMaxQ(km[0], km[1], km[2]);
break;
}
-
+
case DISTANCE_ONLY: {
minmaxQ = valueTable.getMinMaxQ(access.getFrom(), access.getTo(), 0.1);
break;
@@ -509,11 +414,11 @@
final double[] km = access.getKms();
minmaxQ = valueTable.getMinMaxQ(km[0]);
for (int i = 1; i < km.length; i++) {
- double[] tmp = valueTable.getMinMaxQ(km[i]);
- if(tmp[0] < minmaxQ[0]) {
+ final double[] tmp = valueTable.getMinMaxQ(km[i]);
+ if (tmp[0] < minmaxQ[0]) {
minmaxQ[0] = tmp[0];
}
- if(tmp[1] > minmaxQ[1]) {
+ if (tmp[1] > minmaxQ[1]) {
minmaxQ[1] = tmp[1];
}
}
@@ -521,86 +426,66 @@
}
}
}
- return minmaxQ != null
- ? minmaxQ
- : new double[] { Double.MIN_VALUE, Double.MAX_VALUE };
+ return minmaxQ != null ? minmaxQ : new double[] { Double.MIN_VALUE, Double.MAX_VALUE };
}
-
@Override
- public boolean validate(Artifact artifact)
- throws IllegalArgumentException
- {
+ public boolean validate(final Artifact artifact) throws IllegalArgumentException {
log.debug("WQSelect.validate");
- D4EArtifact flys = (D4EArtifact) artifact;
+ final D4EArtifact flys = (D4EArtifact) artifact;
- StateData data = getData(flys, WQ_SELECTION);
- boolean isRange = data != null
- ? Boolean.valueOf((String) data.getValue())
- : false;
-
-
+ final StateData data = getData(flys, WQ_SELECTION);
+ final boolean isRange = data != null ? Boolean.valueOf((String) data.getValue()) : false;
if (!isRange) {
return validateSingle(flys);
- }
- else {
+ } else {
return validateRange(flys);
}
}
-
- protected boolean validateBounds(
- double fromValid, double toValid,
- double from, double to, double step)
- throws IllegalArgumentException
- {
+ protected boolean validateBounds(final double fromValid, final double toValid, final double from, final double to, final double step)
+ throws IllegalArgumentException {
log.debug("RangeState.validateRange");
if (from < fromValid) {
- log.error(
- "Invalid 'from'. " + from + " is smaller than " + fromValid);
+ log.error("Invalid 'from'. " + from + " is smaller than " + fromValid);
throw new IllegalArgumentException("error_feed_from_out_of_range");
- }
- else if (to > toValid) {
- log.error(
- "Invalid 'to'. " + to + " is bigger than " + toValid);
+ } else if (to > toValid) {
+ log.error("Invalid 'to'. " + to + " is bigger than " + toValid);
throw new IllegalArgumentException("error_feed_to_out_of_range");
}
return true;
}
-
- protected boolean validateSingle(D4EArtifact artifact)
- throws IllegalArgumentException
- {
+ protected boolean validateSingle(final D4EArtifact artifact) throws IllegalArgumentException {
log.debug("WQSelect.validateSingle");
- StateData data = getData(artifact, WQ_SINGLE);
+ final StateData data = getData(artifact, WQ_SINGLE);
- String tmp = data != null ? (String) data.getValue() : null;
+ final String tmp = data != null ? (String) data.getValue() : null;
if (tmp == null || tmp.length() == 0) {
throw new IllegalArgumentException("error_empty_state");
}
- String[] strValues = tmp.split(" ");
- TDoubleArrayList all = new TDoubleArrayList();
+ final String[] strValues = tmp.split(" ");
+ final TDoubleArrayList all = new TDoubleArrayList();
- for (String strValue: strValues) {
+ for (final String strValue : strValues) {
try {
all.add(Double.parseDouble(strValue));
}
- catch (NumberFormatException nfe) {
+ catch (final NumberFormatException nfe) {
log.warn(nfe, nfe);
}
}
all.sort();
- RiverUtils.WQ_MODE mode = RiverUtils.getWQMode(artifact);
+ final RiverUtils.WQ_MODE mode = RiverUtils.getWQMode(artifact);
log.debug("WQ Mode: " + mode);
@@ -608,19 +493,16 @@
if (mode == RiverUtils.WQ_MODE.WGAUGE) {
minmax = determineMinMaxW(artifact);
- }
- else if (mode == RiverUtils.WQ_MODE.QGAUGE) {
+ } else if (mode == RiverUtils.WQ_MODE.QGAUGE) {
minmax = determineMinMaxQAtGauge(artifact);
- }
- else if (mode == RiverUtils.WQ_MODE.QFREE) {
+ } else if (mode == RiverUtils.WQ_MODE.QFREE) {
minmax = determineMinMaxQ(artifact);
- }
- else {
+ } else {
minmax = determineMinMaxWFree(artifact);
}
- double min = all.get(0);
- double max = all.get(all.size()-1);
+ final double min = all.get(0);
+ final double max = all.get(all.size() - 1);
log.debug("Inserted min value = " + min);
log.debug("Inserted max value = " + max);
@@ -628,156 +510,136 @@
return validateBounds(minmax[0], minmax[1], min, max, 0d);
}
-
- protected boolean validateRange(D4EArtifact artifact)
- throws IllegalArgumentException
- {
+ protected boolean validateRange(final D4EArtifact artifact) throws IllegalArgumentException {
log.debug("WQSelect.validateRange");
- RiverUtils.WQ_MODE mode = RiverUtils.getWQMode(artifact);
+ final RiverUtils.WQ_MODE mode = RiverUtils.getWQMode(artifact);
if (mode == null) {
throw new IllegalArgumentException("error_feed_invalid_wq_mode");
}
- StateData dFrom = artifact.getData(WQ_FROM);
- StateData dTo = artifact.getData(WQ_TO);
- StateData dStep = artifact.getData(WQ_STEP);
+ final StateData dFrom = artifact.getData(WQ_FROM);
+ final StateData dTo = artifact.getData(WQ_TO);
+ final StateData dStep = artifact.getData(WQ_STEP);
- String fromStr = dFrom != null ? (String) dFrom.getValue() : null;
- String toStr = dTo != null ? (String) dTo.getValue() : null;
- String stepStr = dStep != null ? (String) dStep.getValue() : null;
+ final String fromStr = dFrom != null ? (String) dFrom.getValue() : null;
+ final String toStr = dTo != null ? (String) dTo.getValue() : null;
+ final String stepStr = dStep != null ? (String) dStep.getValue() : null;
if (fromStr == null || toStr == null || stepStr == null) {
throw new IllegalArgumentException("error_empty_state");
}
try {
- double from = Double.parseDouble(fromStr);
- double to = Double.parseDouble(toStr);
- double step = Double.parseDouble(stepStr);
+ final double from = Double.parseDouble(fromStr);
+ final double to = Double.parseDouble(toStr);
+ final double step = Double.parseDouble(stepStr);
if (mode == RiverUtils.WQ_MODE.WGAUGE) {
return validateGaugeW(artifact, from, to, step);
- }
- else if (mode == RiverUtils.WQ_MODE.QGAUGE) {
+ } else if (mode == RiverUtils.WQ_MODE.QGAUGE) {
return validateGaugeQ(artifact, from, to, step);
- }
- else if (mode == RiverUtils.WQ_MODE.QFREE) {
+ } else if (mode == RiverUtils.WQ_MODE.QFREE) {
return validateFreeQ(artifact, from, to, step);
- }
- else if (mode == RiverUtils.WQ_MODE.WFREE) {
+ } else if (mode == RiverUtils.WQ_MODE.WFREE) {
return validateFreeW(artifact, from, to, step);
- }
- else {
- throw new IllegalArgumentException(
- "error_feed_invalid_wq_mode");
+ } else {
+ throw new IllegalArgumentException("error_feed_invalid_wq_mode");
}
}
- catch (NumberFormatException nfe) {
+ catch (final NumberFormatException nfe) {
throw new IllegalArgumentException("error_feed_number_format");
}
}
-
/**
* Validates the inserted W values.
*
- * @param artifact The owner artifact.
- * @param from The lower value of the W range.
- * @param to The upper value of the W range.
- * @param step The step width.
+ * @param artifact
+ * The owner artifact.
+ * @param from
+ * The lower value of the W range.
+ * @param to
+ * The upper value of the W range.
+ * @param step
+ * The step width.
*
* @return true, if everything was fine, otherwise an exception is thrown.
*/
- protected boolean validateGaugeW(
- D4EArtifact artifact,
- double from,
- double to,
- double step)
- throws IllegalArgumentException
- {
+ protected boolean validateGaugeW(final D4EArtifact artifact, final double from, final double to, final double step) throws IllegalArgumentException {
log.debug("WQSelect.validateGaugeW");
- double[] minmaxW = determineMinMaxW(artifact);
+ final double[] minmaxW = determineMinMaxW(artifact);
return validateBounds(minmaxW[0], minmaxW[1], from, to, step);
}
-
/**
* Validates the inserted Q values based on the Q range for the current
* gauge.
*
- * @param artifact The owner artifact.
- * @param from The lower value of the Q range.
- * @param to The upper value of the Q range.
- * @param step The step width.
+ * @param artifact
+ * The owner artifact.
+ * @param from
+ * The lower value of the Q range.
+ * @param to
+ * The upper value of the Q range.
+ * @param step
+ * The step width.
*
* @return true, if everything was fine, otherwise an exception is thrown.
*/
- protected boolean validateGaugeQ(
- D4EArtifact artifact,
- double from,
- double to,
- double step)
- throws IllegalArgumentException
- {
+ protected boolean validateGaugeQ(final D4EArtifact artifact, final double from, final double to, final double step) throws IllegalArgumentException {
log.debug("WQSelect.validateGaugeQ");
- double[] minmaxQ = determineMinMaxQAtGauge(artifact);
+ final double[] minmaxQ = determineMinMaxQAtGauge(artifact);
return validateBounds(minmaxQ[0], minmaxQ[1], from, to, step);
}
-
/**
* Validates the inserted Q values based on the Q range for the current
* kilometer range.
*
- * @param artifact The owner artifact.
- * @param from The lower value of the Q range.
- * @param to The upper value of the Q range.
- * @param step The step width.
+ * @param artifact
+ * The owner artifact.
+ * @param from
+ * The lower value of the Q range.
+ * @param to
+ * The upper value of the Q range.
+ * @param step
+ * The step width.
*
* @return true, if everything was fine, otherwise an exception is thrown.
*/
- protected boolean validateFreeQ(
- D4EArtifact artifact,
- double from,
- double to,
- double step)
- throws IllegalArgumentException
- {
+ protected boolean validateFreeQ(final D4EArtifact artifact, final double from, final double to, final double step) throws IllegalArgumentException {
log.debug("WQSelect.validateFreeQ");
- double[] minmaxQ = determineMinMaxQ(artifact);
+ final double[] minmaxQ = determineMinMaxQ(artifact);
return validateBounds(minmaxQ[0], minmaxQ[1], from, to, step);
}
-
/**
* Validates the inserted W values based on the W range for the current
* kilometer range.
*
- * @param artifact The owner artifact.
- * @param from The lower value of the W range.
- * @param to The upper value of the W range.
- * @param step The step width.
+ * @param artifact
+ * The owner artifact.
+ * @param from
+ * The lower value of the W range.
+ * @param to
+ * The upper value of the W range.
+ * @param step
+ * The step width.
*
* @return true, if everything was fine, otherwise an exception is thrown.
*/
- protected boolean validateFreeW(
- D4EArtifact artifact,
- double from,
- double to,
- double step)
- throws IllegalArgumentException
- {
+ protected boolean validateFreeW(final D4EArtifact artifact, final double from, final double to, final double step) throws IllegalArgumentException {
log.debug("WQSelect.validateFreeW");
- double[] minmaxW = determineMinMaxWFree(artifact);
+ final double[] minmaxW = determineMinMaxWFree(artifact);
return validateBounds(minmaxW[0], minmaxW[1], from, to, step);
}
diff -r 3141f0e7314e -r 2323d005f9a5 artifacts/src/main/java/org/dive4elements/river/artifacts/states/WaterlevelGroundDifferences.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/WaterlevelGroundDifferences.java Thu Jul 19 17:54:10 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/WaterlevelGroundDifferences.java Fri Jul 20 10:39:02 2018 +0200
@@ -8,77 +8,56 @@
package org.dive4elements.river.artifacts.states;
-import org.w3c.dom.Element;
-
import org.apache.log4j.Logger;
-
-import org.dive4elements.river.artifacts.D4EArtifact;
-
+import org.dive4elements.artifactdatabase.data.StateData;
import org.dive4elements.artifacts.Artifact;
import org.dive4elements.artifacts.CallContext;
-
import org.dive4elements.artifacts.common.utils.XMLUtils;
-
-import org.dive4elements.artifactdatabase.data.StateData;
-import org.dive4elements.artifactdatabase.ProtocolUtils;
-
+import org.dive4elements.river.artifacts.D4EArtifact;
+import org.w3c.dom.Element;
/**
* @author Ingo Weinzierl
*/
public class WaterlevelGroundDifferences extends RangeState {
- public static final String LOWER_FIELD = "diff_from";
- public static final String UPPER_FIELD = "diff_to";
- public static final String DIFF_FIELD = "diff_diff";
+ public static final String LOWER_FIELD = "diff_from";
+ public static final String UPPER_FIELD = "diff_to";
+ public static final String DIFF_FIELD = "diff_diff";
public static final double DEFAULT_STEP = 0d;
-
- private static Logger log =
- Logger.getLogger(WaterlevelGroundDifferences.class);
-
+ private static Logger log = Logger.getLogger(WaterlevelGroundDifferences.class);
protected String getLowerField() {
return LOWER_FIELD;
}
-
protected String getUpperField() {
return UPPER_FIELD;
}
-
protected String getStepField() {
return DIFF_FIELD;
}
-
@Override
- protected double[] getMinMax(Artifact artifact) {
+ protected double[] getMinMax(final Artifact artifact) {
return new double[] { -Double.MAX_VALUE, Double.MAX_VALUE };
}
-
@Override
protected String getUIProvider() {
return "waterlevel_ground_panel";
}
-
protected double getDefaultStep() {
return DEFAULT_STEP;
}
-
@Override
- protected Element[] createItems(
- XMLUtils.ElementCreator cr,
- Artifact artifact,
- String name,
- CallContext context)
- {
- double[] minmax = getMinMax(artifact);
+ protected Element[] createItems(final XMLUtils.ElementCreator cr, final Artifact artifact, final String name, final CallContext context) {
+ final double[] minmax = getMinMax(artifact);
double minVal = Double.MIN_VALUE;
double maxVal = Double.MAX_VALUE;
@@ -86,90 +65,75 @@
if (minmax != null) {
minVal = minmax[0];
maxVal = minmax[1];
- }
- else {
+ } else {
log.warn("Could not read min/max distance values!");
}
if (name.equals(LOWER_FIELD)) {
- Element min = createItem(
- cr,
- new String[] {"min", new Double(minVal).toString()});
+ final Element min = createItem(cr, new String[] { "min", new Double(minVal).toString() });
return new Element[] { min };
- }
- else if (name.equals(UPPER_FIELD)) {
- Element max = createItem(
- cr,
- new String[] {"max", new Double(maxVal).toString()});
+ } else if (name.equals(UPPER_FIELD)) {
+ final Element max = createItem(cr, new String[] { "max", new Double(maxVal).toString() });
return new Element[] { max };
- }
- else {
- Element step = createItem(
- cr,
- new String[] {"step", String.valueOf(getDefaultStep())});
+ } else {
+ final Element step = createItem(cr, new String[] { "step", String.valueOf(getDefaultStep()) });
return new Element[] { step };
}
}
-
- protected Element createItem(XMLUtils.ElementCreator cr, Object obj) {
- Element item = ProtocolUtils.createArtNode(cr, "item", null, null);
- Element label = ProtocolUtils.createArtNode(cr, "label", null, null);
- Element value = ProtocolUtils.createArtNode(cr, "value", null, null);
-
- String[] arr = (String[]) obj;
-
- label.setTextContent(arr[0]);
- value.setTextContent(arr[1]);
-
- item.appendChild(label);
- item.appendChild(value);
-
- return item;
- }
+ // ist mit super identisch!
+ // protected Element createItem(XMLUtils.ElementCreator cr, Object obj) {
+ // Element item = ProtocolUtils.createArtNode(cr, "item", null, null);
+ // Element label = ProtocolUtils.createArtNode(cr, "label", null, null);
+ // Element value = ProtocolUtils.createArtNode(cr, "value", null, null);
+ //
+ // String[] arr = (String[]) obj;
+ //
+ // label.setTextContent(arr[0]);
+ // value.setTextContent(arr[1]);
+ //
+ // item.appendChild(label);
+ // item.appendChild(value);
+ //
+ // return item;
+ // }
@Override
- public boolean validate(Artifact artifact)
- throws IllegalArgumentException
- {
- D4EArtifact flys = (D4EArtifact) artifact;
+ public boolean validate(final Artifact artifact) throws IllegalArgumentException {
+ final D4EArtifact flys = (D4EArtifact) artifact;
- StateData dFrom = getData(flys, getLowerField());
- StateData dTo = getData(flys, getUpperField());
- StateData dStep = getData(flys, getStepField());
+ final StateData dFrom = getData(flys, getLowerField());
+ final StateData dTo = getData(flys, getUpperField());
+ final StateData dStep = getData(flys, getStepField());
- String fromStr = dFrom != null ? (String) dFrom.getValue() : null;
- String toStr = dTo != null ? (String) dTo.getValue() : null;
- String stepStr = dStep != null ? (String) dStep.getValue() : null;
+ final String fromStr = dFrom != null ? (String) dFrom.getValue() : null;
+ final String toStr = dTo != null ? (String) dTo.getValue() : null;
+ final String stepStr = dStep != null ? (String) dStep.getValue() : null;
if (fromStr == null || toStr == null || stepStr == null) {
throw new IllegalArgumentException("error_empty_state");
}
try {
- double from = Double.parseDouble(fromStr);
- double to = Double.parseDouble(toStr);
- double step = Double.parseDouble(stepStr);
+ final double from = Double.parseDouble(fromStr);
+ final double to = Double.parseDouble(toStr);
+ final double step = Double.parseDouble(stepStr);
- double[] minmax = getMinMax(flys);
+ final double[] minmax = getMinMax(flys);
return validateBounds(minmax[0], minmax[1], from, to, step);
}
- catch (NumberFormatException nfe) {
+ catch (final NumberFormatException nfe) {
throw new IllegalArgumentException("error_invalid_double_value");
}
}
@Override
- protected boolean validateBounds(
- double fromValid, double toValid,
- double from, double to
- ) throws IllegalArgumentException {
+ protected boolean validateBounds(final double fromValid, final double toValid, final double from, final double to) throws IllegalArgumentException {
if (to < 0d) {
- log.error(
- "Invalid 'to' " + to + " is lesser than zero.");
+ log.error("Invalid 'to' " + to + " is lesser than zero.");
throw new IllegalArgumentException("error_feed_from_out_of_range");
}
return super.validateBounds(fromValid, toValid, from, to);
diff -r 3141f0e7314e -r 2323d005f9a5 artifacts/src/main/java/org/dive4elements/river/artifacts/states/sq/OutlierMethod.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/sq/OutlierMethod.java Thu Jul 19 17:54:10 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/sq/OutlierMethod.java Fri Jul 20 10:39:02 2018 +0200
@@ -9,31 +9,22 @@
package org.dive4elements.river.artifacts.states.sq;
import org.apache.log4j.Logger;
-import org.w3c.dom.Element;
-
-import org.dive4elements.artifactdatabase.ProtocolUtils;
import org.dive4elements.artifacts.Artifact;
import org.dive4elements.artifacts.CallContext;
import org.dive4elements.artifacts.CallMeta;
import org.dive4elements.artifacts.common.utils.XMLUtils;
import org.dive4elements.river.artifacts.resources.Resources;
import org.dive4elements.river.artifacts.states.DefaultState;
-
+import org.w3c.dom.Element;
-public class OutlierMethod
-extends DefaultState
-{
- /** The log that is used in this class.*/
+public class OutlierMethod extends DefaultState {
+ /** The log that is used in this class. */
private static Logger log = Logger.getLogger(OutlierMethod.class);
- public static final String STD_DEV = "outlier.method.std-dev";
+ public static final String STD_DEV = "outlier.method.std-dev";
public static final String GRUBBS = "outlier.method.grubbs";
- public static final String[] METHODS = {
- STD_DEV,
- GRUBBS,
- };
-
+ public static final String[] METHODS = { STD_DEV, GRUBBS, };
@Override
protected String getUIProvider() {
@@ -41,44 +32,35 @@
}
@Override
- protected Element[] createItems(
- XMLUtils.ElementCreator cr,
- Artifact artifact,
- String name,
- CallContext context)
- {
- CallMeta meta = context.getMeta();
+ protected Element[] createItems(final XMLUtils.ElementCreator cr, final Artifact artifact, final String name, final CallContext context) {
+ final CallMeta meta = context.getMeta();
- Element[] methods = new Element[METHODS.length];
+ final Element[] methods = new Element[METHODS.length];
int i = 0;
- for (String method: METHODS) {
- methods[i++] = createItem(
- cr, new String[] {
- Resources.getMsg(meta, method, method),
- method
- });
+ for (final String method : METHODS) {
+ methods[i++] = createItem(cr, new String[] { Resources.getMsg(meta, method, method), method });
}
return methods;
}
-
- @Override
- protected Element createItem(XMLUtils.ElementCreator cr, Object obj) {
- Element item = ProtocolUtils.createArtNode(cr, "item", null, null);
- Element label = ProtocolUtils.createArtNode(cr, "label", null, null);
- Element value = ProtocolUtils.createArtNode(cr, "value", null, null);
-
- String[] arr = (String[]) obj;
-
- label.setTextContent(arr[0]);
- value.setTextContent(arr[1]);
-
- item.appendChild(label);
- item.appendChild(value);
-
- return item;
- }
+ // ist mit super identisch!
+ // @Override
+ // protected Element createItem(final XMLUtils.ElementCreator cr, final Object obj) {
+ // final Element item = ProtocolUtils.createArtNode(cr, "item", null, null);
+ // final Element label = ProtocolUtils.createArtNode(cr, "label", null, null);
+ // final Element value = ProtocolUtils.createArtNode(cr, "value", null, null);
+ //
+ // final String[] arr = (String[]) obj;
+ //
+ // label.setTextContent(arr[0]);
+ // value.setTextContent(arr[1]);
+ //
+ // item.appendChild(label);
+ // item.appendChild(value);
+ //
+ // return item;
+ // }
}
diff -r 3141f0e7314e -r 2323d005f9a5 gwt-client/src/main/java/org/dive4elements/river/client/client/ui/bundu/BunduWstWQPanel.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/bundu/BunduWstWQPanel.java Thu Jul 19 17:54:10 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/bundu/BunduWstWQPanel.java Fri Jul 20 10:39:02 2018 +0200
@@ -14,8 +14,11 @@
import org.dive4elements.river.client.client.ui.DoubleArrayPanel;
import org.dive4elements.river.client.client.ui.WQAdaptedInputPanel;
+import org.dive4elements.river.client.shared.model.Data;
+import org.dive4elements.river.client.shared.model.DataList;
import com.google.gwt.i18n.client.NumberFormat;
+import com.smartgwt.client.widgets.Canvas;
/**
* This UIProvider creates a widget to enter W or Q data for
@@ -26,6 +29,15 @@
public class BunduWstWQPanel extends WQAdaptedInputPanel {
private static final long serialVersionUID = -3218827566805476423L;
+ /** get bezugsjahr + range from server HERE **/
+ @Override
+ public Canvas create(final DataList data) {
+ final Data test = data.get(0);
+
+ return super.create(data);
+ }
+
+ // TODO: ValidateRange verstehen und dann ggf. Löschen/Ändern/was auch immer
@Override
protected List validateRange(final Map ranges) {
final List errors = new ArrayList();