Search in sources :

Example 1 with UserInterfaceElementVisibilityType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.UserInterfaceElementVisibilityType in project midpoint by Evolveum.

the class SchemaTransformer method reduceItems.

@NotNull
private UserInterfaceElementVisibilityType reduceItems(PrismContainerDefinition<?> containerDefinition, UniformItemPath containerPath, List<VisibilityPolicyEntry> visibilityPolicy) {
    UserInterfaceElementVisibilityType containerVisibility = determineVisibility(visibilityPolicy, containerPath);
    if (containerDefinition.isElaborate()) {
        return containerVisibility;
    }
    Collection<ItemName> itemsToDelete;
    if (containerVisibility == HIDDEN) {
        // Delete everything
        itemsToDelete = containerDefinition.getItemNames();
    } else {
        // Use item visibility to select individual items
        itemsToDelete = selectItemsToDelete(containerDefinition, containerPath, visibilityPolicy);
    }
    MutableComplexTypeDefinition mutableContainerCtDef = containerDefinition.getComplexTypeDefinition().toMutable();
    for (ItemName itemName : itemsToDelete) {
        LOGGER.trace("Removing item {}/{} due to visibility constraint", containerPath, itemName.getLocalPart());
        mutableContainerCtDef.delete(itemName);
    }
    return containerVisibility;
}
Also used : ItemName(com.evolveum.midpoint.prism.path.ItemName) UserInterfaceElementVisibilityType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserInterfaceElementVisibilityType) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with UserInterfaceElementVisibilityType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.UserInterfaceElementVisibilityType in project midpoint by Evolveum.

the class SchemaTransformer method getVisibilityPolicy.

@NotNull
private <O extends ObjectType> List<VisibilityPolicyEntry> getVisibilityPolicy(ArchetypePolicyType archetypePolicy, Object contextDesc) throws SchemaException {
    List<VisibilityPolicyEntry> visibilityPolicy = new ArrayList<>();
    for (ItemConstraintType itemConstraint : archetypePolicy.getItemConstraint()) {
        UserInterfaceElementVisibilityType visibility = itemConstraint.getVisibility();
        if (visibility != null) {
            ItemPathType itemPathType = itemConstraint.getPath();
            if (itemPathType == null) {
                throw new SchemaException("No 'path' in item definition in archetype policy for " + contextDesc);
            }
            UniformItemPath itemPath = prismContext.toUniformPath(itemPathType);
            visibilityPolicy.add(new VisibilityPolicyEntry(itemPath, visibility));
        }
    }
    return visibilityPolicy;
}
Also used : ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) UniformItemPath(com.evolveum.midpoint.prism.path.UniformItemPath) UserInterfaceElementVisibilityType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserInterfaceElementVisibilityType) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with UserInterfaceElementVisibilityType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.UserInterfaceElementVisibilityType in project midpoint by Evolveum.

the class SchemaTransformer method selectItemsToDelete.

@NotNull
private List<ItemName> selectItemsToDelete(PrismContainerDefinition<?> containerDefinition, UniformItemPath containerPath, List<VisibilityPolicyEntry> visibilityPolicy) {
    List<ItemName> itemsToDelete = new ArrayList<>();
    for (ItemDefinition<?> subDefinition : containerDefinition.getDefinitions()) {
        UniformItemPath itemPath = containerPath.append(subDefinition.getItemName());
        if (subDefinition instanceof PrismContainerDefinition) {
            PrismContainerDefinition<?> subContainerDef = (PrismContainerDefinition<?>) subDefinition;
            UserInterfaceElementVisibilityType itemVisibility = reduceItems(subContainerDef, itemPath, visibilityPolicy);
            if (subContainerDef.isEmpty()) {
                /*
                     * Empty sub-containers are treated in this way:
                     * - "completely defined" ones (no xsd:any) are hidden, unless explicitly set
                     *    to VISIBLE i.e. if VACANT, HIDDEN, or AUTOMATIC
                     * - "open" ones (xsd:any) are dealt with just like properties: hidden if VACANT or HIDDEN
                     *
                     * Primary motivation for this behavior is the fact that we need to keep assignment/extension definition
                     * in the object. It is required for normal model operation, specifically for the construction of "magic
                     * assignment".
                     *
                     * Note that this somehow mixes presentation requirements (hiding/showing items) with the requirements of
                     * business logic. This is because the current solution is a temporary one, to be replaced by something
                     * more serious.
                     */
                if (itemVisibility == VACANT || itemVisibility == HIDDEN || itemVisibility == AUTOMATIC && subContainerDef.isCompletelyDefined()) {
                    itemsToDelete.add(subDefinition.getItemName());
                }
            }
        } else {
            UserInterfaceElementVisibilityType itemVisibility = determineVisibility(visibilityPolicy, itemPath);
            if (itemVisibility == VACANT || itemVisibility == HIDDEN) {
                itemsToDelete.add(subDefinition.getItemName());
            }
        }
    }
    return itemsToDelete;
}
Also used : ItemName(com.evolveum.midpoint.prism.path.ItemName) UniformItemPath(com.evolveum.midpoint.prism.path.UniformItemPath) UserInterfaceElementVisibilityType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserInterfaceElementVisibilityType) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

UserInterfaceElementVisibilityType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserInterfaceElementVisibilityType)3 NotNull (org.jetbrains.annotations.NotNull)3 ItemName (com.evolveum.midpoint.prism.path.ItemName)2 UniformItemPath (com.evolveum.midpoint.prism.path.UniformItemPath)2 ItemPathType (com.evolveum.prism.xml.ns._public.types_3.ItemPathType)1