Search in sources :

Example 86 with ItemName

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

the class MappedItems method createAuxObjClassesMappingCreationRequest.

/**
 * Creates a mapping creation request for mapping(s) for auxiliary object classes.
 *
 * @see #createAttributeMappingCreationRequest(QName)
 * @see #createAttributeMappingCreationRequest(QName)
 */
private void createAuxObjClassesMappingCreationRequest() {
    // 1. Definitions
    ItemName itemPath = ShadowType.F_AUXILIARY_OBJECT_CLASS;
    String itemDescription = "auxiliary object classes";
    ResourceBidirectionalMappingAndDefinitionType auxiliaryObjectClassMappings = source.resourceObjectDefinition.getAuxiliaryObjectClassMappings();
    if (auxiliaryObjectClassMappings == null) {
        return;
    }
    // TODO add filtering after these mappings are promoted to InboundMappingType
    List<MappingType> mappingBeans = auxiliaryObjectClassMappings.getInbound();
    if (mappingBeans.isEmpty()) {
        return;
    }
    // 2. Values
    ItemDelta<PrismPropertyValue<QName>, PrismPropertyDefinition<QName>> itemAPrioriDelta = getItemAPrioriDelta(itemPath);
    MappedItem.ItemProvider<PrismPropertyValue<QName>, PrismPropertyDefinition<QName>> itemProvider = this::getCurrentAuxiliaryObjectClasses;
    // 3. Processing source
    ProcessingMode processingMode = source.getItemProcessingMode(itemDescription, itemAPrioriDelta, mappingBeans, // aux OCs are never ignored
    false, // aux OCs are never unreadable
    null);
    if (processingMode == ProcessingMode.NONE) {
        return;
    }
    // 4. Mapping creation request
    // Note that we intentionally ignore a-priori delta for aux OCs. The reason is unknown for me, but
    // this is how it was done before 4.5.
    // 
    // We also insist on fetching the full shadow, unless getProcessingSource() has told us that we should not process
    // these mappings.
    // 
    // TODO reconsider these irregularities in behavior (comparing with attribute/association mappings).
    mappedItems.add(new MappedItem<>(source, target, context, mappingBeans, itemPath, itemDescription, // ignoring a priori delta
    null, lazyAuxiliaryObjectClassPropertyDefinition.get(), itemProvider, // postprocessor
    null, // variable producer
    null, ProcessingMode.ABSOLUTE_STATE));
}
Also used : ItemName(com.evolveum.midpoint.prism.path.ItemName)

Example 87 with ItemName

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

the class MappedItems method createAssociationMappingCreationRequest.

/**
 * Creates a mapping creation request for mapping(s) for given association.
 *
 * The situation is complicated by the fact that all associations are mixed up in `shadow.association` container.
 *
 * @see #createAttributeMappingCreationRequest(QName)
 * @see #createAuxObjClassesMappingCreationRequest()
 */
private void createAssociationMappingCreationRequest(QName associationName) {
    // 1. Definitions
    ResourceAssociationDefinition associationDefinition = Objects.requireNonNull(source.resourceObjectDefinition.findAssociationDefinition(associationName), () -> "No definition for association " + associationName);
    ItemName itemPath = ShadowType.F_ASSOCIATION;
    String itemDescription = "association " + associationName;
    List<InboundMappingType> mappingBeans = source.filterApplicableMappingBeans(associationDefinition.getInboundMappingTypes());
    if (mappingBeans.isEmpty()) {
        LOGGER.trace("No applicable beans for this phase");
        return;
    }
    // 2. Values
    // TODO Shouldn't we filter the apriori delta for specific association? (Instead of passing any association deltas?)
    ItemDelta<PrismContainerValue<ShadowAssociationType>, PrismContainerDefinition<ShadowAssociationType>> associationAPrioriDelta = getItemAPrioriDelta(itemPath);
    MappedItem.ItemProvider<PrismContainerValue<ShadowAssociationType>, PrismContainerDefinition<ShadowAssociationType>> associationProvider = () -> getCurrentAssociation(associationName);
    // 3. Processing source
    ProcessingMode processingMode = source.getItemProcessingMode(itemDescription, associationAPrioriDelta, mappingBeans, associationDefinition.isIgnored(LayerType.MODEL), associationDefinition.getLimitations(LayerType.MODEL));
    if (processingMode == ProcessingMode.NONE) {
        return;
    }
    // 4. Mapping creation request
    mappedItems.add(new MappedItem<>(source, target, context, mappingBeans, // source path (cannot point to specified association name!)
    itemPath, itemDescription, // a priori delta for all associations - see TO-DO above
    associationAPrioriDelta, lazyAssociationContainerDefinition.get(), // association item provider
    associationProvider, // postprocessor
    source::resolveInputEntitlements, // so-called variable producer
    source::getEntitlementVariableProducer, processingMode));
}
Also used : ItemName(com.evolveum.midpoint.prism.path.ItemName) ResourceAssociationDefinition(com.evolveum.midpoint.schema.processor.ResourceAssociationDefinition)

