use of com.evolveum.midpoint.prism.query.ObjectQuery in project midpoint by Evolveum.
the class TestActivitiQuery method test100SearchByMoreAssignees.
@Test
public void test100SearchByMoreAssignees() throws Exception {
final String TEST_NAME = "test100SearchByMoreAssignees";
TestUtil.displayTestTile(this, TEST_NAME);
login(userAdministrator);
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
// should start approval process
assignRole(userJackOid, roleRole1aOid, task, result);
assertNotAssignedRole(userJackOid, roleRole1aOid, task, result);
{
SearchResultList<WorkItemType> itemsAll = modelService.searchContainers(WorkItemType.class, null, null, task, result);
assertEquals("Wrong # of total work items", 1, itemsAll.size());
}
{
ObjectQuery query2 = QueryBuilder.queryFor(WorkItemType.class, prismContext).item(WorkItemType.F_ASSIGNEE_REF).ref(userLead1Oid).build();
SearchResultList<WorkItemType> items2 = modelService.searchContainers(WorkItemType.class, query2, null, task, result);
assertEquals("Wrong # of work items found using single-assignee query", 1, items2.size());
}
{
List<PrismReferenceValue> refs = new ArrayList<>();
refs.add(prv("oid-number-1"));
refs.add(prv(userLead1Oid));
refs.add(prv("oid-number-3"));
ObjectQuery query3 = QueryBuilder.queryFor(WorkItemType.class, prismContext).item(WorkItemType.F_ASSIGNEE_REF).ref(refs).build();
SearchResultList<WorkItemType> items3 = modelService.searchContainers(WorkItemType.class, query3, null, task, result);
assertEquals("Wrong # of work items found using multi-assignee query", 1, items3.size());
}
}
use of com.evolveum.midpoint.prism.query.ObjectQuery in project midpoint by Evolveum.
the class TestActivitiQuery method test300SearchByAssignee.
@Test
public void test300SearchByAssignee() throws Exception {
final String TEST_NAME = "test210SearchByAssignee";
TestUtil.displayTestTile(this, TEST_NAME);
login(userAdministrator);
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
List<PrismReferenceValue> assigneeRefs = new ArrayList<>();
assigneeRefs.add(prv("oid-number-1"));
assigneeRefs.add(prv(userLead1Oid));
assigneeRefs.add(prv("oid-number-3"));
assigneeRefs.add(prv("oid-number-4"));
assigneeRefs.add(prv("oid-number-5"));
assigneeRefs.add(prv("oid-number-6"));
ObjectQuery query = QueryBuilder.queryFor(WorkItemType.class, prismContext).item(WorkItemType.F_ASSIGNEE_REF).ref(assigneeRefs).build();
SearchResultList<WorkItemType> items = modelService.searchContainers(WorkItemType.class, query, null, task, result);
assertEquals("Wrong # of work items found using multi-assignee/multi-delegate query", 1, items.size());
}
use of com.evolveum.midpoint.prism.query.ObjectQuery in project midpoint by Evolveum.
the class AbstractTestAssignmentApproval method assertActiveWorkItems.
protected void assertActiveWorkItems(String approverOid, int expectedCount) throws Exception {
if (approverOid == null && expectedCount == 0) {
return;
}
Task task = createTask("query");
ObjectQuery query = QueryBuilder.queryFor(WorkItemType.class, prismContext).item(WorkItemType.F_ASSIGNEE_REF).ref(getPotentialAssignees(getUser(approverOid))).build();
List<WorkItemType> items = modelService.searchContainers(WorkItemType.class, query, null, task, task.getResult());
assertEquals("Wrong active work items for " + approverOid, expectedCount, items.size());
}
use of com.evolveum.midpoint.prism.query.ObjectQuery in project midpoint by Evolveum.
the class CertificationCaseHelper method updateLoadedCertificationWorkItem.
public AccessCertificationWorkItemType updateLoadedCertificationWorkItem(GetCertificationWorkItemResult result, // key=OID:ID
Map<String, PrismContainerValue<AccessCertificationCaseType>> casesCache, // key=OID
Map<String, PrismObject<AccessCertificationCampaignType>> campaignsCache, Collection<SelectorOptions<GetOperationOptions>> options, QueryEngine2 engine, Session session, OperationResult operationResult) throws SchemaException, QueryException {
String campaignOid = result.getCampaignOid();
Integer caseId = result.getCaseId();
Integer workItemId = result.getId();
String caseKey = campaignOid + ":" + caseId;
PrismContainerValue<AccessCertificationCaseType> casePcv = casesCache.get(caseKey);
if (casePcv == null) {
ObjectQuery query = QueryBuilder.queryFor(AccessCertificationCaseType.class, prismContext).ownerId(campaignOid).and().id(caseId).build();
RQuery caseQuery = engine.interpret(query, AccessCertificationCaseType.class, null, false, session);
List<GetContainerableResult> cases = caseQuery.list();
if (cases.size() > 1) {
throw new IllegalStateException("More than one certification case found for campaign " + campaignOid + ", ID " + caseId);
} else if (cases.isEmpty()) {
// we need it, because otherwise we have only identifiers for the work item, no data
throw new IllegalStateException("No certification case found for campaign " + campaignOid + ", ID " + caseId);
}
AccessCertificationCaseType _case = updateLoadedCertificationCase(cases.get(0), campaignsCache, null, session, operationResult);
casePcv = _case.asPrismContainerValue();
casesCache.put(caseKey, casePcv);
}
@SuppressWarnings({ "raw", "unchecked" }) PrismContainerValue<AccessCertificationWorkItemType> workItemPcv = (PrismContainerValue<AccessCertificationWorkItemType>) casePcv.find(new ItemPath(AccessCertificationCaseType.F_WORK_ITEM, workItemId));
if (workItemPcv == null) {
throw new IllegalStateException("No work item " + workItemId + " in " + casePcv);
} else {
return workItemPcv.asContainerable();
}
}
use of com.evolveum.midpoint.prism.query.ObjectQuery in project midpoint by Evolveum.
the class AbstractLdapConnTest method test162SeachFirst50AccountsOffset0.
@Test
public void test162SeachFirst50AccountsOffset0() throws Exception {
final String TEST_NAME = "test152SeachFirst50Accounts";
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.setOffset(0);
paging.setMaxSize(50);
query.setPaging(paging);
SearchResultList<PrismObject<ShadowType>> searchResultList = doSearch(TEST_NAME, query, 50, task, result);
assertConnectorOperationIncrement(1, 51);
assertConnectorSimulatedPagingSearchIncrement(0);
SearchResultMetadata metadata = searchResultList.getMetadata();
if (metadata != null) {
assertFalse(metadata.isPartialResults());
}
assertLdapConnectorInstances(1, 2);
}
Aggregations