use of org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagram in project kie-wb-common by kiegroup.
the class ProcessVariablesProvider 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) {
BPMNDiagramImpl bpmnDiagram = (BPMNDiagramImpl) oDefinition;
ProcessVariables processVars = bpmnDiagram.getProcessData().getProcessVariables();
if (processVars.getValue().length() > 0) {
List<String> list = Arrays.asList(processVars.getValue().split(","));
list.forEach(s1 -> {
String value = s1.split(":")[0];
result.add(new Pair<>(value, value));
});
}
}
}
return result;
}
use of org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagram in project kie-wb-common by kiegroup.
the class BPMNDirectDiagramMarshallerTest method testUnmarshallProcessVariables.
@Test
@SuppressWarnings("unchecked")
public void testUnmarshallProcessVariables() throws Exception {
Diagram<Graph, Metadata> diagram = unmarshall(BPMN_PROCESSVARIABLES);
assertDiagram(diagram, 8);
assertEquals("ProcessVariables", diagram.getMetadata().getTitle());
ProcessVariables variables = null;
Iterator<Element> it = nodesIterator(diagram);
while (it.hasNext()) {
Element element = it.next();
if (element.getContent() instanceof View) {
Object oDefinition = ((View) element.getContent()).getDefinition();
if (oDefinition instanceof BPMNDiagram) {
BPMNDiagramImpl bpmnDiagram = (BPMNDiagramImpl) oDefinition;
variables = bpmnDiagram.getProcessData().getProcessVariables();
break;
}
}
}
assertEquals(variables.getValue(), "employee:java.lang.String,reason:java.lang.String,performance:java.lang.String");
Node<? extends Definition, ?> diagramNode = diagram.getGraph().getNode("_luRBMdEjEeWXpsZ1tNStKQ");
assertTrue(diagramNode.getContent().getDefinition() instanceof BPMNDiagram);
BPMNDiagramImpl bpmnDiagram = (BPMNDiagramImpl) diagramNode.getContent().getDefinition();
assertTrue(bpmnDiagram.getProcessData() != null);
assertTrue(bpmnDiagram.getProcessData().getProcessVariables() != null);
variables = bpmnDiagram.getProcessData().getProcessVariables();
assertEquals(variables.getValue(), "employee:java.lang.String,reason:java.lang.String,performance:java.lang.String");
}
use of org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagram in project kie-wb-common by kiegroup.
the class BPMNDirectDiagramMarshallerTest method testUnmarshallProcessProperties.
@Test
@SuppressWarnings("unchecked")
public void testUnmarshallProcessProperties() throws Exception {
Diagram<Graph, Metadata> diagram = unmarshall(BPMN_PROCESSPROPERTIES);
assertDiagram(diagram, 4);
assertEquals("BPSimple", diagram.getMetadata().getTitle());
DiagramSet diagramProperties = null;
Iterator<Element> it = nodesIterator(diagram);
while (it.hasNext()) {
Element element = it.next();
if (element.getContent() instanceof View) {
Object oDefinition = ((View) element.getContent()).getDefinition();
if (oDefinition instanceof BPMNDiagram) {
BPMNDiagramImpl bpmnDiagram = (BPMNDiagramImpl) oDefinition;
diagramProperties = bpmnDiagram.getDiagramSet();
break;
}
}
}
assertEquals("BPSimple", diagramProperties.getName().getValue());
assertEquals("This is a\n" + "simple\n" + "process", diagramProperties.getDocumentation().getValue());
assertEquals("JDLProj.BPSimple", diagramProperties.getId().getValue());
assertEquals("org.jbpm", diagramProperties.getPackageProperty().getValue());
assertEquals(Boolean.TRUE, diagramProperties.getExecutable().getValue());
assertEquals(Boolean.TRUE, diagramProperties.getAdHoc().getValue());
assertEquals("This is the\n" + "Process\n" + "Instance\n" + "Description", diagramProperties.getProcessInstanceDescription().getValue());
}
use of org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagram in project kie-wb-common by kiegroup.
the class BPMNProjectDiagramFactoryImpl method updateDiagramProperties.
@Override
protected void updateDiagramProperties(final String name, final Node<Definition<BPMNDiagram>, ?> diagramNode, final ProjectMetadata metadata) {
super.updateDiagramProperties(name, diagramNode, metadata);
// Set kie related properties for the current project.
final BPMNDiagram diagram = diagramNode.getContent().getDefinition();
final DiagramSet diagramSet = diagram.getDiagramSet();
final String id = diagramSet.getId().getValue();
if (id == null || id.isEmpty()) {
final String projectName = null != metadata.getModuleName() ? metadata.getModuleName() + "." : "";
diagramSet.getId().setValue(projectName + name);
}
final String p = diagramSet.getPackageProperty().getValue();
if (p == null || p.isEmpty()) {
final Package metadataPackage = metadata.getProjectPackage();
final String value = metadataPackage == null ? org.kie.workbench.common.stunner.bpmn.definition.property.diagram.Package.DEFAULT_PACKAGE : metadata.getProjectPackage().getPackageName();
diagramSet.getPackageProperty().setValue(value);
}
final String diagramName = diagramSet.getName().getValue();
if (null == diagramName || diagramName.isEmpty()) {
diagramSet.getName().setValue(name);
}
}
use of org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagram in project kie-wb-common by kiegroup.
the class BPMNDiagramMarshallerTest method testUnmarshallProcessVariables.
@Test
@SuppressWarnings("unchecked")
public void testUnmarshallProcessVariables() throws Exception {
Diagram<Graph, Metadata> diagram = unmarshall(BPMN_PROCESSVARIABLES);
assertDiagram(diagram, 8);
assertEquals("ProcessVariables", diagram.getMetadata().getTitle());
ProcessVariables variables = null;
Iterator<Element> it = nodesIterator(diagram);
while (it.hasNext()) {
Element element = it.next();
if (element.getContent() instanceof View) {
Object oDefinition = ((View) element.getContent()).getDefinition();
if (oDefinition instanceof BPMNDiagram) {
BPMNDiagramImpl bpmnDiagram = (BPMNDiagramImpl) oDefinition;
variables = bpmnDiagram.getProcessData().getProcessVariables();
break;
}
}
}
assertEquals(variables.getValue(), "employee:java.lang.String,reason:java.lang.String,performance:java.lang.String");
Node<? extends Definition, ?> diagramNode = diagram.getGraph().getNode("_luRBMdEjEeWXpsZ1tNStKQ");
assertTrue(diagramNode.getContent().getDefinition() instanceof BPMNDiagram);
BPMNDiagramImpl bpmnDiagram = (BPMNDiagramImpl) diagramNode.getContent().getDefinition();
assertTrue(bpmnDiagram.getProcessData() != null);
assertTrue(bpmnDiagram.getProcessData().getProcessVariables() != null);
variables = bpmnDiagram.getProcessData().getProcessVariables();
assertEquals(variables.getValue(), "employee:java.lang.String,reason:java.lang.String,performance:java.lang.String");
}
Aggregations