Search in sources :

Example 6 with ObjectQuery

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;
}
Also used : PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

Example 7 with ObjectQuery

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;
}
Also used : ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) AccessCertificationWorkItemType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationWorkItemType)

Example 8 with ObjectQuery

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);
    }
}
Also used : ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

Example 9 with ObjectQuery

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);
}
Also used : InOidFilter(com.evolveum.midpoint.prism.query.InOidFilter) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

Example 10 with ObjectQuery

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;
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

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