Search in sources :

Example 16 with ObjectQuery

use of com.evolveum.midpoint.prism.query.ObjectQuery in project midpoint by Evolveum.

the class RoleMemberPanel method createTenantList.

private List<OrgType> createTenantList() {
    ObjectQuery query = QueryBuilder.queryFor(OrgType.class, getPrismContext()).item(OrgType.F_TENANT).eq(true).build();
    List<PrismObject<OrgType>> orgs = WebModelServiceUtils.searchObjects(OrgType.class, query, new OperationResult("Tenant search"), getPageBase());
    List<OrgType> orgTypes = new ArrayList<>();
    for (PrismObject<OrgType> org : orgs) {
        orgTypes.add(org.asObjectable());
    }
    return orgTypes;
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

Example 17 with ObjectQuery

use of com.evolveum.midpoint.prism.query.ObjectQuery 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();
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) Task(com.evolveum.midpoint.task.api.Task) ObjectPaging(com.evolveum.midpoint.prism.query.ObjectPaging) NodeType(com.evolveum.midpoint.xml.ns._public.common.common_3.NodeType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

Example 18 with ObjectQuery

use of com.evolveum.midpoint.prism.query.ObjectQuery in project midpoint by Evolveum.

the class TestCertificationBasic method test054SearchDecisionsByOrgRef.

@Test
public void test054SearchDecisionsByOrgRef() throws Exception {
    final String TEST_NAME = "test054SearchDecisionsByOrgRef";
    TestUtil.displayTestTile(this, TEST_NAME);
    login(getUserFromRepo(USER_ADMINISTRATOR_OID));
    // GIVEN
    Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    ObjectQuery query = QueryBuilder.queryFor(AccessCertificationWorkItemType.class, prismContext).exists(T_PARENT).block().item(AccessCertificationCaseType.F_ORG_REF).ref(ORG_SCUMM_BAR_OID).and().ownerId(campaignOid).endBlock().build();
    List<AccessCertificationWorkItemType> workItems = certificationService.searchOpenWorkItems(query, false, null, task, result);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    display("workItems", workItems);
    assertEquals("Wrong number of certification work items", 1, workItems.size());
    checkWorkItem(workItems, USER_JACK_OID, ROLE_CEO_OID, userJack, campaignOid, ORG_GOVERNOR_OFFICE_OID, ORG_SCUMM_BAR_OID, ENABLED);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) Test(org.testng.annotations.Test)

Example 19 with ObjectQuery

use of com.evolveum.midpoint.prism.query.ObjectQuery in project midpoint by Evolveum.

the class TestSoDCertification method test200StartRemediation.

@Test
public void test200StartRemediation() throws Exception {
    final String TEST_NAME = "test200StartRemediation";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(TestSoDCertification.class.getName() + "." + TEST_NAME);
    task.setOwner(userAdministrator.asPrismObject());
    OperationResult result = task.getResult();
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    certificationManager.startRemediation(campaignOid, task, result);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    result.computeStatus();
    TestUtil.assertInProgressOrSuccess(result);
    AccessCertificationCampaignType campaign = getCampaignWithCases(campaignOid);
    display("campaign after remediation start", campaign);
    assertTrue("wrong campaign state: " + campaign.getState(), campaign.getState() == CLOSED || campaign.getState() == IN_REMEDIATION);
    ObjectQuery query = QueryBuilder.queryFor(TaskType.class, prismContext).item(TaskType.F_OBJECT_REF).ref(campaign.getOid()).build();
    List<PrismObject<TaskType>> tasks = taskManager.searchObjects(TaskType.class, query, null, result);
    assertEquals("unexpected number of related tasks", 1, tasks.size());
    waitForTaskFinish(tasks.get(0).getOid(), true);
    campaign = getCampaignWithCases(campaignOid);
    display("campaign after remediation finished", campaign);
    assertEquals("wrong campaign state", CLOSED, campaign.getState());
    assertEquals("wrong campaign stage", 2, campaign.getStageNumber());
    assertDefinitionAndOwner(campaign, certificationDefinition);
    assertApproximateTime("end time", new Date(), campaign.getEndTimestamp());
    assertEquals("wrong # of stages", 1, campaign.getStage().size());
    List<AccessCertificationCaseType> caseList = queryHelper.searchCases(campaignOid, null, null, result);
    assertEquals("wrong # of cases", 5, caseList.size());
    AccessCertificationCaseType test2aCase = findCase(caseList, USER_JACK_OID, roleATest2aOid);
    assertApproximateTime("test2aCase.remediedTimestamp", new Date(), test2aCase.getRemediedTimestamp());
    userJack = getUser(USER_JACK_OID).asObjectable();
    display("userJack after remediation", userJack);
    assertNotAssignedRole(userJack.asPrismObject(), roleATest2aOid);
    PrismObject<AccessCertificationDefinitionType> def = getObject(AccessCertificationDefinitionType.class, certificationDefinition.getOid());
    assertApproximateTime("last campaign closed", new Date(), def.asObjectable().getLastCampaignClosedTimestamp());
    assertPercentComplete(campaign, 100, 100, 100);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) Date(java.util.Date) PrismObject(com.evolveum.midpoint.prism.PrismObject) Test(org.testng.annotations.Test)

Example 20 with ObjectQuery

use of com.evolveum.midpoint.prism.query.ObjectQuery in project midpoint by Evolveum.

the class TestCertificationBasic method test040SearchCasesFilteredSortedPaged.

@Test
public void test040SearchCasesFilteredSortedPaged() throws Exception {
    final String TEST_NAME = "test040SearchCasesFilteredSortedPaged";
    TestUtil.displayTestTile(this, TEST_NAME);
    login(getUserFromRepo(USER_BOB_OID));
    // GIVEN
    Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    Collection<SelectorOptions<GetOperationOptions>> resolveNames = SelectorOptions.createCollection(GetOperationOptions.createResolveNames());
    ObjectQuery query = QueryBuilder.queryFor(AccessCertificationCaseType.class, prismContext).item(AccessCertificationCaseType.F_OBJECT_REF).ref(userAdministrator.getOid()).desc(AccessCertificationCaseType.F_TARGET_REF, PrismConstants.T_OBJECT_REFERENCE, ObjectType.F_NAME).offset(2).maxSize(2).build();
    List<AccessCertificationCaseType> caseList = modelService.searchContainers(AccessCertificationCaseType.class, query, resolveNames, task, result);
    // THEN
    // Cases for administrator are (ordered by name, descending):
    //  - Superuser
    //  - ERoot
    //  - COO
    //  - CEO
    // so paging (2, 2) should return the last two
    TestUtil.displayThen(TEST_NAME);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    display("caseList", caseList);
    assertEquals("Wrong number of certification cases", 2, caseList.size());
    checkCase(caseList, USER_ADMINISTRATOR_OID, ROLE_COO_OID, userAdministrator, campaignOid);
    checkCase(caseList, USER_ADMINISTRATOR_OID, ROLE_CEO_OID, userAdministrator, campaignOid);
    assertEquals("Wrong target OID in case #0", ROLE_COO_OID, caseList.get(0).getTargetRef().getOid());
    assertEquals("Wrong target OID in case #1", ROLE_CEO_OID, caseList.get(1).getTargetRef().getOid());
}
Also used : Task(com.evolveum.midpoint.task.api.Task) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) 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)355 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)241 PrismObject (com.evolveum.midpoint.prism.PrismObject)217 Test (org.testng.annotations.Test)159 Task (com.evolveum.midpoint.task.api.Task)150 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)67 QName (javax.xml.namespace.QName)58 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)50 ArrayList (java.util.ArrayList)50 SearchResultMetadata (com.evolveum.midpoint.schema.SearchResultMetadata)38 ObjectPaging (com.evolveum.midpoint.prism.query.ObjectPaging)35 SelectorOptions (com.evolveum.midpoint.schema.SelectorOptions)33 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)30 ObjectFilter (com.evolveum.midpoint.prism.query.ObjectFilter)25 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)23 ResultHandler (com.evolveum.midpoint.schema.ResultHandler)21 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)18 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)17 QueryType (com.evolveum.prism.xml.ns._public.query_3.QueryType)17 PrismReferenceValue (com.evolveum.midpoint.prism.PrismReferenceValue)16