Search in sources :

Example 1 with ObjectPaging

use of com.evolveum.midpoint.prism.query.ObjectPaging in project midpoint by Evolveum.

the class TaskDtoProvider method internalIterator.

@Override
public Iterator<? extends TaskDto> internalIterator(long first, long count) {
    Collection<String> selectedOids = getSelectedOids();
    getAvailableData().clear();
    OperationResult result = new OperationResult(OPERATION_LIST_TASKS);
    Task operationTask = getTaskManager().createTaskInstance(OPERATION_LIST_TASKS);
    try {
        ObjectPaging paging = createPaging(first, count);
        ObjectQuery query = getQuery();
        if (query == null) {
            query = new ObjectQuery();
        }
        query.setPaging(paging);
        List<QName> propertiesToGet = new ArrayList<>();
        if (options.isUseClusterInformation()) {
            propertiesToGet.add(TaskType.F_NODE_AS_OBSERVED);
        }
        if (options.isGetNextRunStartTime()) {
            propertiesToGet.add(TaskType.F_NEXT_RUN_START_TIMESTAMP);
            propertiesToGet.add(TaskType.F_NEXT_RETRY_TIMESTAMP);
        }
        Collection<SelectorOptions<GetOperationOptions>> searchOptions = GetOperationOptions.createRetrieveAttributesOptions(propertiesToGet.toArray(new QName[0]));
        List<PrismObject<TaskType>> tasks = getModel().searchObjects(TaskType.class, query, searchOptions, operationTask, result);
        for (PrismObject<TaskType> task : tasks) {
            try {
                TaskDto taskDto = createTaskDto(task, operationTask, result);
                getAvailableData().add(taskDto);
            } catch (Exception ex) {
                LoggingUtils.logUnexpectedException(LOGGER, "Unhandled exception when getting task {} details", ex, task.getOid());
                result.recordPartialError("Couldn't get details of task " + task.getOid(), ex);
            // todo display the result somehow
            }
        }
    } catch (Exception ex) {
        LoggingUtils.logUnexpectedException(LOGGER, "Unhandled exception when listing tasks", ex);
        result.recordFatalError("Couldn't list tasks.", ex);
    } finally {
        if (result.hasUnknownStatus()) {
            result.recomputeStatus();
        }
    }
    setSelectedOids(selectedOids);
    return getAvailableData().iterator();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) QName(javax.xml.namespace.QName) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) PrismObject(com.evolveum.midpoint.prism.PrismObject) ObjectPaging(com.evolveum.midpoint.prism.query.ObjectPaging) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType)

Example 2 with ObjectPaging

use of com.evolveum.midpoint.prism.query.ObjectPaging 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)

Example 3 with ObjectPaging

use of com.evolveum.midpoint.prism.query.ObjectPaging in project midpoint by Evolveum.

the class SelectableBeanObjectDataProvider method internalIterator.

