Search in sources :

Example 56 with BpmnModel

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

the class AbstractActivitiTestCase method deployTwoTasksTestProcess.

public String deployTwoTasksTestProcess() {
    BpmnModel bpmnModel = createTwoTasksTestProcess();
    Deployment deployment = repositoryService.createDeployment().addBpmnModel("twoTasksTestProcess.bpmn20.xml", bpmnModel).deploy();
    // For auto-cleanup
    deploymentIdsForAutoCleanup.add(deployment.getId());
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().deploymentId(deployment.getId()).singleResult();
    return processDefinition.getId();
}
Also used : Deployment(org.activiti.engine.repository.Deployment) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) BpmnModel(org.activiti.bpmn.model.BpmnModel)

Example 57 with BpmnModel

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

the class AbstractActivitiTestCase method createTwoTasksTestProcess.

public BpmnModel createTwoTasksTestProcess() {
    BpmnModel model = new BpmnModel();
    org.activiti.bpmn.model.Process process = new org.activiti.bpmn.model.Process();
    model.addProcess(process);
    process.setId("twoTasksProcess");
    process.setName("The two tasks process");
    StartEvent startEvent = new StartEvent();
    startEvent.setId("start");
    process.addFlowElement(startEvent);
    UserTask userTask = new UserTask();
    userTask.setName("The First Task");
    userTask.setId("task1");
    userTask.setAssignee("kermit");
    process.addFlowElement(userTask);
    UserTask userTask2 = new UserTask();
    userTask2.setName("The Second Task");
    userTask2.setId("task2");
    userTask2.setAssignee("kermit");
    process.addFlowElement(userTask2);
    EndEvent endEvent = new EndEvent();
    endEvent.setId("theEnd");
    process.addFlowElement(endEvent);
    process.addFlowElement(new SequenceFlow("start", "task1"));
    process.addFlowElement(new SequenceFlow("start", "task2"));
    process.addFlowElement(new SequenceFlow("task1", "theEnd"));
    process.addFlowElement(new SequenceFlow("task2", "theEnd"));
    return model;
}
Also used : SequenceFlow(org.activiti.bpmn.model.SequenceFlow) StartEvent(org.activiti.bpmn.model.StartEvent) UserTask(org.activiti.bpmn.model.UserTask) EndEvent(org.activiti.bpmn.model.EndEvent) BpmnModel(org.activiti.bpmn.model.BpmnModel)

Example 58 with BpmnModel

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

the class AbstractActivityBpmnParseHandler method createMultiInstanceLoopCharacteristics.

protected void createMultiInstanceLoopCharacteristics(BpmnParse bpmnParse, Activity modelActivity) {
    MultiInstanceLoopCharacteristics loopCharacteristics = modelActivity.getLoopCharacteristics();
    // Activity Behavior
    MultiInstanceActivityBehavior miActivityBehavior = null;
    ActivityImpl activity = bpmnParse.getCurrentScope().findActivity(modelActivity.getId());
    if (activity == null) {
        throw new ActivitiException("Activity " + modelActivity.getId() + " needed for multi instance cannot bv found");
    }
    if (loopCharacteristics.isSequential()) {
        miActivityBehavior = bpmnParse.getActivityBehaviorFactory().createSequentialMultiInstanceBehavior(activity, (AbstractBpmnActivityBehavior) activity.getActivityBehavior());
    } else {
        miActivityBehavior = bpmnParse.getActivityBehaviorFactory().createParallelMultiInstanceBehavior(activity, (AbstractBpmnActivityBehavior) activity.getActivityBehavior());
    }
    // ActivityImpl settings
    activity.setScope(true);
    activity.setProperty("multiInstance", loopCharacteristics.isSequential() ? "sequential" : "parallel");
    activity.setActivityBehavior(miActivityBehavior);
    ExpressionManager expressionManager = bpmnParse.getExpressionManager();
    BpmnModel bpmnModel = bpmnParse.getBpmnModel();
    // loopcardinality
    if (StringUtils.isNotEmpty(loopCharacteristics.getLoopCardinality())) {
        miActivityBehavior.setLoopCardinalityExpression(expressionManager.createExpression(loopCharacteristics.getLoopCardinality()));
    }
    // completion condition
    if (StringUtils.isNotEmpty(loopCharacteristics.getCompletionCondition())) {
        miActivityBehavior.setCompletionConditionExpression(expressionManager.createExpression(loopCharacteristics.getCompletionCondition()));
    }
    // activiti:collection
    if (StringUtils.isNotEmpty(loopCharacteristics.getInputDataItem())) {
        if (loopCharacteristics.getInputDataItem().contains("{")) {
            miActivityBehavior.setCollectionExpression(expressionManager.createExpression(loopCharacteristics.getInputDataItem()));
        } else {
            miActivityBehavior.setCollectionVariable(loopCharacteristics.getInputDataItem());
        }
    }
    // activiti:elementVariable
    if (StringUtils.isNotEmpty(loopCharacteristics.getElementVariable())) {
        miActivityBehavior.setCollectionElementVariable(loopCharacteristics.getElementVariable());
    }
    // activiti:elementIndexVariable
    if (StringUtils.isNotEmpty(loopCharacteristics.getElementIndexVariable())) {
        miActivityBehavior.setCollectionElementIndexVariable(loopCharacteristics.getElementIndexVariable());
    }
}
Also used : ExpressionManager(org.activiti.engine.impl.el.ExpressionManager) ActivitiException(org.activiti.engine.ActivitiException) ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) MultiInstanceLoopCharacteristics(org.activiti.bpmn.model.MultiInstanceLoopCharacteristics) AbstractBpmnActivityBehavior(org.activiti.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior) MultiInstanceActivityBehavior(org.activiti.engine.impl.bpmn.behavior.MultiInstanceActivityBehavior) BpmnModel(org.activiti.bpmn.model.BpmnModel)

