Skip to content

Commit

Permalink
Add draft of built-in manual correlation
Browse files Browse the repository at this point in the history
Filter and Expression correlators can now create "manual" correlation
cases as well.

Work in progress. No GUI, no case resolution, messy code.
  • Loading branch information
mederly committed Jan 18, 2022
1 parent 15db665 commit b451d4f
Show file tree
Hide file tree
Showing 32 changed files with 1,072 additions and 116 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1311,6 +1311,14 @@
</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="refreshWhenOpened" type="xsd:boolean" minOccurs="0" default="false">
<xsd:annotation>
<xsd:documentation>
Should be the case automatically refreshed when opened in GUI?
NOT IMPLEMENTED YET
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="correlatorPart" type="tns:AbstractCorrelationContextType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Expand Down Expand Up @@ -1358,8 +1366,8 @@
minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>
Potential matches among which (if any) the user should decide. Should be at least one,
otherwise there's nothing to decide.
Potential matches among which (if any) the user should decide. Should be at least two,
otherwise there's nothing to decide. (TODO: decide on the "create new option").
</xsd:documentation>
</xsd:annotation>
</xsd:element>
Expand Down Expand Up @@ -1398,7 +1406,7 @@
<xsd:element name="referenceId" type="xsd:string" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Reference ID of the entity.
Reference ID of the entity. Null if we want to create a new entity. (TODO: decide on the nullness.)
</xsd:documentation>
</xsd:annotation>
</xsd:element>
Expand All @@ -1412,4 +1420,73 @@
</xsd:sequence>
<xsd:attribute name="id" type="xsd:long"/>
</xsd:complexType>

<xsd:complexType name="BuiltInCorrelationContextType">
<xsd:annotation>
<xsd:documentation>
Parts of the context specific to built-in correlation mechanism.
</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:complexContent>
<xsd:extension base="tns:AbstractCorrelationContextType">
<xsd:sequence>
<xsd:element name="potentialMatch" type="tns:BuiltInCorrelationPotentialMatchType"
minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>
Potential matches among which (if any) the user should decide. Should be at least two,
otherwise there's nothing to decide. (TODO: decide on the "create new option").
</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:element name="builtInCorrelationContext" type="tns:BuiltInCorrelationContextType"/>

<xsd:complexType name="BuiltInCorrelationPotentialMatchType">
<xsd:annotation>
<xsd:documentation>
A potential match found by ID Match service.
</xsd:documentation>
<xsd:appinfo>
<a:since>4.5</a:since>
<a:experimental>true</a:experimental>
<a:container>true</a:container>
</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="uri" type="xsd:anyURI" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
URI used to reference this option in the work item outcome.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="confidence" type="xsd:int" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
An integer between 0 and 100. TODO
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="candidateOwnerRef" type="tns:ObjectReferenceType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
The candidate owner. Null if a new owner has to be created. (TODO reconsider this)
</xsd:documentation>
<xsd:appinfo>
<a:objectReferenceTargetType>tns:FocusType</a:objectReferenceTargetType>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="id" type="xsd:long"/>
</xsd:complexType>
</xsd:schema>
Original file line number Diff line number Diff line change
Expand Up @@ -23364,6 +23364,13 @@
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="manual" type="c:ManualCorrelationConfigurationType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Configuration of the (optional) manual configuration.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
Expand Down Expand Up @@ -23401,6 +23408,13 @@
</xsd:annotation>
</xsd:element>
</xsd:choice>
<xsd:element name="manual" type="c:ManualCorrelationConfigurationType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Configuration of the (optional) manual configuration.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
Expand Down Expand Up @@ -23486,6 +23500,83 @@
</xsd:complexType>
<xsd:element name="idMatchCorrelator" type="tns:IdMatchCorrelatorType"/>

<xsd:complexType name="ManualCorrelationConfigurationType">
<xsd:annotation>
<xsd:documentation>
Configuration of manual correlation - to be used with user-based correlators,
like `filter` or `expression`.
</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="enabled" type="tns:ManualCorrelationEnabledType" minOccurs="0" default="whenRequested">
<xsd:annotation>
<xsd:documentation>
Is manual correlation enabled?
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<!-- TODO assignee, etc -->
</xsd:sequence>
<xsd:attribute name="id" type="xsd:long"/>
</xsd:complexType>

<xsd:simpleType name="ManualCorrelationEnabledType">
<xsd:annotation>
<xsd:documentation>
Is manual correlation enabled? (For e.g. filter and expression correlators.)
</xsd:documentation>
</xsd:annotation>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="always">
<xsd:annotation>
<xsd:documentation>
The manual correlation will always be applied if there are at least two options.
(I.e. at least one candidate owner found.)
</xsd:documentation>
<xsd:appinfo>
<jaxb:typesafeEnumMember name="ALWAYS"/>
</xsd:appinfo>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="whenMoreCandidates">
<xsd:annotation>
<xsd:documentation>
The manual correlation will be applied if more than one candidate owner was found.
</xsd:documentation>
<xsd:appinfo>
<jaxb:typesafeEnumMember name="WHEN_MORE_CANDIDATES"/>
</xsd:appinfo>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="whenRequested">
<xsd:annotation>
<xsd:documentation>
The manual correlation will be applied if requested by the script code.
See `manualCorrelationContext` expression variable. TODO
</xsd:documentation>
<xsd:appinfo>
<jaxb:typesafeEnumMember name="WHEN_REQUESTED"/>
</xsd:appinfo>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="never">
<xsd:annotation>
<xsd:documentation>
The manual correlation will never be applied.
</xsd:documentation>
<xsd:appinfo>
<jaxb:typesafeEnumMember name="NEVER"/>
</xsd:appinfo>
</xsd:annotation>
</xsd:enumeration>
</xsd:restriction>
</xsd:simpleType>

