Search in sources :

Example 16 with BpmnModel

use of org.activiti.bpmn.model.BpmnModel in project Activiti by Activiti.

the class StartEventConverterTest method connvertJsonToModel.

@Test
public void connvertJsonToModel() throws Exception {
    BpmnModel bpmnModel = readJsonFile();
    validateModel(bpmnModel);
}
Also used : BpmnModel(org.activiti.bpmn.model.BpmnModel) Test(org.junit.Test)

Example 17 with BpmnModel

use of org.activiti.bpmn.model.BpmnModel in project Activiti by Activiti.

the class SubProcessConverterTest method connvertJsonToModel.

@Test
public void connvertJsonToModel() throws Exception {
    BpmnModel bpmnModel = readJsonFile();
    validateModel(bpmnModel);
}
Also used : BpmnModel(org.activiti.bpmn.model.BpmnModel) Test(org.junit.Test)

Example 18 with BpmnModel

use of org.activiti.bpmn.model.BpmnModel in project Activiti by Activiti.

the class UserTaskConverterTest method connvertJsonToModel.

@Test
public void connvertJsonToModel() throws Exception {
    BpmnModel bpmnModel = readJsonFile();
    validateModel(bpmnModel);
}
Also used : BpmnModel(org.activiti.bpmn.model.BpmnModel) Test(org.junit.Test)

Example 19 with BpmnModel

use of org.activiti.bpmn.model.BpmnModel in project Activiti by Activiti.

the class ProcessDefinitionImageStreamResourceBuilder method buildStreamResource.

public StreamResource buildStreamResource(ProcessInstance processInstance, RepositoryService repositoryService, RuntimeService runtimeService, ProcessDiagramGenerator diagramGenerator, ProcessEngineConfiguration processEngineConfig) {
    StreamResource imageResource = null;
    ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService).getDeployedProcessDefinition(processInstance.getProcessDefinitionId());
    if (processDefinition != null && processDefinition.isGraphicalNotationDefined()) {
        try {
            BpmnModel bpmnModel = repositoryService.getBpmnModel(processInstance.getProcessDefinitionId());
            InputStream definitionImageStream = diagramGenerator.generateDiagram(bpmnModel, "png", runtimeService.getActiveActivityIds(processInstance.getId()), Collections.<String>emptyList(), processEngineConfig.getActivityFontName(), processEngineConfig.getLabelFontName(), processEngineConfig.getAnnotationFontName(), processEngineConfig.getClassLoader(), 1.0);
            if (definitionImageStream != null) {
                StreamSource streamSource = new InputStreamStreamSource(definitionImageStream);
                // Create image name
                String imageExtension = extractImageExtension(processDefinition.getDiagramResourceName());
                String fileName = processInstance.getId() + UUID.randomUUID() + "." + imageExtension;
                imageResource = new StreamResource(streamSource, fileName, ExplorerApp.get());
            }
        } catch (Throwable t) {
            // Image can't be generated, ignore this
            LOGGER.warn("Process image cannot be generated due to exception: {} - {}", t.getClass().getName(), t.getMessage());
        }
    }
    return imageResource;
}
Also used : StreamResource(com.vaadin.terminal.StreamResource) InputStream(java.io.InputStream) StreamSource(com.vaadin.terminal.StreamResource.StreamSource) InputStreamStreamSource(org.activiti.explorer.ui.util.InputStreamStreamSource) ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity) InputStreamStreamSource(org.activiti.explorer.ui.util.InputStreamStreamSource) BpmnModel(org.activiti.bpmn.model.BpmnModel)

Example 20 with BpmnModel

use of org.activiti.bpmn.model.BpmnModel in project Activiti by Activiti.

the class ProcessDefinitionImageStreamResourceBuilder method buildStreamResource.

public StreamResource buildStreamResource(String processInstanceId, String processDefinitionId, RepositoryService repositoryService, RuntimeService runtimeService, ProcessDiagramGenerator diagramGenerator, ProcessEngineConfiguration processEngineConfig) {
    StreamResource imageResource = null;
    ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService).getDeployedProcessDefinition(processDefinitionId);
    if (processDefinition != null && processDefinition.isGraphicalNotationDefined()) {
        BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinitionId);
        InputStream definitionImageStream = diagramGenerator.generateDiagram(bpmnModel, "png", runtimeService.getActiveActivityIds(processInstanceId), Collections.<String>emptyList(), processEngineConfig.getActivityFontName(), processEngineConfig.getLabelFontName(), processEngineConfig.getAnnotationFontName(), processEngineConfig.getClassLoader(), 1.0);
        StreamSource streamSource = new InputStreamStreamSource(definitionImageStream);
        // Create image name
        String imageExtension = extractImageExtension(processDefinition.getDiagramResourceName());
        String fileName = processInstanceId + UUID.randomUUID() + "." + imageExtension;
        imageResource = new StreamResource(streamSource, fileName, ExplorerApp.get());
    }
    return imageResource;
}
Also used : StreamResource(com.vaadin.terminal.StreamResource) InputStream(java.io.InputStream) StreamSource(com.vaadin.terminal.StreamResource.StreamSource) InputStreamStreamSource(org.activiti.explorer.ui.util.InputStreamStreamSource) ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity) InputStreamStreamSource(org.activiti.explorer.ui.util.InputStreamStreamSource) BpmnModel(org.activiti.bpmn.model.BpmnModel)

Aggregations

BpmnModel (org.activiti.bpmn.model.BpmnModel)265 Test (org.junit.jupiter.api.Test)123 Test (org.junit.Test)57 Process (org.activiti.bpmn.model.Process)26 BpmnXMLConverter (org.activiti.bpmn.converter.BpmnXMLConverter)22 InputStream (java.io.InputStream)19 StartEvent (org.activiti.bpmn.model.StartEvent)17 SequenceFlow (org.activiti.bpmn.model.SequenceFlow)16 ArrayList (java.util.ArrayList)14 FlowElement (org.activiti.bpmn.model.FlowElement)13 ServiceTask (org.activiti.bpmn.model.ServiceTask)13 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)12 EndEvent (org.activiti.bpmn.model.EndEvent)11 ValidationError (org.activiti.validation.ValidationError)11 ByteArrayInputStream (java.io.ByteArrayInputStream)10 SubProcess (org.activiti.bpmn.model.SubProcess)10 JsonNode (com.fasterxml.jackson.databind.JsonNode)9 Deployment (org.activiti.engine.repository.Deployment)9 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)9 ProcessDiagramGenerator (org.activiti.image.ProcessDiagramGenerator)9