use of org.eclipse.bpmn2.Definitions in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshaller method orderDiagramElements.
private void orderDiagramElements(Definitions def) {
if (zOrderEnabled) {
if (def.getDiagrams() != null) {
for (BPMNDiagram diagram : def.getDiagrams()) {
if (diagram != null) {
_logger.debug("Sorting diagram elements using DIZorderComparator");
BPMNPlane plane = diagram.getPlane();
List<DiagramElement> unsortedElements = new ArrayList<DiagramElement>(plane.getPlaneElement());
plane.getPlaneElement().clear();
Collections.sort(unsortedElements, new DIZorderComparator());
plane.getPlaneElement().addAll(unsortedElements);
diagram.setPlane(plane);
}
}
}
}
}
use of org.eclipse.bpmn2.Definitions in project kie-wb-common by kiegroup.
the class DefaultProfileImpl method getDefinitions.
private Definitions getDefinitions(String xml) {
try {
DroolsFactoryImpl.init();
BpsimFactoryImpl.init();
ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, new Bpmn2ResourceFactoryImpl());
resourceSet.getPackageRegistry().put("http://www.omg.org/spec/BPMN/20100524/MODEL", Bpmn2Package.eINSTANCE);
Resource resource = resourceSet.createResource(URI.createURI("inputStream://dummyUriWithValidSuffix.xml"));
InputStream is = new ByteArrayInputStream(xml.getBytes("UTF-8"));
resource.load(is, Collections.EMPTY_MAP);
resource.load(Collections.EMPTY_MAP);
return ((DocumentRoot) resource.getContents().get(0)).getDefinitions();
} catch (Throwable t) {
t.printStackTrace();
return null;
}
}
use of org.eclipse.bpmn2.Definitions in project kie-wb-common by kiegroup.
the class JBPMBpmn2ResourceFactoryImpl method createAndInitResource.
/*
*
* Creates a new BpmnResourceImpl and initializes it.
*
* The method creates a DocumentRoot and a Definitions element, as both are
* mandatory.
*/
public Definitions createAndInitResource(URI uri) {
DroolsFactoryImpl.init();
BpsimFactoryImpl.init();
Resource resource = createResource(uri);
Bpmn2Factory factory = Bpmn2Factory.eINSTANCE;
Definitions definitions = factory.createDefinitions();
DocumentRoot docummentRoot = factory.createDocumentRoot();
docummentRoot.setDefinitions(definitions);
resource.getContents().add(docummentRoot);
return definitions;
}
use of org.eclipse.bpmn2.Definitions in project kie-wb-common by kiegroup.
the class BPMNDiagramMarshallerTest method testMarshallProcessVariables.
@Test
public void testMarshallProcessVariables() throws Exception {
Diagram<Graph, Metadata> diagram = unmarshall(BPMN_PROCESSVARIABLES);
JBPMBpmn2ResourceImpl resource = tested.marshallToBpmn2Resource(diagram);
String result = tested.marshall(diagram);
assertDiagram(result, 1, 7, 7);
Definitions definitions = (Definitions) resource.getContents().get(0);
assertNotNull(definitions);
List<RootElement> rootElements = definitions.getRootElements();
assertNotNull(rootElements);
assertNotNull(getItemDefinition(rootElements, "_employeeItem", "java.lang.String"));
assertNotNull(getItemDefinition(rootElements, "_reasonItem", "java.lang.String"));
assertNotNull(getItemDefinition(rootElements, "_performanceItem", "java.lang.String"));
Process process = getProcess(definitions);
assertNotNull(process);
List<Property> properties = process.getProperties();
assertNotNull(properties);
assertNotNull(getProcessProperty(properties, "employee", "_employeeItem"));
assertNotNull(getProcessProperty(properties, "reason", "_reasonItem"));
assertNotNull(getProcessProperty(properties, "performance", "_performanceItem"));
}
use of org.eclipse.bpmn2.Definitions in project kie-wb-common by kiegroup.
the class BPMNDirectDiagramMarshallerTest method testMarshallProcessVariables.
@Test
public void testMarshallProcessVariables() throws Exception {
Diagram<Graph, Metadata> diagram = unmarshall(BPMN_PROCESSVARIABLES);
String result = tested.marshall(diagram);
assertDiagram(result, 1, 7, 7);
Definitions definitions = new DefinitionsConverter(diagram.getGraph()).toDefinitions();
assertNotNull(definitions);
List<RootElement> rootElements = definitions.getRootElements();
assertNotNull(rootElements);
assertItemExists(rootElements, "_employeeItem", "java.lang.String");
assertItemExists(rootElements, "_reasonItem", "java.lang.String");
assertItemExists(rootElements, "_performanceItem", "java.lang.String");
Process process = getProcess(definitions);
assertNotNull(process);
List<Property> properties = process.getProperties();
assertNotNull(properties);
assertNotNull(getProcessProperty(properties, "employee", "_employeeItem"));
assertNotNull(getProcessProperty(properties, "reason", "_reasonItem"));
assertNotNull(getProcessProperty(properties, "performance", "_performanceItem"));
}
Aggregations