# HG changeset patch
# User gernotbelger
# Date 1533820951 -7200
# Node ID f575ff573cbbcad83b01396922e38e5382115a90
# Parent 63c086139391c10078efcc8cf754dc77a909ccad
"Name der Peilung" columname minfo.
diff -r 63c086139391 -r f575ff573cbb artifacts/src/main/java/org/dive4elements/river/artifacts/states/DischargeState.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/DischargeState.java Thu Aug 09 12:03:30 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/DischargeState.java Thu Aug 09 15:22:31 2018 +0200
@@ -8,85 +8,72 @@
package org.dive4elements.river.artifacts.states;
-import java.util.List;
import java.util.Collections;
import java.util.Comparator;
+import java.util.List;
import org.apache.log4j.Logger;
-
import org.dive4elements.artifacts.Artifact;
import org.dive4elements.artifacts.CallContext;
-
import org.dive4elements.artifacts.common.model.KVP;
-
+import org.dive4elements.river.artifacts.D4EArtifact;
import org.dive4elements.river.model.DischargeZone;
import org.dive4elements.river.model.River;
-
-import org.dive4elements.river.artifacts.D4EArtifact;
import org.dive4elements.river.utils.RiverUtils;
-
public class DischargeState extends MultiIntArrayState {
- public static final String MAIN_CHANNEL = "main_channel";
+ public static final String MAIN_CHANNEL = "main_channel";
public static final String TOTAL_CHANNEL = "total_channel";
-
private static final Logger log = Logger.getLogger(DischargeState.class);
-
/** Let client display a matrix. */
@Override
public String getUIProvider() {
- return "parameter-matrix";
+ return "parameter-matrix-flowvelocity";
}
-
/**
* This method fetches all DischargeZones for a given river (extracted from
* artifact) and returns a KVP[] where the key is the ID of the
* DischargeZone and the value is a string that consists of lower discharge
* and upper discharge.
*
- * @param artifact Needs to be a D4EArtifact that provides river
- * information.
- * @param parameterName The name of a parameter.
+ * @param artifact
+ * Needs to be a D4EArtifact that provides river
+ * information.
+ * @param parameterName
+ * The name of a parameter.
*
* @return a KVP[].
*/
@Override
- protected KVP[] getOptions(
- Artifact artifact,
- String parameterName
- )
- throws IllegalArgumentException
- {
+ protected KVP[] getOptions(final Artifact artifact, final String parameterName) throws IllegalArgumentException {
if (!testParameterName(parameterName)) {
- throw new IllegalArgumentException(
- "Invalid parameter for state: '" + parameterName + "'");
+ throw new IllegalArgumentException("Invalid parameter for state: '" + parameterName + "'");
}
- List zones = getDischargeZones(artifact);
+ final List zones = getDischargeZones(artifact);
- KVP[] kvp = new KVP[zones.size()];
+ final KVP[] kvp = new KVP[zones.size()];
Collections.sort(zones, new Comparator() {
@Override
- public int compare(DischargeZone a, DischargeZone b) {
+ public int compare(final DischargeZone a, final DischargeZone b) {
return a.getValue().compareTo(b.getValue());
}
});
int i = 0;
- for (DischargeZone zone: zones) {
- String lower = zone.getLowerDischarge();
- String upper = zone.getUpperDischarge();
+ for (final DischargeZone zone : zones) {
+ final String lower = zone.getLowerDischarge();
+ final String upper = zone.getUpperDischarge();
if (lower.equals(upper)) {
kvp[i] = new KVP(zone.getId(), lower);
- }
- else {
+ } else {
kvp[i] = new KVP(zone.getId(), lower + " - " + upper);
}
i++;
@@ -95,81 +82,67 @@
return kvp;
}
-
@Override
- protected String getLabelFor(
- CallContext cc,
- String parameterName,
- int value
- ) throws IllegalArgumentException
- {
+ protected String getLabelFor(final CallContext cc, final String parameterName, final int value) throws IllegalArgumentException {
if (!testParameterName(parameterName)) {
- throw new IllegalArgumentException(
- "Invalid parameter for state: '" + parameterName + "'");
+ throw new IllegalArgumentException("Invalid parameter for state: '" + parameterName + "'");
}
- DischargeZone zone = DischargeZone.getDischargeZoneById(value);
+ final DischargeZone zone = DischargeZone.getDischargeZoneById(value);
if (zone == null) {
- throw new IllegalArgumentException(
- "Invalid id for DischargeZone: '" + value + "'");
+ throw new IllegalArgumentException("Invalid id for DischargeZone: '" + value + "'");
}
- String lo = zone.getLowerDischarge();
- String hi = zone.getUpperDischarge();
+ final String lo = zone.getLowerDischarge();
+ final String hi = zone.getUpperDischarge();
- return hi != null && !lo.equals(hi)
- ? lo + " - " + hi
- : lo;
+ return hi != null && !lo.equals(hi) ? lo + " - " + hi : lo;
}
-
/**
* This method might be used to test, if a parameter name is handled by this
* state.
*
- * @param parameterName The name of a parameter.
+ * @param parameterName
+ * The name of a parameter.
*
* @return true, if parameterName is one of MAIN_CHANNEL or
- * TOTAL_CHANNEL. Otherwise false.
+ * TOTAL_CHANNEL. Otherwise false.
*/
- protected boolean testParameterName(String parameterName) {
+ protected boolean testParameterName(final String parameterName) {
if (parameterName == null || parameterName.length() == 0) {
return false;
- }
- else if (parameterName.equals(MAIN_CHANNEL)) {
+ } else if (parameterName.equals(MAIN_CHANNEL)) {
return true;
- }
- else if (parameterName.equals(TOTAL_CHANNEL)) {
+ } else if (parameterName.equals(TOTAL_CHANNEL)) {
return true;
- }
- else {
+ } else {
return false;
}
}
-
/**
* Returns all discharge zones for a given river. The river information is
* extracted from artifact using RiverUtils.getRiver().
*
- * @param artifact Needs to be a D4EArtifact that stores a rivername.
+ * @param artifact
+ * Needs to be a D4EArtifact that stores a rivername.
*
* @return a list of DischargeZones.
*
- * @throws IllegalArgumentException if no river information is provided by
- * artifact.
+ * @throws IllegalArgumentException
+ * if no river information is provided by
+ * artifact.
*/
- protected List getDischargeZones(Artifact artifact)
- throws IllegalArgumentException
- {
- River river = RiverUtils.getRiver((D4EArtifact) artifact);
+ protected List getDischargeZones(final Artifact artifact) throws IllegalArgumentException {
+ final River river = RiverUtils.getRiver((D4EArtifact) artifact);
if (river == null) {
throw new IllegalArgumentException("No river found");
}
- List zones = DischargeZone.getDischargeZones(river);
+ final List zones = DischargeZone.getDischargeZones(river);
log.debug("Found " + zones.size() + " DischargeZones.");
diff -r 63c086139391 -r f575ff573cbb artifacts/src/main/java/org/dive4elements/river/artifacts/states/SoundingsSelect.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/SoundingsSelect.java Thu Aug 09 12:03:30 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/SoundingsSelect.java Thu Aug 09 15:22:31 2018 +0200
@@ -18,15 +18,14 @@
import org.dive4elements.artifacts.common.model.KVP;
import org.dive4elements.artifacts.common.utils.XMLUtils;
import org.dive4elements.artifacts.common.utils.XMLUtils.ElementCreator;
+import org.dive4elements.river.artifacts.D4EArtifact;
+import org.dive4elements.river.artifacts.resources.Resources;
import org.dive4elements.river.model.BedHeight;
import org.dive4elements.river.model.River;
-import org.dive4elements.river.artifacts.D4EArtifact;
-import org.dive4elements.river.artifacts.resources.Resources;
import org.dive4elements.river.utils.Formatter;
import org.dive4elements.river.utils.RiverUtils;
import org.w3c.dom.Element;
-
public class SoundingsSelect extends DefaultState {
public static final String SOUNDINGS = "soundings";
@@ -36,20 +35,13 @@
/** Private log. */
private static final Logger log = Logger.getLogger(SoundingsSelect.class);
-
@Override
public String getUIProvider() {
- return "parameter-matrix";
+ return "parameter-matrix-sounding";
}
@Override
- protected void appendItems(
- Artifact artifact,
- ElementCreator creator,
- String name,
- CallContext context,
- Element select
- ) {
+ protected void appendItems(final Artifact artifact, final ElementCreator creator, final String name, final CallContext context, final Element select) {
try {
creator.addAttr(select, "type", "multiattribute", true);
@@ -57,99 +49,73 @@
getOptions(artifact, name, context, creator, select);
}
- catch (IllegalArgumentException iae) {
+ catch (final IllegalArgumentException iae) {
log.warn("Illegal argument", iae);
}
}
- private static Element order(
- ElementCreator creator,
- String name,
- String order
- ) {
- Element element = creator.create(name);
+ private static Element order(final ElementCreator creator, final String name, final String order) {
+ final Element element = creator.create(name);
creator.addAttr(element, "order", order, false);
return element;
}
- private void appendMeta(ElementCreator creator, Element select) {
-
- Element meta = creator.create("meta");
+ private void appendMeta(final ElementCreator creator, final Element select) {
- meta.appendChild(order(creator, "year", "0"));
- meta.appendChild(order(creator, "value", "1"));
+ final Element meta = creator.create("meta");
+ meta.appendChild(order(creator, "year", "0"));
+ meta.appendChild(order(creator, "value", "1"));
meta.appendChild(order(creator, "analyzed_range", "2"));
- meta.appendChild(order(creator, "label", "3"));
- meta.appendChild(order(creator, "minfo_type", "4"));
+ meta.appendChild(order(creator, "label", "3"));
+ meta.appendChild(order(creator, "minfo_type", "4"));
select.appendChild(meta);
}
- protected KVP[] getOptions(
- Artifact artifact,
- String parameterName,
- CallContext context,
- ElementCreator creator,
- Element select
- )
- throws IllegalArgumentException
- {
+ protected KVP[] getOptions(final Artifact artifact, final String parameterName, final CallContext context, final ElementCreator creator,
+ final Element select) throws IllegalArgumentException {
log.debug("Get options for parameter: '" + parameterName + "'");
if (!testParameterName(parameterName)) {
- throw new IllegalArgumentException(
- "Invalid parameter for state: '" + parameterName + "'");
+ throw new IllegalArgumentException("Invalid parameter for state: '" + parameterName + "'");
}
- River river = RiverUtils.getRiver((D4EArtifact) artifact);
- double lo = ((D4EArtifact) artifact).getDataAsDouble("ld_from");
- double hi = ((D4EArtifact) artifact).getDataAsDouble("ld_to");
+ final River river = RiverUtils.getRiver((D4EArtifact) artifact);
+ final double lo = ((D4EArtifact) artifact).getDataAsDouble("ld_from");
+ final double hi = ((D4EArtifact) artifact).getDataAsDouble("ld_to");
- double kmLo = Math.min(lo, hi);
- double kmHi = Math.max(lo, hi);
+ final double kmLo = Math.min(lo, hi);
+ final double kmHi = Math.max(lo, hi);
appendSingles(river, kmLo, kmHi, creator, select, context);
- List> kvp =
- Collections.>emptyList();
+ final List> kvp = Collections.>emptyList();
return kvp.toArray(new KVP[kvp.size()]);
}
-
- protected void appendSingles(
- River river,
- double kmLo,
- double kmHi,
- ElementCreator creator,
- Element select,
- CallContext context
- ) {
- List singles =
- BedHeight.getBedHeights(river, kmLo, kmHi);
+ protected void appendSingles(final River river, final double kmLo, final double kmHi, final ElementCreator creator, final Element select,
+ final CallContext context) {
+ final List singles = BedHeight.getBedHeights(river, kmLo, kmHi);
if (singles != null) {
- int size = singles.size();
+ final int size = singles.size();
log.debug("Found " + size + " singles.");
- NumberFormat nf = Formatter.getCalculationKm(context.getMeta());
+ final NumberFormat nf = Formatter.getCalculationKm(context.getMeta());
for (int i = 0; i < size; i++) {
- BedHeight s = singles.get(i);
+ final BedHeight s = singles.get(i);
- String id = PREFIX_SINGLE + s.getId();
- String value = s.getDescription();
+ final String id = PREFIX_SINGLE + s.getId();
+ final String value = s.getDescription();
- Integer year = s.getYear();
- Element item = creator.create("item");
+ final Integer year = s.getYear();
+ final Element item = creator.create("item");
creator.addAttr(item, "label", value, true);
creator.addAttr(item, "value", id, true);
- creator.addAttr(item, "analyzed_range",
- nf.format(s.getRange().getA()) +
- " - " +
- nf.format(s.getRange().getB()));
- creator.addAttr(item, "year",
- year != null ? s.getYear().toString() : "");
+ creator.addAttr(item, "analyzed_range", nf.format(s.getRange().getA()) + " - " + nf.format(s.getRange().getB()));
+ creator.addAttr(item, "year", year != null ? s.getYear().toString() : "");
creator.addAttr(item, "minfo_type", s.getType().getName());
select.appendChild(item);
}
@@ -161,24 +127,17 @@
}
@Override
- protected Element createStaticData(
- D4EArtifact flys,
- ElementCreator creator,
- CallContext cc,
- String name,
- String value,
- String type
- ) {
- Element data = creator.create("data");
- creator.addAttr(data, "name", name, true);
- creator.addAttr(data, "type", type, true);
- creator.addAttr(data, "label",
- Resources.getMsg(cc.getMeta(), name, name), true);
+ protected Element createStaticData(final D4EArtifact flys, final ElementCreator creator, final CallContext cc, final String name, final String value,
+ final String type) {
+ final Element data = creator.create("data");
+ creator.addAttr(data, "name", name, true);
+ creator.addAttr(data, "type", type, true);
+ creator.addAttr(data, "label", Resources.getMsg(cc.getMeta(), name, name), true);
- String[] values = value.split(";");
+ final String[] values = value.split(";");
- for (String val: values) {
- Element item = creator.create("item");
+ for (final String val : values) {
+ final Element item = creator.create("item");
creator.addAttr(item, "value", val, true);
creator.addAttr(item, "label", getLabelFor(cc, name, val), true);
@@ -188,15 +147,9 @@
return data;
}
- protected String getLabelFor(
- CallContext cc,
- String parameterName,
- String value
- ) throws IllegalArgumentException
- {
+ protected String getLabelFor(final CallContext cc, final String parameterName, final String value) throws IllegalArgumentException {
if (!testParameterName(parameterName)) {
- throw new IllegalArgumentException(
- "Invalid parameter for state: '" + parameterName + "'");
+ throw new IllegalArgumentException("Invalid parameter for state: '" + parameterName + "'");
}
if (value.indexOf(PREFIX_SINGLE) >= 0) {
@@ -205,45 +158,40 @@
return value;
}
-
- protected String getLabelForSingle(CallContext cc, String value) {
- String id = value.replace(PREFIX_SINGLE, "");
+ protected String getLabelForSingle(final CallContext cc, final String value) {
+ final String id = value.replace(PREFIX_SINGLE, "");
try {
- BedHeight s = BedHeight.getBedHeightById(
- Integer.parseInt(id));
+ final BedHeight s = BedHeight.getBedHeightById(Integer.parseInt(id));
if (s != null) {
return s.getDescription();
- }
- else {
+ } else {
return "no value for '" + id + "'";
}
}
- catch (NumberFormatException nfe) {
+ catch (final NumberFormatException nfe) {
log.warn("Could not parse id from string '" + id + "'", nfe);
}
return "n.A.";
}
-
/**
* This method might be used to test, if a parameter name
* is handled by this state.
*
- * @param parameterName The name of a parameter.
+ * @param parameterName
+ * The name of a parameter.
*
* @return true, if parameterName is one of MAIN_CHANNEL or
- * TOTAL_CHANNEL. Otherwise false.
+ * TOTAL_CHANNEL. Otherwise false.
*/
- protected boolean testParameterName(String parameterName) {
+ protected boolean testParameterName(final String parameterName) {
if (parameterName == null || parameterName.length() == 0) {
return false;
- }
- else if (parameterName.equals(SOUNDINGS)) {
+ } else if (parameterName.equals(SOUNDINGS)) {
return true;
- }
- else {
+ } else {
return false;
}
}
diff -r 63c086139391 -r f575ff573cbb artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/CharDiameter.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/CharDiameter.java Thu Aug 09 12:03:30 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/CharDiameter.java Thu Aug 09 15:22:31 2018 +0200
@@ -12,7 +12,6 @@
import java.util.List;
import org.apache.log4j.Logger;
-
import org.dive4elements.artifacts.Artifact;
import org.dive4elements.artifacts.CallContext;
import org.dive4elements.artifacts.CallMeta;
@@ -24,43 +23,28 @@
private static final Logger log = Logger.getLogger(CharDiameter.class);
- public static final String UI_PROVIDER = "parameter-matrix";
+ public static final String UI_PROVIDER = "parameter-matrix-char-diameter";
- private static final String CHAR_DIAMETER_MIN = "calc.bed.dmin";
- private static final String CHAR_DIAMETER_MAX = "calc.bed.dmax";
- private static final String CHAR_DIAMETER_90 = "calc.bed.d90";
- private static final String CHAR_DIAMETER_84 = "calc.bed.d84";
- private static final String CHAR_DIAMETER_80 = "calc.bed.d80";
- private static final String CHAR_DIAMETER_75 = "calc.bed.d75";
- private static final String CHAR_DIAMETER_70 = "calc.bed.d70";
- private static final String CHAR_DIAMETER_60 = "calc.bed.d60";
- private static final String CHAR_DIAMETER_50 = "calc.bed.d50";
- private static final String CHAR_DIAMETER_40 = "calc.bed.d40";
- private static final String CHAR_DIAMETER_30 = "calc.bed.d30";
- private static final String CHAR_DIAMETER_25 = "calc.bed.d25";
- private static final String CHAR_DIAMETER_20 = "calc.bed.d20";
- private static final String CHAR_DIAMETER_16 = "calc.bed.d16";
- private static final String CHAR_DIAMETER_10 = "calc.bed.d10";
- private static final String CHAR_DIAMETER_DM = "calc.bed.dm";
+ private static final String CHAR_DIAMETER_MIN = "calc.bed.dmin";
+ private static final String CHAR_DIAMETER_MAX = "calc.bed.dmax";
+ private static final String CHAR_DIAMETER_90 = "calc.bed.d90";
+ private static final String CHAR_DIAMETER_84 = "calc.bed.d84";
+ private static final String CHAR_DIAMETER_80 = "calc.bed.d80";
+ private static final String CHAR_DIAMETER_75 = "calc.bed.d75";
+ private static final String CHAR_DIAMETER_70 = "calc.bed.d70";
+ private static final String CHAR_DIAMETER_60 = "calc.bed.d60";
+ private static final String CHAR_DIAMETER_50 = "calc.bed.d50";
+ private static final String CHAR_DIAMETER_40 = "calc.bed.d40";
+ private static final String CHAR_DIAMETER_30 = "calc.bed.d30";
+ private static final String CHAR_DIAMETER_25 = "calc.bed.d25";
+ private static final String CHAR_DIAMETER_20 = "calc.bed.d20";
+ private static final String CHAR_DIAMETER_16 = "calc.bed.d16";
+ private static final String CHAR_DIAMETER_10 = "calc.bed.d10";
+ private static final String CHAR_DIAMETER_DM = "calc.bed.dm";
- public static final String[] CHAR_DIAMETER = {
- CHAR_DIAMETER_DM,
- CHAR_DIAMETER_10,
- CHAR_DIAMETER_16,
- CHAR_DIAMETER_20,
- CHAR_DIAMETER_25,
- CHAR_DIAMETER_30,
- CHAR_DIAMETER_40,
- CHAR_DIAMETER_50,
- CHAR_DIAMETER_60,
- CHAR_DIAMETER_70,
- CHAR_DIAMETER_75,
- CHAR_DIAMETER_80,
- CHAR_DIAMETER_84,
- CHAR_DIAMETER_90,
- CHAR_DIAMETER_MAX,
- CHAR_DIAMETER_MIN
- };
+ public static final String[] CHAR_DIAMETER = { CHAR_DIAMETER_DM, CHAR_DIAMETER_10, CHAR_DIAMETER_16, CHAR_DIAMETER_20, CHAR_DIAMETER_25, CHAR_DIAMETER_30,
+ CHAR_DIAMETER_40, CHAR_DIAMETER_50, CHAR_DIAMETER_60, CHAR_DIAMETER_70, CHAR_DIAMETER_75, CHAR_DIAMETER_80, CHAR_DIAMETER_84, CHAR_DIAMETER_90,
+ CHAR_DIAMETER_MAX, CHAR_DIAMETER_MIN };
@Override
public String getUIProvider() {
@@ -68,29 +52,20 @@
}
@Override
- protected KVP[] getOptions(
- Artifact artifact,
- String parameterName,
- CallContext context
- )
- throws IllegalArgumentException
- {
- CallMeta meta = context.getMeta();
+ protected KVP[] getOptions(final Artifact artifact, final String parameterName, final CallContext context) throws IllegalArgumentException {
+ final CallMeta meta = context.getMeta();
- List> rows = new ArrayList>();
- String key = parameterName;
- for (int i = 0; i < CHAR_DIAMETER.length; ++i) {
- String calc = CHAR_DIAMETER[i];
- rows.add(new KVP (calc,
- Resources.getMsg(meta, calc, calc)));
+ final List> rows = new ArrayList<>();
+ final String key = parameterName;
+ for (final String calc : CHAR_DIAMETER) {
+ rows.add(new KVP(calc, Resources.getMsg(meta, calc, calc)));
}
return rows.toArray(new KVP[rows.size()]);
}
@Override
- protected String getLabelFor(CallContext cc, String parameterName,
- String value) throws IllegalArgumentException {
+ protected String getLabelFor(final CallContext cc, final String parameterName, final String value) throws IllegalArgumentException {
return Resources.getMsg(cc.getMeta(), value, value);
}
diff -r 63c086139391 -r f575ff573cbb gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.java Thu Aug 09 12:03:30 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.java Thu Aug 09 15:22:31 2018 +0200
@@ -1608,4 +1608,7 @@
String uinfo_inundation_duration_set_vegetation_zone();
String bundu_wst_export();
+
+ String name_of_sounding();
+
}
\ No newline at end of file
diff -r 63c086139391 -r f575ff573cbb gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.properties
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.properties Thu Aug 09 12:03:30 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.properties Thu Aug 09 15:22:31 2018 +0200
@@ -169,6 +169,7 @@
minfo_type = Type
analyzed_range = Analyzed Range
+name_of_sounding = Name of Sounding
wqTitle = Input for W/Q Data
wqadaptedTitle = Input for W/Q Data
diff -r 63c086139391 -r f575ff573cbb gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_de.properties
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_de.properties Thu Aug 09 12:03:30 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_de.properties Thu Aug 09 15:22:31 2018 +0200
@@ -169,6 +169,7 @@
minfo_type = Aufnahmeart
analyzed_range = ausgewertete Strecke
+name_of_sounding = Name der Peilung
wqTitle = Eingabe f\u00fcr W/Q Daten
wqadaptedTitle = Eingabe f\u00fcr W/Q Daten
diff -r 63c086139391 -r f575ff573cbb gwt-client/src/main/java/org/dive4elements/river/client/client/ui/ParameterMatrix.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/ParameterMatrix.java Thu Aug 09 12:03:30 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/ParameterMatrix.java Thu Aug 09 15:22:31 2018 +0200
@@ -8,19 +8,11 @@
package org.dive4elements.river.client.client.ui;
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.event.dom.client.ClickEvent;
-import com.google.gwt.event.dom.client.ClickHandler;
-import com.google.gwt.user.client.ui.CheckBox;
-import com.google.gwt.user.client.ui.Grid;
-import com.google.gwt.user.client.ui.Widget;
-
-import com.smartgwt.client.types.ListGridFieldType;
-import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.Label;
-import com.smartgwt.client.widgets.grid.ListGrid;
-import com.smartgwt.client.widgets.grid.ListGridField;
-import com.smartgwt.client.widgets.grid.ListGridRecord;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import org.dive4elements.river.client.client.FLYSConstants;
import org.dive4elements.river.client.shared.model.DataItem;
@@ -29,12 +21,18 @@
import org.dive4elements.river.client.shared.model.MultiDataItem;
import org.dive4elements.river.client.shared.model.StringOptionsData;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.user.client.ui.CheckBox;
+import com.google.gwt.user.client.ui.Grid;
+import com.google.gwt.user.client.ui.Widget;
+import com.smartgwt.client.types.ListGridFieldType;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.Label;
+import com.smartgwt.client.widgets.grid.ListGrid;
+import com.smartgwt.client.widgets.grid.ListGridField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
/**
* Some parameters take the form of on/off options that can also be seen
@@ -52,242 +50,235 @@
private static final long serialVersionUID = -3493426383086860118L;
- protected String name;
+ protected String name;
protected Map values;
private Column() {
this.values = new HashMap();
}
- public Column(String name) {
+ public Column(final String name) {
this();
this.name = name;
}
- public void addValue(String label, String value) {
- values.put(label, value);
+ public void addValue(final String label, final String value) {
+ this.values.put(label, value);
}
- public String getValue(String label) {
- return values.get(label);
+ public String getValue(final String label) {
+ return this.values.get(label);
}
} // end of class Column
- /** The message class that provides i18n strings.*/
+ /** The message class that provides i18n strings. */
protected FLYSConstants MESSAGE = GWT.create(FLYSConstants.class);
public static final int CELL_HEIGHT = 25;
- private Map columns;
- private List columnNames;
- private List valueNames;
- private Map> attributes;
+ private final Map columns;
+ private final List columnNames;
+ private final List valueNames;
+ private final Map> attributes;
/** Maps column names to list of rows' first fields. */
- private Map> selected;
+ private final Map> selected;
+ private final String itemname;
- public ParameterMatrix() {
+ public ParameterMatrix(final String itemnameColTitle) {
super();
- this.columns = new HashMap();
+ this.itemname = itemnameColTitle;
+ this.columns = new HashMap();
this.columnNames = new ArrayList();
- this.valueNames = new ArrayList();
- this.selected = new HashMap>();
- this.attributes = new HashMap>();
+ this.valueNames = new ArrayList();
+ this.selected = new HashMap>();
+ this.attributes = new HashMap>();
}
+ public void addColumn(final IntegerOptionsData group) {
+ final String groupTitle = group.getLabel();
- public void addColumn(IntegerOptionsData group) {
- String groupTitle = group.getLabel();
-
- Column col = new Column(groupTitle);
- DataItem[] items = group.getItems();
+ final Column col = new Column(groupTitle);
+ final DataItem[] items = group.getItems();
if (items == null) {
GWT.log("No items found in StringOptionsData '" + groupTitle + "'");
return;
}
- for (DataItem item: items) {
- String title = item.getLabel();
+ for (final DataItem item : items) {
+ final String title = item.getLabel();
- if (valueNames.indexOf(title) < 0) {
- valueNames.add(title);
+ if (this.valueNames.indexOf(title) < 0) {
+ this.valueNames.add(title);
}
col.addValue(item.getLabel(), item.getStringValue());
}
- columnNames.add(groupTitle);
- columns.put(groupTitle, col);
- }
-
-
- public List getColumnNames() {
- return columnNames;
+ this.columnNames.add(groupTitle);
+ this.columns.put(groupTitle, col);
}
+ public List getColumnNames() {
+ return this.columnNames;
+ }
- public void addColumn(StringOptionsData options) {
- String groupTitle = options.getLabel();
+ public void addColumn(final StringOptionsData options) {
+ final String groupTitle = options.getLabel();
- Column col = new Column(groupTitle);
- DataItem[] items = options.getItems();
+ final Column col = new Column(groupTitle);
+ final DataItem[] items = options.getItems();
if (items == null) {
- GWT.log("No items found in StringOptionsData '"
- + groupTitle + "'");
+ GWT.log("No items found in StringOptionsData '" + groupTitle + "'");
return;
}
- for (DataItem item: items) {
- String title = item.getLabel();
+ for (final DataItem item : items) {
+ final String title = item.getLabel();
- if (valueNames.indexOf(title) < 0) {
- valueNames.add(title);
+ if (this.valueNames.indexOf(title) < 0) {
+ this.valueNames.add(title);
}
col.addValue(item.getLabel(), item.getStringValue());
}
- columnNames.add(groupTitle);
- columns.put(groupTitle, col);
+ this.columnNames.add(groupTitle);
+ this.columns.put(groupTitle, col);
}
- public void addColumn(MultiAttributeData options) {
+ public void addColumn(final MultiAttributeData options) {
GWT.log("Add Columns for MultiAttribute data");
- String groupTitle = options.getLabel();
+ final String groupTitle = options.getLabel();
- Column col = new Column(groupTitle);
- DataItem[] items = options.getItems();
+ final Column col = new Column(groupTitle);
+ final DataItem[] items = options.getItems();
if (items == null) {
- GWT.log("No items found in StringOptionsData '"
- + groupTitle + "'");
+ GWT.log("No items found in StringOptionsData '" + groupTitle + "'");
return;
}
- MultiDataItem mItem = (MultiDataItem)items[0];
- for (Map.Entry entry: mItem.getValue().entrySet()) {
- if (entry.getKey().equals("art:value") ||
- entry.getKey().equals("art:label")) {
+ final MultiDataItem mItem = (MultiDataItem) items[0];
+ for (final Map.Entry entry : mItem.getValue().entrySet()) {
+ if (entry.getKey().equals("art:value") || entry.getKey().equals("art:label")) {
continue;
}
- attributes.put(entry.getKey(), new ArrayList());
+ this.attributes.put(entry.getKey(), new ArrayList());
}
- for (DataItem item: items) {
+ for (final DataItem item : items) {
GWT.log("multidataitem: " + item.getLabel());
- String title = item.getLabel();
+ final String title = item.getLabel();
- if (valueNames.indexOf(title) < 0) {
- valueNames.add(title);
+ if (this.valueNames.indexOf(title) < 0) {
+ this.valueNames.add(title);
}
- MultiDataItem mi = (MultiDataItem)item;
- Map vs = mi.getValue();
- for (Map.Entrye: vs.entrySet()) {
- if (e.getKey().equals("art:value") ||
- e.getKey().equals("art:label")) {
+ final MultiDataItem mi = (MultiDataItem) item;
+ final Map vs = mi.getValue();
+ for (final Map.Entry e : vs.entrySet()) {
+ if (e.getKey().equals("art:value") || e.getKey().equals("art:label")) {
continue;
}
- List data = attributes.get(e.getKey());
+ final List data = this.attributes.get(e.getKey());
data.add(e.getValue());
}
col.addValue(item.getLabel(), mi.getValue().get("art:value"));
}
- columnNames.add(groupTitle);
- columns.put(groupTitle, col);
+ this.columnNames.add(groupTitle);
+ this.columns.put(groupTitle, col);
}
public Widget createParameterGrid() {
- listGrid = new ListGrid();
- listGrid.setShowAllRecords(true);
- listGrid.setWrapCells(true);
- listGrid.setShowHeaderContextMenu(false);
- listGrid.setCanReorderFields(false);
-// listGrid.setCanSort(false);
- //listGrid.setAutoFitData(Autofit.VERTICAL);
- listGrid.setFixedRecordHeights(false);
+ this.listGrid = new ListGrid();
+ this.listGrid.setShowAllRecords(true);
+ this.listGrid.setWrapCells(true);
+ this.listGrid.setShowHeaderContextMenu(false);
+ this.listGrid.setCanReorderFields(false);
+ // listGrid.setCanSort(false);
+ // listGrid.setAutoFitData(Autofit.VERTICAL);
+ this.listGrid.setFixedRecordHeights(false);
// TODO: Then also need "autofit" (when wrapping)
- ListGridField itemNameField = new ListGridField("itemname", " ");
- ArrayList fields = new ArrayList();
+ final ListGridField itemNameField = new ListGridField("itemname", this.itemname);
+ final ArrayList fields = new ArrayList();
fields.add(itemNameField);
- for (Map.Entry> entry: attributes.entrySet()) {
- ListGridField attrField = new ListGridField(
- entry.getKey(), MESSAGE.getString(entry.getKey()));
+ for (final Map.Entry> entry : this.attributes.entrySet()) {
+ final ListGridField attrField = new ListGridField(entry.getKey(), this.MESSAGE.getString(entry.getKey()));
fields.add(attrField);
}
- for (int i = 0, n = columnNames.size(); i < n; i++) {
- ListGridField field = new ListGridField(
- columnNames.get(i), MESSAGE.getString(columnNames.get(i)));
+ for (int i = 0, n = this.columnNames.size(); i < n; i++) {
+ final ListGridField field = new ListGridField(this.columnNames.get(i), this.MESSAGE.getString(this.columnNames.get(i)));
field.setType(ListGridFieldType.BOOLEAN);
field.setCanEdit(true);
fields.add(field);
- selected.put(columnNames.get(i), new ArrayList());
+ this.selected.put(this.columnNames.get(i), new ArrayList());
}
- ListGridField[] fieldsArray = fields.toArray(
- new ListGridField[fields.size()]);
- listGrid.setFields(fieldsArray);
+ final ListGridField[] fieldsArray = fields.toArray(new ListGridField[fields.size()]);
+ this.listGrid.setFields(fieldsArray);
- int nVals = valueNames.size();
+ final int nVals = this.valueNames.size();
- ArrayList records = new ArrayList();
+ final ArrayList records = new ArrayList();
for (int j = 0; j < nVals; j++) {
- String valueName = valueNames.get(j);
- ListGridRecord record = new ListGridRecord();
+ final String valueName = this.valueNames.get(j);
+ final ListGridRecord record = new ListGridRecord();
record.setAttribute("itemname", valueName);
- for (int i = 0, n = columnNames.size(); i < n; i++) {
- String columnName = columnNames.get(i);
- Column col = columns.get(columnName);
- String value = col.getValue(valueName);
+ for (int i = 0, n = this.columnNames.size(); i < n; i++) {
+ final String columnName = this.columnNames.get(i);
+ final Column col = this.columns.get(columnName);
+ final String value = col.getValue(valueName);
record.setAttribute(columnName, false);
- record.setAttribute(columnName+"-value", value);
+ record.setAttribute(columnName + "-value", value);
}
- for (Map.Entry> entry: attributes.entrySet()) {
+ for (final Map.Entry> entry : this.attributes.entrySet()) {
record.setAttribute(entry.getKey(), entry.getValue().get(j));
}
records.add(record);
}
- listGrid.setData(records.toArray(new ListGridRecord[records.size()]));
+ this.listGrid.setData(records.toArray(new ListGridRecord[records.size()]));
- return listGrid;
+ return this.listGrid;
}
-
/**
* Returns a widget with matrix of checkboxes and labels.
- * @param asListGrid if true, use a ListGrid (for inclusion in SmartGWT
- * containers, avoiding scrollbar-issues.
+ *
+ * @param asListGrid
+ * if true, use a ListGrid (for inclusion in SmartGWT
+ * containers, avoiding scrollbar-issues.
*/
- public Widget create(boolean asListGrid) {
+ public Widget create(final boolean asListGrid) {
if (asListGrid) {
return createParameterGrid();
}
- Grid grid = new Grid(valueNames.size() + 1, columnNames.size() + 1);
-
- for (int i = 0, n = columnNames.size(); i < n; i++) {
- String columnName = columnNames.get(i);
- Column col = columns.get(columnName);
+ final Grid grid = new Grid(this.valueNames.size() + 1, this.columnNames.size() + 1);
- selected.put(columnName, new ArrayList());
+ for (int i = 0, n = this.columnNames.size(); i < n; i++) {
+ final String columnName = this.columnNames.get(i);
+ final Column col = this.columns.get(columnName);
- grid.setWidget(0, i+1, createLabel(MESSAGE.getString(columnName)));
+ this.selected.put(columnName, new ArrayList());
- for (int j = 0, o = valueNames.size(); j < o; j++) {
- String valueName = valueNames.get(j);
- String value = col.getValue(valueName);
+ grid.setWidget(0, i + 1, createLabel(this.MESSAGE.getString(columnName)));
+
+ for (int j = 0, o = this.valueNames.size(); j < o; j++) {
+ final String valueName = this.valueNames.get(j);
+ final String value = col.getValue(valueName);
if (i == 0) {
- grid.setWidget(j+1, 0, createLabel(valueName));
+ grid.setWidget(j + 1, 0, createLabel(valueName));
}
if (value != null && value.length() > 0) {
- grid.setWidget(j+1, i+1, createCheckBox(columnName, value));
+ grid.setWidget(j + 1, i + 1, createCheckBox(columnName, value));
}
}
}
@@ -295,58 +286,52 @@
return grid;
}
-
/** Creates label with given text. */
- protected Label createLabel(String text) {
- Label label = new Label(text);
+ protected Label createLabel(final String text) {
+ final Label label = new Label(text);
label.setHeight(CELL_HEIGHT);
return label;
}
-
/** Create Checkbox for column/value. */
protected Canvas createCheckBox(final String colName, final String value) {
- CheckBox box = new CheckBox();
+ final CheckBox box = new CheckBox();
box.addClickHandler(new ClickHandler() {
@Override
- public void onClick(ClickEvent event) {
- Map> selection = getSelection();
+ public void onClick(final ClickEvent event) {
+ final Map> selection = getSelection();
- List values = selection.get(colName);
+ final List values = selection.get(colName);
if (values.indexOf(value) >= 0) {
values.remove(value);
- }
- else {
+ } else {
values.add(value);
}
}
});
- Canvas c = new Canvas();
+ final Canvas c = new Canvas();
c.addChild(box);
return c;
}
-
public Map> getSelection() {
- if (listGrid == null) {
- return selected;
+ if (this.listGrid == null) {
+ return this.selected;
}
- ListGridRecord[] records = listGrid.getRecords();
- Map> result = new HashMap>();
- for (ListGridRecord record : records) {
- for (int i = 0, n = columnNames.size(); i < n; i++) {
- String columnName = columnNames.get(i);
+ final ListGridRecord[] records = this.listGrid.getRecords();
+ final Map> result = new HashMap>();
+ for (final ListGridRecord record : records) {
+ for (int i = 0, n = this.columnNames.size(); i < n; i++) {
+ final String columnName = this.columnNames.get(i);
if (Boolean.valueOf(record.getAttribute(columnName)) == true) {
if (result.containsKey(columnName)) {
- result.get(columnName).add(
- record.getAttribute(columnName + "-value"));
- }
- else {
- List items = new ArrayList();
+ result.get(columnName).add(record.getAttribute(columnName + "-value"));
+ } else {
+ final List items = new ArrayList();
items.add(record.getAttribute(columnName + "-value"));
result.put(columnName, items);
}
diff -r 63c086139391 -r f575ff573cbb gwt-client/src/main/java/org/dive4elements/river/client/client/ui/ParameterMatrixPanel.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/ParameterMatrixPanel.java Thu Aug 09 12:03:30 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/ParameterMatrixPanel.java Thu Aug 09 15:22:31 2018 +0200
@@ -8,13 +8,10 @@
package org.dive4elements.river.client.client.ui;
-import com.google.gwt.core.client.GWT;
-
-import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.Label;
-import com.smartgwt.client.widgets.layout.HLayout;
-import com.smartgwt.client.widgets.layout.VLayout;
-import com.smartgwt.client.widgets.layout.LayoutSpacer;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
import org.dive4elements.river.client.client.FLYSConstants;
import org.dive4elements.river.client.shared.model.Data;
@@ -26,10 +23,12 @@
import org.dive4elements.river.client.shared.model.MultiAttributeData;
import org.dive4elements.river.client.shared.model.StringOptionsData;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import com.google.gwt.core.client.GWT;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.Label;
+import com.smartgwt.client.widgets.layout.HLayout;
+import com.smartgwt.client.widgets.layout.LayoutSpacer;
+import com.smartgwt.client.widgets.layout.VLayout;
/**
* @author Ingo Weinzierl
@@ -42,33 +41,34 @@
protected FLYSConstants MESSAGES = GWT.create(FLYSConstants.class);
private ParameterMatrix matrix;
+ private final String itemnameColTitle;
+
+ public ParameterMatrixPanel(final String itemNameColTitle) {
+ this.itemnameColTitle = itemNameColTitle;
+ }
@Override
protected Data[] getData() {
- Map> selection = matrix.getSelection();
- Set>> entries = selection.entrySet();
+ final Map> selection = this.matrix.getSelection();
+ final Set>> entries = selection.entrySet();
- Data[] list = new Data[matrix.getColumnNames().size()];
+ final Data[] list = new Data[this.matrix.getColumnNames().size()];
int i = 0;
- for (Map.Entry> entry: entries) {
- String value = buildValueString(entry.getValue());
+ for (final Map.Entry> entry : entries) {
+ final String value = buildValueString(entry.getValue());
- DataItem item = new DefaultDataItem(
- entry.getKey(),
- null,
- value);
+ final DataItem item = new DefaultDataItem(entry.getKey(), null, value);
- list[i++] = new DefaultData(
- entry.getKey(), null, null, new DataItem[] { item });
+ list[i++] = new DefaultData(entry.getKey(), null, null, new DataItem[] { item });
}
// To delete old values already given, construct empty ones
// for all not-specified options.
- for (String colName : matrix.getColumnNames()) {
+ for (final String colName : this.matrix.getColumnNames()) {
boolean found = false;
- for (Data data : list) {
+ for (final Data data : list) {
if (data != null && data.getLabel().equals(colName)) {
found = true;
break;
@@ -76,21 +76,19 @@
}
if (!found) {
// Add an empty data for this.
- list[i++] = new DefaultData(
- colName, null, null, new DataItem[] { });
+ list[i++] = new DefaultData(colName, null, null, new DataItem[] {});
}
}
return list;
}
-
- protected String buildValueString(List values) {
- StringBuilder sb = new StringBuilder();
+ protected String buildValueString(final List values) {
+ final StringBuilder sb = new StringBuilder();
boolean first = true;
- for (String value: values) {
+ for (final String value : values) {
if (!first) {
sb.append(";");
}
@@ -103,40 +101,37 @@
return sb.toString();
}
-
/** Canvas to show in non-edit mode. */
@Override
- public Canvas createOld(DataList dataList) {
- HLayout layout = new HLayout();
- VLayout vLayout = new VLayout();
+ public Canvas createOld(final DataList dataList) {
+ final HLayout layout = new HLayout();
+ final VLayout vLayout = new VLayout();
layout.setWidth(300);
vLayout.setWidth(280);
for (int i = 0, n = dataList.size(); i < n; i++) {
- HLayout row = new HLayout();
- VLayout cols = new VLayout();
+ final HLayout row = new HLayout();
+ final VLayout cols = new VLayout();
row.setWidth(300);
cols.setWidth(100);
- Data data = dataList.get(i);
- DataItem[] items = data.getItems();
+ final Data data = dataList.get(i);
+ final DataItem[] items = data.getItems();
- Label parameter = new Label(data.getDescription());
+ final Label parameter = new Label(data.getDescription());
parameter.setWidth(200);
- for (int j = 0, m = items.length; j < m; j++) {
- DataItem item = items[j];
- Label value = new Label(item.getLabel());
+ for (final DataItem item : items) {
+ final Label value = new Label(item.getLabel());
- value.setValign(
- com.smartgwt.client.types.VerticalAlignment.TOP);
+ value.setValign(com.smartgwt.client.types.VerticalAlignment.TOP);
value.setWidth(130);
value.setHeight(15);
cols.addMember(value);
- LayoutSpacer spacer = new LayoutSpacer();
+ final LayoutSpacer spacer = new LayoutSpacer();
spacer.setHeight(5);
cols.addMember(spacer);
}
@@ -147,7 +142,7 @@
vLayout.addMember(row);
}
- Canvas back = getBackButton(dataList.getState());
+ final Canvas back = getBackButton(dataList.getState());
layout.addMember(vLayout);
layout.addMember(back);
@@ -155,73 +150,66 @@
return layout;
}
-
/** Create the main canvas in the "editing" mode. */
@Override
- public Canvas create(DataList dataList) {
- VLayout v = new VLayout();
+ public Canvas create(final DataList dataList) {
+ final VLayout v = new VLayout();
v.addMember(createTitle(dataList));
- matrix = new ParameterMatrix();
+ this.matrix = new ParameterMatrix(this.itemnameColTitle);
- for (Data data: dataList.getAll()) {
+ for (final Data data : dataList.getAll()) {
if (data instanceof IntegerOptionsData) {
- matrix.addColumn((IntegerOptionsData) data);
- }
- else if (data instanceof StringOptionsData) {
- matrix.addColumn((StringOptionsData) data);
- }
- else if (data instanceof MultiAttributeData) {
- matrix.addColumn((MultiAttributeData)data);
+ this.matrix.addColumn((IntegerOptionsData) data);
+ } else if (data instanceof StringOptionsData) {
+ this.matrix.addColumn((StringOptionsData) data);
+ } else if (data instanceof MultiAttributeData) {
+ this.matrix.addColumn((MultiAttributeData) data);
}
}
// If too many items are shown, show it in the helper Panel.
// TODO its not about the datalist, but about the "rows" in the data.
if (dataList.getAll().size() > 5) {
- v.addMember(matrix.create(false));
- }
- else {
- helperContainer.addMember(matrix.create(true));
+ v.addMember(this.matrix.create(false));
+ } else {
+ this.helperContainer.addMember(this.matrix.create(true));
}
v.addMember(getNextButton());
return v;
}
-
/** Reaturns a label with description of first Data. */
- protected Canvas createTitle(DataList dataList) {
- Data data = dataList.get(0);
- Label label = new Label(data.getDescription());
+ protected Canvas createTitle(final DataList dataList) {
+ final Data data = dataList.get(0);
+ final Label label = new Label(data.getDescription());
label.setHeight(35);
return label;
}
-
/** Selection shall not be empty. */
@Override
public List validate() {
- GWT.log ("validation. validation. validation. ");
- List errors = new ArrayList();
+ GWT.log("validation. validation. validation. ");
+ final List errors = new ArrayList();
// Early stop on one (only) error.
boolean ok = false;
- for (Map.Entry> entry:
- matrix.getSelection().entrySet()
- ) {
- /* single entries are allowed!!
- if (entry.getValue() == null || entry.getValue().size() == 0) {
- errors.add(MESSAGES.error_values_needed());
- return errors;
- }
- */
+ for (final Map.Entry> entry : this.matrix.getSelection().entrySet()) {
+ /*
+ * single entries are allowed!!
+ * if (entry.getValue() == null || entry.getValue().size() == 0) {
+ * errors.add(MESSAGES.error_values_needed());
+ * return errors;
+ * }
+ */
if (entry.getValue() != null && entry.getValue().size() > 0) {
ok = true;
}
}
if (!ok) {
- errors.add(MESSAGES.error_values_needed());
+ errors.add(this.MESSAGES.error_values_needed());
}
return errors;
}
diff -r 63c086139391 -r f575ff573cbb gwt-client/src/main/java/org/dive4elements/river/client/client/ui/UIProviderFactory.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/UIProviderFactory.java Thu Aug 09 12:03:30 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/UIProviderFactory.java Thu Aug 09 15:22:31 2018 +0200
@@ -162,9 +162,18 @@
return new DoubleInputPanel();
} else if (uiProvider.equals("percent_input")) {
return new DoubleInputPanel("percent");
- } else if (uiProvider.equals("parameter-matrix")) {
- return new ParameterMatrixPanel();
- } else if (uiProvider.equals("minfo.bed.year_epoch")) {// legacy
+ } else if (uiProvider.equals("parameter-matrix-sounding")) {
+ return new ParameterMatrixPanel(getMSG().getString("name_of_sounding"));
+ } else if (uiProvider.equals("parameter-matrix-flowvelocity")) {
+ return new ParameterMatrixPanel(" "); // TODO minfo.fließgeschwindigkeiten auflusszustand und gerinne title erste spalte ausdenken (nur
+ // wenn jemand
+ // danach fragt, ansonsten ist es old stuff)
+ } else if (uiProvider.equals("parameter-matrix-char-diameter")) {
+ return new ParameterMatrixPanel(" "); // TODO minfo.sohlbeschaffenheit ? title erste spalte ausdenken (nur wenn jemand
+ // danach fragt, ansonsten ist es old stuff)
+ }
+
+ else if (uiProvider.equals("minfo.bed.year_epoch")) {// legacy
return new RadioPanel("ye_select");
} else if (uiProvider.equals("bundu_calc_choice_radio_panel")) {
return new BunduWstCalcSelectRadioPanel("calc_choice");
diff -r 63c086139391 -r f575ff573cbb gwt-client/src/main/java/org/dive4elements/river/client/server/ArtifactDescriptionFactory.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/server/ArtifactDescriptionFactory.java Thu Aug 09 12:03:30 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/server/ArtifactDescriptionFactory.java Thu Aug 09 15:22:31 2018 +0200
@@ -13,17 +13,10 @@
import javax.xml.xpath.XPathConstants;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
import org.apache.log4j.Logger;
-
import org.dive4elements.artifacts.common.ArtifactNamespaceContext;
import org.dive4elements.artifacts.common.utils.ClientProtocolUtils;
import org.dive4elements.artifacts.common.utils.XMLUtils;
-
import org.dive4elements.river.client.shared.model.ArtifactDescription;
import org.dive4elements.river.client.shared.model.DataItem;
import org.dive4elements.river.client.shared.model.DataList;
@@ -34,13 +27,16 @@
import org.dive4elements.river.client.shared.model.DoubleArrayData;
import org.dive4elements.river.client.shared.model.DoubleRangeData;
import org.dive4elements.river.client.shared.model.IntegerArrayData;
+import org.dive4elements.river.client.shared.model.IntegerOptionsData;
import org.dive4elements.river.client.shared.model.IntegerRangeData;
-import org.dive4elements.river.client.shared.model.IntegerOptionsData;
import org.dive4elements.river.client.shared.model.LongRangeData;
import org.dive4elements.river.client.shared.model.OutputMode;
import org.dive4elements.river.client.shared.model.Recommendation;
import org.dive4elements.river.client.shared.model.WQDataItem;
-
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
/**
* This factory class helps creating an {@link ArtifactDescription} based on the
@@ -52,9 +48,7 @@
*/
public class ArtifactDescriptionFactory {
- private static final Logger log =
- Logger.getLogger(ArtifactDescriptionFactory.class);
-
+ private static final Logger log = Logger.getLogger(ArtifactDescriptionFactory.class);
public static final String XPATH_STATE_NAME = "@art:name";
@@ -70,85 +64,71 @@
public static final String XPATH_STATIC_ITEM_NODE = "art:item";
- public static final String XPATH_RECOMMENDED_ARTIFACTS =
- "/art:result/art:recommended-artifacts//*[@factory]";
+ public static final String XPATH_RECOMMENDED_ARTIFACTS = "/art:result/art:recommended-artifacts//*[@factory]";
/**
* This method creates the {@link ArtifactDescription} of the DESCRIBE
* document doc.
*
- * @param doc A DESCRIBE document.
+ * @param doc
+ * A DESCRIBE document.
*
* @return the {@link ArtifactDescription}.
*/
- public static ArtifactDescription createArtifactDescription(Document doc) {
+ public static ArtifactDescription createArtifactDescription(final Document doc) {
log.debug("ArtifactDescriptionFactory.createArtifactDescription");
- Node currentState = ClientProtocolUtils.getCurrentState(doc);
- Node staticNode = ClientProtocolUtils.getStaticUI(doc);
- Node dynamicNode = ClientProtocolUtils.getDynamicUI(doc);
- Node reachable = ClientProtocolUtils.getReachableStates(doc);
- NodeList outputs = ClientProtocolUtils.getOutputModes(doc);
+ final Node currentState = ClientProtocolUtils.getCurrentState(doc);
+ final Node staticNode = ClientProtocolUtils.getStaticUI(doc);
+ final Node dynamicNode = ClientProtocolUtils.getDynamicUI(doc);
+ final Node reachable = ClientProtocolUtils.getReachableStates(doc);
+ final NodeList outputs = ClientProtocolUtils.getOutputModes(doc);
- String state = (String) XMLUtils.xpath(
- currentState,
- XPATH_STATE_NAME,
- XPathConstants.STRING,
- ArtifactNamespaceContext.INSTANCE);
+ final String state = (String) XMLUtils.xpath(currentState, XPATH_STATE_NAME, XPathConstants.STRING, ArtifactNamespaceContext.INSTANCE);
log.debug("Current state name: " + state);
- DataList currentData = extractCurrentData(dynamicNode, state);
- DataList[] old = extractOldData(staticNode);
- String[] states = extractReachableStates(reachable);
- OutputMode[] outs = extractOutputModes(outputs);
- Recommendation[] rec = extractRecommendedArtifacts(doc);
+ final DataList currentData = extractCurrentData(dynamicNode, state);
+ final DataList[] old = extractOldData(staticNode);
+ final String[] states = extractReachableStates(reachable);
+ final OutputMode[] outs = extractOutputModes(outputs);
+ final Recommendation[] rec = extractRecommendedArtifacts(doc);
- return new DefaultArtifactDescription(
- old,
- currentData,
- state,
- states,
- outs,
- rec);
+ return new DefaultArtifactDescription(old, currentData, state, states, outs, rec);
}
-
/**
* This method extracts the data that the user is able to enter in the
* current state of the artifact.
*
- * @param dynamicNode The dynamic node of the DESCRIBE document.
- * @param state The name of the current state.
+ * @param dynamicNode
+ * The dynamic node of the DESCRIBE document.
+ * @param state
+ * The name of the current state.
*
* @return A {@link Data} object that represents the data which might be
- * entered by the user in the current state or null, if no data might be
- * entered.
+ * entered by the user in the current state or null, if no data might be
+ * entered.
*/
- protected static DataList extractCurrentData(
- Node dynamicNode,
- String state
- ) {
+ protected static DataList extractCurrentData(final Node dynamicNode, final String state) {
log.debug("ArtifactDescriptionFactory.extractCurrentData");
- NodeList data = ClientProtocolUtils.getSelectNode(dynamicNode);
- String help = extractHelpText(dynamicNode);
- String uiProvider = extractUIProvider(dynamicNode);
+ final NodeList data = ClientProtocolUtils.getSelectNode(dynamicNode);
+ final String help = extractHelpText(dynamicNode);
+ final String uiProvider = extractUIProvider(dynamicNode);
if (data == null || data.getLength() == 0) {
return null;
}
- int dataNum = data.getLength();
- DataList list = new DataList(state, dataNum, uiProvider, null, help);
+ final int dataNum = data.getLength();
+ final DataList list = new DataList(state, dataNum, uiProvider, null, help);
for (int i = 0; i < dataNum; i++) {
- Element d = (Element) data.item(i);
- String label = ClientProtocolUtils.getLabel(d);
- String name = XMLUtils.xpathString(
- d, "@art:name", ArtifactNamespaceContext.INSTANCE);
- String type = XMLUtils.xpathString(
- d, "@art:type", ArtifactNamespaceContext.INSTANCE);
+ final Element d = (Element) data.item(i);
+ final String label = ClientProtocolUtils.getLabel(d);
+ final String name = XMLUtils.xpathString(d, "@art:name", ArtifactNamespaceContext.INSTANCE);
+ final String type = XMLUtils.xpathString(d, "@art:type", ArtifactNamespaceContext.INSTANCE);
log.debug("Create new IntegerRangeData object for: " + name);
log.debug("New Data is from type: " + type);
@@ -156,98 +136,77 @@
// TODO replace with DataFactory.
if (type == null || type.length() == 0) {
- NodeList choices = ClientProtocolUtils.getItemNodes(d);
- DataItem[] dataItems = extractCurrentDataItems(choices);
- DataItem def = extractDefaultDataItem(d);
+ final NodeList choices = ClientProtocolUtils.getItemNodes(d);
+ final DataItem[] dataItems = extractCurrentDataItems(choices);
+ final DataItem def = extractDefaultDataItem(d);
list.add(new DefaultData(name, label, null, dataItems, def));
- }
- else if (type.equals("intrange")) {
- String min = ClientProtocolUtils.getMinNode(d);
- String max = ClientProtocolUtils.getMaxNode(d);
+ } else if (type.equals("intrange")) {
+ final String min = ClientProtocolUtils.getMinNode(d);
+ final String max = ClientProtocolUtils.getMaxNode(d);
- String defMin = ClientProtocolUtils.getDefMin(d);
- String defMax = ClientProtocolUtils.getDefMax(d);
+ final String defMin = ClientProtocolUtils.getDefMin(d);
+ final String defMax = ClientProtocolUtils.getDefMax(d);
try {
- int lower = Integer.parseInt(min);
- int upper = Integer.parseInt(max);
-
- if (defMin != null && defMax != null) {
- list.add(new IntegerRangeData(
- name, label,
- lower, upper,
- Integer.parseInt(defMin),
- Integer.parseInt(defMax)));
- }
- else {
- list.add(
- new IntegerRangeData(name, label, lower, upper));
- }
- }
- catch (NumberFormatException nfe) {
- log.warn("NumberFormatException: ", nfe);
- }
- }
- else if (type.equals("longrange")) {
- String min = ClientProtocolUtils.getMinNode(d);
- String max = ClientProtocolUtils.getMaxNode(d);
-
- String defMin = ClientProtocolUtils.getDefMin(d);
- String defMax = ClientProtocolUtils.getDefMax(d);
-
- try {
- long lower = Long.valueOf(min);
- long upper = Long.valueOf(max);
+ final int lower = Integer.parseInt(min);
+ final int upper = Integer.parseInt(max);
if (defMin != null && defMax != null) {
- list.add(new LongRangeData(
- name, label,
- lower, upper,
- Long.valueOf(defMin),
- Long.valueOf(defMax)));
+ list.add(new IntegerRangeData(name, label, lower, upper, Integer.parseInt(defMin), Integer.parseInt(defMax)));
+ } else {
+ list.add(new IntegerRangeData(name, label, lower, upper));
}
}
- catch (NumberFormatException nfe) {
+ catch (final NumberFormatException nfe) {
log.warn("NumberFormatException: ", nfe);
}
- }
- else if (type.equals("intarray")) {
+ } else if (type.equals("longrange")) {
+ final String min = ClientProtocolUtils.getMinNode(d);
+ final String max = ClientProtocolUtils.getMaxNode(d);
+
+ final String defMin = ClientProtocolUtils.getDefMin(d);
+ final String defMax = ClientProtocolUtils.getDefMax(d);
+
+ try {
+ final long lower = Long.valueOf(min);
+ final long upper = Long.valueOf(max);
+
+ if (defMin != null && defMax != null) {
+ list.add(new LongRangeData(name, label, lower, upper, Long.valueOf(defMin), Long.valueOf(defMax)));
+ }
+ }
+ catch (final NumberFormatException nfe) {
+ log.warn("NumberFormatException: ", nfe);
+ }
+ } else if (type.equals("intarray")) {
list.add(new IntegerArrayData(name, label, null));
- }
- else if (type.equals("intoptions")
- && uiProvider.equals("parameter-matrix")
+ } else if (type.equals("intoptions") && uiProvider.startsWith("parameter-matrix")// uiProvider.equals("parameter-matrix") // what the...? used to be
+ // "equals", but column-name for "itemname" refactoring created new
+ // UIProviderFactory-Names starting with "parameter-matrix"
) {
list.add(DataFactory.createIntegerOptionsData(d, name, label));
- }
- else if (type.equals("options")) {
+ } else if (type.equals("options")) {
list.add(DataFactory.createStringOptionsData(d, name, label));
- }
- else if (type.equals("intoptions")) {
- NodeList choices = ClientProtocolUtils.getItemNodes(d);
- DataItem[] opts = extractCurrentDataItems(choices);
+ } else if (type.equals("intoptions")) {
+ final NodeList choices = ClientProtocolUtils.getItemNodes(d);
+ final DataItem[] opts = extractCurrentDataItems(choices);
list.add(new IntegerOptionsData(name, label, opts));
- }
- else if (type.equals("doublearray")) {
+ } else if (type.equals("doublearray")) {
list.add(new DoubleArrayData(name, label, null));
- }
- else if (type.equals("multiattribute")) {
+ } else if (type.equals("multiattribute")) {
list.add(DataFactory.createMultiAttributeData(d, name, label));
- }
- else {
+ } else {
log.warn("Unrecognized Dynamic data type.");
- NodeList choices = ClientProtocolUtils.getItemNodes(d);
- DataItem[] dataItems = extractCurrentDataItems(choices);
- DataItem def = extractDefaultDataItem(d);
+ final NodeList choices = ClientProtocolUtils.getItemNodes(d);
+ final DataItem[] dataItems = extractCurrentDataItems(choices);
+ final DataItem def = extractDefaultDataItem(d);
- String min = ClientProtocolUtils.getMinNode(d);
- String max = ClientProtocolUtils.getMaxNode(d);
+ final String min = ClientProtocolUtils.getMinNode(d);
+ final String max = ClientProtocolUtils.getMaxNode(d);
if (min != null && max != null) {
- list.add(new DoubleRangeData(
- name, label,
- Double.valueOf(min), Double.valueOf(max),
- Double.valueOf(min), Double.valueOf(max)));
+ list.add(new DoubleRangeData(name, label, Double.valueOf(min), Double.valueOf(max), Double.valueOf(min), Double.valueOf(max)));
}
list.add(new DefaultData(name, label, null, dataItems, def));
@@ -258,22 +217,20 @@
return list;
}
-
/**
* This method extracts the default value of a Data object.
*
- * @param data The data object node.
+ * @param data
+ * The data object node.
*
* @return the default DataItem.
*/
- protected static DataItem extractDefaultDataItem(Node data) {
+ protected static DataItem extractDefaultDataItem(final Node data) {
log.debug("ArtifactDescriptionFactory.extractDefaultDataItem");
- String value = XMLUtils.xpathString(
- data, "@art:defaultValue", ArtifactNamespaceContext.INSTANCE);
+ final String value = XMLUtils.xpathString(data, "@art:defaultValue", ArtifactNamespaceContext.INSTANCE);
- String label = XMLUtils.xpathString(
- data, "@art:defaultLabel", ArtifactNamespaceContext.INSTANCE);
+ final String label = XMLUtils.xpathString(data, "@art:defaultLabel", ArtifactNamespaceContext.INSTANCE);
if (value != null && label != null) {
return new DefaultDataItem(label, null, value);
@@ -282,15 +239,15 @@
return null;
}
-
/**
* This method extract the {@link DataItem}s of the DESCRIBE document.
*
- * @param items The items in the DESCRIBE document.
+ * @param items
+ * The items in the DESCRIBE document.
*
* @return the {@link DataItem}s.
*/
- protected static DataItem[] extractCurrentDataItems(NodeList items) {
+ protected static DataItem[] extractCurrentDataItems(final NodeList items) {
log.debug("ArtifactDescriptionFactory.extractCurrentDataItems");
if (items == null || items.getLength() == 0) {
@@ -298,22 +255,21 @@
return null;
}
- int count = items.getLength();
+ final int count = items.getLength();
- List dataItems = new ArrayList(count);
+ final List dataItems = new ArrayList(count);
for (int i = 0; i < count; i++) {
- Node item = items.item(i);
- String label = ClientProtocolUtils.getLabel(item);
- String value = ClientProtocolUtils.getValue(item);
+ final Node item = items.item(i);
+ final String label = ClientProtocolUtils.getLabel(item);
+ final String value = ClientProtocolUtils.getValue(item);
- double[] mmQ = extractMinMaxQValues(item);
- double[] mmW = extractMinMaxWValues(item);
+ final double[] mmQ = extractMinMaxQValues(item);
+ final double[] mmW = extractMinMaxWValues(item);
if (mmQ != null || mmW != null) {
dataItems.add(new WQDataItem(label, null, value, mmQ, mmW));
- }
- else {
+ } else {
dataItems.add(new DefaultDataItem(label, null, value));
}
}
@@ -321,8 +277,7 @@
return dataItems.toArray(new DataItem[count]);
}
-
- protected static double[] extractMinMaxQValues(Node item) {
+ protected static double[] extractMinMaxQValues(final Node item) {
log.debug("ArtifactDescriptionFactory.extractMinMaxQValues");
if (item == null) {
@@ -330,11 +285,7 @@
return null;
}
- Node node = (Node) XMLUtils.xpath(
- item,
- "art:range[@art:type='Q']",
- XPathConstants.NODE,
- ArtifactNamespaceContext.INSTANCE);
+ final Node node = (Node) XMLUtils.xpath(item, "art:range[@art:type='Q']", XPathConstants.NODE, ArtifactNamespaceContext.INSTANCE);
if (node == null) {
log.debug("No min/max Q values found.");
@@ -344,8 +295,7 @@
return extractMinMaxValues(node);
}
-
- protected static double[] extractMinMaxWValues(Node item) {
+ protected static double[] extractMinMaxWValues(final Node item) {
log.debug("ArtifactDescriptionFactory.extractMinMaxWValues");
if (item == null) {
@@ -353,11 +303,7 @@
return null;
}
- Node node = (Node) XMLUtils.xpath(
- item,
- "art:range[@art:type='W']",
- XPathConstants.NODE,
- ArtifactNamespaceContext.INSTANCE);
+ final Node node = (Node) XMLUtils.xpath(item, "art:range[@art:type='W']", XPathConstants.NODE, ArtifactNamespaceContext.INSTANCE);
if (node == null) {
log.debug("No min/max W values found.");
@@ -367,15 +313,12 @@
return extractMinMaxValues(node);
}
-
- protected static double[] extractMinMaxValues(Node node) {
+ protected static double[] extractMinMaxValues(final Node node) {
log.debug("ArtifactDescriptionFactory.extractMinMaxValues");
- String minStr = XMLUtils.xpathString(
- node, "art:min/text()", ArtifactNamespaceContext.INSTANCE);
+ final String minStr = XMLUtils.xpathString(node, "art:min/text()", ArtifactNamespaceContext.INSTANCE);
- String maxStr = XMLUtils.xpathString(
- node, "art:max/text()", ArtifactNamespaceContext.INSTANCE);
+ final String maxStr = XMLUtils.xpathString(node, "art:max/text()", ArtifactNamespaceContext.INSTANCE);
if (maxStr == null || minStr == null) {
log.debug("No min/max values found.");
@@ -383,71 +326,59 @@
}
try {
- double min = Double.valueOf(minStr);
- double max = Double.valueOf(maxStr);
+ final double min = Double.valueOf(minStr);
+ final double max = Double.valueOf(maxStr);
return new double[] { min, max };
}
- catch (NumberFormatException nfe) {
+ catch (final NumberFormatException nfe) {
log.debug("Error while parsing min/max values.");
}
return null;
}
-
/**
* This method extracts the data objects from the data node of the static ui
* part of the DESCRIBE document.
*
- * @param staticNode The static ui node of the DESCRIBE.
+ * @param staticNode
+ * The static ui node of the DESCRIBE.
*
* @return the DataList objects.
*/
- protected static DataList[] extractOldData(Node staticNode) {
+ protected static DataList[] extractOldData(final Node staticNode) {
log.debug("ArtifactDescriptionFactory.extractOldData()");
- NodeList stateNodes = (NodeList) XMLUtils.xpath(
- staticNode,
- XPATH_STATIC_STATE_NODE,
- XPathConstants.NODESET,
- ArtifactNamespaceContext.INSTANCE);
+ final NodeList stateNodes = (NodeList) XMLUtils.xpath(staticNode, XPATH_STATIC_STATE_NODE, XPathConstants.NODESET, ArtifactNamespaceContext.INSTANCE);
if (stateNodes == null || stateNodes.getLength() == 0) {
log.debug("No old items found.");
return null;
}
- int count = stateNodes.getLength();
- DataList[] data = new DataList[count];
+ final int count = stateNodes.getLength();
+ final DataList[] data = new DataList[count];
for (int i = 0; i < count; i++) {
- Node tmp = stateNodes.item(i);
+ final Node tmp = stateNodes.item(i);
- String name = XMLUtils.xpathString(
- tmp, "@art:name", ArtifactNamespaceContext.INSTANCE);
- String uiprovider = XMLUtils.xpathString(
- tmp, "@art:uiprovider", ArtifactNamespaceContext.INSTANCE);
- String label = XMLUtils.xpathString(
- tmp, "@art:label", ArtifactNamespaceContext.INSTANCE);
- String help = XMLUtils.xpathString(
- tmp, "@art:helpText", ArtifactNamespaceContext.INSTANCE);
+ final String name = XMLUtils.xpathString(tmp, "@art:name", ArtifactNamespaceContext.INSTANCE);
+ final String uiprovider = XMLUtils.xpathString(tmp, "@art:uiprovider", ArtifactNamespaceContext.INSTANCE);
+ final String label = XMLUtils.xpathString(tmp, "@art:label", ArtifactNamespaceContext.INSTANCE);
+ final String help = XMLUtils.xpathString(tmp, "@art:helpText", ArtifactNamespaceContext.INSTANCE);
- NodeList dataNodes = (NodeList) XMLUtils.xpath(
- tmp,
- XPATH_STATIC_DATA_NODE,
- XPathConstants.NODESET,
- ArtifactNamespaceContext.INSTANCE);
+ final NodeList dataNodes = (NodeList) XMLUtils.xpath(tmp, XPATH_STATIC_DATA_NODE, XPathConstants.NODESET, ArtifactNamespaceContext.INSTANCE);
if (dataNodes == null || dataNodes.getLength() == 0) {
continue;
}
- int size = dataNodes.getLength();
- DataList list = new DataList(name, size, uiprovider, label, help);
+ final int size = dataNodes.getLength();
+ final DataList list = new DataList(name, size, uiprovider, label, help);
for (int j = 0; j < size; j++) {
- Node dataNode = dataNodes.item(j);
+ final Node dataNode = dataNodes.item(j);
list.add(DataFactory.createDataFromElement((Element) dataNode));
@@ -458,68 +389,55 @@
return data;
}
-
/**
* This method extracts the UIProvider specified by the data node.
*
- * @param data The data node.
+ * @param data
+ * The data node.
*
* @return the UIProvider that is specified in the data node.
*/
- protected static String extractUIProvider(Node ui) {
- return (String) XMLUtils.xpath(
- ui,
- XPATH_UIPROVIDER,
- XPathConstants.STRING,
- ArtifactNamespaceContext.INSTANCE);
+ protected static String extractUIProvider(final Node ui) {
+ return (String) XMLUtils.xpath(ui, XPATH_UIPROVIDER, XPathConstants.STRING, ArtifactNamespaceContext.INSTANCE);
}
-
/**
* This method extracts the help text specified by the data node.
*
- * @param ui The data node.
+ * @param ui
+ * The data node.
*
* @return the help text.
*/
- protected static String extractHelpText(Node ui) {
- return (String) XMLUtils.xpath(
- ui,
- XPATH_HELP_TEXT,
- XPathConstants.STRING,
- ArtifactNamespaceContext.INSTANCE);
+ protected static String extractHelpText(final Node ui) {
+ return (String) XMLUtils.xpath(ui, XPATH_HELP_TEXT, XPathConstants.STRING, ArtifactNamespaceContext.INSTANCE);
}
-
/**
* This method extracts the reachable states of the current artifact.
*
- * @param reachable The reachable states node.
+ * @param reachable
+ * The reachable states node.
*
* @return an array with identifiers of reachable states.
*/
- protected static String[] extractReachableStates(Node reachable) {
+ protected static String[] extractReachableStates(final Node reachable) {
log.debug("ArtifactDescriptionFactory.extractReachableStates()");
- NodeList list = (NodeList) XMLUtils.xpath(
- reachable,
- XPATH_REACHABLE_STATE,
- XPathConstants.NODESET,
- ArtifactNamespaceContext.INSTANCE);
+ final NodeList list = (NodeList) XMLUtils.xpath(reachable, XPATH_REACHABLE_STATE, XPathConstants.NODESET, ArtifactNamespaceContext.INSTANCE);
if (list == null || list.getLength() == 0) {
return null;
}
- int count = list.getLength();
+ final int count = list.getLength();
- String[] states = new String[count];
+ final String[] states = new String[count];
for (int i = 0; i < count; i++) {
- Node state = list.item(i);
+ final Node state = list.item(i);
- String name = XMLUtils.xpathString(
- state, "@art:name", ArtifactNamespaceContext.INSTANCE);
+ final String name = XMLUtils.xpathString(state, "@art:name", ArtifactNamespaceContext.INSTANCE);
states[i] = name;
}
@@ -527,72 +445,61 @@
return states;
}
-
/**
* This method extract available output modes of the the current artifact.
*
- * @param outputs A list of nodes that contain information about output
- * modes.
+ * @param outputs
+ * A list of nodes that contain information about output
+ * modes.
*
* @return an array of Output modes.
*/
- protected static OutputMode[] extractOutputModes(NodeList outputs) {
+ protected static OutputMode[] extractOutputModes(final NodeList outputs) {
log.debug("ArtifactDescriptionFactory.extractOutputModes");
if (outputs == null || outputs.getLength() == 0) {
return null;
}
- int size = outputs.getLength();
+ final int size = outputs.getLength();
- List outs = new ArrayList(size);
+ final List outs = new ArrayList(size);
for (int i = 0; i < size; i++) {
- Node out = outputs.item(i);
+ final Node out = outputs.item(i);
- String name = XMLUtils.xpathString(
- out, "@art:name", ArtifactNamespaceContext.INSTANCE);
- String desc = XMLUtils.xpathString(
- out, "@art:description", ArtifactNamespaceContext.INSTANCE);
- String mimeType = XMLUtils.xpathString(
- out, "@art:mime-type", ArtifactNamespaceContext.INSTANCE);
+ final String name = XMLUtils.xpathString(out, "@art:name", ArtifactNamespaceContext.INSTANCE);
+ final String desc = XMLUtils.xpathString(out, "@art:description", ArtifactNamespaceContext.INSTANCE);
+ final String mimeType = XMLUtils.xpathString(out, "@art:mime-type", ArtifactNamespaceContext.INSTANCE);
if (name != null) {
outs.add(new DefaultOutputMode(name, desc, mimeType));
- }
- else {
+ } else {
log.debug("Found an invalid output mode.");
}
}
- return (OutputMode[]) outs.toArray(new OutputMode[size]);
+ return outs.toArray(new OutputMode[size]);
}
-
- protected static Recommendation[] extractRecommendedArtifacts(Document doc){
+ protected static Recommendation[] extractRecommendedArtifacts(final Document doc) {
log.debug("ArtifactDescriptionFactory.extractRecommendedArtifacts.");
- NodeList list = (NodeList) XMLUtils.xpath(
- doc,
- XPATH_RECOMMENDED_ARTIFACTS,
- XPathConstants.NODESET,
- ArtifactNamespaceContext.INSTANCE);
+ final NodeList list = (NodeList) XMLUtils.xpath(doc, XPATH_RECOMMENDED_ARTIFACTS, XPathConstants.NODESET, ArtifactNamespaceContext.INSTANCE);
- int num = list != null ? list.getLength() : 0;
+ final int num = list != null ? list.getLength() : 0;
- Recommendation[] rec = new Recommendation[num];
+ final Recommendation[] rec = new Recommendation[num];
for (int i = 0; i < num; i++) {
- Element e = (Element) list.item(i);
- String factory = e.getAttribute("factory");
- String index = e.getAttribute("ids");
- String targetOut = e.getAttribute("target_out");
+ final Element e = (Element) list.item(i);
+ final String factory = e.getAttribute("factory");
+ final String index = e.getAttribute("ids");
+ final String targetOut = e.getAttribute("target_out");
if (factory != null && factory.length() > 0) {
- log.debug("Adding Recommendation. Factory: " + factory +
- " IDs: " + index + " target out " + targetOut);
- rec[i] = new Recommendation(
- factory, index, null, null, targetOut);
+ log.debug("Adding Recommendation. Factory: " + factory + " IDs: " + index + " target out " + targetOut);
+ rec[i] = new Recommendation(factory, index, null, null, targetOut);
}
}