Example 88 with ItemName

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

the class CaseWorkItemReferenceMapper method map.

@Override
public RCaseWorkItemReference map(Referencable input, MapperContext context) {
    RCaseWorkItem owner = (RCaseWorkItem) context.getOwner();
    ObjectReferenceType objectRef = buildReference(input);
    RCaseWorkItemReferenceOwner type;
    ItemName name = context.getDelta().getPath().lastName();
    if (QNameUtil.match(name, CaseWorkItemType.F_ASSIGNEE_REF)) {
        type = RCaseWorkItemReferenceOwner.ASSIGNEE;
    } else if (QNameUtil.match(name, CaseWorkItemType.F_CANDIDATE_REF)) {
        type = RCaseWorkItemReferenceOwner.CANDIDATE;
    } else {
        throw new IllegalStateException("Unknown case work item reference owner: " + name + "(delta = " + context.getDelta() + ")");
    }
    return RCaseWorkItemReference.jaxbRefToRepo(objectRef, owner, context.getRelationRegistry(), type);
}
Also used : RCaseWorkItem(com.evolveum.midpoint.repo.sql.data.common.container.RCaseWorkItem) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) RCaseWorkItemReferenceOwner(com.evolveum.midpoint.repo.sql.data.common.other.RCaseWorkItemReferenceOwner) ItemName(com.evolveum.midpoint.prism.path.ItemName)

Example 89 with ItemName

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

the class ClassDefinitionParser method addVirtualDefinitionsForClass.

private void addVirtualDefinitionsForClass(Class jpaClass, JpaEntityDefinition entityDef) {
    QueryEntity qEntity = (QueryEntity) jpaClass.getAnnotation(QueryEntity.class);
    if (qEntity == null) {
        return;
    }
    for (VirtualAny any : qEntity.anyElements()) {
        ItemName jaxbName = new ItemName(any.jaxbNameNamespace(), any.jaxbNameLocalPart());
        VirtualAnyContainerDefinition def = new VirtualAnyContainerDefinition(any.ownerType());
        JpaLinkDefinition linkDefinition = new JpaLinkDefinition<>(jaxbName, null, null, false, def);
        entityDef.addDefinition(linkDefinition);
    }
    for (VirtualCollection collection : qEntity.collections()) {
        // only collections of entities expected at this moment
        VirtualCollectionSpecification colSpec = new VirtualCollectionSpecification(collection.additionalParams());
        ItemName jaxbName = createItemName(collection.jaxbName());
        String jpaName = collection.jpaName();
        JpaEntityDefinition content = parseClass(collection.collectionType());
        JpaLinkDefinition linkDefinition = new JpaLinkDefinition<>(jaxbName, jpaName, colSpec, false, content);
        entityDef.addDefinition(linkDefinition);
    }
}
Also used : ItemName(com.evolveum.midpoint.prism.path.ItemName) RPolyString(com.evolveum.midpoint.repo.sql.data.common.embedded.RPolyString)

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