Search in sources :

Example 41 with ObjectTypes

use of com.evolveum.midpoint.schema.constants.ObjectTypes in project midpoint by Evolveum.

the class ModelImplUtils method getApplicablePolicies.

// from the most to least appropriate
@NotNull
public static <O extends ObjectType> List<ObjectPolicyConfigurationType> getApplicablePolicies(@Nullable Class<O> objectClass, List<String> objectSubtypes, SystemConfigurationType systemConfigurationType) throws ConfigurationException {
    List<ObjectPolicyConfigurationType> rv = new ArrayList<>();
    List<ObjectPolicyConfigurationType> typeNoSubtype = new ArrayList<>();
    List<ObjectPolicyConfigurationType> typeWithSubtype = new ArrayList<>();
    List<ObjectPolicyConfigurationType> noTypeNoSubtype = new ArrayList<>();
    List<ObjectPolicyConfigurationType> noTypeWithSubtype = new ArrayList<>();
    List<ObjectPolicyConfigurationType> all = new ArrayList<>(systemConfigurationType.getDefaultObjectPolicyConfiguration());
    for (ObjectPolicyConfigurationType aPolicyConfigurationType : all) {
        QName typeQName = aPolicyConfigurationType.getType();
        if (typeQName != null) {
            ObjectTypes objectType = ObjectTypes.getObjectTypeFromTypeQName(typeQName);
            if (objectType == null) {
                throw new ConfigurationException("Unknown type " + typeQName + " in default object policy definition or object template definition in system configuration");
            }
            if (objectType.getClassDefinition() == objectClass) {
                String aSubType = aPolicyConfigurationType.getSubtype();
                if (aSubType == null) {
                    typeNoSubtype.add(aPolicyConfigurationType);
                } else if (objectSubtypes != null && objectSubtypes.contains(aSubType)) {
                    typeWithSubtype.add(aPolicyConfigurationType);
                }
            }
        } else {
            String aSubType = aPolicyConfigurationType.getSubtype();
            if (aSubType == null) {
                noTypeNoSubtype.add(aPolicyConfigurationType);
            } else if (objectSubtypes != null && objectSubtypes.contains(aSubType)) {
                noTypeWithSubtype.add(aPolicyConfigurationType);
            }
        }
    }
    rv.addAll(typeWithSubtype);
    rv.addAll(typeNoSubtype);
    rv.addAll(noTypeWithSubtype);
    rv.addAll(noTypeNoSubtype);
    return rv;
}
Also used : ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes) NotNull(org.jetbrains.annotations.NotNull)

Example 42 with ObjectTypes

use of com.evolveum.midpoint.schema.constants.ObjectTypes in project midpoint by Evolveum.

the class ExpressionHandler method resolveRef.

// Called from the ObjectResolver.resolve
public ObjectType resolveRef(ObjectReferenceType ref, String contextDescription, OperationResult result) throws ObjectNotFoundException, SchemaException {
    Class<? extends ObjectType> type;
    if (ref.getType() != null) {
        ObjectTypes objectTypeType = ObjectTypes.getObjectTypeFromTypeQName(ref.getType());
        type = objectTypeType.getClassDefinition();
    } else {
        type = ObjectType.class;
    }
    return repositoryService.getObject(type, ref.getOid(), createReadOnlyCollection(), result).asObjectable();
}
Also used : ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes)

Example 43 with ObjectTypes

use of com.evolveum.midpoint.schema.constants.ObjectTypes in project midpoint by Evolveum.

the class ClassMapper method getHQLTypeClass.

public static Class<? extends RObject> getHQLTypeClass(Class<? extends ObjectType> clazz) {
    Objects.requireNonNull(clazz, "Class must not be null.");
    ObjectTypes type = ObjectTypes.getObjectType(clazz);
    Class<? extends RObject> hqlType = TYPES.get(type).getClazz();
    if (hqlType == null) {
        throw new IllegalStateException("Couldn't find DB type for '" + clazz + "'.");
    }
    return hqlType;
}
Also used : ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes)

Example 44 with ObjectTypes

use of com.evolveum.midpoint.schema.constants.ObjectTypes in project midpoint by Evolveum.

the class DeleteRepositoryAction method deleteByFilter.

