Search in sources :

Example 1 with QueryFactory

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

the class PageAssignmentsList method getTaskQuery.

private ObjectQuery getTaskQuery() {
    List<String> targetUsersOids = getSessionStorage().getRoleCatalog().isSelfRequest() ? Collections.singletonList(getPrincipalFocus().getOid()) : getSessionStorage().getRoleCatalog().getTargetUserOidsList();
    QueryFactory queryFactory = getPrismContext().queryFactory();
    return queryFactory.createQuery(queryFactory.createInOid(targetUsersOids));
}
Also used : QueryFactory(com.evolveum.midpoint.prism.query.QueryFactory)

Example 2 with QueryFactory

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

the class ExportAuditRepositoryAction method createProducers.

private List<ExportAuditProducerWorker> createProducers(BlockingQueue<AuditEventRecordType> queue, OperationStatus operation) throws SchemaException, IOException {
    QueryFactory queryFactory = context.getPrismContext().queryFactory();
    List<ExportAuditProducerWorker> producers = new ArrayList<>();
    ObjectFilter filter = NinjaUtils.createObjectFilter(options.getFilter(), context, AuditEventRecordType.class);
    ObjectQuery query = queryFactory.createQuery(filter);
    producers.add(new ExportAuditProducerWorker(context, options, queue, operation, producers, query));
    return producers;
}
Also used : QueryFactory(com.evolveum.midpoint.prism.query.QueryFactory) ArrayList(java.util.ArrayList) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

Example 3 with QueryFactory

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

the class PageDebugList method deleteAllShadowsConfirmed.

private String deleteAllShadowsConfirmed(OperationResult result, boolean deleteAccountShadows) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException {
    ObjectFilter kindFilter = getPrismContext().queryFor(ShadowType.class).item(ShadowType.F_KIND).eq(ShadowKindType.ACCOUNT).buildFilter();
    String taskName;
    ObjectQuery query;
    QueryFactory factory = getPrismContext().queryFactory();
    if (deleteAccountShadows) {
        taskName = "Delete all account shadows";
        query = factory.createQuery(kindFilter);
    } else {
        taskName = "Delete all non-account shadows";
        query = factory.createQuery(factory.createNot(kindFilter));
    }
    return deleteObjectsAsync(ShadowType.COMPLEX_TYPE, query, taskName, result);
}
Also used : QueryFactory(com.evolveum.midpoint.prism.query.QueryFactory) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

Example 4 with QueryFactory

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

the class PageAbout method resetStateToInitialConfig.

