Search in sources :

Example 1 with PropertyLimitationsType

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

the class ItemLimitationsChecker method checkItemsLimitations.

/**
 * @pre Focus context is recomputed.
 */
<O extends ObjectType> void checkItemsLimitations(LensFocusContext<O> focusContext) throws SchemaException {
    PathKeyedMap<ObjectTemplateItemDefinitionType> itemDefinitionsMap = focusContext.getItemDefinitionsMap();
    PrismObject<O> objectNew = focusContext.getObjectNew();
    if (objectNew == null) {
        // nothing to check on DELETE operation
        return;
    }
    for (Map.Entry<ItemPath, ObjectTemplateItemDefinitionType> entry : itemDefinitionsMap.entrySet()) {
        for (PropertyLimitationsType limitation : entry.getValue().getLimitations()) {
            if (!limitation.getLayer().contains(LayerType.MODEL)) {
                // or should we apply SCHEMA-layer limitations as well?
                continue;
            }
            checkItemLimitations(objectNew, entry.getKey(), limitation);
        }
    }
}
Also used : ObjectTemplateItemDefinitionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectTemplateItemDefinitionType) Map(java.util.Map) PathKeyedMap(com.evolveum.midpoint.prism.path.PathKeyedMap) PropertyLimitationsType(com.evolveum.midpoint.xml.ns._public.common.common_3.PropertyLimitationsType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 2 with PropertyLimitationsType

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

the class LimitationsEditorDialog method loadLimitationsModel.

private List<PropertyLimitationsTypeDto> loadLimitationsModel(IModel<List<PropertyLimitationsType>> limList) {
    List<PropertyLimitationsTypeDto> limitations = new ArrayList<>();
    List<PropertyLimitationsType> limitationTypeList = limList.getObject();
    for (PropertyLimitationsType limitation : limitationTypeList) {
        limitations.add(new PropertyLimitationsTypeDto(limitation));
    }
    return limitations;
}
Also used : PropertyLimitationsTypeDto(com.evolveum.midpoint.web.component.wizard.resource.dto.PropertyLimitationsTypeDto) ArrayList(java.util.ArrayList) PropertyLimitationsType(com.evolveum.midpoint.xml.ns._public.common.common_3.PropertyLimitationsType)

Example 3 with PropertyLimitationsType

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

the class SchemaTransformer method applyObjectTemplateItem.

private <IV extends PrismValue, ID extends ItemDefinition> void applyObjectTemplateItem(ID itemDef, ObjectTemplateItemDefinitionType templateItemDefType, String desc) throws SchemaException {
    if (itemDef == null) {
        throw new SchemaException("No definition for " + desc);
    }
    String displayName = templateItemDefType.getDisplayName();
    if (displayName != null) {
        ((ItemDefinitionImpl) itemDef).setDisplayName(displayName);
    }
    Integer displayOrder = templateItemDefType.getDisplayOrder();
    if (displayOrder != null) {
        ((ItemDefinitionImpl) itemDef).setDisplayOrder(displayOrder);
    }
    Boolean emphasized = templateItemDefType.isEmphasized();
    if (emphasized != null) {
        ((ItemDefinitionImpl) itemDef).setEmphasized(emphasized);
    }
    List<PropertyLimitationsType> limitations = templateItemDefType.getLimitations();
    if (limitations != null) {
        PropertyLimitationsType limitationsType = MiscSchemaUtil.getLimitationsType(limitations, LayerType.PRESENTATION);
        if (limitationsType != null) {
            if (limitationsType.getMinOccurs() != null) {
                ((ItemDefinitionImpl) itemDef).setMinOccurs(XsdTypeMapper.multiplicityToInteger(limitationsType.getMinOccurs()));
            }
            if (limitationsType.getMaxOccurs() != null) {
                ((ItemDefinitionImpl) itemDef).setMaxOccurs(XsdTypeMapper.multiplicityToInteger(limitationsType.getMaxOccurs()));
            }
            if (limitationsType.isIgnore() != null) {
                ((ItemDefinitionImpl) itemDef).setIgnored(limitationsType.isIgnore());
            }
            PropertyAccessType accessType = limitationsType.getAccess();
            if (accessType != null) {
                if (accessType.isAdd() != null) {
                    ((ItemDefinitionImpl) itemDef).setCanAdd(accessType.isAdd());
                }
                if (accessType.isModify() != null) {
                    ((ItemDefinitionImpl) itemDef).setCanModify(accessType.isModify());
                }
                if (accessType.isRead() != null) {
                    ((ItemDefinitionImpl) itemDef).setCanRead(accessType.isRead());
                }
            }
        }
    }
    ObjectReferenceType valueEnumerationRef = templateItemDefType.getValueEnumerationRef();
    if (valueEnumerationRef != null) {
        PrismReferenceValue valueEnumerationRVal = MiscSchemaUtil.objectReferenceTypeToReferenceValue(valueEnumerationRef);
        ((ItemDefinitionImpl) itemDef).setValueEnumerationRef(valueEnumerationRVal);
    }
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) PropertyAccessType(com.evolveum.midpoint.xml.ns._public.common.common_3.PropertyAccessType) PropertyLimitationsType(com.evolveum.midpoint.xml.ns._public.common.common_3.PropertyLimitationsType)

Example 4 with PropertyLimitationsType

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

the class RefinedAttributeDefinitionImpl method isIgnored.

static boolean isIgnored(ResourceAttributeDefinitionType attrDefType) throws SchemaException {
    List<PropertyLimitationsType> limitations = attrDefType.getLimitations();
    if (limitations == null) {
        return false;
    }
    PropertyLimitationsType limitationsType = MiscSchemaUtil.getLimitationsType(limitations, DEFAULT_LAYER);
    if (limitationsType == null) {
        return false;
    }
    if (limitationsType.isIgnore() == null) {
        return false;
    }
    return limitationsType.isIgnore();
}
Also used : PropertyLimitationsType(com.evolveum.midpoint.xml.ns._public.common.common_3.PropertyLimitationsType)

Example 5 with PropertyLimitationsType

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

the class RefinedAttributeDefinitionImpl method parse.

// schemaHandlingAttrDefType may be null if we are parsing from schema only
static <T> RefinedAttributeDefinition<T> parse(ResourceAttributeDefinition<T> schemaAttrDef, ResourceAttributeDefinitionType schemaHandlingAttrDefType, ObjectClassComplexTypeDefinition objectClassDef, PrismContext prismContext, String contextDescription) throws SchemaException {
    RefinedAttributeDefinitionImpl<T> rAttrDef = new RefinedAttributeDefinitionImpl<T>(schemaAttrDef, prismContext);
    if (schemaHandlingAttrDefType != null && schemaHandlingAttrDefType.getDisplayName() != null) {
        rAttrDef.setDisplayName(schemaHandlingAttrDefType.getDisplayName());
    } else {
        if (schemaAttrDef.getDisplayName() != null) {
            rAttrDef.setDisplayName(schemaAttrDef.getDisplayName());
        }
    }
    if (schemaHandlingAttrDefType != null && schemaHandlingAttrDefType.getDisplayOrder() != null) {
        rAttrDef.setDisplayOrder(schemaHandlingAttrDefType.getDisplayOrder());
    } else {
        if (schemaAttrDef.getDisplayOrder() != null) {
            rAttrDef.setDisplayOrder(schemaAttrDef.getDisplayOrder());
        }
    }
    rAttrDef.matchingRuleQName = schemaAttrDef.getMatchingRuleQName();
    if (schemaHandlingAttrDefType != null) {
        rAttrDef.fetchStrategy = schemaHandlingAttrDefType.getFetchStrategy();
        if (schemaHandlingAttrDefType.getMatchingRule() != null) {
            rAttrDef.matchingRuleQName = schemaHandlingAttrDefType.getMatchingRule();
        }
    }
    PropertyLimitations schemaLimitations = getOrCreateLimitations(rAttrDef.limitationsMap, LayerType.SCHEMA);
    schemaLimitations.setMinOccurs(schemaAttrDef.getMinOccurs());
    schemaLimitations.setMaxOccurs(schemaAttrDef.getMaxOccurs());
    schemaLimitations.setIgnore(schemaAttrDef.isIgnored());
    schemaLimitations.getAccess().setAdd(schemaAttrDef.canAdd());
    schemaLimitations.getAccess().setModify(schemaAttrDef.canModify());
    schemaLimitations.getAccess().setRead(schemaAttrDef.canRead());
    if (schemaHandlingAttrDefType != null) {
        if (schemaHandlingAttrDefType.getDescription() != null) {
            rAttrDef.setDescription(schemaHandlingAttrDefType.getDescription());
        }
        if (schemaHandlingAttrDefType.isTolerant() == null) {
            rAttrDef.tolerant = true;
        } else {
            rAttrDef.tolerant = schemaHandlingAttrDefType.isTolerant();
        }
        if (schemaHandlingAttrDefType.isSecondaryIdentifier() == null) {
            rAttrDef.secondaryIdentifier = false;
        } else {
            rAttrDef.secondaryIdentifier = schemaHandlingAttrDefType.isSecondaryIdentifier();
        }
        rAttrDef.tolerantValuePattern = schemaHandlingAttrDefType.getTolerantValuePattern();
        rAttrDef.intolerantValuePattern = schemaHandlingAttrDefType.getIntolerantValuePattern();
        rAttrDef.isExclusiveStrong = BooleanUtils.isTrue(schemaHandlingAttrDefType.isExclusiveStrong());
        rAttrDef.isVolatilityTrigger = BooleanUtils.isTrue(schemaHandlingAttrDefType.isVolatilityTrigger());
        if (schemaHandlingAttrDefType.getOutbound() != null) {
            rAttrDef.setOutboundMappingType(schemaHandlingAttrDefType.getOutbound());
        }
        if (schemaHandlingAttrDefType.getInbound() != null) {
            rAttrDef.setInboundMappingTypes(schemaHandlingAttrDefType.getInbound());
        }
        rAttrDef.setModificationPriority(schemaHandlingAttrDefType.getModificationPriority());
        // may be null at this point
        rAttrDef.setReadReplaceMode(schemaHandlingAttrDefType.isReadReplaceMode());
        if (schemaHandlingAttrDefType.isDisplayNameAttribute() != null && schemaHandlingAttrDefType.isDisplayNameAttribute()) {
            rAttrDef.isDisplayNameAttribute = true;
        }
    }
    PropertyLimitations previousLimitations = null;
    for (LayerType layer : LayerType.values()) {
        PropertyLimitations limitations = getOrCreateLimitations(rAttrDef.limitationsMap, layer);
        if (previousLimitations != null) {
            limitations.setMinOccurs(previousLimitations.getMinOccurs());
            limitations.setMaxOccurs(previousLimitations.getMaxOccurs());
            limitations.setIgnore(previousLimitations.isIgnore());
            limitations.getAccess().setAdd(previousLimitations.getAccess().isAdd());
            limitations.getAccess().setRead(previousLimitations.getAccess().isRead());
            limitations.getAccess().setModify(previousLimitations.getAccess().isModify());
        }
        previousLimitations = limitations;
        if (schemaHandlingAttrDefType != null) {
            if (layer != LayerType.SCHEMA) {
                // SCHEMA is a pseudo-layer. It cannot be overriden ... unless specified explicitly
                PropertyLimitationsType genericLimitationsType = MiscSchemaUtil.getLimitationsType(schemaHandlingAttrDefType.getLimitations(), null);
                if (genericLimitationsType != null) {
                    applyLimitationsType(limitations, genericLimitationsType);
                }
            }
            PropertyLimitationsType layerLimitationsType = MiscSchemaUtil.getLimitationsType(schemaHandlingAttrDefType.getLimitations(), layer);
            if (layerLimitationsType != null) {
                applyLimitationsType(limitations, layerLimitationsType);
            }
        }
    }
    return rAttrDef;
}
Also used : LayerType(com.evolveum.midpoint.xml.ns._public.common.common_3.LayerType) PropertyLimitationsType(com.evolveum.midpoint.xml.ns._public.common.common_3.PropertyLimitationsType)

Aggregations

PropertyLimitationsType (com.evolveum.midpoint.xml.ns._public.common.common_3.PropertyLimitationsType)7 PropertyLimitationsTypeDto (com.evolveum.midpoint.web.component.wizard.resource.dto.PropertyLimitationsTypeDto)3 ArrayList (java.util.ArrayList)2 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)1 PathKeyedMap (com.evolveum.midpoint.prism.path.PathKeyedMap)1 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)1 LayerType (com.evolveum.midpoint.xml.ns._public.common.common_3.LayerType)1 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)1 ObjectTemplateItemDefinitionType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectTemplateItemDefinitionType)1 PropertyAccessType (com.evolveum.midpoint.xml.ns._public.common.common_3.PropertyAccessType)1 Map (java.util.Map)1