Search in sources :

Example 1 with WorkItemId

use of com.evolveum.midpoint.schema.util.WorkItemId in project midpoint by Evolveum.

the class AbstractIdMatchTest method test130ResolveAmbiguityAsExisting.

/**
 * Resolve the case created in the previous test. (By confirming it is the same person.)
 *
 * The user should be updated, because the import is executed immediately.
 */
@Test
public void test130ResolveAmbiguityAsExisting() throws CommonException {
    given();
    Task task = getTestTask();
    OperationResult result = task.getResult();
    ShadowType newShadow = getShadow("4", result).asObjectable();
    CaseType correlationCase = java.util.Objects.requireNonNull(correlationCaseManager.findCorrelationCase(newShadow, true, result));
    WorkItemId workItemId = WorkItemId.of(correlationCase.getWorkItem().get(0));
    // TODO adapt when URIs are changed to use OIDs
    AbstractWorkItemOutputType output = new AbstractWorkItemOutputType(prismContext).outcome(// unqualified should be OK here
    SchemaConstants.CORRELATION_EXISTING_PREFIX + getReferenceId(john));
    dummyAuditService.clear();
    dummyTransport.clearMessages();
    when();
    caseService.completeWorkItem(workItemId, output, task, result);
    then();
    assertSuccess(result);
    // @formatter:off
    UserType john = findUserByUsername("smith2").asObjectable();
    assertUser(john, "John after").display().assertFullName("John Smith").assignments().assertAssignments(3).assertOrg(ORG_PROGRAM_SW_ENG.oid).assertOrg(ORG_PROGRAM_MATH.oid).assertOrg(ORG_PROGRAM_E_ENG.oid).end().assertLinks(3, 0);
    // @formatter:on
    PrismObject<ShadowType> newShadowAfter = getShadow("4", result);
    assertShadow(newShadowAfter, "after").display().assertSynchronizationSituation(LINKED).assertMatchReferenceId(getReferenceId(john));
    // match request ID may or may not be there
    // @formatter:off
    assertCase(correlationCase.getOid(), "correlation case").display().assertClosed().workItems().assertWorkItems(2).forOriginalAssignee(USER_ADMINISTRATOR_OID).assertClosed().end().forOriginalAssignee(USER_FRED.oid).assertClosed().end();
    // @formatter:on
    displayDumpable("audit", dummyAuditService);
    displayDumpable("dummy transport", dummyTransport);
// TODO check audit and notification event content
}
Also used : Task(com.evolveum.midpoint.task.api.Task) TestTask(com.evolveum.midpoint.test.TestTask) WorkItemId(com.evolveum.midpoint.schema.util.WorkItemId) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test)

Example 2 with WorkItemId

use of com.evolveum.midpoint.schema.util.WorkItemId in project midpoint by Evolveum.

the class CompleteWorkItemsAction method updateCaseHistory.

private void updateCaseHistory(@NotNull CaseWorkItemType workItem, @NotNull AbstractWorkItemOutputType output) {
    WorkItemId workItemId = WorkItemId.create(operation.getCaseOidRequired(), workItem.getId());
    WorkItemCompletionEventType event = new WorkItemCompletionEventType(PrismContext.get());
    fillInWorkItemEvent(event, operation.getPrincipal(), workItemId, workItem);
    event.setCause(request.getCauseInformation());
    event.setOutput(output);
    operation.addCaseHistoryEvent(event);
}
Also used : WorkItemId(com.evolveum.midpoint.schema.util.WorkItemId)

Example 3 with WorkItemId

use of com.evolveum.midpoint.schema.util.WorkItemId in project midpoint by Evolveum.

the class CorrelationContextPanel method initLayout.

@Override
protected void initLayout() {
    IModel<CorrelationContextDto> correlationCtxModel = createCorrelationContextModel();
    ListView<String> headers = new ListView<>(ID_HEADERS, new PropertyModel<>(correlationCtxModel, F_OPTION_HEADERS)) {

        @Override
        protected void populateItem(ListItem<String> item) {
            item.add(new Label(ID_HEADER, item.getModel()));
        }
    };
    add(headers);
    ListView<CorrelationOptionDto> actions = new ListView<>(ID_ACTIONS, new PropertyModel<>(correlationCtxModel, CorrelationContextDto.F_CORRELATION_OPTIONS)) {

        @Override
        protected void populateItem(ListItem<CorrelationOptionDto> item) {
            AjaxButton actionButton = new AjaxButton(ID_ACTION) {

                @Override
                public void onClick(AjaxRequestTarget target) {
                    CaseType correlationCase = getObjectDetailsModels().getObjectType();
                    WorkItemId workItemId = WorkItemId.of(correlationCase.getWorkItem().get(0));
                    AbstractWorkItemOutputType output = new AbstractWorkItemOutputType().outcome(item.getModelObject().getIdentifier());
                    Task task = getPageBase().createSimpleTask("DecideCorrelation");
                    OperationResult result = task.getResult();
                    try {
                        getPageBase().getCaseService().completeWorkItem(workItemId, output, task, result);
                        result.computeStatusIfUnknown();
                    } catch (Throwable e) {
                        result.recordFatalError("Cannot finish correlation process, " + e.getMessage(), e);
                    }
                    getPageBase().showResult(result);
                    target.add(getPageBase().getFeedbackPanel());
                }
            };
            actionButton.add(new Label(ID_ACTION_LABEL, item.getModelObject().isNewOwner() ? TEXT_CREATE_NEW : TEXT_CORRELATE));
            item.add(actionButton);
        }
    };
    add(actions);
    ListView<CorrelationOptionDto> referenceIds = new ListView<>(ID_NAMES, new PropertyModel<>(correlationCtxModel, CorrelationContextDto.F_CORRELATION_OPTIONS)) {

        @Override
        protected void populateItem(ListItem<CorrelationOptionDto> item) {
            // A full-object reference to the candidate owner
            ReadOnlyModel<ObjectReferenceType> referenceModel = new ReadOnlyModel<>(() -> {
                CorrelationOptionDto optionDto = item.getModelObject();
                if (!optionDto.isNewOwner()) {
                    return ObjectTypeUtil.createObjectRefWithFullObject(optionDto.getObject());
                } else {
                    // GUI cannot currently open object that does not exist in the repository.
                    return null;
                }
            });
            item.add(new LinkedReferencePanel<>(ID_NAME, referenceModel));
        }
    };
    add(referenceIds);
    ListView<CorrelationPropertyDefinition> rows = new ListView<>(ID_ROWS, new PropertyModel<>(correlationCtxModel, CorrelationContextDto.F_CORRELATION_PROPERTIES)) {

        @Override
        protected void populateItem(ListItem<CorrelationPropertyDefinition> item) {
            // First column contains the property name
            item.add(new Label(ID_ATTR_NAME, new PropertyModel<>(item.getModel(), CorrelationPropertyDefinition.F_DISPLAY_NAME)));
            // Here are columns for values for individual options
            item.add(createColumnsForPropertyRow(correlationCtxModel, item));
        }
    };
    add(rows);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) Label(org.apache.wicket.markup.html.basic.Label) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) ListView(org.apache.wicket.markup.html.list.ListView) ReadOnlyModel(com.evolveum.midpoint.gui.api.model.ReadOnlyModel) WorkItemId(com.evolveum.midpoint.schema.util.WorkItemId) PropertyModel(org.apache.wicket.model.PropertyModel) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ListItem(org.apache.wicket.markup.html.list.ListItem)

Example 4 with WorkItemId

use of com.evolveum.midpoint.schema.util.WorkItemId in project midpoint by Evolveum.

the class AbstractMultiAccountsCorrelationTest method test130ResolveAmbiguityAsExisting.

/**
 * Resolve the case created in the previous test. (By confirming it is the same person.)
 *
 * The user should be updated, because the import is executed immediately.
 */
