Search in sources :

Example 46 with TaskType

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

the class PageTaskEdit method loadTaskType.

TaskType loadTaskType(String taskOid, Task operationTask, OperationResult result) {
    TaskType taskType = null;
    try {
        Collection<SelectorOptions<GetOperationOptions>> options = GetOperationOptions.retrieveItemsNamed(TaskType.F_SUBTASK, TaskType.F_NODE_AS_OBSERVED, TaskType.F_NEXT_RUN_START_TIMESTAMP, TaskType.F_NEXT_RETRY_TIMESTAMP, new ItemPath(TaskType.F_WORKFLOW_CONTEXT, WfContextType.F_WORK_ITEM));
        options.addAll(GetOperationOptions.resolveItemsNamed(new ItemPath(TaskType.F_WORKFLOW_CONTEXT, WfContextType.F_REQUESTER_REF)));
        taskType = getModelService().getObject(TaskType.class, taskOid, options, operationTask, result).asObjectable();
        result.computeStatus();
    } catch (Exception ex) {
        result.recordFatalError("Couldn't get task.", ex);
    }
    return taskType;
}
Also used : SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) SystemException(com.evolveum.midpoint.util.exception.SystemException) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 47 with TaskType

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

the class ResourceDetailsTabPanel method createResourceConfigList.

private List<ResourceConfigurationDto> createResourceConfigList(ResourceType resource) {
    OperationResult result = new OperationResult(OPERATION_SEARCH_TASKS_FOR_RESOURCE);
    List<PrismObject<TaskType>> tasks = WebModelServiceUtils.searchObjects(TaskType.class, QueryBuilder.queryFor(TaskType.class, parentPage.getPrismContext()).item(TaskType.F_OBJECT_REF).ref(resource.getOid()).build(), result, parentPage);
    List<ResourceConfigurationDto> configs = new ArrayList<>();
    if (resource.getSchemaHandling() == null) {
        return configs;
    }
    List<ResourceObjectTypeDefinitionType> objectTypes = resource.getSchemaHandling().getObjectType();
    if (objectTypes == null) {
        return configs;
    }
    try {
        for (ResourceObjectTypeDefinitionType objectType : objectTypes) {
            ObjectSynchronizationType obejctSynchronization = null;
            if (resource.getSynchronization() != null && resource.getSynchronization().getObjectSynchronization() != null) {
                obejctSynchronization = getSynchronizationFor(objectType, resource.getSynchronization().getObjectSynchronization(), resource.asPrismObject());
            }
            List<TaskType> syncTask = new ArrayList<>();
            if (obejctSynchronization != null) {
                syncTask = getTaskFor(tasks, obejctSynchronization, resource.asPrismObject());
            }
            ResourceConfigurationDto resourceConfig = new ResourceConfigurationDto(objectType, obejctSynchronization != null, syncTask);
            configs.add(resourceConfig);
        }
    } catch (SchemaException ex) {
        LoggingUtils.logUnexpectedException(LOGGER, "Could not determine resource configuration", ex);
    }
    return configs;
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ResourceObjectTypeDefinitionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectTypeDefinitionType) ObjectSynchronizationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectSynchronizationType) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceConfigurationDto(com.evolveum.midpoint.web.page.admin.resources.dto.ResourceConfigurationDto)

Example 48 with TaskType

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

the class ResourceTasksPanel method createTaskModel.

private ListModel<TaskType> createTaskModel(PrismObject<ResourceType> object) {
    OperationResult result = new OperationResult(OPERATION_LOAD_TASKS);
    List<PrismObject<TaskType>> tasks = WebModelServiceUtils.searchObjects(TaskType.class, QueryBuilder.queryFor(TaskType.class, pageBase.getPrismContext()).item(TaskType.F_OBJECT_REF).ref(object.getOid()).build(), result, pageBase);
    List<TaskType> tasksType = new ArrayList<TaskType>();
    for (PrismObject<TaskType> task : tasks) {
        tasksType.add(task.asObjectable());
    }
    return new ListModel<>(tasksType);
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) ListModel(org.apache.wicket.model.util.ListModel) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Example 49 with TaskType

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

