use of org.activiti.engine.repository.ProcessDefinition in project Activiti by Activiti.
the class CdiExecutionListener method createEvent.
protected BusinessProcessEvent createEvent(DelegateExecution execution) {
ProcessDefinition processDefinition = Context.getExecutionContext().getProcessDefinition();
Date now = Context.getProcessEngineConfiguration().getClock().getCurrentTime();
return new CdiBusinessProcessEvent(activityId, transitionName, processDefinition, execution, type, execution.getProcessInstanceId(), execution.getId(), now);
}
use of org.activiti.engine.repository.ProcessDefinition in project Activiti by Activiti.
the class BusinessProcess method startProcessByName.
@Deprecated
public ProcessInstance startProcessByName(String string, Map<String, Object> variables) {
if (Context.getCommandContext() != null) {
throw new ActivitiCdiException("Cannot use startProcessByName in an activiti command.");
}
ProcessDefinition definition = processEngine.getRepositoryService().createProcessDefinitionQuery().processDefinitionName(string).singleResult();
if (definition == null) {
throw new ActivitiObjectNotFoundException("No process definition found for name: " + string, ProcessDefinition.class);
}
Map<String, Object> cachedVariables = getAndClearCachedVariables();
cachedVariables.putAll(variables);
ProcessInstance instance = processEngine.getRuntimeService().startProcessInstanceById(definition.getId(), cachedVariables);
if (!instance.isEnded()) {
setExecution(instance);
}
return instance;
}
use of org.activiti.engine.repository.ProcessDefinition in project Activiti by Activiti.
the class BusinessProcess method startProcessByName.
@Deprecated
public ProcessInstance startProcessByName(String string) {
if (Context.getCommandContext() != null) {
throw new ActivitiCdiException("Cannot use startProcessByName in an activiti command.");
}
ProcessDefinition definition = processEngine.getRepositoryService().createProcessDefinitionQuery().processDefinitionName(string).singleResult();
if (definition == null) {
throw new ActivitiObjectNotFoundException("No process definition found for name: " + string, ProcessDefinition.class);
}
ProcessInstance instance = processEngine.getRuntimeService().startProcessInstanceById(definition.getId(), getAndClearCachedVariables());
if (!instance.isEnded()) {
setExecution(instance);
}
return instance;
}
use of org.activiti.engine.repository.ProcessDefinition in project Activiti by Activiti.
the class ProcessDefinitionCategoryTest method testSetProcessDefinitionCategory.
@org.activiti.engine.test.Deployment
public void testSetProcessDefinitionCategory() {
// Verify category and see if we can start a process instance
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
assertEquals("testCategory", processDefinition.getCategory());
processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionCategory("testCategory").singleResult();
assertNotNull(processDefinition);
long count = runtimeService.createProcessInstanceQuery().count();
runtimeService.startProcessInstanceById(processDefinition.getId());
long newCount = runtimeService.createProcessInstanceQuery().count();
assertTrue(newCount == count + 1);
// Update category
repositoryService.setProcessDefinitionCategory(processDefinition.getId(), "UpdatedCategory");
assertEquals(0, repositoryService.createProcessDefinitionQuery().processDefinitionCategory("testCategory").count());
processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionCategory("UpdatedCategory").singleResult();
assertNotNull(processDefinition);
// Start a process instance
runtimeService.startProcessInstanceById(processDefinition.getId());
newCount = runtimeService.createProcessInstanceQuery().count();
assertTrue(newCount == count + 2);
// Set category to null
repositoryService.setProcessDefinitionCategory(processDefinition.getId(), null);
assertEquals(0, repositoryService.createProcessDefinitionQuery().processDefinitionCategory("testCategory").count());
assertEquals(0, repositoryService.createProcessDefinitionQuery().processDefinitionCategory("UpdatedCategory").count());
assertEquals(1, repositoryService.createProcessDefinitionQuery().processDefinitionCategoryNotEquals("UpdatedCategory").count());
}
use of org.activiti.engine.repository.ProcessDefinition in project Activiti by Activiti.
the class ProcessDefinitionQueryByLatestTest method testQueryByLatestAndVersion.
public void testQueryByLatestAndVersion() throws Exception {
// Deploy
List<String> xmlFileNameList = Arrays.asList("version_testProcess1_one.bpmn20.xml", "version_testProcess1_two.bpmn20.xml", "version_testProcess2_one.bpmn20.xml");
List<String> deploymentIdList = deploy(xmlFileNameList);
// version
ProcessDefinitionQuery nameQuery = repositoryService.createProcessDefinitionQuery().processDefinitionVersion(1).latestVersion();
List<ProcessDefinition> processDefinitions = nameQuery.list();
assertEquals(1, processDefinitions.size());
assertEquals("testProcess2", processDefinitions.get(0).getKey());
// Undeploy
unDeploy(deploymentIdList);
}
Aggregations