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();
}
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;
}
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());
}
}
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);
}
}
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;
}
Aggregations