Search in sources :

Example 11 with TaskService

use of org.activiti.engine.TaskService in project midpoint by Evolveum.

the class TestActivitiQuery method test200TestQueryByTaskVariable.

/**
	 * Actually, this mechanism is not used anymore. We use identity links to store information about assignees.
	 * But keeping this test - just in case something like that would be needed later.
	 */
@Test
public void test200TestQueryByTaskVariable() throws Exception {
    final String TEST_NAME = "test200TestQueryByTaskVariable";
    TestUtil.displayTestTile(this, TEST_NAME);
    login(userAdministrator);
    TaskService taskService = activitiEngine.getTaskService();
    TaskQuery tq = taskService.createTaskQuery();
    org.activiti.engine.task.Task task = tq.singleResult();
    System.out.println("Task = " + task);
    assertNotNull("No task", task);
    final String TASK_NAME = "Approve assigning Role1a to jack";
    final String VAR = "someVariable";
    taskService.setVariableLocal(task.getId(), VAR, "[:abc];[:def];[UserType:" + userLead1Oid + "]");
    TaskQuery tq1 = taskService.createTaskQuery().includeTaskLocalVariables().taskVariableValueLike(VAR, "%:def]%").taskName(TASK_NAME);
    assertFound(tq1, "#1");
    TaskQuery tq2 = taskService.createTaskQuery().includeTaskLocalVariables().taskVariableValueLike(VAR, "%:xyz]%");
    org.activiti.engine.task.Task task2 = tq2.singleResult();
    System.out.println("Task2 = " + task2);
    assertNull("Found task2 even if it shouldn't", task2);
    TaskQuery tq3 = taskService.createTaskQuery().includeTaskLocalVariables().taskName(TASK_NAME).or().taskVariableValueLike(VAR, "%:ghi]%").taskVariableValueLike(VAR, "%:xxx]%").taskVariableValueLike(VAR, "%:" + userLead1Oid + "]%").endOr();
    org.activiti.engine.task.Task task3 = tq3.singleResult();
    System.out.println("Task3 = " + task3);
    assertNotNull("No task3", task3);
    TaskQuery tq4 = taskService.createTaskQuery().includeTaskLocalVariables().taskName(TASK_NAME).or().taskVariableValueLike(VAR, "%:" + userLead1Oid + "]%").taskVariableValueLike(VAR, "%:xxx]%").taskAssignee(userLead1Oid).endOr();
    org.activiti.engine.task.Task task4 = tq4.singleResult();
    System.out.println("Task4 = " + task4);
    assertNotNull("No task4", task4);
    TaskQuery tq5 = taskService.createTaskQuery().includeTaskLocalVariables().taskName(TASK_NAME).or().taskVariableValueLike(VAR, "%:" + userLead1Oid + "]%").taskVariableValueLike(VAR, "%:xxx]%").taskAssignee("xxx;" + userLead1Oid).endOr();
    org.activiti.engine.task.Task task5 = tq5.singleResult();
    System.out.println("Task5 = " + task5);
    assertNotNull("No task5", task5);
    TaskQuery tq6 = taskService.createTaskQuery().includeTaskLocalVariables().taskName(TASK_NAME).or().taskVariableValueLike(VAR, "%:xxx]%").taskVariableValueLike(VAR, "%:" + userLead1Oid + "]%").taskAssignee("xxx;yyy").endOr();
    org.activiti.engine.task.Task task6 = tq6.singleResult();
    System.out.println("Task6 = " + task6);
    assertNotNull("No task6", task6);
    TaskQuery tq7 = taskService.createTaskQuery().includeTaskLocalVariables().taskName(TASK_NAME).or().taskVariableValueLike(VAR, "%:xxx]%").taskVariableValueLike(VAR, "%:yyy]%").taskAssignee("xxx;UserType:" + userLead1Oid).endOr();
    org.activiti.engine.task.Task task7 = tq7.singleResult();
    System.out.println("Task7 = " + task7);
    assertNotNull("No task7", task7);
}
Also used : TaskService(org.activiti.engine.TaskService) TaskQuery(org.activiti.engine.task.TaskQuery) Test(org.testng.annotations.Test)

Example 12 with TaskService

use of org.activiti.engine.TaskService in project midpoint by Evolveum.

the class TaskCreateListener method notify.

