Search in sources :

Example 1 with CaseFileVariables

use of org.kie.workbench.common.stunner.bpmn.definition.property.cm.CaseFileVariables 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 CaseFileVariables

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

the class ProcessPropertyWriterTest method caseFileVariables.

@Test
public void caseFileVariables() {
    CaseFileVariables caseFileVariables = new CaseFileVariables("CFV1:Boolean,CFV2:Boolean,CFV3:Boolean");
    p.setCaseFileVariables(caseFileVariables);
    assertThat(p.itemDefinitions.size() == 3);
}
Also used : CaseFileVariables(org.kie.workbench.common.stunner.bpmn.definition.property.cm.CaseFileVariables) Test(org.junit.Test)

Example 3 with CaseFileVariables

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

the class BaseRootProcessConverter method convertProcessNode.

private BpmnNode convertProcessNode(String id, Process process) {
    Node<View<D>, Edge> diagramNode = createNode(id);
    D definition = diagramNode.getContent().getDefinition();
    DefinitionsPropertyReader d = delegate.propertyReaderFactory.of(delegate.definitionResolver.getDefinitions());
    ProcessPropertyReader p = delegate.propertyReaderFactory.of(process);
    definition.setDiagramSet(createDiagramSet(process, p, d));
    definition.setCaseManagementSet(new CaseManagementSet(new CaseIdPrefix(p.getCaseIdPrefix()), new CaseRoles(p.getCaseRoles()), new CaseFileVariables(p.getCaseFileVariables())));
    definition.setProcessData(createProcessData(p.getProcessVariables()));
    definition.setAdvancedData(createAdvancedData(p.getGlobalVariables(), p.getMetaDataAttributes()));
    diagramNode.getContent().setBounds(p.getBounds());
    definition.setFontSet(p.getFontSet());
    definition.setBackgroundSet(p.getBackgroundSet());
    return BpmnNode.of(diagramNode, p);
}
Also used : CaseFileVariables(org.kie.workbench.common.stunner.bpmn.definition.property.cm.CaseFileVariables) DefinitionsPropertyReader(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.DefinitionsPropertyReader) CaseRoles(org.kie.workbench.common.stunner.bpmn.definition.property.cm.CaseRoles) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Edge(org.kie.workbench.common.stunner.core.graph.Edge) ProcessPropertyReader(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.ProcessPropertyReader) CaseManagementSet(org.kie.workbench.common.stunner.bpmn.definition.property.cm.CaseManagementSet) CaseIdPrefix(org.kie.workbench.common.stunner.bpmn.definition.property.cm.CaseIdPrefix)

Example 4 with CaseFileVariables

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

the class VariableProviderTest method mockRootNode.

private Element mockRootNode(String processVariables, String caseFileVariables) {
    BPMNDiagramImpl rootNode = new BPMNDiagramImpl();
    rootNode.setProcessData(new ProcessData(new ProcessVariables(processVariables)));
    rootNode.setCaseManagementSet((new CaseManagementSet(new CaseIdPrefix(""), new CaseRoles(""), new CaseFileVariables(caseFileVariables))));
    return mockNode(rootNode);
}
Also used : ProcessVariables(org.kie.workbench.common.stunner.bpmn.definition.property.variables.ProcessVariables) CaseFileVariables(org.kie.workbench.common.stunner.bpmn.definition.property.cm.CaseFileVariables) CaseRoles(org.kie.workbench.common.stunner.bpmn.definition.property.cm.CaseRoles) BPMNDiagramImpl(org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagramImpl) ProcessData(org.kie.workbench.common.stunner.bpmn.definition.property.variables.ProcessData) CaseManagementSet(org.kie.workbench.common.stunner.bpmn.definition.property.cm.CaseManagementSet) CaseIdPrefix(org.kie.workbench.common.stunner.bpmn.definition.property.cm.CaseIdPrefix)

Example 5 with CaseFileVariables

use of org.kie.workbench.common.stunner.bpmn.definition.property.cm.CaseFileVariables 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

CaseFileVariables (org.kie.workbench.common.stunner.bpmn.definition.property.cm.CaseFileVariables)7 CaseManagementSet (org.kie.workbench.common.stunner.bpmn.definition.property.cm.CaseManagementSet)4 BPMNDiagram (org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagram)3 CaseIdPrefix (org.kie.workbench.common.stunner.bpmn.definition.property.cm.CaseIdPrefix)3 CaseRoles (org.kie.workbench.common.stunner.bpmn.definition.property.cm.CaseRoles)3 View (org.kie.workbench.common.stunner.core.graph.content.view.View)3 BPMNDiagramImpl (org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagramImpl)2 BaseProcessVariables (org.kie.workbench.common.stunner.bpmn.definition.property.variables.BaseProcessVariables)2 ProcessData (org.kie.workbench.common.stunner.bpmn.definition.property.variables.ProcessData)2 Edge (org.kie.workbench.common.stunner.core.graph.Edge)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 Process (org.eclipse.bpmn2.Process)1 Test (org.junit.Test)1