Search in sources :

Example 1 with BaseProcessVariables

use of org.kie.workbench.common.stunner.bpmn.definition.property.variables.BaseProcessVariables in project kie-wb-common by kiegroup.

the class VariablesProvider method findElements.

@Override
protected Collection<Pair<Object, String>> findElements(Predicate<Node> filter, Function<Node, Pair<Object, String>> mapper) {
    Collection<Pair<Object, String>> result = new ArrayList<>();
    String elementUUID = sessionManager.getCurrentSession().getCanvasHandler().getDiagram().getMetadata().getCanvasRootUUID();
    Node node;
    if (elementUUID != null) {
        node = sessionManager.getCurrentSession().getCanvasHandler().getDiagram().getGraph().getNode(elementUUID);
        Object oDefinition = ((View) node.getContent()).getDefinition();
        if (oDefinition instanceof BPMNDiagram) {
            BPMNDiagram bpmnDiagram = (BPMNDiagram) oDefinition;
            BaseProcessVariables processVars = bpmnDiagram.getProcessData().getProcessVariables();
            addPropertyVariableToResult(result, processVars.getValue());
            Iterable<Node> nodes = sessionManager.getCurrentSession().getCanvasHandler().getDiagram().getGraph().nodes();
            StreamSupport.stream(nodes.spliterator(), false).filter(this::isBPMNDefinition).map(elm -> (Node<View<BPMNDefinition>, Edge>) elm).forEach(elm -> processNode(elm, result));
            CaseFileVariables caseVars = bpmnDiagram.getCaseManagementSet().getCaseFileVariables();
            addCaseFileVariableToResult(result, caseVars.getValue());
        }
    }
    return result;
}
Also used : BaseProcessVariables(org.kie.workbench.common.stunner.bpmn.definition.property.variables.BaseProcessVariables) Arrays(java.util.Arrays) Predicate(java.util.function.Predicate) Collection(java.util.Collection) BPMNDefinition(org.kie.workbench.common.stunner.bpmn.definition.BPMNDefinition) BPMNDiagram(org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagram) Edge(org.kie.workbench.common.stunner.core.graph.Edge) Function(java.util.function.Function) View(org.kie.workbench.common.stunner.core.graph.content.view.View) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) List(java.util.List) DataObject(org.kie.workbench.common.stunner.bpmn.definition.DataObject) StreamSupport(java.util.stream.StreamSupport) SessionManager(org.kie.workbench.common.stunner.core.client.api.SessionManager) Pair(org.uberfire.commons.data.Pair) Node(org.kie.workbench.common.stunner.core.graph.Node) CaseFileVariables(org.kie.workbench.common.stunner.bpmn.definition.property.cm.CaseFileVariables) Node(org.kie.workbench.common.stunner.core.graph.Node) ArrayList(java.util.ArrayList) View(org.kie.workbench.common.stunner.core.graph.content.view.View) BPMNDiagram(org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagram) CaseFileVariables(org.kie.workbench.common.stunner.bpmn.definition.property.cm.CaseFileVariables) BaseProcessVariables(org.kie.workbench.common.stunner.bpmn.definition.property.variables.BaseProcessVariables) DataObject(org.kie.workbench.common.stunner.bpmn.definition.DataObject) BPMNDefinition(org.kie.workbench.common.stunner.bpmn.definition.BPMNDefinition) Pair(org.uberfire.commons.data.Pair)

Example 2 with BaseProcessVariables

use of org.kie.workbench.common.stunner.bpmn.definition.property.variables.BaseProcessVariables in project kie-wb-common by kiegroup.

the class VariableUtils method encodeProcessVariables.

