Search in sources :

Example 1 with ResourceObjectAssociationType

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

the class Construction method evaluateAssociations.

private void evaluateAssociations(Task task, OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException {
    associationMappings = new ArrayList<>();
    for (ResourceObjectAssociationType associationDefinitionType : getConstructionType().getAssociation()) {
        QName assocName = ItemPathUtil.getOnlySegmentQName(associationDefinitionType.getRef());
        if (assocName == null) {
            throw new SchemaException("No association name (ref) in association definition in construction in " + getSource());
        }
        MappingType outboundMappingType = associationDefinitionType.getOutbound();
        if (outboundMappingType == null) {
            throw new SchemaException("No outbound section in definition of association " + assocName + " in construction in " + getSource());
        }
        Mapping<PrismContainerValue<ShadowAssociationType>, PrismContainerDefinition<ShadowAssociationType>> assocMapping = evaluateAssociation(associationDefinitionType, task, result);
        if (assocMapping != null) {
            associationMappings.add(assocMapping);
        }
    }
}
Also used : MappingType(com.evolveum.midpoint.xml.ns._public.common.common_3.MappingType) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) PrismContainerValue(com.evolveum.midpoint.prism.PrismContainerValue) QName(javax.xml.namespace.QName) PrismContainerDefinition(com.evolveum.midpoint.prism.PrismContainerDefinition) ResourceObjectAssociationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectAssociationType)

Example 2 with ResourceObjectAssociationType

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

the class ResourceTypeAssignmentPopupTabPanel method getSelectedAssignmentsMap.

@Override
protected Map<String, AssignmentType> getSelectedAssignmentsMap() {
    Map<String, AssignmentType> assignmentList = new HashMap<>();
    List<ResourceType> selectedObjects = getSelectedObjectsList();
    ShadowKindType kind = getKindValue();
    String intent = getIntentValue();
    selectedObjects.forEach(selectedObject -> {
        AssignmentType newConstructionAssignment = ObjectTypeUtil.createAssignmentWithConstruction(selectedObject.asPrismObject(), kind, intent, getPageBase().getPrismContext());
        if (isEntitlementAssignment()) {
            NameItemPathSegment segment = getAssociationValue() != null ? new NameItemPathSegment(getAssociationValue().getName()) : null;
            if (segment != null) {
                ResourceObjectAssociationType association = new ResourceObjectAssociationType();
                association.setRef(new ItemPathType(ItemPath.create(segment)));
                newConstructionAssignment.getConstruction().getAssociation().add(association);
            }
        }
        assignmentList.put(selectedObject.getOid(), newConstructionAssignment);
    });
    return assignmentList;
}
Also used : HashMap(java.util.HashMap) ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) ShadowKindType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType) NameItemPathSegment(com.evolveum.midpoint.prism.path.NameItemPathSegment) ResourceObjectAssociationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectAssociationType)

Example 3 with ResourceObjectAssociationType

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

the class Construction method evaluateAssociation.

private Mapping<PrismContainerValue<ShadowAssociationType>, PrismContainerDefinition<ShadowAssociationType>> evaluateAssociation(ResourceObjectAssociationType associationDefinitionType, Task task, OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException {
    QName assocName = ItemPathUtil.getOnlySegmentQName(associationDefinitionType.getRef());
    if (assocName == null) {
        throw new SchemaException("Missing 'ref' in association in construction in " + getSource());
    }
    MappingType outboundMappingType = associationDefinitionType.getOutbound();
    if (outboundMappingType == null) {
        throw new SchemaException("No outbound section in definition of association " + assocName + " in construction in " + getSource());
    }
    PrismContainerDefinition<ShadowAssociationType> outputDefinition = getAssociationContainerDefinition();
    Mapping.Builder<PrismContainerValue<ShadowAssociationType>, PrismContainerDefinition<ShadowAssociationType>> mappingBuilder = mappingFactory.<PrismContainerValue<ShadowAssociationType>, PrismContainerDefinition<ShadowAssociationType>>createMappingBuilder().mappingType(outboundMappingType).contextDescription("for association " + PrettyPrinter.prettyPrint(assocName) + " in " + getSource()).originType(OriginType.ASSIGNMENTS).originObject(getSource());
    RefinedAssociationDefinition rAssocDef = refinedObjectClassDefinition.findAssociationDefinition(assocName);
    if (rAssocDef == null) {
        throw new SchemaException("No association " + assocName + " in object class " + refinedObjectClassDefinition.getHumanReadableName() + " in construction in " + getSource());
    }
    Mapping<PrismContainerValue<ShadowAssociationType>, PrismContainerDefinition<ShadowAssociationType>> evaluatedMapping = evaluateMapping(mappingBuilder, assocName, outputDefinition, rAssocDef.getAssociationTarget(), task, result);
    LOGGER.trace("Evaluated mapping for association " + assocName + ": " + evaluatedMapping);
    return evaluatedMapping;
}
Also used : MappingType(com.evolveum.midpoint.xml.ns._public.common.common_3.MappingType) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) PrismContainerValue(com.evolveum.midpoint.prism.PrismContainerValue) QName(javax.xml.namespace.QName) PrismContainerDefinition(com.evolveum.midpoint.prism.PrismContainerDefinition) Mapping(com.evolveum.midpoint.model.common.mapping.Mapping) ShadowAssociationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowAssociationType) RefinedAssociationDefinition(com.evolveum.midpoint.common.refinery.RefinedAssociationDefinition)

Aggregations

PrismContainerDefinition (com.evolveum.midpoint.prism.PrismContainerDefinition)2 PrismContainerValue (com.evolveum.midpoint.prism.PrismContainerValue)2 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)2 MappingType (com.evolveum.midpoint.xml.ns._public.common.common_3.MappingType)2 ResourceObjectAssociationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectAssociationType)2 QName (javax.xml.namespace.QName)2 RefinedAssociationDefinition (com.evolveum.midpoint.common.refinery.RefinedAssociationDefinition)1 Mapping (com.evolveum.midpoint.model.common.mapping.Mapping)1 NameItemPathSegment (com.evolveum.midpoint.prism.path.NameItemPathSegment)1 AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)1 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)1 ShadowAssociationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowAssociationType)1 ShadowKindType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType)1 ItemPathType (com.evolveum.prism.xml.ns._public.types_3.ItemPathType)1 HashMap (java.util.HashMap)1