Diagram2BpmnConverter { public Definitions getDefinitionsFromDiagram() throws BpmnConverterException { this.setDefinitionsAttributes(); try { createBpmnElementsRecursively(diagram); } catch (Exception e) { throw new BpmnConverterException( "Error while converting to BPMN model", e); } for (Map.Entry<Configurable.Configuration,Set> entry : this.state.configurableGatewaySourceMap.entrySet()) { assert entry.getValue().size() > 0; for (Object element : entry.getValue()) { entry.getKey().getSourceRefs().add(this.state.shapeToXMLObjectMap.get(element)); } } for (Map.Entry<Configurable.Configuration,Set> entry : this.state.configurableGatewayTargetMap.entrySet()) { assert entry.getValue().size() > 0; for (Object element : entry.getValue()) { entry.getKey().getTargetRefs().add(this.state.shapeToXMLObjectMap.get(element)); } } this.detectBoundaryEvents(); this.detectConnectors(); this.setInitiatingParticipant(); this.updateDataAssociationsRefs(); this.setIOSpecification(); this.setDefaultSequenceFlowOfExclusiveGateway(); this.setCompensationEventActivityRef(); this.identifyProcesses(); this.handleDataObjects(); this.handleArtifacts(); this.addAssociationsToProcess(); this.addAssociationsToConversation(); this.createProcessIOSpec(); this.processChoreographies(); this.putGlobalElementsIntoDefinitions(); this.putCalledElementsIntoDefinitions(); this.insertCollaborationElements(); this.insertChoreographyProcessesIntoDefinitions(); this.insertProcessesIntoDefinitions(); this.insertEdgeDiagramElements(); this.insertDiagramsForLinkedSubprocesses(); { String cmap = this.diagram.getProperty("cmap"); if (cmap != null) { for (BaseElement root: this.definitions.getRootElement()) { ConfigurationMapping configurationMapping = new ConfigurationMapping(); configurationMapping.setHref(cmap); root.getOrCreateExtensionElements().add(configurationMapping); } } } if (!this.state.variantMap.isEmpty()) { Variants variants = new Variants(); for (Map.Entry<String,Variants.Variant> entry : this.state.variantMap.entrySet()) { Variants.Variant variant = new Variants.Variant(); variant.setId(entry.getValue().getId()); variant.setName(entry.getKey()); variants.getVariant().add(variant); } this.definitions.getFirstPlane().getBpmnElement().getOrCreateExtensionElements().getAny().add(variants); } this.determineUnusedNamespaceDeclarations(); this.collectExternalNamespaces(); this.ensureSignavioUUIDStyle(); this.checkUniquenessOfProcessIDs(); return definitions; } Diagram2BpmnConverter(GenericDiagram diagram,
                                 List<Class<? extends AbstractBpmnFactory>> factoryClasses);  Diagram2BpmnConverter(GenericDiagram diagram,
                                 List<Class<? extends AbstractBpmnFactory>> factoryClasses, boolean checkOnSignavioIDs);  Diagram2BpmnConverter(GenericDiagram diagram,
                                 List<Class<? extends AbstractBpmnFactory>> factoryClasses,
                                 Map<String, Object> configuration);  Diagram2BpmnConverter(Map<String, LinkedModel> linkedModels,
                                 GenericDiagram diagram,
                                 List<Class<? extends AbstractBpmnFactory>> factoryClasses); void handleMessageAssociationOnChoreographyActivity(
            Association association); Definitions getDefinitionsFromDiagram(); static HashSet<String> getEdgeIds(); static Constants getConstants(); static void setConstants(Constants constants); final static HashSet<String> edgeIds; final static HashSet<String> dataObjectIds; }
@Test public void testGetDefinitionsFromDiagram1() throws BpmnConverterException, IOException, JAXBException, JSONException, SAXException { BufferedReader br = new BufferedReader(new FileReader(new File(new File(testsDirectory, "data"), "GetDiagramFromBpmn20_1-expected.json"))); String bpmnJson = ""; String line; while ((line = br.readLine()) != null) { bpmnJson += line; } BasicDiagram diagram = BasicDiagramBuilder.parseJson(bpmnJson); Diagram2BpmnConverter converter = new Diagram2BpmnConverter(diagram, AbstractBpmnFactory.getFactoryClasses()); Definitions definitions = converter.getDefinitionsFromDiagram(); assertValidBPMN(definitions, "test-GetDefinitionsFromDiagram.bpmn.xml"); Task airbus = (Task) ((Process) definitions.getRootElement().get(0)).getFlowElement().get(0); assertEquals("sid-B8EA9D11-3DF2-46E9-8498-9351EEB1C3B4", airbus.getId()); assertEquals(1, airbus.getIncoming().size()); assertEquals("sid-B6C60809-2232-4F2B-B290-A4639AD05BCD", airbus.getIncoming().get(0).getId()); assertEquals(1, ((FlowNode) airbus).getIncomingSequenceFlows().size()); assertEquals("sid-B6C60809-2232-4F2B-B290-A4639AD05BCD", ((FlowNode) airbus).getIncomingSequenceFlows().get(0).getId()); assertEquals(1, airbus.getOutgoing().size()); assertEquals("sid-F44D88A1-2E18-43E6-93C7-7F038AB2C2A1", airbus.getOutgoing().get(0).getId()); assertEquals(1, ((FlowNode) airbus).getOutgoingSequenceFlows().size()); assertEquals("sid-F44D88A1-2E18-43E6-93C7-7F038AB2C2A1", ((FlowNode) airbus).getOutgoingSequenceFlows().get(0).getId()); }