private void deleteByFilter(ObjectTypes type, ObjectQuery query, OperationStatus operation, OperationResult result) throws SchemaException {
    ResultHandler<?> handler = (prismObject, operationResult) -> {
        try {
            State state = options.isAsk() ? askForState(prismObject) : State.DELETE;
            switch(state) {
                case SKIP:
                    operation.incrementSkipped();
                    return true;
                case STOP:
                    return false;
                case DELETE:
                default:
            }
            RepositoryService repository = context.getRepository();
            repository.deleteObject(prismObject.getCompileTimeClass(), prismObject.getOid(), operationResult);
            operation.incrementTotal();
        } catch (ObjectNotFoundException ex) {
        // object was already gone
        } catch (IOException ex) {
            context.getLog().error("Couldn't delete object {}, reason: {}", ex, prismObject, ex.getMessage());
            operation.incrementError();
        }
        return true;
    };
    Collection<SelectorOptions<GetOperationOptions>> opts = new ArrayList<>();
    if (options.isRaw()) {
        opts.add(new SelectorOptions<>(GetOperationOptions.createRaw()));
    }
    RepositoryService repository = context.getRepository();
    repository.searchObjectsIterative(type.getClassDefinition(), query, handler, opts, true, result);
}
Also used : ResultHandler(com.evolveum.midpoint.schema.ResultHandler) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) QueryFactory(com.evolveum.midpoint.prism.query.QueryFactory) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) OperationStatus(com.evolveum.midpoint.ninja.util.OperationStatus) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) Collection(java.util.Collection) NinjaUtils(com.evolveum.midpoint.ninja.util.NinjaUtils) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) IOException(java.io.IOException) PrismObject(com.evolveum.midpoint.prism.PrismObject) DeleteOptions(com.evolveum.midpoint.ninja.opts.DeleteOptions) InputStreamReader(java.io.InputStreamReader) StringUtils(org.apache.commons.lang3.StringUtils) ArrayList(java.util.ArrayList) InOidFilter(com.evolveum.midpoint.prism.query.InOidFilter) Modifier(java.lang.reflect.Modifier) GetOperationOptions(com.evolveum.midpoint.schema.GetOperationOptions) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes) BufferedReader(java.io.BufferedReader) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) RepositoryService(com.evolveum.midpoint.repo.api.RepositoryService) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) ArrayList(java.util.ArrayList) IOException(java.io.IOException) RepositoryService(com.evolveum.midpoint.repo.api.RepositoryService)

Example 45 with ObjectTypes

use of com.evolveum.midpoint.schema.constants.ObjectTypes in project midpoint by Evolveum.

the class DeleteRepositoryAction method deleteByFilter.

private void deleteByFilter(ObjectQuery query) throws SchemaException {
    OperationResult result = new OperationResult(OPERATION_DELETE);
    OperationStatus operation = new OperationStatus(context, result);
    operation.start();
    log.info("Starting delete");
    ObjectTypes type = options.getType();
    if (type != null) {
        deleteByFilter(type, query, operation, result);
    } else {
        for (ObjectTypes t : ObjectTypes.values()) {
            if (Modifier.isAbstract(t.getClassDefinition().getModifiers())) {
                continue;
            }
            deleteByFilter(t, query, operation, result);
        }
    }
    operation.finish();
    handleResultOnFinish(operation, "Delete finished");
}
Also used : OperationStatus(com.evolveum.midpoint.ninja.util.OperationStatus) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes)

Aggregations

ObjectTypes (com.evolveum.midpoint.schema.constants.ObjectTypes)46 QName (javax.xml.namespace.QName)16 ArrayList (java.util.ArrayList)11 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)11 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)8 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)8 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)7 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)7 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)6 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)6 List (java.util.List)6 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)5 ITab (org.apache.wicket.extensions.markup.html.tabs.ITab)5 AssignmentPopup (com.evolveum.midpoint.gui.api.component.AssignmentPopup)4 OnChangeAjaxBehavior (org.apache.wicket.ajax.form.OnChangeAjaxBehavior)4 DropDownChoice (org.apache.wicket.markup.html.form.DropDownChoice)4 CountablePanelTab (com.evolveum.midpoint.gui.api.component.tabs.CountablePanelTab)3 PanelTab (com.evolveum.midpoint.gui.api.component.tabs.PanelTab)3 PrismContainerWrapper (com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper)3 AssignmentObjectRelation (com.evolveum.midpoint.model.api.AssignmentObjectRelation)3