use of com.centurylink.mdw.plugin.designer.model.VariableBinding in project mdw-designer by CenturyLinkCloud.
the class MappingEditor method getMappedVariableBindings.
private List<VariableBinding> getMappedVariableBindings(Map<String, String> map) {
List<VariableBinding> bindings = new ArrayList<VariableBinding>();
for (String variableName : map.keySet()) {
VariableVO variableVO = getOwningProcess().getVariable(variableName);
if (variableVO != null)
bindings.add(new VariableBinding(variableVO, map.get(variableName)));
}
Collections.<VariableBinding>sort(bindings);
return bindings;
}
use of com.centurylink.mdw.plugin.designer.model.VariableBinding in project mdw-designer by CenturyLinkCloud.
the class MappingEditor method serializeMapping.
/**
* Converts a list of variable bindings to a string value to be stored with
* the activity attribute.
*/
public String serializeMapping(List<VariableBinding> bindings) {
if (getProject().checkRequiredVersion(6, 0, 4)) {
if (bindings.isEmpty())
return "";
JSONObject json = new JSONObject();
try {
for (VariableBinding variableBinding : bindings) {
json.put(variableBinding.getVariableVO().getVariableName(), variableBinding.getExpression());
}
} catch (JSONException ex) {
throw new StringParseException(ex.getMessage(), ex);
}
return json.toString();
} else {
StringBuffer sb = new StringBuffer();
boolean first = true;
for (VariableBinding variableBinding : bindings) {
if (first)
first = false;
else
sb.append(getRowDelimiter());
sb.append(variableBinding.getVariableVO().getVariableName());
sb.append(getColumnDelimiter());
sb.append(StringHelper.escapeWithBackslash(variableBinding.getExpression() == null ? "" : variableBinding.getExpression(), ";"));
}
return sb.toString();
}
}
use of com.centurylink.mdw.plugin.designer.model.VariableBinding in project mdw-designer by CenturyLinkCloud.
the class SubProcessMappingSection method populateVariableBindingsTable.
private void populateVariableBindingsTable() {
mappingEditor.disposeWidget();
mappingEditor.setOwningProcess(subProcess);
inputOutputVariables = getInputOutputVariables();
List<ColumnSpec> columnSpecs = createColumnSpecs();
mappingEditor.setColumnSpecs(columnSpecs);
mappingEditor.render(composite, false);
if (subProcess != null) {
Map<String, String> map = StringHelper.parseMap(activity.getAttribute("variables"));
// clear inapplicable bindings
List<String> inapplicableVars = new ArrayList<>();
for (String varName : map.keySet()) {
boolean found = false;
for (VariableVO inputVar : subProcess.getInputOutputVariables()) {
if (inputVar.getName().equals(varName)) {
found = true;
break;
}
}
if (!found)
inapplicableVars.add(varName);
}
for (String inapplicableVar : inapplicableVars) map.remove(inapplicableVar);
if (!inapplicableVars.isEmpty()) {
String newAttrVal = StringHelper.formatMap(map);
activity.setAttribute("variables", newAttrVal);
activity.fireAttributeValueChanged("variables", newAttrVal);
}
List<VariableBinding> variableBindings = getVariableBindings(map);
mappingEditor.setValue(variableBindings);
}
composite.layout(true);
}
use of com.centurylink.mdw.plugin.designer.model.VariableBinding in project mdw-designer by CenturyLinkCloud.
the class SubProcessMappingSection method getVariableBindings.
/**
* Returns a list of variable bindings corresponding to the input, output
* and input/output variables of the subprocess, with expressions populated
* based on the activity attribute map.
*/
private List<VariableBinding> getVariableBindings(Map<String, String> map) {
List<VariableBinding> variableBindings = new ArrayList<>();
for (VariableVO variableVO : inputOutputVariables.values()) {
VariableBinding variableBinding = new VariableBinding(variableVO, null);
if (map.containsKey(variableVO.getVariableName())) {
variableBinding.setExpression(map.get(variableVO.getVariableName()));
}
variableBindings.add(variableBinding);
}
return variableBindings;
}
Aggregations