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;
}
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();
}
Aggregations