@Override
public void notify(DelegateTask delegateTask) {
    OperationResult result = new OperationResult(TaskCreateListener.class.getName() + ".notify");
    Task wfTask = ActivitiUtil.getTask(delegateTask.getExecution(), result);
    String taskId = delegateTask.getId();
    // duration/deadline
    ApprovalStageDefinitionType stageDef = WfContextUtil.getCurrentStageDefinition(wfTask.getWorkflowContext());
    if (stageDef == null) {
        throw new IllegalStateException("No approval stage information in " + delegateTask);
    }
    if (stageDef.getDuration() != null) {
        MidpointUtil.setTaskDeadline(delegateTask, stageDef.getDuration());
    }
    // triggers
    int escalationLevel = ActivitiUtil.getEscalationLevelNumber(delegateTask.getVariables());
    MidpointUtil.createTriggersForTimedActions(taskId, escalationLevel, delegateTask.getCreateTime(), delegateTask.getDueDate(), wfTask, stageDef.getTimedActions(), result);
    // originalAssignee
    String assignee = delegateTask.getAssignee();
    if (assignee != null) {
        TaskService taskService = delegateTask.getExecution().getEngineServices().getTaskService();
        taskService.setVariableLocal(taskId, CommonProcessVariableNames.VARIABLE_ORIGINAL_ASSIGNEE, assignee);
        taskService.addUserIdentityLink(taskId, assignee, CommonProcessVariableNames.MIDPOINT_ASSIGNEE);
    }
    getActivitiInterface().notifyMidpointAboutTaskEvent(delegateTask);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) DelegateTask(org.activiti.engine.delegate.DelegateTask) ApprovalStageDefinitionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ApprovalStageDefinitionType) TaskService(org.activiti.engine.TaskService) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Example 13 with TaskService

use of org.activiti.engine.TaskService in project bamboobsc by billchen198318.

the class TestBPMN001 method completeTask.

@Test
public void completeTask() throws Exception {
    String assignee = "張三";
    //String assignee = "王經理";
    TaskService taskService = (TaskService) AppContext.getBean("taskService");
    List<Task> tasks = taskService.createTaskQuery().list();
    if (tasks == null || tasks.size() < 1) {
        System.out.println("no task.");
        return;
    }
    for (Task task : tasks) {
        taskService.setAssignee(task.getId(), assignee);
        taskService.complete(task.getId());
        this.printTask(task);
    }
}
Also used : Task(org.activiti.engine.task.Task) TaskService(org.activiti.engine.TaskService) Test(org.junit.Test)

Example 14 with TaskService

use of org.activiti.engine.TaskService in project bamboobsc by billchen198318.

the class TestBPMN001 method queryTask.

@Test
public void queryTask() throws Exception {
    String assignee = "張三";
    TaskService taskService = (TaskService) AppContext.getBean("taskService");
    List<Task> tasks = taskService.createTaskQuery().taskAssignee(assignee).list();
    if (tasks == null || tasks.size() < 1) {
        System.out.println("no task.");
        return;
    }
    for (Task task : tasks) {
        this.printTask(task);
    }
}
Also used : Task(org.activiti.engine.task.Task) TaskService(org.activiti.engine.TaskService) Test(org.junit.Test)

Example 15 with TaskService

use of org.activiti.engine.TaskService in project crnk-framework by crnk-project.

the class ActivitiTestBase method teardown.

@After
public void teardown() {
    RuntimeService runtimeService = processEngine.getRuntimeService();
    List<ProcessInstance> processInstances = runtimeService.createProcessInstanceQuery().list();
    for (ProcessInstance processInstance : processInstances) {
        runtimeService.deleteProcessInstance(processInstance.getId(), "");
    }
    TaskService taskService = processEngine.getTaskService();
    List<Task> tasks = taskService.createTaskQuery().list();
    for (Task task : tasks) {
        taskService.deleteTask(task.getId());
    }
}
Also used : Task(org.activiti.engine.task.Task) ApproveTask(io.crnk.activiti.example.model.ApproveTask) RuntimeService(org.activiti.engine.RuntimeService) TaskService(org.activiti.engine.TaskService) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) After(org.junit.After)

Aggregations

TaskService (org.activiti.engine.TaskService)38 Task (org.activiti.engine.task.Task)25 Test (org.junit.Test)15 RuntimeService (org.activiti.engine.RuntimeService)10 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)10 ProcessEngine (org.activiti.engine.ProcessEngine)6 WorkflowDefinition (org.activiti.workflow.simple.definition.WorkflowDefinition)6 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)5 HashMap (java.util.HashMap)5 SecurityViolationException (com.evolveum.midpoint.util.exception.SecurityViolationException)4 StandaloneProcessEngineConfiguration (org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration)4 ObjectTypeUtil.toShortString (com.evolveum.midpoint.schema.util.ObjectTypeUtil.toShortString)3 MidPointPrincipal (com.evolveum.midpoint.security.api.MidPointPrincipal)3 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)3 ArrayList (java.util.ArrayList)3 RepositoryService (org.activiti.engine.RepositoryService)3 Task (com.evolveum.midpoint.task.api.Task)2 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)2 SystemException (com.evolveum.midpoint.util.exception.SystemException)2 ExternalResource (com.vaadin.terminal.ExternalResource)2