public SearchResultList<T> clone() { SearchResultList<T> clone = new SearchResultList<>(); clone.metadata = this.metadata; // considered read-only object if (this.list != null) { clone.list = new ArrayList(this.list.size()); for (T item : this.list) { clone.list.add(CloneUtil.clone(item)); } } return clone; }
@NotNull @Override public <T extends ObjectType> SearchResultList<PrismObject<T>> searchObjects(Class<T> type, ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> options, OperationResult result) throws SchemaException { Validate.notNull(type, "Object type must not be null."); Validate.notNull(result, "Operation result must not be null."); logSearchInputParameters(type, query, false, null); OperationResult subResult = result.createSubresult(SEARCH_OBJECTS); subResult.addParam("type", type.getName()); subResult.addParam("query", query); return executeQueryAttempts(query, "searchObjects", "searching", subResult, () -> new SearchResultList<>(new ArrayList<PrismObject<T>>(0)), (q) -> objectRetriever.searchObjectsAttempt(type, q, options, subResult)); }
private SearchResultList<WorkItemType> tasksToWorkItems(List<Task> tasks, Map<String, Object> processVariables, boolean resolveTask, boolean resolveAssignee, boolean resolveCandidates, boolean fetchAllVariables, OperationResult result) { SearchResultList<WorkItemType> retval = new SearchResultList<>(new ArrayList<WorkItemType>()); for (Task task : tasks) { try { retval.add(taskToWorkItem(task, processVariables, resolveTask, resolveAssignee, resolveCandidates, fetchAllVariables, result)); } catch (RuntimeException e) { // operation result already contains corresponding error record LoggingUtils.logUnexpectedException(LOGGER, "Couldn't get information on activiti task {}", e, task.getId()); } } return retval; }
@Override public <T extends Containerable> SearchResultList<T> searchContainers(Class<T> type, ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> options, OperationResult parentResult) throws SchemaException { Validate.notNull(type, "Object type must not be null."); Validate.notNull(parentResult, "Operation result must not be null."); logSearchInputParameters(type, query, false, null); OperationResult result = parentResult.createSubresult(SEARCH_CONTAINERS); result.addParam("type", type.getName()); result.addParam("query", query); return executeQueryAttempts(query, "searchContainers", "searching", result, () -> new SearchResultList<>(new ArrayList<T>(0)), (q) -> objectRetriever.searchContainersAttempt(type, q, options, result)); }
public SearchResultList<PrismObject<ShadowType>> searchObjects(ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> options, final boolean readFromRepository, Task task, final OperationResult parentResult) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { SearchResultList<PrismObject<ShadowType>> list = new SearchResultList<>(); SearchResultMetadata metadata = searchObjectsIterative(query, options, (shadow,result) -> list.add(shadow), readFromRepository, task, parentResult); list.setMetadata(metadata); return list; }
public <T extends Containerable> SearchResultList<T> searchContainers(Class<T> type, ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> options, OperationResult result) throws SchemaException { if (!CaseWorkItemType.class.equals(type)) { throw new UnsupportedOperationException("searchContainers is supported only for CaseWorkItemType, not for " + type); } List<CaseWorkItemType> allValues = new ArrayList<>(); SearchResultList<PrismObject<CaseType>> cases = cacheRepositoryService .searchObjects(CaseType.class, null, null, result); for (PrismObject<CaseType> aCase : cases) { allValues.addAll(CloneUtil.cloneCollectionMembers(aCase.asObjectable().getWorkItem())); } if (query == null) { //noinspection unchecked return (SearchResultList<T>) new SearchResultList<>(allValues); } List<CaseWorkItemType> filtered = doFiltering(query, allValues, (v) -> v.asPrismContainerValue()); List<CaseWorkItemType> paged = doPaging(query, filtered, (v) -> v.asPrismContainerValue()); //noinspection unchecked return (SearchResultList<T>) new SearchResultList<>(paged); }
@Override public Object answer(InvocationOnMock invocation) throws Throwable { Object answer = super.answer(invocation); if (answer != null) { return null; } Class returnType = invocation.getMethod().getReturnType(); if (SearchResultList.class.isAssignableFrom(returnType)) { return new SearchResultList(new ArrayList<>(0)); } return null; } }
public <T extends ObjectType> SearchResultList<PrismObject<T>> searchObjects(Class<T> type, ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> options, OperationResult result) throws SchemaException { SearchResultList<PrismObject<T>> allObjects = cacheRepositoryService.searchObjects(type, null, options, result); if (query == null) { return allObjects; } List<PrismObject<T>> filtered = doFiltering(query, allObjects, (o) -> o.getValue()); List<PrismObject<T>> paged = doPaging(query, filtered, (o) -> o.getValue()); return new SearchResultList<>(paged); }
@NotNull public <T extends ObjectType> SearchResultList<PrismObject<T>> searchObjectsAttempt(Class<T> type, ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> options, OperationResult result) throws SchemaException { LOGGER_PERFORMANCE.debug("> search objects {}", type.getSimpleName()); Session session = null; try { session = baseHelper.beginReadOnlyTransaction(); RQuery rQuery; QueryEngine2 engine = new QueryEngine2(getConfiguration(), extItemDictionary, prismContext, relationRegistry); rQuery = engine.interpret(query, type, options, false, session); @SuppressWarnings({"unchecked", "raw"}) List<GetObjectResult> queryResult = rQuery.list(); LOGGER.trace("Found {} objects, translating to JAXB.", queryResult != null ? queryResult.size() : 0); List<PrismObject<T>> list = queryResultToPrismObjects(queryResult, type, options, session, result); session.getTransaction().commit(); return new SearchResultList<>(list); } catch (QueryException | RuntimeException ex) { baseHelper.handleGeneralException(ex, session, result); throw new IllegalStateException("shouldn't get here"); } finally { baseHelper.cleanupSessionAndResult(session, result); } }
return new SearchResultList<>(list);
public SearchResultList<WorkItemType> searchWorkItems(ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> options, OperationResult result) throws SchemaException { TaskQuery taskQuery = createTaskQuery(query, true, options, result); if (taskQuery == null) { return new SearchResultList<>(Collections.emptyList()); } Integer offset = query != null ? query.getOffset() : null; Integer maxSize = query != null ? query.getMaxSize() : null; List<Task> tasks; if (offset == null && maxSize == null) { tasks = taskQuery.list(); } else { tasks = taskQuery.listPage(defaultIfNull(offset, 0), defaultIfNull(maxSize, Integer.MAX_VALUE)); } boolean getAllVariables = true; // TODO implement based on options // there's no need to fill-in assignee details ; but candidates are necessary to fill-in; TODO implement based on options (resolve) return tasksToWorkItems(tasks, null, false, false, true, getAllVariables, result); }
return new SearchResultList<>(newValues, originalResultList.getMetadata());
public SearchResultList<PrismObject<TaskType>> searchTasks(ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> options, OperationResult result) throws SchemaException { ClusterStatusInformation clusterStatusInformation = getClusterStatusInformation(options, TaskType.class, true, result); // returns null if noFetch is set List<PrismObject<TaskType>> tasksInRepository; try { tasksInRepository = repositoryService.searchObjects(TaskType.class, query, options, result); } catch (SchemaException e) { result.recordFatalError("Couldn't get tasks from repository: " + e.getMessage(), e); throw e; } boolean retrieveNextRunStartTime = SelectorOptions.hasToLoadPath(TaskType.F_NEXT_RUN_START_TIMESTAMP, options); boolean retrieveRetryTime = SelectorOptions.hasToLoadPath(TaskType.F_NEXT_RETRY_TIMESTAMP, options); boolean retrieveNodeAsObserved = SelectorOptions.hasToLoadPath(TaskType.F_NODE_AS_OBSERVED, options); List<PrismObject<TaskType>> retval = new ArrayList<>(); for (PrismObject<TaskType> taskInRepository : tasksInRepository) { TaskType taskInResult = addTransientTaskInformation(taskInRepository, clusterStatusInformation, retrieveNextRunStartTime, retrieveRetryTime, retrieveNodeAsObserved, result); retval.add(taskInResult.asPrismObject()); } result.computeStatus(); return new SearchResultList<>(retval); }
result.addContext(OperationResult.CONTEXT_IMPLEMENTATION_CLASS, ProvisioningServiceImpl.class); final SearchResultList<PrismObject<T>> objListType = new SearchResultList<>(new ArrayList<PrismObject<T>>());
return new SearchResultList<>(new ArrayList<>()); list = new SearchResultList<>(new ArrayList<>());
return new SearchResultList<>(list);
return new SearchResultList<>(new ArrayList<>()); list = new SearchResultList<>(new ArrayList<PrismObject<T>>());
SearchResultList<PrismObject<T>> newObjListType = new SearchResultList(new ArrayList<PrismObject<T>>()); for (PrismObject<T> repoObject : repoObjects) { OperationResult objResult = new OperationResult(ProvisioningService.class.getName()