the class AbstractRoleMemberPanel method executeMemberOperation.

protected void executeMemberOperation(Task operationalTask, QName type, ObjectQuery memberQuery, ObjectDelta delta, String category, AjaxRequestTarget target) {
    OperationResult parentResult = operationalTask.getResult();
    try {
        ModelExecuteOptions options = TaskCategory.EXECUTE_CHANGES.equals(category) ? // This was originally in ExecuteChangesTaskHandler, now it's transferred through task extension.
        ModelExecuteOptions.createReconcile() : null;
        TaskType task = WebComponentUtil.createSingleRecurrenceTask(parentResult.getOperation(), type, memberQuery, delta, options, category, getPageBase());
        WebModelServiceUtils.runTask(task, operationalTask, parentResult, getPageBase());
    } catch (SchemaException e) {
        parentResult.recordFatalError(parentResult.getOperation(), e);
        LoggingUtils.logUnexpectedException(LOGGER, "Failed to execute operation " + parentResult.getOperation(), e);
        target.add(getPageBase().getFeedbackPanel());
    }
    target.add(getPageBase().getFeedbackPanel());
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) ModelExecuteOptions(com.evolveum.midpoint.model.api.ModelExecuteOptions) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Example 50 with TaskType

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

the class ProcessInstanceDtoProvider method internalIterator.

@Override
public Iterator<? extends ProcessInstanceDto> internalIterator(long first, long count) {
    getAvailableData().clear();
    Task opTask = getTaskManager().createTaskInstance(OPERATION_LIST_ITEMS);
    OperationResult result = opTask.getResult();
    try {
        //            SortParam sortParam = getSort();
        //            OrderDirectionType order;
        //            if (sortParam.isAscending()) {
        //                order = OrderDirectionType.ASCENDING;
        //            } else {
        //                order = OrderDirectionType.DESCENDING;
        //            }
        ObjectQuery query = getObjectQuery();
        // we know the paging object is not null
        query.getPaging().setOffset(safeLongToInteger(first));
        query.getPaging().setMaxSize(safeLongToInteger(count));
        Collection<SelectorOptions<GetOperationOptions>> options = createCollection(createResolveNames());
        List<PrismObject<TaskType>> tasks = getModel().searchObjects(TaskType.class, query, options, opTask, result);
        for (PrismObject<TaskType> task : tasks) {
            try {
                getAvailableData().add(new ProcessInstanceDto(task.asObjectable()));
            } catch (Exception e) {
                LoggingUtils.logUnexpectedException(LOGGER, "Unhandled exception when listing workflow task {}", e, task);
                result.recordPartialError("Couldn't list process instance.", e);
            }
        }
    } catch (Exception ex) {
        LoggingUtils.logUnexpectedException(LOGGER, "Unhandled exception when listing wf-related tasks", ex);
        result.recordFatalError("Couldn't list wf-related tasks.", ex);
    }
    if (result.isUnknown()) {
        result.computeStatus();
    }
    if (!result.isSuccess()) {
        getPage().showResult(result);
    }
    return getAvailableData().iterator();
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) Task(com.evolveum.midpoint.task.api.Task) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) SchemaException(com.evolveum.midpoint.util.exception.SchemaException)

Aggregations

TaskType (com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType)88 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)63 Test (org.testng.annotations.Test)50 Task (com.evolveum.midpoint.task.api.Task)47 PrismObject (com.evolveum.midpoint.prism.PrismObject)30 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)25 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)23 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)19 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)18 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)17 PrismAsserts.assertEqualsPolyString (com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString)16 AbstractInitializedModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)15 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)15 ArrayList (java.util.ArrayList)14 QName (javax.xml.namespace.QName)13 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)11 ObjectDeltaType (com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType)10 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)8 Checker (com.evolveum.midpoint.test.Checker)8 ObjectChecker (com.evolveum.midpoint.test.ObjectChecker)8