Search in sources :

Example 1 with BpmnXMLConverter

use of org.activiti.bpmn.converter.BpmnXMLConverter in project Activiti by Activiti.

the class LaneExtensionTest method testLaneExtensionElement.

@Test
@Deployment
public void testLaneExtensionElement() {
    ProcessDefinition processDefinition = activitiRule.getRepositoryService().createProcessDefinitionQuery().processDefinitionKey("swimlane-extension").singleResult();
    BpmnModel bpmnModel = activitiRule.getRepositoryService().getBpmnModel(processDefinition.getId());
    byte[] xml = new BpmnXMLConverter().convertToXML(bpmnModel);
    System.out.println(new String(xml));
    Process bpmnProcess = bpmnModel.getMainProcess();
    for (Lane l : bpmnProcess.getLanes()) {
        Map<String, List<ExtensionElement>> extensions = l.getExtensionElements();
        Assert.assertTrue(extensions.size() > 0);
    }
}
Also used : Lane(org.activiti.bpmn.model.Lane) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) Process(org.activiti.bpmn.model.Process) List(java.util.List) BpmnModel(org.activiti.bpmn.model.BpmnModel) BpmnXMLConverter(org.activiti.bpmn.converter.BpmnXMLConverter) Test(org.junit.Test) Deployment(org.activiti.engine.test.Deployment)

Example 2 with BpmnXMLConverter

use of org.activiti.bpmn.converter.BpmnXMLConverter in project Activiti by Activiti.

the class ImportExportTest method readXMLFile.

protected BpmnModel readXMLFile() throws Exception {
    InputStream xmlStream = this.getClass().getClassLoader().getResourceAsStream(getResource());
    StreamSource xmlSource = new InputStreamSource(xmlStream);
    BpmnModel bpmnModel = new BpmnXMLConverter().convertToBpmnModel(xmlSource, false, false, processEngineConfiguration.getXmlEncoding());
    return bpmnModel;
}
Also used : InputStreamSource(org.activiti.engine.impl.util.io.InputStreamSource) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) StreamSource(org.activiti.engine.impl.util.io.StreamSource) InputStreamSource(org.activiti.engine.impl.util.io.InputStreamSource) BpmnXMLConverter(org.activiti.bpmn.converter.BpmnXMLConverter)

Example 3 with BpmnXMLConverter

use of org.activiti.bpmn.converter.BpmnXMLConverter in project Activiti by Activiti.

the class ImportExportTest method testConvertXMLToModel.

public void testConvertXMLToModel() throws Exception {
    BpmnModel bpmnModel = readXMLFile();
    bpmnModel = exportAndReadXMLFile(bpmnModel);
    byte[] xml = new BpmnXMLConverter().convertToXML(bpmnModel);
    org.activiti.engine.repository.Deployment deployment = processEngine.getRepositoryService().createDeployment().name("test1").addString("test1.bpmn20.xml", new String(xml)).deploy();
    String processInstanceKey = runtimeService.startProcessInstanceByKey("process").getId();
    Execution execution = runtimeService.createExecutionQuery().processInstanceId(processInstanceKey).messageEventSubscriptionName("InterruptMessage").singleResult();
    assertNotNull(execution);
}
Also used : Execution(org.activiti.engine.runtime.Execution) BpmnXMLConverter(org.activiti.bpmn.converter.BpmnXMLConverter)

Example 4 with BpmnXMLConverter

use of org.activiti.bpmn.converter.BpmnXMLConverter in project Activiti by Activiti.

the class ImportExportTest method exportAndReadXMLFile.

protected BpmnModel exportAndReadXMLFile(BpmnModel bpmnModel) throws Exception {
    byte[] xml = new BpmnXMLConverter().convertToXML(bpmnModel, processEngineConfiguration.getXmlEncoding());
    StreamSource xmlSource = new InputStreamSource(new ByteArrayInputStream(xml));
    BpmnModel parsedModel = new BpmnXMLConverter().convertToBpmnModel(xmlSource, false, false, processEngineConfiguration.getXmlEncoding());
    return parsedModel;
}
Also used : InputStreamSource(org.activiti.engine.impl.util.io.InputStreamSource) ByteArrayInputStream(java.io.ByteArrayInputStream) StreamSource(org.activiti.engine.impl.util.io.StreamSource) InputStreamSource(org.activiti.engine.impl.util.io.InputStreamSource) BpmnXMLConverter(org.activiti.bpmn.converter.BpmnXMLConverter)

Example 5 with BpmnXMLConverter

use of org.activiti.bpmn.converter.BpmnXMLConverter in project Activiti by Activiti.

the class CallActivityTest method loadBPMNModel.

protected BpmnModel loadBPMNModel(String bpmnModelFilePath) throws Exception {
    InputStream xmlStream = this.getClass().getClassLoader().getResourceAsStream(bpmnModelFilePath);
    StreamSource xmlSource = new InputStreamSource(xmlStream);
    BpmnModel bpmnModel = new BpmnXMLConverter().convertToBpmnModel(xmlSource, false, false, processEngineConfiguration.getXmlEncoding());
    return bpmnModel;
}
Also used : InputStreamSource(org.activiti.engine.impl.util.io.InputStreamSource) InputStream(java.io.InputStream) InputStreamSource(org.activiti.engine.impl.util.io.InputStreamSource) StreamSource(org.activiti.engine.impl.util.io.StreamSource) BpmnModel(org.activiti.bpmn.model.BpmnModel) BpmnXMLConverter(org.activiti.bpmn.converter.BpmnXMLConverter)

Aggregations

BpmnXMLConverter (org.activiti.bpmn.converter.BpmnXMLConverter)23 BpmnModel (org.activiti.bpmn.model.BpmnModel)15 ByteArrayInputStream (java.io.ByteArrayInputStream)12 InputStream (java.io.InputStream)9 XMLInputFactory (javax.xml.stream.XMLInputFactory)8 XMLStreamReader (javax.xml.stream.XMLStreamReader)8 InputStreamReader (java.io.InputStreamReader)6 InputStreamSource (org.activiti.engine.impl.util.io.InputStreamSource)6 StreamSource (org.activiti.engine.impl.util.io.StreamSource)5 BpmnJsonConverter (org.activiti.editor.language.json.converter.BpmnJsonConverter)4 Test (org.junit.Test)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 ExternalResource (com.vaadin.terminal.ExternalResource)3 HorizontalLayout (com.vaadin.ui.HorizontalLayout)3 URL (java.net.URL)3 Deployment (org.activiti.engine.repository.Deployment)3 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 StreamResource (com.vaadin.terminal.StreamResource)2 Embedded (com.vaadin.ui.Embedded)2 Label (com.vaadin.ui.Label)2