<!--<xsd:complexType name="CorrelationRequestType">-->
<!-- <xsd:annotation>-->
<!-- <xsd:documentation>-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,13 @@
import com.evolveum.midpoint.schema.processor.ResourceObjectTypeDefinition;
import com.evolveum.midpoint.util.DebugDumpable;
import com.evolveum.midpoint.util.DebugUtil;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractCorrelationStateType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;

import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType;

import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;

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

import java.util.List;

/**
* The context of the correlation operation(s).
*
Expand Down Expand Up @@ -55,6 +52,11 @@ public class CorrelationContext implements DebugDumpable {
*/
private AbstractCorrelationStateType correlationState;

/**
* User scripts can request manual correlation here.
*/
@NotNull private final ManualCorrelationContext manualCorrelationContext = new ManualCorrelationContext();

public CorrelationContext(
@NotNull Class<? extends ObjectType> focusType,
@NotNull ResourceType resource,
Expand Down Expand Up @@ -90,6 +92,35 @@ public void setCorrelationState(AbstractCorrelationStateType correlationState) {
this.correlationState = correlationState;
}

public @NotNull ManualCorrelationContext getManualCorrelationContext() {
return manualCorrelationContext;
}

public void setManualCorrelationConfiguration(ManualCorrelationConfigurationType configuration) {
manualCorrelationContext.setConfiguration(configuration);
}

/**
* Instructs the correlator that the manual correlation should be carried out. If there's only one option,
* an error should be signalled.
*/
@SuppressWarnings("unused") // called from scripts
public void requestManualCorrelation() {
manualCorrelationContext.setRequested(true);
}

/**
* Instructs the correlator that the manual correlation should be carried out. Provides explicit list of potential matches
* to display.
*
* If there's only one option, an error should be signalled.
*/
@SuppressWarnings("unused") // called from scripts
public void requestManualCorrelation(List<BuiltInCorrelationPotentialMatchType> potentialMatches) {
manualCorrelationContext.setRequested(true);
manualCorrelationContext.setPotentialMatches(potentialMatches);
}

@Override
public String toString() {
return "CorrelationContext("
Expand All @@ -105,7 +136,8 @@ public String debugDump(int indent) {
DebugUtil.debugDumpWithLabelLn(sb, "resource", String.valueOf(resource), indent + 1);
DebugUtil.debugDumpWithLabelLn(sb, "objectTypeDefinition", String.valueOf(objectTypeDefinition), indent + 1);
DebugUtil.debugDumpWithLabelLn(sb, "systemConfiguration", String.valueOf(systemConfiguration), indent + 1);
DebugUtil.debugDumpWithLabel(sb, "correlationState", correlationState, indent + 1);
DebugUtil.debugDumpWithLabelLn(sb, "correlationState", correlationState, indent + 1);
DebugUtil.debugDumpWithLabel(sb, "manualCorrelationContext", manualCorrelationContext, indent + 1);
return sb.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,8 @@ public enum Status {
NO_OWNER,

/**
* The situation is not certain.
* The situation is not certain. (Correlation case may or may not be created.)
*/
UNCERTAIN

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* Copyright (C) 2010-2022 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/

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

import com.evolveum.midpoint.util.DebugDumpable;
import com.evolveum.midpoint.util.DebugUtil;

import com.evolveum.midpoint.xml.ns._public.common.common_3.BuiltInCorrelationPotentialMatchType;

import com.evolveum.midpoint.xml.ns._public.common.common_3.ManualCorrelationConfigurationType;

import java.util.List;

/**
* Here can the user script in the correlator request the manual resolution. (Plus provide additional information.)
*/
public class ManualCorrelationContext implements DebugDumpable {

/**
* The configuration from the correlator configuration bean. (Or constructed artificially.)
*/
private ManualCorrelationConfigurationType configuration;

/**
* Was the manual correlation requested by the user code?
*/
private boolean requested;

/**
* Explicit list of potential matches provided by the user code.
*/
private List<BuiltInCorrelationPotentialMatchType> potentialMatches;

public ManualCorrelationConfigurationType getConfiguration() {
return configuration;
}

public void setConfiguration(ManualCorrelationConfigurationType configuration) {
this.configuration = configuration;
}

public boolean isRequested() {
return requested;
}

public void setRequested(boolean requested) {
this.requested = requested;
}

public List<BuiltInCorrelationPotentialMatchType> getPotentialMatches() {
return potentialMatches;
}

public void setPotentialMatches(List<BuiltInCorrelationPotentialMatchType> potentialMatches) {
this.potentialMatches = potentialMatches;
}

@Override
public String debugDump(int indent) {
StringBuilder sb = DebugUtil.createTitleStringBuilderLn(getClass(), indent);
DebugUtil.debugDumpWithLabel(sb, "requested", requested, indent + 1);
return sb.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.evolveum.midpoint.model.common.ModelCommonBeans;

import com.evolveum.midpoint.model.common.SystemObjectCache;
import com.evolveum.midpoint.model.impl.correlator.BuiltInCaseManager;
import com.evolveum.midpoint.model.impl.correlator.CorrelationCaseManager;
import com.evolveum.midpoint.model.impl.lens.*;
import com.evolveum.midpoint.model.impl.lens.projector.ContextLoader;
Expand Down Expand Up @@ -123,4 +124,5 @@ public static ModelBeans get() {
@Autowired public SecurityHelper securityHelper;
@Autowired public CorrelatorFactoryRegistry correlatorFactoryRegistry;
@Autowired public CorrelationCaseManager correlationCaseManager;
@Autowired public BuiltInCaseManager builtInCaseManager;
}

0 comments on commit b451d4f

Please sign in to comment.