Search in sources :

Example 71 with ItemName

use of com.evolveum.midpoint.prism.path.ItemName in project midpoint by Evolveum.

the class TestParsePasswordPolicy method assertPropertyDefinition.

private void assertPropertyDefinition(PrismContainer<?> container, String propName, QName xsdType, int minOccurs, int maxOccurs) {
    ItemName propQName = new ItemName(SchemaConstantsGenerated.NS_COMMON, propName);
    PrismAsserts.assertPropertyDefinition(container, propQName, xsdType, minOccurs, maxOccurs);
}
Also used : ItemName(com.evolveum.midpoint.prism.path.ItemName)

Example 72 with ItemName

use of com.evolveum.midpoint.prism.path.ItemName in project midpoint by Evolveum.

the class TestParseObjectTemplate method assertPropertyValue.

public static void assertPropertyValue(PrismContainer<?> container, String propName, Object propValue) {
    ItemName propQName = new ItemName(SchemaConstantsGenerated.NS_COMMON, propName);
    PrismAsserts.assertPropertyValue(container, propQName, propValue);
}
Also used : ItemName(com.evolveum.midpoint.prism.path.ItemName)

Example 73 with ItemName

use of com.evolveum.midpoint.prism.path.ItemName in project midpoint by Evolveum.

the class TestParseTask method assertPropertyValue.

public static void assertPropertyValue(PrismContainer<?> container, String propName, Object propValue) {
    ItemName propQName = new ItemName(SchemaConstantsGenerated.NS_COMMON, propName);
    PrismAsserts.assertPropertyValue(container, propQName, propValue);
}
Also used : ItemName(com.evolveum.midpoint.prism.path.ItemName)

Example 74 with ItemName

use of com.evolveum.midpoint.prism.path.ItemName 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 75 with ItemName

use of com.evolveum.midpoint.prism.path.ItemName 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

ItemName (com.evolveum.midpoint.prism.path.ItemName)89 Test (org.testng.annotations.Test)24 QName (javax.xml.namespace.QName)19 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)15 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)13 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)13 NotNull (org.jetbrains.annotations.NotNull)10 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)8 PrismObject (com.evolveum.midpoint.prism.PrismObject)6 Task (com.evolveum.midpoint.task.api.Task)6 SqaleRepoBaseTest (com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)5 MUser (com.evolveum.midpoint.repo.sqale.qmodel.focus.MUser)5 com.evolveum.midpoint.xml.ns._public.common.common_3 (com.evolveum.midpoint.xml.ns._public.common.common_3)5 Element (org.w3c.dom.Element)5 JdbcSession (com.evolveum.midpoint.repo.sqlbase.JdbcSession)4 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)4 ItemPathType (com.evolveum.prism.xml.ns._public.types_3.ItemPathType)4 PolyStringType (com.evolveum.prism.xml.ns._public.types_3.PolyStringType)4 ArrayList (java.util.ArrayList)4 ItemDefinition (com.evolveum.midpoint.prism.ItemDefinition)3