Search in sources :

Example 11 with VariableVO

use of com.centurylink.mdw.model.value.variable.VariableVO in project mdw-designer by CenturyLinkCloud.

the class VariableInstancesSection method getTheUninitializedVariables.

private List<VariableInstanceInfo> getTheUninitializedVariables() {
    HashMap<String, String> variableNamesMap = new HashMap<String, String>();
    List<String> variableInstances = new ArrayList<String>();
    for (VariableVO variable : process.getProcessVO().getVariables()) {
        variableNamesMap.put(variable.getVariableName(), variable.getVariableType());
    }
    for (VariableInstanceInfo varInst : process.getProcessInstance().getVariables()) {
        variableInstances.add(varInst.getName());
    }
    Set<String> variableNames = variableNamesMap.keySet();
    variableNames.removeAll(variableInstances);
    List<VariableInstanceInfo> uninitializedVariableInstances = new ArrayList<VariableInstanceInfo>();
    for (String varName : variableNames) {
        VariableInstanceInfo newVarInst = new VariableInstanceInfo();
        newVarInst.setName(varName);
        newVarInst.setType(variableNamesMap.get(varName));
        uninitializedVariableInstances.add(newVarInst);
    }
    return uninitializedVariableInstances;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) VariableVO(com.centurylink.mdw.model.value.variable.VariableVO) VariableInstanceInfo(com.centurylink.mdw.model.value.variable.VariableInstanceInfo)

Example 12 with VariableVO

use of com.centurylink.mdw.model.value.variable.VariableVO in project mdw-designer by CenturyLinkCloud.

the class StartProcessMappingSection method getInputVariables.

private Map<Integer, VariableVO> getInputVariables() {
    Map<Integer, VariableVO> inputVariables = new TreeMap<Integer, VariableVO>();
    List<VariableVO> inputVariableVOs = activity.getProcess().getInputVariables();
    for (int i = 0; i < inputVariableVOs.size(); i++) {
        VariableVO inputVariableVO = (VariableVO) inputVariableVOs.get(i);
        inputVariables.put(new Integer(i), inputVariableVO);
    }
    return inputVariables;
}
Also used : VariableVO(com.centurylink.mdw.model.value.variable.VariableVO) TreeMap(java.util.TreeMap)

Example 13 with VariableVO

use of com.centurylink.mdw.model.value.variable.VariableVO 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);
}
Also used : ColumnSpec(com.centurylink.mdw.plugin.designer.properties.editor.ColumnSpec) ArrayList(java.util.ArrayList) VariableVO(com.centurylink.mdw.model.value.variable.VariableVO) VariableBinding(com.centurylink.mdw.plugin.designer.model.VariableBinding)

Example 14 with VariableVO

use of com.centurylink.mdw.model.value.variable.VariableVO 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;
}
Also used : ArrayList(java.util.ArrayList) VariableVO(com.centurylink.mdw.model.value.variable.VariableVO) VariableBinding(com.centurylink.mdw.plugin.designer.model.VariableBinding)

Example 15 with VariableVO

use of com.centurylink.mdw.model.value.variable.VariableVO in project mdw-designer by CenturyLinkCloud.

the class SubProcessMappingSection method getInputOutputVariables.

/**
 * Builds a map of Integer to VariableVO for the combo box cell editor.
 */
private Map<Integer, VariableVO> getInputOutputVariables() {
    Map<Integer, VariableVO> inOutVariables = new TreeMap<>();
    if (subProcess != null) {
        List<VariableVO> inputOutputVariableVOs = subProcess.getInputOutputVariables();
        for (int i = 0; i < inputOutputVariableVOs.size(); i++) {
            VariableVO inputOutputVariableVO = inputOutputVariableVOs.get(i);
            inOutVariables.put(Integer.valueOf(i), inputOutputVariableVO);
        }
    }
    return inOutVariables;
}
Also used : VariableVO(com.centurylink.mdw.model.value.variable.VariableVO) TreeMap(java.util.TreeMap)

Aggregations

VariableVO (com.centurylink.mdw.model.value.variable.VariableVO)34 ArrayList (java.util.ArrayList)12 HashMap (java.util.HashMap)9 ProcessVO (com.centurylink.mdw.model.value.process.ProcessVO)7 VariableValue (com.centurylink.mdw.plugin.designer.model.VariableValue)5 IOException (java.io.IOException)4 Map (java.util.Map)4 TreeMap (java.util.TreeMap)4 DataAccessException (com.centurylink.mdw.common.exception.DataAccessException)3 ValidationException (com.centurylink.mdw.designer.utils.ValidationException)3 ActivityVO (com.centurylink.mdw.model.value.activity.ActivityVO)3 VariableTypeVO (com.centurylink.mdw.model.value.variable.VariableTypeVO)3 VariableBinding (com.centurylink.mdw.plugin.designer.model.VariableBinding)3 ActionRequestDocument (com.centurylink.mdw.service.ActionRequestDocument)3 Parameter (com.centurylink.mdw.service.Parameter)3 XmlException (org.apache.xmlbeans.XmlException)3 JSONException (org.json.JSONException)3 MDWStatusMessage (com.centurylink.mdw.bpm.MDWStatusMessageDocument.MDWStatusMessage)2 SubGraph (com.centurylink.mdw.designer.display.SubGraph)2 RestfulServer (com.centurylink.mdw.designer.utils.RestfulServer)2