Search in sources :

Example 1 with LayerType

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

the class LimitationsEditorDialog method createLimitationsLabelModel.

private IModel<String> createLimitationsLabelModel(final ListItem<PropertyLimitationsTypeDto> item) {
    return new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            StringBuilder sb = new StringBuilder();
            PropertyLimitationsTypeDto dto = item.getModelObject();
            sb.append("#").append(item.getIndex() + 1).append(" - ");
            List<LayerType> layers = new ArrayList<>();
            if (dto.isModel()) {
                layers.add(LayerType.MODEL);
            }
            if (dto.isPresentation()) {
                layers.add(LayerType.PRESENTATION);
            }
            if (dto.isSchema()) {
                layers.add(LayerType.SCHEMA);
            }
            sb.append(StringUtils.join(layers, ", "));
            sb.append(":");
            if (dto.getLimitationObject().getAccess() != null) {
                List<String> accesses = new ArrayList<>();
                PropertyAccessType access = dto.getLimitationObject().getAccess();
                if (BooleanUtils.isTrue(access.isRead())) {
                    accesses.add(getString("LimitationsEditorDialog.label.read"));
                }
                if (BooleanUtils.isTrue(access.isAdd())) {
                    accesses.add(getString("LimitationsEditorDialog.label.add"));
                }
                if (BooleanUtils.isTrue(access.isModify())) {
                    accesses.add(getString("LimitationsEditorDialog.label.modify"));
                }
                sb.append(StringUtils.join(accesses, ", "));
            }
            return sb.toString();
        }
    };
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) PropertyLimitationsTypeDto(com.evolveum.midpoint.web.component.wizard.resource.dto.PropertyLimitationsTypeDto) LayerType(com.evolveum.midpoint.xml.ns._public.common.common_3.LayerType) ArrayList(java.util.ArrayList) PropertyAccessType(com.evolveum.midpoint.xml.ns._public.common.common_3.PropertyAccessType)

Example 2 with LayerType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.LayerType 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

LayerType (com.evolveum.midpoint.xml.ns._public.common.common_3.LayerType)2 PropertyLimitationsTypeDto (com.evolveum.midpoint.web.component.wizard.resource.dto.PropertyLimitationsTypeDto)1 PropertyAccessType (com.evolveum.midpoint.xml.ns._public.common.common_3.PropertyAccessType)1 PropertyLimitationsType (com.evolveum.midpoint.xml.ns._public.common.common_3.PropertyLimitationsType)1 ArrayList (java.util.ArrayList)1 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)1