Search in sources :

Example 1 with InOidFilter

use of com.evolveum.midpoint.prism.query.InOidFilter 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 2 with InOidFilter

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

the class ImportRepositoryAction method execute.

@Override
public void execute() throws Exception {
    OperationResult result = new OperationResult(OPERATION_IMPORT);
    OperationStatus progress = new OperationStatus(context, result);
    BlockingQueue<ObjectType> queue = new LinkedBlockingQueue<>(QUEUE_CAPACITY_PER_THREAD * options.getMultiThread());
    // "+ 2" will be used for producer and progress reporter
    ExecutorService executor = Executors.newFixedThreadPool(options.getMultiThread() + 2);
    ImportProducerWorker<ObjectType> producer;
    if (options.getOid() != null) {
        InOidFilter filter = context.getPrismContext().queryFactory().createInOid(options.getOid());
        producer = importByFilter(filter, true, queue, progress);
    } else {
        ObjectFilter filter = NinjaUtils.createObjectFilter(options.getFilter(), context, ObjectType.class);
        producer = importByFilter(filter, false, queue, progress);
    }
    executor.execute(producer);
    Thread.sleep(CONSUMERS_WAIT_FOR_START);
    executor.execute(new ProgressReporterWorker<>(context, options, queue, progress));
    List<ImportRepositoryConsumerWorker> consumers = createConsumers(queue, progress);
    consumers.forEach(c -> executor.execute(c));
    executor.shutdown();
    boolean awaitResult = executor.awaitTermination(NinjaUtils.WAIT_FOR_EXECUTOR_FINISH, TimeUnit.DAYS);
    if (!awaitResult) {
        log.error("Executor did not finish before timeout");
    }
    handleResultOnFinish(progress, "Import finished");
}
Also used : InOidFilter(com.evolveum.midpoint.prism.query.InOidFilter) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) ImportRepositoryConsumerWorker(com.evolveum.midpoint.ninja.action.worker.ImportRepositoryConsumerWorker) OperationStatus(com.evolveum.midpoint.ninja.util.OperationStatus)

Example 3 with InOidFilter

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

the class PageDebugList method createDeleteAllUsersQuery.

private ObjectQuery createDeleteAllUsersQuery() {
    InOidFilter inOid = InOidFilter.createInOid(SystemObjectsType.USER_ADMINISTRATOR.value());
    NotFilter not = new NotFilter(inOid);
    return ObjectQuery.createObjectQuery(not);
}
Also used : InOidFilter(com.evolveum.midpoint.prism.query.InOidFilter) NotFilter(com.evolveum.midpoint.prism.query.NotFilter)

Example 4 with InOidFilter

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

the class TestAdHocCertification method test010HireUserOutOfScope.

@Test
public void test010HireUserOutOfScope() throws Exception {
    // GIVEN
    Task task = getTestTask();
    task.setOwner(userAdministrator.asPrismObject());
    OperationResult result = task.getResult();
    // WHEN
    when();
    assignOrg(USER_INDIGO_OID, ORG_LABORATORY_OID, task, result);
    // THEN
    then();
    result.computeStatus();
    TestUtil.assertSuccess(result);
    SearchResultList<PrismObject<AccessCertificationCampaignType>> campaigns = getAllCampaigns(result);
    assertEquals("Wrong # of campaigns", 1, campaigns.size());
    AccessCertificationObjectBasedScopeType scope = (AccessCertificationObjectBasedScopeType) campaigns.get(0).asObjectable().getScopeDefinition();
    Class<? extends ObjectType> objectClass = ObjectTypes.getObjectTypeClass(scope.getObjectType());
    ObjectFilter parsedFilter = prismContext.getQueryConverter().parseFilter(scope.getSearchFilter(), objectClass);
    assertTrue("Unexpected type of scope filter, expected AndFilter", parsedFilter instanceof AndFilter);
    for (ObjectFilter subFilter : ((AndFilter) parsedFilter).getConditions()) {
        assertTrue("Unexpected type of subfilter in scope filter, expected EqualFilter or InOidFilter", (subFilter instanceof EqualFilter || subFilter instanceof InOidFilter));
    }
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) AndFilter(com.evolveum.midpoint.prism.query.AndFilter) InOidFilter(com.evolveum.midpoint.prism.query.InOidFilter) Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) EqualFilter(com.evolveum.midpoint.prism.query.EqualFilter) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) Test(org.testng.annotations.Test)

Example 5 with InOidFilter

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

the class DeleteRepositoryAction method deleteByOid.

private void deleteByOid() throws SchemaException {
    QueryFactory queryFactory = context.getPrismContext().queryFactory();
    InOidFilter filter = queryFactory.createInOid(options.getOid());
    ObjectQuery query = queryFactory.createQuery(filter);
    deleteByFilter(query);
}
Also used : InOidFilter(com.evolveum.midpoint.prism.query.InOidFilter) QueryFactory(com.evolveum.midpoint.prism.query.QueryFactory) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

Aggregations

InOidFilter (com.evolveum.midpoint.prism.query.InOidFilter)5 ObjectFilter (com.evolveum.midpoint.prism.query.ObjectFilter)2 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)2 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)2 ImportRepositoryConsumerWorker (com.evolveum.midpoint.ninja.action.worker.ImportRepositoryConsumerWorker)1 OperationStatus (com.evolveum.midpoint.ninja.util.OperationStatus)1 PrismObject (com.evolveum.midpoint.prism.PrismObject)1 AndFilter (com.evolveum.midpoint.prism.query.AndFilter)1 EqualFilter (com.evolveum.midpoint.prism.query.EqualFilter)1 NotFilter (com.evolveum.midpoint.prism.query.NotFilter)1 QueryFactory (com.evolveum.midpoint.prism.query.QueryFactory)1 Task (com.evolveum.midpoint.task.api.Task)1 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)1 Test (org.testng.annotations.Test)1