use of org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.DefinitionsConverter in project kie-wb-common by kiegroup.
the class BaseDirectDiagramMarshaller method marshall.
@Override
@SuppressWarnings("unchecked")
public String marshall(final Diagram<Graph, Metadata> diagram) throws IOException {
LOG.debug("Starting diagram marshalling...");
Bpmn2Resource resource = createBpmn2Resource();
// we start converting from the root, then pull out the result
PropertyWriterFactory propertyWriterFactory = new PropertyWriterFactory();
DefinitionsConverter definitionsConverter = new DefinitionsConverter(new ConverterFactory(new DefinitionsBuildingContext(diagram.getGraph(), getDiagramClass()), propertyWriterFactory), propertyWriterFactory);
Definitions definitions = definitionsConverter.toDefinitions();
resource.getContents().add(definitions);
LOG.debug("Diagram marshalling completed successfully.");
String outputString = renderToString(resource);
LOG.trace(outputString);
return outputString;
}
use of org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.DefinitionsConverter in project kie-wb-common by kiegroup.
the class BPMNDirectDiagramMarshallerTest method testMarshallUserTaskAssignments.
@Test
public void testMarshallUserTaskAssignments() throws Exception {
Diagram<Graph, Metadata> diagram = unmarshall(BPMN_USERTASKASSIGNMENTS);
// JBPMBpmn2ResourceImpl resource = tested.marshallToBpmn2Resource(diagram);
String result = tested.marshall(diagram);
assertDiagram(result, 1, 7, 7);
DefinitionsConverter definitionsConverter = new DefinitionsConverter(diagram.getGraph());
Definitions definitions = definitionsConverter.toDefinitions();
assertNotNull(definitions);
Process process = getProcess(definitions);
assertNotNull(process);
org.eclipse.bpmn2.UserTask userTask = (org.eclipse.bpmn2.UserTask) getNamedFlowElement(process, org.eclipse.bpmn2.UserTask.class, "Self Evaluation");
assertNotNull(userTask);
DataInput dataInput = getDataInput(userTask, "reason");
// this fails because of type
validateDataInputOrOutput(dataInput, "_reasonInputX", "com.test.Reason", "_reasonInputXItem");
DataOutput dataOutput = getDataOutput(userTask, "performance");
validateDataInputOrOutput(dataOutput, "_performanceOutputX", "Object", "_performanceOutputXItem");
ItemAwareElement sourceRef = getDataInputAssociationSourceRef(userTask, "reason");
assertNotNull(sourceRef);
ItemAwareElement targetRef = getDataInputAssociationTargetRef(userTask, "_reasonInputX");
assertNotNull(targetRef);
sourceRef = getDataOutputAssociationSourceRef(userTask, "_performanceOutputX");
assertNotNull(sourceRef);
targetRef = getDataOutputAssociationTargetRef(userTask, "performance");
assertNotNull(targetRef);
}
use of org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.DefinitionsConverter in project kie-wb-common by kiegroup.
the class BPMNDirectDiagramMarshallerTest method testMarshallProcessProperties.
@Test
public void testMarshallProcessProperties() throws Exception {
Diagram<Graph, Metadata> diagram = unmarshall(BPMN_PROCESSPROPERTIES);
String result = tested.marshall(diagram);
assertDiagram(result, 1, 3, 2);
Definitions definitions = new DefinitionsConverter(diagram.getGraph()).toDefinitions();
assertNotNull(definitions);
Process process = getProcess(definitions);
assertNotNull(process);
assertEquals("JDLProj.BPSimple", process.getId());
assertEquals("BPSimple", process.getName());
assertTrue(process.isIsExecutable());
assertEquals("true", getProcessPropertyValue(process, "adHoc"));
assertEquals("org.jbpm", getProcessPropertyValue(process, "packageName"));
assertEquals("1.0", getProcessPropertyValue(process, "version"));
assertNotNull(process.getDocumentation());
assertFalse(process.getDocumentation().isEmpty());
assertEquals("<![CDATA[This is a\nsimple\nprocess]]>", process.getDocumentation().get(0).getText());
assertEquals("<![CDATA[This is the\nProcess\nInstance\nDescription]]>", getProcessExtensionValue(process, "customDescription"));
assertEquals("<![CDATA[12/25/1983]]>", getProcessExtensionValue(process, "customSLADueDate"));
}
Aggregations