Search in sources :

Example 66 with ObjectQuery

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());
    }
}
Also used : SearchResultList(com.evolveum.midpoint.schema.SearchResultList) Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ArrayList(java.util.ArrayList) List(java.util.List) SearchResultList(com.evolveum.midpoint.schema.SearchResultList) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) WorkItemType(com.evolveum.midpoint.xml.ns._public.common.common_3.WorkItemType) Test(org.testng.annotations.Test)

Example 67 with ObjectQuery

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());
}
Also used : Task(com.evolveum.midpoint.task.api.Task) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) WorkItemType(com.evolveum.midpoint.xml.ns._public.common.common_3.WorkItemType) Test(org.testng.annotations.Test)

Example 68 with ObjectQuery

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());
}
Also used : ExpectedTask(com.evolveum.midpoint.wf.impl.policy.ExpectedTask) Task(com.evolveum.midpoint.task.api.Task) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) WorkItemType(com.evolveum.midpoint.xml.ns._public.common.common_3.WorkItemType)

Example 69 with ObjectQuery

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();
    }
}
Also used : AccessCertificationCaseType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType) PrismContainerValue(com.evolveum.midpoint.prism.PrismContainerValue) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) RQuery(com.evolveum.midpoint.repo.sql.query.RQuery) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) AccessCertificationWorkItemType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationWorkItemType)

Example 70 with ObjectQuery

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);
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) Task(com.evolveum.midpoint.task.api.Task) ObjectPaging(com.evolveum.midpoint.prism.query.ObjectPaging) SearchResultMetadata(com.evolveum.midpoint.schema.SearchResultMetadata) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) Test(org.testng.annotations.Test)

Aggregations

ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)697 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)453 Test (org.testng.annotations.Test)335 PrismObject (com.evolveum.midpoint.prism.PrismObject)284 Task (com.evolveum.midpoint.task.api.Task)268 QName (javax.xml.namespace.QName)111 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)78 SearchResultMetadata (com.evolveum.midpoint.schema.SearchResultMetadata)76 ObjectFilter (com.evolveum.midpoint.prism.query.ObjectFilter)64 ArrayList (java.util.ArrayList)61 ObjectPaging (com.evolveum.midpoint.prism.query.ObjectPaging)58 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)53 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)41 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)41 SystemException (com.evolveum.midpoint.util.exception.SystemException)38 SelectorOptions (com.evolveum.midpoint.schema.SelectorOptions)37 NotNull (org.jetbrains.annotations.NotNull)35 List (java.util.List)33 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)32 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)27