@Override
public Iterator<SelectableBean<O>> internalIterator(long offset, long pageSize) {
    LOGGER.trace("begin::iterator() offset {} pageSize {}.", new Object[] { offset, pageSize });
    //        if (pageSize > 1000000) {
    //        	// Failsafe. Do not even try this. This can have huge impact on the resource. (MID-3336)
    //        	throw new IllegalArgumentException("Requested huge page size: "+pageSize);
    //        }
    preprocessSelectedData();
    OperationResult result = new OperationResult(OPERATION_SEARCH_OBJECTS);
    try {
        ObjectPaging paging = createPaging(offset, pageSize);
        Task task = getPage().createSimpleTask(OPERATION_SEARCH_OBJECTS);
        ObjectQuery query = getQuery();
        if (query == null) {
            if (emptyListOnNullQuery) {
                return new ArrayList<SelectableBean<O>>().iterator();
            }
            query = new ObjectQuery();
        }
        query.setPaging(paging);
        if (LOGGER.isTraceEnabled()) {
            LOGGER.trace("Query {} with {}", type.getSimpleName(), query.debugDump());
        }
        if (ResourceType.class.equals(type) && (options == null || options.isEmpty())) {
            options = SelectorOptions.createCollection(GetOperationOptions.createNoFetch());
        }
        List<PrismObject<? extends O>> list = (List) getModel().searchObjects(type, query, options, task, result);
        if (LOGGER.isTraceEnabled()) {
            LOGGER.trace("Query {} resulted in {} objects", type.getSimpleName(), list.size());
        }
        for (PrismObject<? extends O> object : list) {
            getAvailableData().add(createDataObjectWrapper(object.asObjectable()));
        }
    //            result.recordSuccess();
    } catch (Exception ex) {
        result.recordFatalError("Couldn't list objects.", ex);
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't list objects", ex);
        return handleNotSuccessOrHandledErrorInIterator(result);
    } finally {
        result.computeStatusIfUnknown();
    }
    LOGGER.trace("end::iterator() {}", result);
    return getAvailableData().iterator();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) RestartResponseException(org.apache.wicket.RestartResponseException) PrismObject(com.evolveum.midpoint.prism.PrismObject) ObjectPaging(com.evolveum.midpoint.prism.query.ObjectPaging) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) ArrayList(java.util.ArrayList) List(java.util.List)

Example 4 with ObjectPaging

use of com.evolveum.midpoint.prism.query.ObjectPaging in project midpoint by Evolveum.

the class ControllerListResourceObjectsTest method nullResult.

@Test(expectedExceptions = IllegalArgumentException.class)
public void nullResult() throws Exception {
    ObjectPaging paging = ObjectPaging.createPaging(0, Integer.MAX_VALUE, ObjectType.F_NAME, OrderDirection.ASCENDING);
    controller.listResourceObjects("1", new QName("local name"), paging, null, null);
}
Also used : ObjectPaging(com.evolveum.midpoint.prism.query.ObjectPaging) QName(javax.xml.namespace.QName) Test(org.testng.annotations.Test)

Example 5 with ObjectPaging

use of com.evolveum.midpoint.prism.query.ObjectPaging in project midpoint by Evolveum.

the class ControllerSearchObjectsTest method nullResult.

@Test(expectedExceptions = IllegalArgumentException.class)
public void nullResult() throws Exception {
    ObjectPaging paging = ObjectPaging.createPaging(0, Integer.MAX_VALUE, ObjectType.F_NAME, OrderDirection.ASCENDING);
    ObjectQuery query = ObjectQuery.createObjectQuery(paging);
    controller.searchObjects(null, query, null, null, null);
}
Also used : ObjectPaging(com.evolveum.midpoint.prism.query.ObjectPaging) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) Test(org.testng.annotations.Test)

Aggregations

ObjectPaging (com.evolveum.midpoint.prism.query.ObjectPaging)40 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)32 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)32 PrismObject (com.evolveum.midpoint.prism.PrismObject)28 Task (com.evolveum.midpoint.task.api.Task)28 Test (org.testng.annotations.Test)25 SearchResultMetadata (com.evolveum.midpoint.schema.SearchResultMetadata)17 SelectorOptions (com.evolveum.midpoint.schema.SelectorOptions)6 AbstractIntegrationTest (com.evolveum.midpoint.test.AbstractIntegrationTest)6 QueryType (com.evolveum.prism.xml.ns._public.query_3.QueryType)6 QName (javax.xml.namespace.QName)6 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)5 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)4 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)4 GetOperationOptions (com.evolveum.midpoint.schema.GetOperationOptions)3 RelationalValueSearchQuery (com.evolveum.midpoint.schema.RelationalValueSearchQuery)3 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)3 LookupTableType (com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableType)3 RestartResponseException (org.apache.wicket.RestartResponseException)3 CommunicationException (com.evolveum.midpoint.util.exception.CommunicationException)2