Search in sources :

Example 66 with Task

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

the class PageTaskAdd method createResourceList.

private List<TaskAddResourcesDto> createResourceList() {
    OperationResult result = new OperationResult(OPERATION_LOAD_RESOURCES);
    Task task = createSimpleTask(OPERATION_LOAD_RESOURCES);
    List<PrismObject<ResourceType>> resources = null;
    List<TaskAddResourcesDto> resourceList = new ArrayList<TaskAddResourcesDto>();
    try {
        resources = getModelService().searchObjects(ResourceType.class, new ObjectQuery(), null, task, result);
        result.recomputeStatus();
    } catch (Exception ex) {
        result.recordFatalError("Couldn't get resource list.", ex);
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't get resource list", ex);
    }
    // }
    if (resources != null) {
        ResourceType item = null;
        for (PrismObject<ResourceType> resource : resources) {
            item = resource.asObjectable();
            resourceList.add(new TaskAddResourcesDto(item.getOid(), WebComponentUtil.getOrigStringFromPoly(item.getName())));
        }
    }
    return resourceList;
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) Task(com.evolveum.midpoint.task.api.Task) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) TaskAddResourcesDto(com.evolveum.midpoint.web.page.admin.server.dto.TaskAddResourcesDto) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) SystemException(com.evolveum.midpoint.util.exception.SystemException)

Example 67 with Task

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

the class PageTaskEdit method refreshTaskModels.

public void refreshTaskModels() {
    TaskDto oldTaskDto = taskDtoModel.getObject();
    if (oldTaskDto == null) {
        LOGGER.warn("Null or empty taskModel");
        return;
    }
    TaskManager taskManager = getTaskManager();
    OperationResult result = new OperationResult("refresh");
    Task operationTask = taskManager.createTaskInstance("refresh");
    try {
        LOGGER.debug("Refreshing task {}", oldTaskDto);
        TaskType taskType = loadTaskType(oldTaskDto.getOid(), operationTask, result);
        TaskDto newTaskDto = prepareTaskDto(taskType, operationTask, result);
        final ObjectWrapper<TaskType> newWrapper = loadObjectWrapper(taskType.asPrismObject(), operationTask, result);
        previousTaskDto = currentTaskDto;
        currentTaskDto = newTaskDto;
        taskDtoModel.setObject(newTaskDto);
        objectWrapperModel.setObject(newWrapper);
    } catch (ObjectNotFoundException | SchemaException | ExpressionEvaluationException | RuntimeException | Error e) {
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't refresh task {}", e, oldTaskDto);
    }
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Task(com.evolveum.midpoint.task.api.Task) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) TaskManager(com.evolveum.midpoint.task.api.TaskManager) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) TaskDto(com.evolveum.midpoint.web.page.admin.server.dto.TaskDto)

Example 68 with Task

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

the class PageTaskController method savePerformed.

void savePerformed(AjaxRequestTarget target) {
    LOGGER.debug("Saving new task.");
    OperationResult result = new OperationResult(PageTaskEdit.OPERATION_SAVE_TASK);
    TaskDto dto = parentPage.getTaskDto();
    Task operationTask = parentPage.createSimpleTask(PageTaskEdit.OPERATION_SAVE_TASK);
    try {
        List<ItemDelta<?, ?>> itemDeltas = getDeltasToExecute(dto);
        ObjectDelta<TaskType> delta = ObjectDelta.createModifyDelta(dto.getOid(), itemDeltas, TaskType.class, parentPage.getPrismContext());
        final Collection<ObjectDelta<? extends ObjectType>> deltas = Collections.<ObjectDelta<? extends ObjectType>>singletonList(delta);
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Saving task modifications:\n{}", DebugUtil.debugDump(deltas));
        }
        parentPage.getModelService().executeChanges(deltas, null, operationTask, result);
        result.recomputeStatus();
    } catch (Exception ex) {
        result.recomputeStatus();
        result.recordFatalError("Couldn't save task.", ex);
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't save task modifications", ex);
    }
    afterSave(target, result);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) TaskDto(com.evolveum.midpoint.web.page.admin.server.dto.TaskDto) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException)

Example 69 with Task

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

the class RoleMemberPanel method recomputeMembersPerformed.

@Override
protected void recomputeMembersPerformed(QueryScope scope, AjaxRequestTarget target) {
    Task operationalTask = getPageBase().createSimpleTask(getTaskName("Recompute", scope));
    executeMemberOperation(operationalTask, FocusType.COMPLEX_TYPE, getActionQuery(scope), null, TaskCategory.RECOMPUTATION, target);
}
Also used : Task(com.evolveum.midpoint.task.api.Task)

Example 70 with Task

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

the class NodeDtoProvider method internalIterator.

@Override
public Iterator<? extends NodeDto> internalIterator(long first, long count) {
    Collection<String> selectedOids = getSelectedOids();
    getAvailableData().clear();
    OperationResult result = new OperationResult(OPERATION_LIST_NODES);
    Task task = getTaskManager().createTaskInstance(OPERATION_LIST_NODES);
    try {
        ObjectPaging paging = createPaging(first, count);
        ObjectQuery query = getQuery();
        if (query == null) {
            query = new ObjectQuery();
        }
        query.setPaging(paging);
        List<PrismObject<NodeType>> nodes = getModel().searchObjects(NodeType.class, query, null, task, result);
        for (PrismObject<NodeType> node : nodes) {
            getAvailableData().add(createNodeDto(node));
        }
        result.recordSuccess();
    } catch (Exception ex) {
        LoggingUtils.logUnexpectedException(LOGGER, "Unhandled exception when listing nodes", ex);
        result.recordFatalError("Couldn't list nodes.", ex);
    }
    setSelectedOids(selectedOids);
    return getAvailableData().iterator();
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) Task(com.evolveum.midpoint.task.api.Task) ObjectPaging(com.evolveum.midpoint.prism.query.ObjectPaging) NodeType(com.evolveum.midpoint.xml.ns._public.common.common_3.NodeType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

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