private void resetStateToInitialConfig(AjaxRequestTarget target) {
    OperationResult result = new OperationResult(OPERATION_DELETE_ALL_OBJECTS);
    String taskOid = null;
    String taskName = "Delete all objects";
    QueryFactory factory = getPrismContext().queryFactory();
    TypeFilter nodeFilter = factory.createType(NodeType.COMPLEX_TYPE, factory.createAll());
    final ObjectFilter taskFilter = getPrismContext().queryFor(TaskType.class).item(TaskType.F_NAME).eq(taskName).buildFilter();
    NotFilter notNodeFilter = factory.createNot(nodeFilter);
    NotFilter notTaskFilter = factory.createNot(taskFilter);
    try {
        QName type = ObjectType.COMPLEX_TYPE;
        taskOid = deleteObjectsAsync(type, factory.createQuery(factory.createAnd(notTaskFilter, notNodeFilter)), taskName, result);
    } catch (Exception ex) {
        result.recomputeStatus();
        result.recordFatalError(getString("PageAbout.message.resetStateToInitialConfig.allObject.fatalError"), ex);
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't delete all objects", ex);
    }
    final String taskOidToRemoving = taskOid;
    try {
        while (!getTaskManager().getTaskPlain(taskOid, result).isClosed()) {
            TimeUnit.SECONDS.sleep(5);
        }
        runPrivileged(new Producer<Object>() {

            private static final long serialVersionUID = 1L;

            @Override
            public Object run() {
                Task task = createAnonymousTask(OPERATION_DELETE_TASK);
                OperationResult result = new OperationResult(OPERATION_DELETE_TASK);
                ObjectDelta<TaskType> delta = getPrismContext().deltaFactory().object().createDeleteDelta(TaskType.class, taskOidToRemoving);
                Collection<ObjectDelta<? extends ObjectType>> deltaCollection = Collections.singletonList(delta);
                try {
                    getModelService().executeChanges(deltaCollection, null, task, result);
                } catch (Exception ex) {
                    result.recomputeStatus();
                    result.recordFatalError(getString("PageAbout.message.resetStateToInitialConfig.task.fatalError"), ex);
                    LoggingUtils.logUnexpectedException(LOGGER, "Couldn't delete task", ex);
                }
                result.computeStatus();
                return null;
            }
        });
        InitialDataImport initialDataImport = new InitialDataImport();
        initialDataImport.setModel(getModelService());
        initialDataImport.setTaskManager(getTaskManager());
        initialDataImport.setPrismContext(getPrismContext());
        initialDataImport.setConfiguration(getMidpointConfiguration());
        initialDataImport.init(true);
        // TODO consider if we need to go clusterwide here
        getCacheDispatcher().dispatchInvalidation(null, null, true, null);
        getModelService().shutdown();
        getModelService().postInit(result);
    } catch (Exception ex) {
        result.recomputeStatus();
        result.recordFatalError(getString("PageAbout.message.resetStateToInitialConfig.import.fatalError"), ex);
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't import initial objects", ex);
    }
    showResult(result);
    target.add(getFeedbackPanel());
}
Also used : QueryFactory(com.evolveum.midpoint.prism.query.QueryFactory) Task(com.evolveum.midpoint.task.api.Task) QName(javax.xml.namespace.QName) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) TypeFilter(com.evolveum.midpoint.prism.query.TypeFilter) LabeledString(com.evolveum.midpoint.schema.LabeledString) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) InitialDataImport(com.evolveum.midpoint.init.InitialDataImport) RestartResponseException(org.apache.wicket.RestartResponseException) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) NotFilter(com.evolveum.midpoint.prism.query.NotFilter) Collection(java.util.Collection) PrismObject(com.evolveum.midpoint.prism.PrismObject) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta)

Example 5 with QueryFactory

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

the class UserPersonasPanel method loadModel.

private LoadableModel<List<PrismObject<FocusType>>> loadModel() {
    return new LoadableModel<List<PrismObject<FocusType>>>(false) {

        @Override
        protected List<PrismObject<FocusType>> load() {
            List<String> personaOidsList = getPersonasOidsList();
            List<PrismObject<FocusType>> personasList = new ArrayList<>();
            if (personaOidsList.size() > 0) {
                QueryFactory factory = getPrismContext().queryFactory();
                ObjectQuery query = factory.createQuery(factory.createInOid(personaOidsList));
                OperationResult result = new OperationResult(OPERATION_SEARCH_PERSONAS_OBJECTS);
                personasList = WebModelServiceUtils.searchObjects(FocusType.class, query, result, getPageBase());
            }
            return personasList;
        }
    };
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) QueryFactory(com.evolveum.midpoint.prism.query.QueryFactory) FocusType(com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

Aggregations

QueryFactory (com.evolveum.midpoint.prism.query.QueryFactory)10 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)6 ArrayList (java.util.ArrayList)6 ObjectFilter (com.evolveum.midpoint.prism.query.ObjectFilter)4 PrismObject (com.evolveum.midpoint.prism.PrismObject)3 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)3 RestartResponseException (org.apache.wicket.RestartResponseException)3 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)2 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)2 EqualFilter (com.evolveum.midpoint.prism.query.EqualFilter)2 SearchResultList (com.evolveum.midpoint.schema.SearchResultList)2 FocusType (com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType)2 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)2 List (java.util.List)2 QName (javax.xml.namespace.QName)2 InitialDataImport (com.evolveum.midpoint.init.InitialDataImport)1 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)1 InOidFilter (com.evolveum.midpoint.prism.query.InOidFilter)1 NotFilter (com.evolveum.midpoint.prism.query.NotFilter)1 TypeFilter (com.evolveum.midpoint.prism.query.TypeFilter)1