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;
}
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();
}
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);
}
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);
}
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());
}
Aggregations