Search in sources :

Example 6 with WorkItemType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.WorkItemType in project midpoint by Evolveum.

the class TestActivitiQuery method test300SearchByAssignee.

@Test
public void test300SearchByAssignee() throws Exception {
    final String TEST_NAME = "test210SearchByAssignee";
    TestUtil.displayTestTile(this, TEST_NAME);
    login(userAdministrator);
    Task task = createTask(TEST_NAME);
    OperationResult result = task.getResult();
    List<PrismReferenceValue> assigneeRefs = new ArrayList<>();
    assigneeRefs.add(prv("oid-number-1"));
    assigneeRefs.add(prv(userLead1Oid));
    assigneeRefs.add(prv("oid-number-3"));
    assigneeRefs.add(prv("oid-number-4"));
    assigneeRefs.add(prv("oid-number-5"));
    assigneeRefs.add(prv("oid-number-6"));
    ObjectQuery query = QueryBuilder.queryFor(WorkItemType.class, prismContext).item(WorkItemType.F_ASSIGNEE_REF).ref(assigneeRefs).build();
    SearchResultList<WorkItemType> items = modelService.searchContainers(WorkItemType.class, query, null, task, result);
    assertEquals("Wrong # of work items found using multi-assignee/multi-delegate query", 1, items.size());
}
Also used : Task(com.evolveum.midpoint.task.api.Task) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) WorkItemType(com.evolveum.midpoint.xml.ns._public.common.common_3.WorkItemType) Test(org.testng.annotations.Test)

Example 7 with WorkItemType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.WorkItemType in project midpoint by Evolveum.

the class TestDelegation method test110DelegateToUser2Unauthorized.

@Test
public void test110DelegateToUser2Unauthorized() throws Exception {
    final String TEST_NAME = "test110DelegateToUser2Unauthorized";
    TestUtil.displayTestTile(this, TEST_NAME);
    login(userLead3);
    Task task = createTask(TEST_NAME);
    OperationResult result = task.getResult();
    try {
        workflowService.delegateWorkItem(workItemId, Collections.singletonList(ort(userLead2Oid)), ADD_ASSIGNEES, result);
        fail("delegate succeeded even if it shouldn't");
    } catch (SecurityViolationException e) {
    // ok
    }
    WorkItemType workItem = getWorkItem(task, result);
    PrismAsserts.assertReferenceValues(ref(workItem.getAssigneeRef()), userLead1Oid);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) WorkItemType(com.evolveum.midpoint.xml.ns._public.common.common_3.WorkItemType) Test(org.testng.annotations.Test)

Example 8 with WorkItemType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.WorkItemType in project midpoint by Evolveum.

the class TestDelegation method test130DelegateToUser3ByReplace.

@Test
public void test130DelegateToUser3ByReplace() throws Exception {
    final String TEST_NAME = "test130DelegateToUser3ByReplace";
    TestUtil.displayTestTile(this, TEST_NAME);
    login(userLead1);
    Task task = createTask(TEST_NAME);
    OperationResult result = task.getResult();
    workflowService.delegateWorkItem(workItemId, Collections.singletonList(ort(userLead3Oid)), REPLACE_ASSIGNEES, result);
    result.computeStatus();
    assertSuccess(result);
    WorkItemType workItem = getWorkItem(task, result);
    display("work item", workItem);
    PrismObject<TaskType> wfTask = getObjectViaRepo(TaskType.class, taskOid);
    display("task", wfTask);
    PrismAsserts.assertReferenceValues(ref(workItem.getAssigneeRef()), userLead3Oid);
    assertRefEquals("Wrong originalAssigneeRef", ort(userLead1Oid), workItem.getOriginalAssigneeRef());
    org.activiti.engine.task.Task activitiTask = activitiEngine.getTaskService().createTaskQuery().taskId(workItem.getExternalId()).singleResult();
    System.out.println("Activiti task: " + activitiTask);
    assertEquals("Wrong activiti assignee", "UserType:" + userLead3Oid, activitiTask.getAssignee());
    List<String> assignees = getAssignees(activitiTask);
    assertEquals("Wrong midpoint-assignee values", Collections.singleton("UserType:" + userLead3Oid), new HashSet<>(assignees));
    List<WorkItemDelegationEventType> events = WfContextUtil.getWorkItemEvents(wfTask.asObjectable().getWorkflowContext(), workItemId, WorkItemDelegationEventType.class);
    assertEquals("Wrong # of delegation events", 2, events.size());
// TODO check content
}
Also used : Task(com.evolveum.midpoint.task.api.Task) WorkItemDelegationEventType(com.evolveum.midpoint.xml.ns._public.common.common_3.WorkItemDelegationEventType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) WorkItemType(com.evolveum.midpoint.xml.ns._public.common.common_3.WorkItemType) Test(org.testng.annotations.Test)

Example 9 with WorkItemType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.WorkItemType in project midpoint by Evolveum.

the class AbstractTestAssignmentApproval method assertActiveWorkItems.

