Search in sources :

Example 1 with NotFilter

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

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

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

the class LogicalOperation method interpret.

@Override
public <T> Filter interpret(ObjectFilter objectFilter, ConnIdNameMapper icfNameMapper) throws SchemaException {
    if (objectFilter instanceof NotFilter) {
        NotFilter not = (NotFilter) objectFilter;
        if (not.getFilter() == null) {
            LOGGER.debug("Not filter does not contain any condition. Skipping processing not filter.");
            return null;
        }
        Filter f = getInterpreter().interpret(not.getFilter(), icfNameMapper);
        return FilterBuilder.not(f);
    } else {
        NaryLogicalFilter nAry = (NaryLogicalFilter) objectFilter;
        List<? extends ObjectFilter> conditions = nAry.getConditions();
        if (conditions == null || conditions.isEmpty()) {
            LOGGER.debug("No conditions specified for logical filter. Skipping processing logical filter.");
            return null;
        }
        if (conditions.size() < 2) {
            LOGGER.debug("Logical filter contains only one condition. Skipping processing logical filter and process simple operation of type {}.", conditions.get(0).getClass().getSimpleName());
            return getInterpreter().interpret(conditions.get(0), icfNameMapper);
        }
        List<Filter> filters = new ArrayList<>();
        for (ObjectFilter objFilter : nAry.getConditions()) {
            Filter f = getInterpreter().interpret(objFilter, icfNameMapper);
            filters.add(f);
        }
        Filter nAryFilter = null;
        if (filters.size() >= 2) {
            if (nAry instanceof AndFilter) {
                nAryFilter = interpretAnd(filters.get(0), filters.subList(1, filters.size()));
            } else if (nAry instanceof OrFilter) {
                nAryFilter = interpretOr(filters.get(0), filters.subList(1, filters.size()));
            }
        }
        return nAryFilter;
    }
}
Also used : NaryLogicalFilter(com.evolveum.midpoint.prism.query.NaryLogicalFilter) AndFilter(com.evolveum.midpoint.prism.query.AndFilter) NaryLogicalFilter(com.evolveum.midpoint.prism.query.NaryLogicalFilter) Filter(org.identityconnectors.framework.common.objects.filter.Filter) AndFilter(com.evolveum.midpoint.prism.query.AndFilter) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) NotFilter(com.evolveum.midpoint.prism.query.NotFilter) OrFilter(com.evolveum.midpoint.prism.query.OrFilter) NotFilter(com.evolveum.midpoint.prism.query.NotFilter) ArrayList(java.util.ArrayList) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) OrFilter(com.evolveum.midpoint.prism.query.OrFilter)

Aggregations

NotFilter (com.evolveum.midpoint.prism.query.NotFilter)3 ObjectFilter (com.evolveum.midpoint.prism.query.ObjectFilter)2 InitialDataImport (com.evolveum.midpoint.init.InitialDataImport)1 PrismObject (com.evolveum.midpoint.prism.PrismObject)1 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)1 AndFilter (com.evolveum.midpoint.prism.query.AndFilter)1 InOidFilter (com.evolveum.midpoint.prism.query.InOidFilter)1 NaryLogicalFilter (com.evolveum.midpoint.prism.query.NaryLogicalFilter)1 OrFilter (com.evolveum.midpoint.prism.query.OrFilter)1 QueryFactory (com.evolveum.midpoint.prism.query.QueryFactory)1 TypeFilter (com.evolveum.midpoint.prism.query.TypeFilter)1 LabeledString (com.evolveum.midpoint.schema.LabeledString)1 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 Task (com.evolveum.midpoint.task.api.Task)1 TaskType (com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 QName (javax.xml.namespace.QName)1 RestartResponseException (org.apache.wicket.RestartResponseException)1 Filter (org.identityconnectors.framework.common.objects.filter.Filter)1