public static String encodeProcessVariables(Diagram diagram, Node selectedElement) {
    Element parent = null;
    if (selectedElement != null) {
        parent = GraphUtils.getParent(selectedElement);
    }
    Iterator<Element> it = diagram.getGraph().nodes().iterator();
    StringBuffer variables = new StringBuffer();
    while (it.hasNext()) {
        Element element = it.next();
        if (element.getContent() instanceof View) {
            Object oDefinition = ((View) element.getContent()).getDefinition();
            if ((oDefinition instanceof BPMNDiagram)) {
                BPMNDiagram bpmnDiagram = (BPMNDiagram) oDefinition;
                BaseProcessVariables processVariables = bpmnDiagram.getProcessData().getProcessVariables();
                if (processVariables != null) {
                    if (variables.length() > 0) {
                        variables.append(",");
                    }
                    variables.append(processVariables.getValue());
                }
                CaseManagementSet caseManagementSet = bpmnDiagram.getCaseManagementSet();
                if (caseManagementSet != null) {
                    CaseFileVariables caseFileVariables = caseManagementSet.getCaseFileVariables();
                    if (caseFileVariables != null) {
                        if (variables.length() > 0) {
                            variables.append(",");
                        }
                        variables.append(caseFileVariables.getRawValue());
                    }
                }
            }
            if ((Objects.nonNull(parent) && Objects.equals(parent, element)) || Objects.isNull(selectedElement)) {
                BaseProcessVariables subprocessVariables = null;
                if (oDefinition instanceof EventSubprocess) {
                    EventSubprocess subprocess = (EventSubprocess) oDefinition;
                    subprocessVariables = subprocess.getProcessData().getProcessVariables();
                } else if (oDefinition instanceof BaseAdHocSubprocess) {
                    BaseAdHocSubprocess subprocess = (BaseAdHocSubprocess) oDefinition;
                    subprocessVariables = subprocess.getProcessData().getProcessVariables();
                } else if (oDefinition instanceof MultipleInstanceSubprocess) {
                    MultipleInstanceSubprocess subprocess = (MultipleInstanceSubprocess) oDefinition;
                    subprocessVariables = subprocess.getProcessData().getProcessVariables();
                } else if (oDefinition instanceof EmbeddedSubprocess) {
                    EmbeddedSubprocess subprocess = (EmbeddedSubprocess) oDefinition;
                    subprocessVariables = subprocess.getProcessData().getProcessVariables();
                }
                if (subprocessVariables != null) {
                    if (variables.length() > 0) {
                        variables.append(",");
                    }
                    variables.append(subprocessVariables.getValue());
                }
            }
        }
    }
    return variables.toString();
}
Also used : Element(org.kie.workbench.common.stunner.core.graph.Element) BaseAdHocSubprocess(org.kie.workbench.common.stunner.bpmn.definition.BaseAdHocSubprocess) View(org.kie.workbench.common.stunner.core.graph.content.view.View) MultipleInstanceSubprocess(org.kie.workbench.common.stunner.bpmn.definition.MultipleInstanceSubprocess) CaseManagementSet(org.kie.workbench.common.stunner.bpmn.definition.property.cm.CaseManagementSet) BPMNDiagram(org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagram) CaseFileVariables(org.kie.workbench.common.stunner.bpmn.definition.property.cm.CaseFileVariables) EventSubprocess(org.kie.workbench.common.stunner.bpmn.definition.EventSubprocess) BaseProcessVariables(org.kie.workbench.common.stunner.bpmn.definition.property.variables.BaseProcessVariables) EmbeddedSubprocess(org.kie.workbench.common.stunner.bpmn.definition.EmbeddedSubprocess)

Aggregations

BPMNDiagram (org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagram)2 CaseFileVariables (org.kie.workbench.common.stunner.bpmn.definition.property.cm.CaseFileVariables)2 BaseProcessVariables (org.kie.workbench.common.stunner.bpmn.definition.property.variables.BaseProcessVariables)2 View (org.kie.workbench.common.stunner.core.graph.content.view.View)2 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 List (java.util.List)1 Function (java.util.function.Function)1 Predicate (java.util.function.Predicate)1 StreamSupport (java.util.stream.StreamSupport)1 Inject (javax.inject.Inject)1 BPMNDefinition (org.kie.workbench.common.stunner.bpmn.definition.BPMNDefinition)1 BaseAdHocSubprocess (org.kie.workbench.common.stunner.bpmn.definition.BaseAdHocSubprocess)1 DataObject (org.kie.workbench.common.stunner.bpmn.definition.DataObject)1 EmbeddedSubprocess (org.kie.workbench.common.stunner.bpmn.definition.EmbeddedSubprocess)1 EventSubprocess (org.kie.workbench.common.stunner.bpmn.definition.EventSubprocess)1 MultipleInstanceSubprocess (org.kie.workbench.common.stunner.bpmn.definition.MultipleInstanceSubprocess)1 CaseManagementSet (org.kie.workbench.common.stunner.bpmn.definition.property.cm.CaseManagementSet)1 SessionManager (org.kie.workbench.common.stunner.core.client.api.SessionManager)1