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