Skip to content

Commit

Permalink
Outbound mapping processing improvements (MID-4236)
Browse files Browse the repository at this point in the history
* Refactored value consolidation
* improved the code
* Fixed MID-4236
* Fixed several smalled bugs (e.g. intolerant values and primary delta)
* New and fixed tests
  • Loading branch information
semancik committed Nov 20, 2017
1 parent b14f54c commit a3e9d73
Show file tree
Hide file tree
Showing 30 changed files with 2,681 additions and 875 deletions.
Expand Up @@ -259,6 +259,7 @@ public String toString() {
return toHumanReadableDescription();
}

@Override
public String toHumanReadableDescription() {
StringBuilder sb = new StringBuilder("RSD(");
sb.append(kind==null?"null":kind.value());
Expand Down
Expand Up @@ -61,6 +61,7 @@
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.util.DOMUtil;
import com.evolveum.midpoint.util.DebugDumpable;
import com.evolveum.midpoint.util.DebugUtil;
import com.evolveum.midpoint.util.MiscUtil;
import com.evolveum.midpoint.util.exception.CommunicationException;
import com.evolveum.midpoint.util.exception.ConfigurationException;
Expand Down Expand Up @@ -1283,17 +1284,10 @@ public boolean equals(Object obj) {
return true;
}

@Override
public String debugDump() {
return debugDump(0);
}

@Override
public String debugDump(int indent) {
StringBuilder sb = new StringBuilder();
for (int i=0;i<indent;i++) {
sb.append(INDENT_STRING);
}
DebugUtil.indentDebugDump(sb, indent);
sb.append(toString());
return sb.toString();
}
Expand Down Expand Up @@ -1331,6 +1325,24 @@ public String getIdentifier() {
return mappingType != null ? mappingType.getName() : null;
}

@Override
public String toHumanReadableDescription() {
StringBuilder sb = new StringBuilder();
sb.append("mapping ");
if (mappingType != null && mappingType.getName() != null) {
sb.append("'").append(mappingType.getName()).append("'");
} else {
sb.append(getMappingDisplayName());
}
if (originObject != null) {
sb.append(" in ");
sb.append(originObject);
}
return sb.toString();
}



/**
* Builder is used to construct a configuration of Mapping object, which - after building - becomes
* immutable.
Expand Down Expand Up @@ -1836,4 +1848,5 @@ public MappingStrengthType getStrength() {
return Mapping.getStrength(mappingType);
}
}

}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015-2016 Evolveum
* Copyright (c) 2015-2017 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -20,9 +20,10 @@
import com.evolveum.midpoint.prism.ItemDefinition;
import com.evolveum.midpoint.prism.PrismValue;
import com.evolveum.midpoint.prism.delta.PrismValueDeltaSetTriple;
import com.evolveum.midpoint.util.HumanReadableDescribable;
import com.evolveum.midpoint.xml.ns._public.common.common_3.MappingStrengthType;

public interface PrismValueDeltaSetTripleProducer<V extends PrismValue, D extends ItemDefinition> {
public interface PrismValueDeltaSetTripleProducer<V extends PrismValue, D extends ItemDefinition> extends HumanReadableDescribable {

QName getMappingQName();

Expand Down
Expand Up @@ -19,6 +19,7 @@

import com.evolveum.midpoint.prism.OriginType;
import com.evolveum.midpoint.prism.PrismContext;
import com.evolveum.midpoint.prism.delta.PlusMinusZero;
import com.evolveum.midpoint.repo.common.expression.ObjectDeltaObject;
import com.evolveum.midpoint.schema.util.ObjectResolver;
import com.evolveum.midpoint.util.DebugDumpable;
Expand All @@ -45,8 +46,9 @@ public abstract class AbstractConstruction<F extends FocusType, T extends Abstra
private ObjectDeltaObject<F> focusOdo;
private ObjectResolver objectResolver;
private PrismContext prismContext;

private boolean isValid = true;
private boolean wasValid = true;
private PlusMinusZero relativityMode;

public AbstractConstruction(T constructionType, ObjectType source) {
this.constructionType = constructionType;
Expand Down Expand Up @@ -130,6 +132,22 @@ public void setValid(boolean isValid) {
this.isValid = isValid;
}

public boolean getWasValid() {
return wasValid;
}

public void setWasValid(boolean wasValid) {
this.wasValid = wasValid;
}

public PlusMinusZero getRelativityMode() {
return relativityMode;
}

public void setRelativityMode(PlusMinusZero relativityMode) {
this.relativityMode = relativityMode;
}

public AssignmentPathImpl getAssignmentPath() {
return assignmentPath;
}
Expand Down
Expand Up @@ -475,6 +475,7 @@ private void collectConstruction(AssignmentPathSegmentImpl segment, PlusMinusZer
construction.setChannel(channel);
construction.setOrderOneObject(segment.getOrderOneObject());
construction.setValid(isValid);
construction.setRelativityMode(mode);

// Do not evaluate the construction here. We will do it in the second pass. Just prepare everything to be evaluated.
if (mode == null) {
Expand Down Expand Up @@ -505,6 +506,7 @@ private void collectPersonaConstruction(AssignmentPathSegmentImpl segment, PlusM
construction.setOriginType(OriginType.ASSIGNMENTS);
construction.setChannel(channel);
construction.setValid(isValid);
construction.setRelativityMode(mode);

ctx.evalAssignment.addPersonaConstruction(construction, mode);
}
Expand Down
Expand Up @@ -739,8 +739,9 @@ public String debugDump(int indent) {
sb.append(" weak");
}
sb.append("\n");
DebugUtil.debugDumpWithLabel(sb, "isValid", isValid(), indent + 1);
sb.append("\n");
DebugUtil.debugDumpWithLabelLn(sb, "isValid", isValid(), indent + 1);
DebugUtil.debugDumpWithLabelLn(sb, "wasValid", getWasValid(), indent + 1);
DebugUtil.debugDumpWithLabelToStringLn(sb, "relativityMode", getRelativityMode(), indent + 1);
DebugUtil.debugDumpLabel(sb, "auxiliary object classes", indent + 1);
if (auxiliaryObjectClassDefinitions == null) {
sb.append(" (null)");
Expand Down Expand Up @@ -783,12 +784,29 @@ public String debugDump(int indent) {

@Override
public String toString() {
return "Construction(" +
(refinedObjectClassDefinition == null ?
getConstructionType() : refinedObjectClassDefinition.getShadowDiscriminator()) +
" in " + getSource() +
(isValid() ? "" : ", invalid") +
")";
StringBuilder sb = new StringBuilder("Construction(");
if (refinedObjectClassDefinition == null) {
sb.append(getConstructionType());
} else {
sb.append(refinedObjectClassDefinition.getShadowDiscriminator());
}
sb.append(" in ").append(getSource());
// if (getRelativityMode() != null) {
// sb.append(", ").append(getRelativityMode());
// }
if (isValid()) {
if (!getWasValid()) {
sb.append(", invalid->valid");
}
} else {
if (getWasValid()) {
sb.append(", valid->invalid");
} else {
sb.append(", invalid");
}
}
sb.append(")");
return sb.toString();
}

}
Expand Up @@ -83,6 +83,7 @@ public class EvaluatedAssignmentImpl<F extends FocusType> implements EvaluatedAs

private PrismObject<?> target;
private boolean isValid;
private boolean wasValid;
private boolean forceRecon; // used also to force recomputation of parentOrgRefs
private boolean presentInCurrentObject;
private boolean presentInOldObject;
Expand Down Expand Up @@ -294,6 +295,14 @@ public void setValid(boolean isValid) {
this.isValid = isValid;
}

public boolean getWasValid() {
return wasValid;
}

public void setWasValid(boolean wasValid) {
this.wasValid = wasValid;
}

public boolean isForceRecon() {
return forceRecon;
}
Expand All @@ -315,6 +324,7 @@ public void evaluateConstructions(ObjectDeltaObject<F> focusOdo, PrismObject<Sys
for (Construction<F> construction :constructionTriple.getAllValues()) {
construction.setFocusOdo(focusOdo);
construction.setSystemConfiguration(systemConfiguration);
construction.setWasValid(wasValid);
LOGGER.trace("Evaluating construction '{}' in {}", construction, construction.getSource());
construction.evaluate(task, result);
}
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2015 Evolveum
* Copyright (c) 2010-2017 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -74,6 +74,10 @@ public ObjectType getSource() {
public boolean isValid() {
return construction == null || construction.isValid();
}

public boolean wasValid() {
return construction == null || construction.getWasValid();
}

public <T> boolean equalsRealValue(V pvalue, ValueMatcher<T> valueMatcher) throws SchemaException {
if (itemValue == null) {
Expand Down Expand Up @@ -127,11 +131,6 @@ private static <V extends PrismValue, D extends ItemDefinition> Collection<ItemV
return ivwoSet;
}

@Override
public String debugDump() {
return debugDump(0);
}

@Override
public String debugDump(int indent) {
StringBuilder sb = new StringBuilder();
Expand Down

0 comments on commit a3e9d73

Please sign in to comment.