use of com.evolveum.midpoint.prism.query.ObjectPaging in project midpoint by Evolveum.
the class WorkItemProvider method createTaskQuery.
// primitive 'query interpreter'
// returns null if no results should be returned
private TaskQuery createTaskQuery(ObjectQuery query, boolean includeVariables, Collection<SelectorOptions<GetOperationOptions>> options, OperationResult result) throws SchemaException {
FilterComponents components = factorOutQuery(query, F_ASSIGNEE_REF, F_CANDIDATE_REF, F_EXTERNAL_ID);
List<ObjectFilter> remainingClauses = components.getRemainderClauses();
if (!remainingClauses.isEmpty()) {
throw new SchemaException("Unsupported clause(s) in search filter: " + remainingClauses);
}
final ItemPath WORK_ITEM_ID_PATH = new ItemPath(F_EXTERNAL_ID);
final ItemPath ASSIGNEE_PATH = new ItemPath(F_ASSIGNEE_REF);
final ItemPath CANDIDATE_PATH = new ItemPath(F_CANDIDATE_REF);
final ItemPath CREATED_PATH = new ItemPath(WorkItemType.F_CREATE_TIMESTAMP);
final Map.Entry<ItemPath, Collection<? extends PrismValue>> workItemIdFilter = components.getKnownComponent(WORK_ITEM_ID_PATH);
final Map.Entry<ItemPath, Collection<? extends PrismValue>> assigneeFilter = components.getKnownComponent(ASSIGNEE_PATH);
final Map.Entry<ItemPath, Collection<? extends PrismValue>> candidateRolesFilter = components.getKnownComponent(CANDIDATE_PATH);
TaskQuery taskQuery = activitiEngine.getTaskService().createTaskQuery();
if (workItemIdFilter != null) {
Collection<? extends PrismValue> filterValues = workItemIdFilter.getValue();
if (filterValues.size() > 1) {
throw new IllegalArgumentException("In a query there must be exactly one value for workItemId: " + filterValues);
}
taskQuery = taskQuery.taskId(((PrismPropertyValue<String>) filterValues.iterator().next()).getValue());
}
if (assigneeFilter != null) {
taskQuery = addAssigneesToQuery(taskQuery, assigneeFilter);
}
if (candidateRolesFilter != null) {
// TODO what about candidate users? (currently these are not supported)
List<String> candidateGroups = MiscDataUtil.prismRefsToStrings((Collection<PrismReferenceValue>) candidateRolesFilter.getValue());
if (!candidateGroups.isEmpty()) {
taskQuery = taskQuery.taskCandidateGroupIn(candidateGroups);
} else {
// no groups -> no result
return null;
}
}
if (query != null && query.getPaging() != null) {
ObjectPaging paging = query.getPaging();
if (paging.getOrderingInstructions().size() > 1) {
throw new UnsupportedOperationException("Ordering by more than one property is not supported: " + paging.getOrderingInstructions());
} else if (paging.getOrderingInstructions().size() == 1) {
ItemPath orderBy = paging.getOrderBy();
if (CREATED_PATH.equivalent(orderBy)) {
taskQuery = taskQuery.orderByTaskCreateTime();
} else {
throw new UnsupportedOperationException("Ordering by " + orderBy + " is not currently supported");
}
switch(paging.getDirection()) {
case DESCENDING:
taskQuery = taskQuery.desc();
break;
case ASCENDING:
default:
taskQuery = taskQuery.asc();
break;
}
}
}
if (includeVariables) {
return taskQuery.includeTaskLocalVariables().includeProcessVariables();
} else {
return taskQuery;
}
}
use of com.evolveum.midpoint.prism.query.ObjectPaging in project midpoint by Evolveum.
the class SqlRepositoryServiceImpl method logSearchInputParameters.
private <T> void logSearchInputParameters(Class<T> type, ObjectQuery query, boolean iterative, Boolean strictlySequential) {
ObjectPaging paging = query != null ? query.getPaging() : null;
LOGGER.debug("Searching objects of type '{}', query (on trace level), offset {}, count {}, iterative {}, strictlySequential {}.", type.getSimpleName(), (paging != null ? paging.getOffset() : "undefined"), (paging != null ? paging.getMaxSize() : "undefined"), iterative, strictlySequential);
if (!LOGGER.isTraceEnabled()) {
return;
}
LOGGER.trace("Full query\n{}\nFull paging\n{}", new Object[] { (query == null ? "undefined" : query.debugDump()), (paging != null ? paging.debugDump() : "undefined") });
if (iterative) {
LOGGER.trace("Iterative search by paging: {}, batch size {}", getConfiguration().isIterativeSearchByPaging(), getConfiguration().getIterativeSearchByPagingBatchSize());
}
}
use of com.evolveum.midpoint.prism.query.ObjectPaging in project midpoint by Evolveum.
the class TestOpenDj method test234SearchObjectsPagedOffsetSortSn.
@Test
public void test234SearchObjectsPagedOffsetSortSn() throws Exception {
final String TEST_NAME = "test234SearchObjectsPagedOffsetSortSn";
TestUtil.displayTestTile(TEST_NAME);
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
QueryType queryType = PrismTestUtil.parseAtomicValue(QUERY_ALL_ACCOUNTS_FILE, QueryType.COMPLEX_TYPE);
ObjectQuery query = QueryJaxbConvertor.createObjectQuery(ShadowType.class, queryType, prismContext);
ObjectPaging paging = ObjectPaging.createPaging(2, 4);
paging.setOrdering(ObjectOrdering.createOrdering(new ItemPath(ShadowType.F_ATTRIBUTES, new QName(RESOURCE_NS, "sn")), OrderDirection.ASCENDING));
query.setPaging(paging);
rememberConnectorOperationCount();
rememberConnectorSimulatedPagingSearchCount();
// WHEN
TestUtil.displayWhen(TEST_NAME);
List<PrismObject<ShadowType>> searchResults = provisioningService.searchObjects(ShadowType.class, query, null, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
assertSuccess(result);
display("Search resutls", searchResults);
assertSearchResults(searchResults, "jbeckett", "jbond", "cook", "drake");
assertConnectorOperationIncrement(1, 9);
assertConnectorSimulatedPagingSearchIncrement(0);
}
use of com.evolveum.midpoint.prism.query.ObjectPaging in project midpoint by Evolveum.
the class TestOpenDj method test231SearchObjectsPagedOffsetZero.
@Test
public void test231SearchObjectsPagedOffsetZero() throws Exception {
final String TEST_NAME = "test231SearchObjectsPagedOffsetZero";
TestUtil.displayTestTile(TEST_NAME);
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
QueryType queryType = PrismTestUtil.parseAtomicValue(QUERY_ALL_ACCOUNTS_FILE, QueryType.COMPLEX_TYPE);
ObjectQuery query = QueryJaxbConvertor.createObjectQuery(ShadowType.class, queryType, prismContext);
ObjectPaging paging = ObjectPaging.createPaging(0, 4);
query.setPaging(paging);
rememberConnectorOperationCount();
rememberConnectorSimulatedPagingSearchCount();
// WHEN
TestUtil.displayWhen(TEST_NAME);
List<PrismObject<ShadowType>> searchResults = provisioningService.searchObjects(ShadowType.class, query, null, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
assertSuccess(result);
display("Search resutls", searchResults);
assertSearchResults(searchResults, "cook", "drake", "hbarbossa", "idm");
assertConnectorOperationIncrement(1, 9);
assertConnectorSimulatedPagingSearchIncrement(0);
}
use of com.evolveum.midpoint.prism.query.ObjectPaging in project midpoint by Evolveum.
the class AbstractAdLdapMultidomainTest method test152SeachFirst2Accounts.
/**
* This is in one block.
*/
@Test
public void test152SeachFirst2Accounts() throws Exception {
final String TEST_NAME = "test152SeachFirst2Accounts";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext);
ObjectPaging paging = ObjectPaging.createEmptyPaging();
paging.setMaxSize(2);
query.setPaging(paging);
SearchResultList<PrismObject<ShadowType>> searchResultList = doSearch(TEST_NAME, query, 2, task, result);
// assertConnectorOperationIncrement(1);
assertConnectorSimulatedPagingSearchIncrement(0);
SearchResultMetadata metadata = searchResultList.getMetadata();
if (metadata != null) {
assertFalse(metadata.isPartialResults());
}
// assertLdapConnectorInstances(2);
}
Aggregations