use of com.evolveum.midpoint.prism.query.ObjectQuery in project midpoint by Evolveum.
the class OrgMemberPanel method createManagerQuery.
private ObjectQuery createManagerQuery() {
String oid = getModelObject().getOid();
PrismReferenceValue referenceFilter = new PrismReferenceValue();
referenceFilter.setOid(oid);
referenceFilter.setRelation(SchemaConstants.ORG_MANAGER);
ObjectQuery query = QueryBuilder.queryFor(FocusType.class, getPageBase().getPrismContext()).item(FocusType.F_PARENT_ORG_REF).ref(referenceFilter).build();
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Searching members of org {} with query:\n{}", oid, query.debugDump());
}
return query;
}
use of com.evolveum.midpoint.prism.query.ObjectQuery in project midpoint by Evolveum.
the class AccCertQueryHelper method searchOpenWorkItems.
// public because of testing
// principal == null => take all work items
public List<AccessCertificationWorkItemType> searchOpenWorkItems(ObjectQuery baseWorkItemsQuery, MidPointPrincipal principal, boolean notDecidedOnly, Collection<SelectorOptions<GetOperationOptions>> options, OperationResult result) throws SchemaException, ObjectNotFoundException {
// enhance filter with reviewerRef + enabled
ObjectQuery newQuery;
ObjectFilter reviewerAndEnabledFilter = getReviewerAndEnabledFilterForWI(principal);
ObjectFilter filterToAdd;
if (notDecidedOnly) {
ObjectFilter noResponseFilter = QueryBuilder.queryFor(AccessCertificationWorkItemType.class, prismContext).item(F_OUTPUT, F_OUTCOME).isNull().buildFilter();
filterToAdd = AndFilter.createAnd(reviewerAndEnabledFilter, noResponseFilter);
} else {
filterToAdd = reviewerAndEnabledFilter;
}
newQuery = replaceFilter(baseWorkItemsQuery, filterToAdd);
// retrieve cases, filtered
List<AccessCertificationWorkItemType> workItems = repositoryService.searchContainers(AccessCertificationWorkItemType.class, newQuery, options, result);
return workItems;
}
use of com.evolveum.midpoint.prism.query.ObjectQuery in project midpoint by Evolveum.
the class AccCertQueryHelper method getCase.
public AccessCertificationCaseType getCase(String campaignOid, long caseId, Task task, OperationResult result) throws SchemaException, SecurityViolationException {
ObjectFilter filter = AndFilter.createAnd(InOidFilter.createOwnerHasOidIn(campaignOid), InOidFilter.createInOid(String.valueOf(caseId)));
ObjectQuery query = ObjectQuery.createObjectQuery(filter);
List<AccessCertificationCaseType> caseList = repositoryService.searchContainers(AccessCertificationCaseType.class, query, null, result);
if (caseList.isEmpty()) {
return null;
} else if (caseList.size() == 1) {
return caseList.get(0);
} else {
throw new IllegalStateException("More than one certification case with ID " + caseId + " in campaign " + campaignOid);
}
}
use of com.evolveum.midpoint.prism.query.ObjectQuery in project midpoint by Evolveum.
the class AccCertQueryHelper method searchCases.
// public because of certification tests
public List<AccessCertificationCaseType> searchCases(String campaignOid, ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> options, OperationResult result) throws SchemaException {
ObjectQuery newQuery;
InOidFilter inOidFilter = InOidFilter.createOwnerHasOidIn(campaignOid);
newQuery = replaceFilter(query, inOidFilter);
return repositoryService.searchContainers(AccessCertificationCaseType.class, newQuery, options, result);
}
use of com.evolveum.midpoint.prism.query.ObjectQuery in project midpoint by Evolveum.
the class AccCertReviewersHelper method getAssignees.
private List<ObjectReferenceType> getAssignees(AbstractRoleType role, QName relation, Task task, OperationResult result) throws SchemaException {
List<ObjectReferenceType> rv = new ArrayList<>();
if (SchemaConstants.ORG_OWNER.equals(relation)) {
CollectionUtils.addIgnoreNull(rv, role.getOwnerRef());
} else if (SchemaConstants.ORG_APPROVER.equals(relation)) {
rv.addAll(role.getApproverRef());
} else {
throw new AssertionError(relation);
}
// TODO in theory, we could look for approvers/owners of UserType, right?
PrismReferenceValue ref = new PrismReferenceValue(role.getOid());
ref.setRelation(relation);
ObjectQuery query = QueryBuilder.queryFor(FocusType.class, prismContext).item(FocusType.F_ROLE_MEMBERSHIP_REF).ref(ref).build();
List<PrismObject<FocusType>> assignees = repositoryService.searchObjects(FocusType.class, query, null, result);
LOGGER.trace("Looking for '{}' of {} using {}: found: {}", relation.getLocalPart(), role, query, assignees);
assignees.forEach(o -> rv.add(ObjectTypeUtil.createObjectRef(o)));
return rv;
}
Aggregations