Dear users, Please note that, from Monday, August 16, 2019, RSA keys shorter than 2048bit will no longer be accepted for security reasons. Please update your keys as needed before this date. If you need assistance with regard to this process, please contact sia@list.lu

Thank you for your understanding.

Commit 2c465577 authored by Nico Mack's avatar Nico Mack

Numerous fixes and improvements to handling of complex variable types

such as Vectors and Maps
parent b8827db6
......@@ -521,6 +521,17 @@ public class SqlExecutor extends Executor {
variable.setValueFromObject(values[index]);
} else {
LOGGER.info("Query returned no results!"); //$NON-NLS-1$
if (variable instanceof VectorVariable) {
VectorVariable<?> vector = (VectorVariable<?>) variable;
vector.clear();
vector.notifyInputChangeListeners();
} else if (variable instanceof MapVariable) {
MapVariable<?, ?> map = (MapVariable<?, ?>) variable;
map.clear();
map.notifyInputChangeListeners();
} else {
variable.setValue(null);
}
}
}
}
......
......@@ -168,7 +168,12 @@ public class MapVariable<K, V> extends Variable<Map<K, V>> implements Map<K, V>
@Override
public void setValueFromObject(Object object) {
this.value = this.valueFromObject(object);
if (this.value != null) {
this.value.clear();
} else {
this.value = new ConcurrentHashMap<K, V>();
}
this.value.putAll(this.valueFromObject(object));
}
// ---------------------------------------------------------------------------
......@@ -186,6 +191,21 @@ public class MapVariable<K, V> extends Variable<Map<K, V>> implements Map<K, V>
/** {@inheritDoc} */
// ---------------------------------------------------------------------------
@Override
public String toString() {
StringBuilder renderer = new StringBuilder(name);
if (value != null) {
renderer.append(value);
} else {
renderer.append("null"); //$NON-NLS-1$
}
return renderer.toString();
}
// ---------------------------------------------------------------------------
/** {@inheritDoc} */
// ---------------------------------------------------------------------------
@Override
public Map<K, V> valueFromString(String stringValue) {
// TODO Auto-generated method stub
......
......@@ -451,10 +451,13 @@ public class NumericalVariable extends Variable<Double> {
@Override
public NumericalVariable clone() {
NumericalVariable variable = new NumericalVariable(name, unit, value);
variable.displayName = displayName;
variable.format = format;
variable.minValue = minValue;
variable.maxValue = maxValue;
variable.scale = scale;
variable.roundingFactor = roundingFactor;
variable.epsilon = epsilon;
variable.listeners = new Vector<>(listeners);
return variable;
}
......
......@@ -361,7 +361,9 @@ public abstract class Variable<V> implements Cloneable {
public HashMap<InputChangeListener, Variable<?>> consolidateListeners(HashMap<InputChangeListener, Variable<?>> consolidated) {
for (InputChangeListener listener : listeners) {
consolidated.put(listener, this);
if (!consolidated.containsKey(listener)) {
consolidated.put(listener, this);
}
}
return consolidated;
}
......
......@@ -274,8 +274,9 @@ public class VectorVariable<B> extends Variable<List<B>> implements List<B> {
if (objectValue instanceof List) {
return (List<B>) objectValue;
}
return new ArrayList<>();
List<B> list = new ArrayList<>();
list.add((B) objectValue);
return list;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment