Search in sources :

Example 16 with Task

use of com.evolveum.midpoint.task.api.Task in project midpoint by Evolveum.

the class PageSelfRegistration method initDynamicFormLayout.

private void initDynamicFormLayout(final Form<?> mainForm) {
    WebMarkupContainer dynamicRegistrationForm = createMarkupContainer(ID_DYNAMIC_FORM, new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return getSelfRegistrationConfiguration().getFormRef() != null;
        }
    }, mainForm);
    DynamicFormPanel<UserType> dynamicForm = runPrivileged(() -> {
        final ObjectReferenceType ort = getSelfRegistrationConfiguration().getFormRef();
        if (ort == null) {
            return null;
        }
        Task task = createAnonymousTask(OPERATION_LOAD_DYNAMIC_FORM);
        return new DynamicFormPanel<UserType>(ID_DYNAMIC_FORM_PANEL, userModel, ort.getOid(), mainForm, task, PageSelfRegistration.this);
    });
    if (dynamicForm != null) {
        dynamicRegistrationForm.add(dynamicForm);
    }
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) Task(com.evolveum.midpoint.task.api.Task) DynamicFormPanel(com.evolveum.midpoint.web.component.prism.DynamicFormPanel) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Example 17 with Task

use of com.evolveum.midpoint.task.api.Task in project midpoint by Evolveum.

the class WorkItemDtoProvider method internalIterator.

@Override
public Iterator<? extends WorkItemDto> internalIterator(long first, long count) {
    getAvailableData().clear();
    Task task = getTaskManager().createTaskInstance();
    OperationResult result = new OperationResult(OPERATION_LIST_ITEMS);
    try {
        ObjectQuery query = createQuery(first, count, result);
        Collection<SelectorOptions<GetOperationOptions>> options = GetOperationOptions.resolveItemsNamed(new ItemPath(F_ASSIGNEE_REF), new ItemPath(T_PARENT, WfContextType.F_OBJECT_REF), new ItemPath(T_PARENT, WfContextType.F_TARGET_REF));
        List<WorkItemType> items = getModel().searchContainers(WorkItemType.class, query, options, task, result);
        for (WorkItemType item : items) {
            try {
                getAvailableData().add(new WorkItemDto(item));
            } catch (Exception e) {
                LoggingUtils.logUnexpectedException(LOGGER, "Unhandled exception when listing work item {}", e, item);
                result.recordFatalError("Couldn't list work item.", e);
            }
        }
    } catch (SchemaException | ObjectNotFoundException | SecurityViolationException | ConfigurationException | RuntimeException ex) {
        LoggingUtils.logUnexpectedException(LOGGER, "Unhandled exception when listing work items", ex);
        result.recordFatalError("Couldn't list work items.", ex);
    }
    if (result.isUnknown()) {
        result.computeStatus();
    }
    return getAvailableData().iterator();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) WorkItemType(com.evolveum.midpoint.xml.ns._public.common.common_3.WorkItemType)

Example 18 with Task

use of com.evolveum.midpoint.task.api.Task in project midpoint by Evolveum.

the class TreeTablePanel method moveConfirmPerformed.

