Class MappingUtils
Provides helpers to:
- Create new virtual
MappingTypevalues and their UI wrappers. - Assemble synthetic containers of mappings for table components.
- Insert hidden virtual
refproperties to support UI editing. - Clone and initialize attribute definitions with inbound mappings if required.
- Extract
refvalues from various attribute container types.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <P extends Containerable>
voidaddNewMappingValue(@NotNull PageBase pageBase, @NotNull org.apache.wicket.model.IModel<PrismContainerValueWrapper<P>> resourceObjectTypeDefinition, @NotNull ResourceDetailsModel assignmentHolderDetailsModel, @NotNull ResourceAttributeDefinitionType newAttribute) static voidcreateDirectRefVirtualItemInMapping(@NotNull PrismContainerValueWrapper<MappingType> mapping, @Nullable ItemPathType attributeRefAttributeValue, @NotNull PrismPropertyDefinition<Object> propertyDef, @NotNull PageBase pageBase, @NotNull ItemName itemNameOfRefAttribute, @NotNull MappingDirection mappingDirection) static voidcreateMappingsValueIfRequired(@NotNull PageBase pageBase, @NotNull org.apache.wicket.model.IModel<PrismContainerValueWrapper<ResourceObjectTypeDefinitionType>> resourceObjectTypeDefinition, @Nullable List<ResourceAttributeDefinitionType> candidateAttributes, @NotNull ResourceDetailsModel assignmentHolderDetailsModel) Ensures that inbound mapping values exist for the given candidate attributes.static <P extends Containerable,AD extends Containerable>
@Nullable PrismContainerValueWrapper<MappingType>createNewVirtualMappingValue(@Nullable PrismContainerValue<MappingType> value, @NotNull org.apache.wicket.model.IModel<PrismContainerValueWrapper<P>> valueModel, @NotNull MappingDirection mappingDirection, @NotNull ItemName itemNameOfContainerWithMappings, @NotNull ItemName itemNameOfRefAttribute, @NotNull PageBase pageBase, org.apache.wicket.ajax.AjaxRequestTarget target) Creates a new virtualMappingTypevalue for the given container model.static <AD extends Containerable>
voidcreateVirtualItemInMapping(@NotNull PrismContainerValueWrapper<MappingType> mapping, @Nullable PrismContainerValueWrapper<AD> value, @NotNull PrismPropertyDefinition<Object> propertyDef, @NotNull PageBase pageBase, @NotNull ItemName itemNameOfRefAttribute, @NotNull MappingDirection mappingDirection) Creates a virtualrefproperty inside the given mapping, if it does not already exist.static <P extends Containerable,AD extends Containerable>
@NotNull org.apache.wicket.model.IModel<PrismContainerWrapper<MappingType>>createVirtualMappingContainerModel(@NotNull PageBase pageBase, @NotNull org.apache.wicket.model.IModel<PrismContainerValueWrapper<P>> valueModel, @NotNull ItemName itemNameOfContainerWithMappings, @NotNull ItemName itemNameOfRefAttribute, @NotNull MappingDirection mappingDirection) Builds a virtual container model forMappingTypevalues.static voidexcludeUnwantedMappings(@NotNull List<PrismContainerValueWrapper<MappingType>> list, MappingUsedFor usedFor) Filters the given list in place, keeping only mappings matching the specified usage type.static <AD extends Containerable>
@Nullable ItemPathTypegetAttributeRefAttributeValue(@Nullable PrismContainerValueWrapper<AD> value) Extracts therefvalue from the given attribute container wrapper.static ItemNamegetPathBaseOnMappingType(MappingDirection mappingDirection) Resolves the container item name corresponding to the given mapping direction.static booleanisExcludedMapping(MappingUsedFor usedFor, @NotNull PrismContainerValueWrapper<MappingType> valueWrapper)
-
Constructor Details
-
MappingUtils
public MappingUtils()
-
-
Method Details
-
createNewVirtualMappingValue
@Nullable public static <P extends Containerable,AD extends Containerable> @Nullable PrismContainerValueWrapper<MappingType> createNewVirtualMappingValue(@Nullable @Nullable PrismContainerValue<MappingType> value, @NotNull @NotNull org.apache.wicket.model.IModel<PrismContainerValueWrapper<P>> valueModel, @NotNull @NotNull MappingDirection mappingDirection, @NotNull @NotNull ItemName itemNameOfContainerWithMappings, @NotNull @NotNull ItemName itemNameOfRefAttribute, @NotNull @NotNull PageBase pageBase, org.apache.wicket.ajax.AjaxRequestTarget target) Creates a new virtualMappingTypevalue for the given container model.A new attribute mapping container value is created, wrapped for UI, marked with the specified
MappingDirection, and initialized with a strong mapping strength. A hidden virtualrefproperty is also created so that the UI can properly display the mapping.- Parameters:
value- optional mapping value to reuse, otherwise a new one is createdvalueModel- model of the parent container value wrappermappingDirection- direction of the mapping (e.g. inbound/outbound)itemNameOfContainerWithMappings- item name of the container holding mappingsitemNameOfRefAttribute- item name of the reference attributepageBase- current page contexttarget- Ajax target for UI updates- Returns:
- created mapping value wrapper, or
nullif creation failed
-
createVirtualMappingContainerModel
@NotNull public static <P extends Containerable,AD extends Containerable> @NotNull org.apache.wicket.model.IModel<PrismContainerWrapper<MappingType>> createVirtualMappingContainerModel(@NotNull @NotNull PageBase pageBase, @NotNull @NotNull org.apache.wicket.model.IModel<PrismContainerValueWrapper<P>> valueModel, @NotNull @NotNull ItemName itemNameOfContainerWithMappings, @NotNull @NotNull ItemName itemNameOfRefAttribute, @NotNull @NotNull MappingDirection mappingDirection) Builds a virtual container model forMappingTypevalues.The returned model collects all mappings of the specified direction from the given parent value, ensures each one has a hidden virtual
refproperty, and presents them as a synthetic container suitable for use in tables or forms.- Parameters:
pageBase- current page contextvalueModel- model of the parent container value wrapperitemNameOfContainerWithMappings- item name of the container holding mappingsitemNameOfRefAttribute- item name of the reference attributemappingDirection- direction of mappings to collect- Returns:
- model of a virtual mapping container
-
createVirtualItemInMapping
public static <AD extends Containerable> void createVirtualItemInMapping(@NotNull @NotNull PrismContainerValueWrapper<MappingType> mapping, @Nullable @Nullable PrismContainerValueWrapper<AD> value, @NotNull @NotNull PrismPropertyDefinition<Object> propertyDef, @NotNull @NotNull PageBase pageBase, @NotNull @NotNull ItemName itemNameOfRefAttribute, @NotNull @NotNull MappingDirection mappingDirection) Creates a virtualrefproperty inside the given mapping, if it does not already exist.The virtual item is initialized from the provided attribute value (if present), wrapped for UI, hidden from the user, and inserted into the mapping container to ensure consistent editing in forms and tables.
- Parameters:
mapping- mapping container value wrapper where the virtual item is createdvalue- optional parent attribute value to initialize the ref frompropertyDef- definition of the reference propertypageBase- current page contextitemNameOfRefAttribute- item name of the reference attributemappingDirection- mapping direction (used for display name and context)
-
createDirectRefVirtualItemInMapping
public static void createDirectRefVirtualItemInMapping(@NotNull @NotNull PrismContainerValueWrapper<MappingType> mapping, @Nullable @Nullable ItemPathType attributeRefAttributeValue, @NotNull @NotNull PrismPropertyDefinition<Object> propertyDef, @NotNull @NotNull PageBase pageBase, @NotNull @NotNull ItemName itemNameOfRefAttribute, @NotNull @NotNull MappingDirection mappingDirection) -
getAttributeRefAttributeValue
@Nullable public static <AD extends Containerable> @Nullable ItemPathType getAttributeRefAttributeValue(@Nullable @Nullable PrismContainerValueWrapper<AD> value) Extracts therefvalue from the given attribute container wrapper.Supports multiple container types (e.g.
ResourceAttributeDefinitionType,AttributeInboundMappingsDefinitionType,AttributeOutboundMappingsDefinitionType,ShadowAssociationDefinitionType). Returnsnullif the value is missing or not of a supported type.- Type Parameters:
AD- concrete attribute container type- Parameters:
value- wrapper of an attribute container- Returns:
- extracted
ItemPathTypereference, ornullif unavailable
-
getPathBaseOnMappingType
Resolves the container item name corresponding to the given mapping direction.- Parameters:
mappingDirection- direction of the mapping (may benull)- Returns:
- item name of the container for this direction, or
nullif direction is not provided
-
createMappingsValueIfRequired
public static void createMappingsValueIfRequired(@NotNull @NotNull PageBase pageBase, @NotNull @NotNull org.apache.wicket.model.IModel<PrismContainerValueWrapper<ResourceObjectTypeDefinitionType>> resourceObjectTypeDefinition, @Nullable @Nullable List<ResourceAttributeDefinitionType> candidateAttributes, @NotNull @NotNull ResourceDetailsModel assignmentHolderDetailsModel) Ensures that inbound mapping values exist for the given candidate attributes.Each provided
ResourceAttributeDefinitionTypeis cloned, added into the attribute container of the given resource object type definition, wrapped for UI, and initialized with a hidden virtualrefproperty. The visible ref is cleared so the user can edit it in the form.- Parameters:
pageBase- current page contextresourceObjectTypeDefinition- model of the resource object type definition wrappercandidateAttributes- attributes to be added (may-benullor empty)assignmentHolderDetailsModel- context used when creating wrappers
-
addNewMappingValue
public static <P extends Containerable> void addNewMappingValue(@NotNull @NotNull PageBase pageBase, @NotNull @NotNull org.apache.wicket.model.IModel<PrismContainerValueWrapper<P>> resourceObjectTypeDefinition, @NotNull @NotNull ResourceDetailsModel assignmentHolderDetailsModel, @NotNull @NotNull ResourceAttributeDefinitionType newAttribute) throws SchemaException - Throws:
SchemaException
-
excludeUnwantedMappings
public static void excludeUnwantedMappings(@NotNull @NotNull List<PrismContainerValueWrapper<MappingType>> list, MappingUsedFor usedFor) Filters the given list in place, keeping only mappings matching the specified usage type. Mappings whoseusevalue differs fromusedForare removed. -
isExcludedMapping
public static boolean isExcludedMapping(MappingUsedFor usedFor, @NotNull @NotNull PrismContainerValueWrapper<MappingType> valueWrapper)
-