@Test
public void test130ResolveAmbiguityAsExisting() throws CommonException {
    given();
    Task task = getTestTask();
    OperationResult result = task.getResult();
    ShadowType newShadow = getShadow("4", result).asObjectable();
    CaseType correlationCase = java.util.Objects.requireNonNull(correlationCaseManager.findCorrelationCase(newShadow, true, result));
    WorkItemId workItemId = WorkItemId.of(correlationCase.getWorkItem().get(0));
    AbstractWorkItemOutputType output = new AbstractWorkItemOutputType(prismContext).outcome(OwnerOptionIdentifier.forExistingOwner(john.getOid()).getStringValue());
    dummyAuditService.clear();
    dummyTransport.clearMessages();
    when();
    caseService.completeWorkItem(workItemId, output, task, result);
    then();
    assertSuccess(result);
    // @formatter:off
    UserType john = findUserByUsername("smith2").asObjectable();
    assertUser(john, "John after").display().assertFullName("John Smith").assignments().assertAssignments(3).assertOrg(ORG_PROGRAM_SW_ENG.oid).assertOrg(ORG_PROGRAM_MATH.oid).assertOrg(ORG_PROGRAM_E_ENG.oid).end().assertLinks(3, 0);
    // @formatter:on
    PrismObject<ShadowType> newShadowAfter = getShadow("4", result);
    assertShadow(newShadowAfter, "after").display().assertSynchronizationSituation(LINKED);
    // @formatter:off
    assertCase(correlationCase.getOid(), "correlation case").display().assertClosed().workItems().assertWorkItems(1);
    // @formatter:on
    displayDumpable("audit", dummyAuditService);
    displayDumpable("dummy transport", dummyTransport);
// TODO check audit and notification event content
}
Also used : Task(com.evolveum.midpoint.task.api.Task) TestTask(com.evolveum.midpoint.test.TestTask) WorkItemId(com.evolveum.midpoint.schema.util.WorkItemId) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test)

Example 5 with WorkItemId

use of com.evolveum.midpoint.schema.util.WorkItemId in project midpoint by Evolveum.

the class AbstractMultiAccountsCorrelationTest method test160ResolveAmbiguityAsNone.

/**
 * Resolve the case created in the previous test. (By telling it's a different person.)
 */
@Test
public void test160ResolveAmbiguityAsNone() throws CommonException {
    given();
    Task task = getTestTask();
    OperationResult result = task.getResult();
    ShadowType newShadow = getShadow("6", result).asObjectable();
    CaseType correlationCase = java.util.Objects.requireNonNull(correlationCaseManager.findCorrelationCase(newShadow, true, result));
    WorkItemId workItemId = WorkItemId.of(correlationCase.getWorkItem().get(0));
    AbstractWorkItemOutputType output = new AbstractWorkItemOutputType(prismContext).outcome(OwnerOptionIdentifier.forNoOwner().getStringValue());
    dummyAuditService.clear();
    dummyTransport.clearMessages();
    when();
    caseService.completeWorkItem(workItemId, output, task, result);
    then();
    assertSuccess(result);
    // @formatter:off
    UserType john = findUserByUsername("smith3").asObjectable();
    assertUser(john, "New john after").display().assertFullName("John Smith").assignments().assertAssignments(1).assertOrg(ORG_PROGRAM_SW_ENG_DOCTORAL.oid).end().assertLinks(1, 0);
    // @formatter:on
    PrismObject<ShadowType> newShadowAfter = getShadow("6", result);
    assertShadow(newShadowAfter, "after").display().assertSynchronizationSituation(LINKED);
    assertCase(correlationCase.getOid(), "correlation case").display().assertClosed();
    displayDumpable("audit", dummyAuditService);
    displayDumpable("dummy transport", dummyTransport);
// TODO check audit and notification event content
}
Also used : Task(com.evolveum.midpoint.task.api.Task) TestTask(com.evolveum.midpoint.test.TestTask) WorkItemId(com.evolveum.midpoint.schema.util.WorkItemId) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test)

Aggregations

WorkItemId (com.evolveum.midpoint.schema.util.WorkItemId)5 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)4 Task (com.evolveum.midpoint.task.api.Task)4 TestTask (com.evolveum.midpoint.test.TestTask)3 Test (org.testng.annotations.Test)3 ReadOnlyModel (com.evolveum.midpoint.gui.api.model.ReadOnlyModel)1 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)1 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)1 Label (org.apache.wicket.markup.html.basic.Label)1 ListItem (org.apache.wicket.markup.html.list.ListItem)1 ListView (org.apache.wicket.markup.html.list.ListView)1 PropertyModel (org.apache.wicket.model.PropertyModel)1