Skip to content

Commit

Permalink
Add preliminary confidence support for correlators
Browse files Browse the repository at this point in the history
Work in progress: only for items, filter, and expression ones. No
composition yet.

Dead code was eliminated: ManualCorrelationContext, DummyCorrelator.
  • Loading branch information
mederly committed Aug 9, 2022
1 parent 6df0bd4 commit 6552758
Show file tree
Hide file tree
Showing 27 changed files with 425 additions and 364 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public class ExpressionConstants {
public static final String VAR_ENTITLEMENT = "entitlement";
public static final String VAR_FILE = "file";
public static final String VAR_PARENT_OBJECT = "parent";
public static final String VAR_CANDIDATE = "candidate";

/**
* User that is currently executing the operation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,4 @@ public class SchemaTestConstants {
public static final ItemName EXTENSION_LONG_TYPE_ELEMENT = new ItemName(NS_EXTENSION, "longType");
public static final ItemName EXTENSION_DATE_TYPE_ELEMENT = new ItemName(NS_EXTENSION, "dateType");
public static final ItemName EXTENSION_SHIP_ELEMENT = new ItemName(NS_EXTENSION, "ship");

private static final String DUMMY_CORRELATOR_NS = "http://midpoint.evolveum.com/xml/ns/test/correlation";
public static final ItemName DUMMY_CORRELATOR_CONFIGURATION_ITEM_NAME = new ItemName(
DUMMY_CORRELATOR_NS, "dummy");
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,16 @@
-->

<xsd:schema targetNamespace="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:tns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:a="http://prism.evolveum.com/xml/ns/public/annotation-3"
xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:t="http://prism.evolveum.com/xml/ns/public/types-3"
xmlns:mr="http://prism.evolveum.com/xml/ns/public/matching-rule-3"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
elementFormDefault="qualified"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
jaxb:extensionBindingPrefixes="xjc"
jaxb:version="2.0">
xmlns:tns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:a="http://prism.evolveum.com/xml/ns/public/annotation-3"
xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:t="http://prism.evolveum.com/xml/ns/public/types-3"
xmlns:mr="http://prism.evolveum.com/xml/ns/public/matching-rule-3"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
elementFormDefault="qualified"
jaxb:extensionBindingPrefixes="xjc"
jaxb:version="2.0">

<xsd:annotation>
<xsd:documentation>
Expand Down Expand Up @@ -226,20 +225,32 @@
</xsd:annotation>
</xsd:element>

<xsd:element name="confidence" type="tns:CorrelationConfidenceDefinitionType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Defines how this correlator - if matching - increases the overall confidence of its results.

NOT IMPLEMENTED YET
</xsd:documentation>
<xsd:appinfo>
<a:since>4.6</a:since>
<a:displayName>AbstractCorrelatorType.confidence</a:displayName>
<a:displayOrder>20</a:displayOrder>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:choice>
<xsd:element name="confidence" type="tns:CorrelationConfidenceDefinitionType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Defines how this correlator - if matching - increases the overall confidence of its results.
</xsd:documentation>
<xsd:appinfo>
<a:since>4.6</a:since>
<a:displayName>AbstractCorrelatorType.confidence</a:displayName>
<a:displayOrder>20</a:displayOrder>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="thresholds" type="tns:CorrelationConfidenceThresholdsDefinitionType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
TODO
</xsd:documentation>
<xsd:appinfo>
<a:since>4.6</a:since>
<a:displayName>AbstractCorrelatorType.thresholds</a:displayName>
<a:displayOrder>20</a:displayOrder>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
</xsd:choice>

<xsd:element name="ignoreIfMatchedBy" type="xsd:string" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
Expand Down Expand Up @@ -953,14 +964,53 @@
<xsd:annotation>
<xsd:documentation>
Expression providing the confidence value if a rule does match.
TODO what are the parameters? (E.g. Levenshtein distance for this item?)
TODO what are the parameters? (E.g. Levenshtein distance for the items?)
</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:choice>
<xsd:attribute name="id" type="xsd:long"/>
</xsd:complexType>

<xsd:complexType name="CorrelationConfidenceThresholdsDefinitionType">
<xsd:annotation>
<xsd:documentation>
TODO
</xsd:documentation>
<xsd:appinfo>
<a:since>4.6</a:since>
<a:container>true</a:container>
<a:experimental>true</a:experimental>
</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="top" type="xsd:double" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
The value that means absolute certainty. No confidence value should be above this one.

TODO decide on this one
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="owner" type="xsd:double" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
The value (inclusive) that marks the candidate as "the chosen" one.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="candidate" type="xsd:double" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
The value (inclusive) that marks the candidate as the considered one.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="id" type="xsd:long"/>
</xsd:complexType>

<xsd:complexType name="ItemCorrelationDefinitionType">
<xsd:annotation>
<xsd:documentation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4070,7 +4070,6 @@
<xsd:documentation>
Kind of a shadow. This means the type of shadow use.
E.g. an account, entitlement, etc.
If not specified defaults to "generic".
</xsd:documentation>
<xsd:appinfo>
<a:displayName>ShadowType.kind</a:displayName>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,6 @@ public class CorrelationContext implements DebugDumpable, Cloneable {
*/
private AbstractCorrelatorStateType correlatorState;

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

public CorrelationContext(
@NotNull ShadowType resourceObject,
@NotNull FocusType preFocus,
Expand Down Expand Up @@ -131,31 +125,6 @@ public void setCorrelatorState(AbstractCorrelatorStateType correlatorState) {
this.correlatorState = correlatorState;
}

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

/**
* 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<ResourceObjectOwnerOptionType> potentialMatches) {
manualCorrelationContext.setRequested(true);
manualCorrelationContext.setPotentialMatches(potentialMatches);
}

public @NotNull Task getTask() {
return task;
}
Expand All @@ -177,8 +146,7 @@ public String debugDump(int indent) {
DebugUtil.debugDumpWithLabelLn(sb, "resource", String.valueOf(resource), indent + 1);
DebugUtil.debugDumpWithLabelLn(sb, "resourceObjectDefinition", String.valueOf(resourceObjectDefinition), indent + 1);
DebugUtil.debugDumpWithLabelLn(sb, "systemConfiguration", String.valueOf(systemConfiguration), indent + 1);
DebugUtil.debugDumpWithLabelLn(sb, "correlatorState", correlatorState, indent + 1);
DebugUtil.debugDumpWithLabel(sb, "manualCorrelationContext", manualCorrelationContext, indent + 1);
DebugUtil.debugDumpWithLabel(sb, "correlatorState", correlatorState, indent + 1);
return sb.toString();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,22 @@ public class CorrelationResult implements Serializable, DebugDumpable {
@Nullable private final ObjectType owner;

/**
* Options for the owner. Non-null if and only if {@link #situation} is {@link CorrelationSituationType#UNCERTAIN}.
* Options for the owner. Typically present when {@link CorrelationSituationType#UNCERTAIN} but (as an auxiliary information)
* may be present also for {@link CorrelationSituationType#EXISTING_OWNER}.
*
* Currently we never put here the candidates with the confidence values below "candidate" level.
* This may change in the future.
*
* May not be supported when the result is fetched from the shadow.
*/
@Nullable private final ResourceObjectOwnerOptionsType ownerOptions;

/**
* All owner candidates matching given criteria. (Constrained by the limits of candidates.)
*
* May not be supported by all correlators. (Required for: query, expression, item.)
*
* May not be supported when the result is fetched from the shadow.
*/
@NotNull private final List<? extends ObjectType> allOwnerCandidates;

Expand All @@ -75,12 +83,12 @@ private CorrelationResult(
this.errorDetails = errorDetails;
}

public static CorrelationResult existingOwner(@NotNull ObjectType owner) {
public static CorrelationResult existingOwner(@NotNull ObjectType owner, @Nullable OwnersInfo ownersInfo) {
return new CorrelationResult(
EXISTING_OWNER,
owner,
null,
List.of(owner),
ownersInfo != null ? ownersInfo.optionsBean : null,
ownersInfo != null ? ownersInfo.allOwnerCandidates.asList() : List.of(owner),
null);
}

Expand All @@ -93,13 +101,13 @@ public static CorrelationResult noOwner() {
null);
}

public static CorrelationResult uncertain(
@NotNull ResourceObjectOwnerOptionsType ownerOptions, List<? extends ObjectType> allOwnerCandidates) {
return new CorrelationResult(UNCERTAIN, null, ownerOptions, allOwnerCandidates, null);
}

public static CorrelationResult uncertain(@NotNull OwnersInfo ownersInfo) {
return uncertain(ownersInfo.optionsBean, ownersInfo.allOwnerCandidates.asList());
return new CorrelationResult(
UNCERTAIN,
null,
ownersInfo.optionsBean,
ownersInfo.allOwnerCandidates.asList(),
null);
}

public static CorrelationResult error(@NotNull Throwable t) {
Expand Down Expand Up @@ -142,12 +150,6 @@ public boolean isExistingOwner() {
return situation == EXISTING_OWNER;
}

/** Returns true if the correlation result points to the given owner OID. */
public boolean isExistingOwner(@NotNull String oid) {
return isExistingOwner()
&& oid.equals(getOwnerRequired().getOid());
}

public boolean isNoOwner() {
return situation == NO_OWNER;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,12 @@ private String dumpXml() {
return e.getMessage();
}
}

// TODO improve
@Override
public String toString() {
return "CorrelatorContext{" +
"configurationBean=" + configurationBean +
'}';
}
}

This file was deleted.

0 comments on commit 6552758

Please sign in to comment.