private void moveConfirmPerformed(SelectableBean<OrgType> orgToMove, SelectableBean<OrgType> selected, AjaxRequestTarget target) {
    getPageBase().hideMainPopup(target);
    Task task = getPageBase().createSimpleTask(OPERATION_MOVE_OBJECT);
    OperationResult result = new OperationResult(OPERATION_MOVE_OBJECT);
    OrgType toMove = orgToMove.getValue();
    if (toMove == null || selected.getValue() == null) {
        return;
    }
    ObjectDelta<OrgType> moveOrgDelta = ObjectDelta.createEmptyModifyDelta(OrgType.class, toMove.getOid(), getPageBase().getPrismContext());
    try {
        for (OrgType parentOrg : toMove.getParentOrg()) {
            AssignmentType oldRoot = new AssignmentType();
            oldRoot.setTargetRef(ObjectTypeUtil.createObjectRef(parentOrg));
            moveOrgDelta.addModification(ContainerDelta.createModificationDelete(OrgType.F_ASSIGNMENT, OrgType.class, getPageBase().getPrismContext(), oldRoot.asPrismContainerValue()));
        // moveOrgDelta.addModification(ReferenceDelta.createModificationDelete(OrgType.F_PARENT_ORG_REF,
        // toMove.asPrismObject().getDefinition(),
        // ObjectTypeUtil.createObjectRef(parentOrg).asReferenceValue()));
        }
        AssignmentType newRoot = new AssignmentType();
        newRoot.setTargetRef(ObjectTypeUtil.createObjectRef(selected.getValue()));
        moveOrgDelta.addModification(ContainerDelta.createModificationAdd(OrgType.F_ASSIGNMENT, OrgType.class, getPageBase().getPrismContext(), newRoot.asPrismContainerValue()));
        // moveOrgDelta.addModification(ReferenceDelta.createModificationAdd(OrgType.F_PARENT_ORG_REF,
        // toMove.asPrismObject().getDefinition(),
        // ObjectTypeUtil.createObjectRef(selected.getValue()).asReferenceValue()));
        getPageBase().getPrismContext().adopt(moveOrgDelta);
        getPageBase().getModelService().executeChanges(WebComponentUtil.createDeltaCollection(moveOrgDelta), null, task, result);
        result.computeStatus();
    } catch (ObjectAlreadyExistsException | ObjectNotFoundException | SchemaException | ExpressionEvaluationException | CommunicationException | ConfigurationException | PolicyViolationException | SecurityViolationException e) {
        result.recordFatalError("Failed to move organization unit " + toMove, e);
        LoggingUtils.logUnexpectedException(LOGGER, "Failed to move organization unit" + toMove, e);
    }
    parentPage.showResult(result);
    target.add(parentPage.getFeedbackPanel());
    setResponsePage(PageOrgTree.class);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Example 19 with Task

use of com.evolveum.midpoint.task.api.Task in project midpoint by Evolveum.

the class AbstractSearchIterativeResultHandler method createWorkerThreads.

public void createWorkerThreads(Task coordinatorTask, OperationResult opResult) {
    Integer threadsCount = getWorkerThreadsCount(coordinatorTask);
    if (threadsCount == null || threadsCount == 0) {
        // nothing to do
        return;
    }
    // actually, size of threadsCount should be sufficient but it doesn't hurt if queue is larger
    int queueSize = threadsCount * 2;
    requestQueue = new ArrayBlockingQueue<>(queueSize);
    workerSpecificResults = new ArrayList<>(threadsCount);
    for (int i = 0; i < threadsCount; i++) {
        // we intentionally do not put worker specific result under main operation result until the handler is done
        // (because of concurrency issues - adding subresults vs e.g. putting main result into the task)
        OperationResult workerSpecificResult = new OperationResult(taskOperationPrefix + ".handleAsynchronously");
        workerSpecificResult.addContext("subtask", i);
        workerSpecificResults.add(workerSpecificResult);
        Task subtask = coordinatorTask.createSubtask(new WorkerHandler(workerSpecificResult));
        if (isEnableIterationStatistics()) {
            subtask.resetIterativeTaskInformation(null);
        }
        if (isEnableSynchronizationStatistics()) {
            subtask.resetSynchronizationInformation(null);
        }
        if (isEnableActionsExecutedStatistics()) {
            subtask.resetActionsExecutedInformation(null);
        }
        subtask.setCategory(coordinatorTask.getCategory());
        subtask.setResult(new OperationResult(taskOperationPrefix + ".executeWorker", OperationResultStatus.IN_PROGRESS, null));
        subtask.setName("Worker thread " + (i + 1) + " of " + threadsCount);
        subtask.startLightweightHandler();
        LOGGER.trace("Worker subtask {} created", subtask);
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Example 20 with Task

use of com.evolveum.midpoint.task.api.Task in project midpoint by Evolveum.

the class ControllerGetObjectTest method nullClass.

@Test(expectedExceptions = IllegalArgumentException.class)
public void nullClass() throws Exception {
    Task task = taskManager.createTaskInstance("Get Object");
    controller.getObject(null, "abababab-abab-abab-abab-000000000001", null, task, task.getResult());
}
Also used : Task(com.evolveum.midpoint.task.api.Task) Test(org.testng.annotations.Test)

Aggregations

Task (com.evolveum.midpoint.task.api.Task)4943 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)4698 Test (org.testng.annotations.Test)3991 AbstractInitializedModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)599 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)542 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)464 PrismObject (com.evolveum.midpoint.prism.PrismObject)327 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)323 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)290 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)282 ArrayList (java.util.ArrayList)249 QName (javax.xml.namespace.QName)208 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)199 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)193 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)175 DummyAccount (com.evolveum.icf.dummy.resource.DummyAccount)159 AbstractConfiguredModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractConfiguredModelIntegrationTest)140 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)123 SelectorOptions (com.evolveum.midpoint.schema.SelectorOptions)108 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)108