protected void assertActiveWorkItems(String approverOid, int expectedCount) throws Exception {
    if (approverOid == null && expectedCount == 0) {
        return;
    }
    Task task = createTask("query");
    ObjectQuery query = QueryBuilder.queryFor(WorkItemType.class, prismContext).item(WorkItemType.F_ASSIGNEE_REF).ref(getPotentialAssignees(getUser(approverOid))).build();
    List<WorkItemType> items = modelService.searchContainers(WorkItemType.class, query, null, task, task.getResult());
    assertEquals("Wrong active work items for " + approverOid, expectedCount, items.size());
}
Also used : ExpectedTask(com.evolveum.midpoint.wf.impl.policy.ExpectedTask) Task(com.evolveum.midpoint.task.api.Task) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) WorkItemType(com.evolveum.midpoint.xml.ns._public.common.common_3.WorkItemType)

Example 10 with WorkItemType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.WorkItemType in project midpoint by Evolveum.

the class ActivitiInterface method notifyMidpointAboutTaskEvent.

public void notifyMidpointAboutTaskEvent(DelegateTask delegateTask) {
    OperationResult result = new OperationResult(DOT_CLASS + "notifyMidpointAboutTaskEvent");
    TaskEvent taskEvent;
    if (TaskListener.EVENTNAME_CREATE.equals(delegateTask.getEventName())) {
        // TODO distinguish created vs. assigned event
        taskEvent = new TaskCreatedEvent();
    } else if (TaskListener.EVENTNAME_COMPLETE.equals(delegateTask.getEventName())) {
        taskEvent = new TaskCompletedEvent();
    } else if (TaskListener.EVENTNAME_DELETE.equals(delegateTask.getEventName())) {
        taskEvent = new TaskDeletedEvent();
    } else {
        // ignoring other events
        return;
    }
    taskEvent.setVariables(delegateTask.getVariables());
    taskEvent.setAssigneeOid(delegateTask.getAssignee());
    taskEvent.setTaskId(delegateTask.getId());
    taskEvent.setTaskName(delegateTask.getName());
    taskEvent.setProcessInstanceName((String) delegateTask.getVariable(CommonProcessVariableNames.VARIABLE_PROCESS_INSTANCE_NAME));
    taskEvent.setProcessInstanceId(delegateTask.getProcessInstanceId());
    taskEvent.setCreateTime(delegateTask.getCreateTime());
    taskEvent.setDueDate(delegateTask.getDueDate());
    taskEvent.setExecutionId(delegateTask.getExecutionId());
    taskEvent.setOwner(delegateTask.getOwner());
    for (IdentityLink identityLink : delegateTask.getCandidates()) {
        if (identityLink.getUserId() != null) {
            taskEvent.getCandidateUsers().add(identityLink.getUserId());
        } else if (identityLink.getGroupId() != null) {
            taskEvent.getCandidateGroups().add(identityLink.getGroupId());
        } else {
            throw new IllegalStateException("Neither candidate user nor group id is provided in delegateTask: " + delegateTask);
        }
    }
    try {
        WorkItemType workItem = workItemProvider.taskEventToWorkItemNew(taskEvent, null, true, true, true, result);
        wfTaskController.onTaskEvent(workItem, taskEvent, result);
    } catch (Exception e) {
        // todo fix the exception processing e.g. think about situation where an event cannot be audited - should we allow to proceed?
        String message = "Couldn't process an event coming from the workflow management system";
        LoggingUtils.logUnexpectedException(LOGGER, message, e);
        result.recordFatalError(message, e);
    }
}
Also used : OperationResult(com.evolveum.midpoint.schema.result.OperationResult) IdentityLink(org.activiti.engine.task.IdentityLink) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) SystemException(com.evolveum.midpoint.util.exception.SystemException) WorkItemType(com.evolveum.midpoint.xml.ns._public.common.common_3.WorkItemType)

Aggregations

WorkItemType (com.evolveum.midpoint.xml.ns._public.common.common_3.WorkItemType)17 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)13 Task (com.evolveum.midpoint.task.api.Task)13 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)6 Test (org.testng.annotations.Test)6 SelectorOptions (com.evolveum.midpoint.schema.SelectorOptions)5 TaskType (com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType)5 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)4 ModelContext (com.evolveum.midpoint.model.api.context.ModelContext)2 HookOperationMode (com.evolveum.midpoint.model.api.hooks.HookOperationMode)2 SearchResultList (com.evolveum.midpoint.schema.SearchResultList)2 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)2 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)2 SystemException (com.evolveum.midpoint.util.exception.SystemException)2 WorkItemDelegationEventType (com.evolveum.midpoint.xml.ns._public.common.common_3.WorkItemDelegationEventType)2 ArrayList (java.util.ArrayList)2 ModelExecuteOptions (com.evolveum.midpoint.model.api.ModelExecuteOptions)1 ModelState (com.evolveum.midpoint.model.api.context.ModelState)1 AbstractModelImplementationIntegrationTest (com.evolveum.midpoint.model.impl.AbstractModelImplementationIntegrationTest)1 ModelOperationTaskHandler (com.evolveum.midpoint.model.impl.controller.ModelOperationTaskHandler)1