Example 59 with BpmnModel

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

the class ProcessEngineConfigurationImpl method initDeployers.

// deployers ////////////////////////////////////////////////////////////////
protected void initDeployers() {
    if (this.deployers == null) {
        this.deployers = new ArrayList<Deployer>();
        if (customPreDeployers != null) {
            this.deployers.addAll(customPreDeployers);
        }
        this.deployers.addAll(getDefaultDeployers());
        if (customPostDeployers != null) {
            this.deployers.addAll(customPostDeployers);
        }
    }
    if (deploymentManager == null) {
        deploymentManager = new DeploymentManager();
        deploymentManager.setDeployers(deployers);
        // Process Definition cache
        if (processDefinitionCache == null) {
            if (processDefinitionCacheLimit <= 0) {
                processDefinitionCache = new DefaultDeploymentCache<ProcessDefinitionEntity>();
            } else {
                processDefinitionCache = new DefaultDeploymentCache<ProcessDefinitionEntity>(processDefinitionCacheLimit);
            }
        }
        // BpmnModel cache
        if (bpmnModelCache == null) {
            if (bpmnModelCacheLimit <= 0) {
                bpmnModelCache = new DefaultDeploymentCache<BpmnModel>();
            } else {
                bpmnModelCache = new DefaultDeploymentCache<BpmnModel>(bpmnModelCacheLimit);
            }
        }
        if (processDefinitionInfoCache == null) {
            if (processDefinitionInfoCacheLimit <= 0) {
                processDefinitionInfoCache = new ProcessDefinitionInfoCache(commandExecutor);
            } else {
                processDefinitionInfoCache = new ProcessDefinitionInfoCache(commandExecutor, processDefinitionInfoCacheLimit);
            }
        }
        // Knowledge base cache (used for Drools business task)
        if (knowledgeBaseCache == null) {
            if (knowledgeBaseCacheLimit <= 0) {
                knowledgeBaseCache = new DefaultDeploymentCache<Object>();
            } else {
                knowledgeBaseCache = new DefaultDeploymentCache<Object>(knowledgeBaseCacheLimit);
            }
        }
        deploymentManager.setProcessDefinitionCache(processDefinitionCache);
        deploymentManager.setBpmnModelCache(bpmnModelCache);
        deploymentManager.setProcessDefinitionInfoCache(processDefinitionInfoCache);
        deploymentManager.setKnowledgeBaseCache(knowledgeBaseCache);
    }
}
Also used : ProcessDefinitionInfoCache(org.activiti.engine.impl.persistence.deploy.ProcessDefinitionInfoCache) DeploymentManager(org.activiti.engine.impl.persistence.deploy.DeploymentManager) ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity) BpmnDeployer(org.activiti.engine.impl.bpmn.deployer.BpmnDeployer) Deployer(org.activiti.engine.impl.persistence.deploy.Deployer) BpmnModel(org.activiti.bpmn.model.BpmnModel)

Example 60 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)

Aggregations

BpmnModel (org.activiti.bpmn.model.BpmnModel)149 Test (org.junit.Test)101 BpmnXMLConverter (org.activiti.bpmn.converter.BpmnXMLConverter)15 InputStream (java.io.InputStream)13 ByteArrayInputStream (java.io.ByteArrayInputStream)10 Deployment (org.activiti.engine.repository.Deployment)10 Process (org.activiti.bpmn.model.Process)8 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)8 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)8 StartEvent (org.activiti.bpmn.model.StartEvent)7 ActivitiException (org.activiti.engine.ActivitiException)7 ProcessDefinitionEntity (org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)7 ArrayList (java.util.ArrayList)6 XMLInputFactory (javax.xml.stream.XMLInputFactory)6 XMLStreamReader (javax.xml.stream.XMLStreamReader)6 UserTask (org.activiti.bpmn.model.UserTask)6 FlowElement (org.activiti.bpmn.model.FlowElement)5 BpmnJsonConverter (org.activiti.editor.language.json.converter.BpmnJsonConverter)5 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 StreamResource (com.vaadin.terminal.StreamResource)4