Search in sources :

Example 1 with ProcessDefinition

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);
}
Also used : ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) Date(java.util.Date)

Example 2 with ProcessDefinition

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;
}
Also used : ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException)

Example 3 with ProcessDefinition

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;
}
Also used : ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException)

Example 4 with ProcessDefinition

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());
}
Also used : ProcessDefinition(org.activiti.engine.repository.ProcessDefinition)

Example 5 with ProcessDefinition

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);
}
Also used : ProcessDefinitionQuery(org.activiti.engine.repository.ProcessDefinitionQuery) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition)

Aggregations

ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)211 Deployment (org.activiti.engine.test.Deployment)82 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)42 ArrayList (java.util.ArrayList)29 ActivitiException (org.activiti.engine.ActivitiException)25 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)23 RepositoryService (org.activiti.engine.RepositoryService)20 ProcessDefinitionQuery (org.activiti.engine.repository.ProcessDefinitionQuery)19 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)19 Task (org.activiti.engine.task.Task)16 Date (java.util.Date)14 Test (org.junit.Test)14 JsonNode (com.fasterxml.jackson.databind.JsonNode)12 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)12 HashMap (java.util.HashMap)12 ProcessDefinitionEntity (org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)11 JobDefinitionEntity (org.finra.herd.model.jpa.JobDefinitionEntity)11 InputStream (java.io.InputStream)10 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)10 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)9