Skip to content

Commit

Permalink
Add configurable normalization
Browse files Browse the repository at this point in the history
It is now possible to configure how data in identity/items/normalized
are computed.

Other changes:
- Removed obsolete correlator/definitions schema item (and relatives).

Work in progress.
  • Loading branch information
mederly committed Aug 8, 2022
1 parent b6200ef commit a75240d
Show file tree
Hide file tree
Showing 34 changed files with 1,131 additions and 740 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ static Map<Class<?>, Supplier<ItemMerger>> createStandardTypeSpecificMergersMap(
entry(
AbstractCorrelatorType.class,
() -> new GenericItemMerger(marker, DefaultNaturalKeyImpl.of(AbstractCorrelatorType.F_NAME))),
entry(
CorrelationItemDefinitionType.class,
() -> new GenericItemMerger(marker, DefaultNaturalKeyImpl.of(CorrelationItemDefinitionType.F_NAME))),
entry(
SynchronizationReactionType.class,
() -> new GenericItemMerger(marker, DefaultNaturalKeyImpl.of(SynchronizationReactionType.F_NAME))),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class CorrelationItemDefinitionUtil {
/**
* Returns the name under which we will reference this item definition (using "ref" elements).
*/
public static @NotNull String getName(@NotNull CorrelationItemDefinitionType definitionBean) {
public static @NotNull String getName(@NotNull ItemCorrelationType definitionBean) {
if (definitionBean.getName() != null) {
return definitionBean.getName();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ public static <F extends FocusType> List<ObjectReferenceType> getLiveLinkRefs(F
return identities != null ? FocusIdentitiesTypeUtil.getMatchingIdentity(identities, source) : null;
}

// TODO reconsider this method placement
public static void addOrReplaceIdentity(@NotNull FocusType focus, @NotNull FocusIdentityType identity) {
deleteCompatibleIdentity(focus, identity);
addIdentity(focus, identity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,99 +341,6 @@
</xsd:appinfo>
</xsd:annotation>
</xsd:element>

<xsd:element name="definitions" type="tns:CorrelatorDefinitionsType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
TODO
</xsd:documentation>
<xsd:appinfo>
<a:displayName>AbstractCorrelatorType.definitions</a:displayName>
<a:displayOrder>5</a:displayOrder>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="id" type="xsd:long"/>
</xsd:complexType>

<xsd:complexType name="CorrelatorDefinitionsType">
<xsd:annotation>
<xsd:documentation>
TODO
</xsd:documentation>
<xsd:appinfo>
<a:since>4.5</a:since>
<a:container>true</a:container>
<a:experimental>true</a:experimental>
</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="items" type="tns:CorrelationItemsDefinitionType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
TODO
</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="id" type="xsd:long"/>
</xsd:complexType>

<xsd:complexType name="CorrelationItemsDefinitionType">
<xsd:annotation>
<xsd:documentation>
Shared (referencable) definitions of correlation items.
</xsd:documentation>
<xsd:appinfo>
<a:since>4.5</a:since>
<a:container>true</a:container>
<a:experimental>true</a:experimental>
</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="item" type="tns:CorrelationItemDefinitionType" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>
Collection of definitions of individual correlation items.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="id" type="xsd:long"/>
</xsd:complexType>

<xsd:complexType name="CorrelationItemDefinitionType">
<xsd:annotation>
<xsd:documentation>
Shared definition of a correlation item.

TODO consider removal
</xsd:documentation>
<xsd:appinfo>
<a:since>4.5</a:since>
<a:container>true</a:container>
<a:experimental>true</a:experimental>
</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="name" type="xsd:string" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Name by which this definition is referenced. If not present, the last segment of the path
is used to derive the name.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element ref="tns:description" minOccurs="0"/>
<xsd:element ref="tns:documentation" minOccurs="0"/>
<xsd:element name="path" type="t:ItemPathType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
TODO
</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="id" type="xsd:long"/>
</xsd:complexType>
Expand Down Expand Up @@ -548,19 +455,32 @@
<a:experimental>true</a:experimental>
</xsd:appinfo>
</xsd:annotation>
<xsd:complexContent>
<xsd:extension base="c:CorrelationItemDefinitionType">
<xsd:sequence>
<xsd:element name="ref" type="xsd:string" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Points to a shared item definition in "items" part of "definitions".
</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
<xsd:sequence>
<xsd:element name="name" type="xsd:string" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Name by which this definition is referenced. If not present, the last segment of the path
is used to derive the name.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element ref="tns:description" minOccurs="0"/>
<xsd:element ref="tns:documentation" minOccurs="0"/>
<xsd:element name="path" type="t:ItemPathType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
TODO
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="index" type="xsd:string" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
What index to use when matching this item? If none is specified, the default one is used. (TODO)
</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="itemCorrelation" type="tns:ItemCorrelationType"/>

Expand Down Expand Up @@ -1442,6 +1362,13 @@
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="default" type="xsd:boolean" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
TODO
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="indexedNormalizedItemName" type="xsd:string" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Expand Down Expand Up @@ -1475,28 +1402,28 @@
</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="none" type="tns:NoOpNormalizationStepType" minOccurs="0">
<xsd:element name="none" type="tns:NoOpNormalizationStepType" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>
TODO
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="polyString" type="tns:PolyStringNormalizationStepType" minOccurs="0">
<xsd:element name="polyString" type="tns:PolyStringNormalizationStepType" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>
TODO
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="prefix" type="tns:PrefixNormalizationStepType" minOccurs="0">
<xsd:element name="prefix" type="tns:PrefixNormalizationStepType" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>
TODO
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="custom" type="tns:CustomNormalizationStepType" minOccurs="0">
<xsd:element name="custom" type="tns:CustomNormalizationStepType" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>
TODO
Expand All @@ -1507,7 +1434,7 @@
<xsd:attribute name="id" type="xsd:long"/>
</xsd:complexType>

<xsd:complexType name="AbstractNormalizationStepsType">
<xsd:complexType name="AbstractNormalizationStepType">
<xsd:annotation>
<xsd:documentation>
TODO
Expand Down Expand Up @@ -1549,7 +1476,7 @@
</xsd:appinfo>
</xsd:annotation>
<xsd:complexContent>
<xsd:extension base="tns:AbstractNormalizationStepsType"/>
<xsd:extension base="tns:AbstractNormalizationStepType"/>
</xsd:complexContent>
</xsd:complexType>

Expand All @@ -1565,7 +1492,7 @@
</xsd:appinfo>
</xsd:annotation>
<xsd:complexContent>
<xsd:extension base="tns:AbstractNormalizationStepsType">
<xsd:extension base="tns:AbstractNormalizationStepType">
<xsd:sequence>
<xsd:element name="configuration" type="t:PolyStringNormalizerConfigurationType" minOccurs="0">
<xsd:annotation>
Expand All @@ -1591,7 +1518,7 @@
</xsd:appinfo>
</xsd:annotation>
<xsd:complexContent>
<xsd:extension base="tns:AbstractNormalizationStepsType">
<xsd:extension base="tns:AbstractNormalizationStepType">
<xsd:sequence>
<xsd:element name="length" type="xsd:int" minOccurs="0">
<xsd:annotation>
Expand All @@ -1617,7 +1544,7 @@
</xsd:appinfo>
</xsd:annotation>
<xsd:complexContent>
<xsd:extension base="tns:AbstractNormalizationStepsType">
<xsd:extension base="tns:AbstractNormalizationStepType">
<xsd:sequence>
<xsd:element name="expression" type="tns:ExpressionType" minOccurs="0">
<xsd:annotation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,22 @@

package com.evolveum.midpoint.model.api.correlator;

import com.evolveum.axiom.concepts.Lazy;
import java.util.HashMap;
import java.util.Map;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import com.evolveum.midpoint.model.api.identities.IdentityManagementConfiguration;
import com.evolveum.midpoint.model.api.identities.IndexingConfiguration;
import com.evolveum.midpoint.prism.PrismContext;
import com.evolveum.midpoint.schema.util.CorrelationItemDefinitionUtil;
import com.evolveum.midpoint.util.DebugDumpable;

import com.evolveum.midpoint.util.DebugUtil;
import com.evolveum.midpoint.util.MiscUtil;
import com.evolveum.midpoint.util.exception.ConfigurationException;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractCorrelatorType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.CorrelationDefinitionType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ItemCorrelationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType;

/**
* Overall context in which the correlator works.
Expand All @@ -49,25 +47,26 @@ public class CorrelatorContext<C extends AbstractCorrelatorType> implements Debu
/** TODO */
@NotNull private final IdentityManagementConfiguration identityManagementConfiguration;

/** TODO */
@NotNull private final IndexingConfiguration indexingConfiguration;

/** System configuration, used to look for correlator configurations. */
@Nullable private final SystemConfigurationType systemConfiguration;

// TODO
@NotNull private final Lazy<Map<String, CorrelationItemDefinitionType>> itemDefinitionsLazy =
Lazy.from(this::createItemDefinitionsMap);

public CorrelatorContext(
@NotNull CorrelatorConfiguration configuration,
@NotNull AbstractCorrelatorType originalConfigurationBean,
@Nullable CorrelationDefinitionType correlationDefinitionBean,
@NotNull IdentityManagementConfiguration identityManagementConfiguration,
@NotNull IndexingConfiguration indexingConfiguration,
@Nullable SystemConfigurationType systemConfiguration) {
//noinspection unchecked
this.configurationBean = (C) configuration.getConfigurationBean();
this.configuration = configuration;
this.originalConfigurationBean = originalConfigurationBean;
this.correlationDefinitionBean = correlationDefinitionBean;
this.identityManagementConfiguration = identityManagementConfiguration;
this.indexingConfiguration = indexingConfiguration;
this.systemConfiguration = systemConfiguration;
}

Expand All @@ -80,38 +79,10 @@ public CorrelatorContext(
}

/**
* Returns the named item definition.
*/
public @NotNull CorrelationItemDefinitionType getNamedItemDefinition(String ref) throws ConfigurationException {
return MiscUtil.requireNonNull(
itemDefinitionsLazy.get().get(ref),
() -> new ConfigurationException("No item named '" + ref + "' exists"));
}

/**
* Returns all relevant named item definitions - from this context and all its parents.
* TODO
*/
public @NotNull Map<String, CorrelationItemDefinitionType> getItemDefinitionsMap() {
return itemDefinitionsLazy.get();
}

private @NotNull Map<String, CorrelationItemDefinitionType> createItemDefinitionsMap() {
Map<String, CorrelationItemDefinitionType> defMap = new HashMap<>();
getLocalItemsDefinitionCollection().forEach(
def -> {
String name = CorrelationItemDefinitionUtil.getName(def);
if (!defMap.containsKey(name)) {
defMap.put(name, def);
}
}
);
return defMap;
}

private List<CorrelationItemDefinitionType> getLocalItemsDefinitionCollection() {
CorrelatorDefinitionsType definitions = configurationBean.getDefinitions();
return definitions != null && definitions.getItems() != null ?
definitions.getItems().getItem() : List.of();
public @NotNull Map<String, ItemCorrelationType> getItemDefinitionsMap() {
return new HashMap<>(); // TODO extract from the object template
}

public @NotNull AbstractCorrelatorType getOriginalConfigurationBean() {
Expand All @@ -130,6 +101,10 @@ private List<CorrelationItemDefinitionType> getLocalItemsDefinitionCollection()
return identityManagementConfiguration;
}

public @NotNull IndexingConfiguration getIndexingConfiguration() {
return indexingConfiguration;
}

@Override
public String debugDump(int indent) {
// Temporary: this config bean is the core of the context; other things need not be so urgently dumped
Expand Down

0 comments on commit a75240d

Please sign in to comment.