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();
}
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();
}
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();
}
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);
}
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);
}
Aggregations