use of com.evolveum.midpoint.xml.ns._public.common.common_3.ProjectionMergeConfigurationType in project midpoint by Evolveum.
the class ObjectMerger method computeProjectionDeltas.
private <O extends ObjectType> void computeProjectionDeltas(final ObjectDelta<O> leftLinkDelta, ObjectDelta<O> rightLinkDelta, final PrismObject<O> objectLeft, final PrismObject<O> objectRight, MergeConfigurationType mergeConfiguration, final String mergeConfigurationName, final Task task, final OperationResult result) throws SchemaException, ConfigurationException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, SecurityViolationException {
List<ShadowType> projectionsLeft = getProjections(objectLeft, task, result);
List<ShadowType> projectionsRight = getProjections(objectRight, task, result);
List<ShadowType> mergedProjections = new ArrayList<>();
List<ShadowType> matchedProjections = new ArrayList<>();
ProjectionMergeConfigurationType defaultProjectionMergeConfig = null;
for (ProjectionMergeConfigurationType projectionMergeConfig : mergeConfiguration.getProjection()) {
if (projectionMergeConfig.getProjectionDiscriminator() == null && projectionMergeConfig.getSituation() == null) {
defaultProjectionMergeConfig = projectionMergeConfig;
} else {
takeProjections(projectionMergeConfig.getLeft(), mergedProjections, matchedProjections, projectionsLeft, projectionsLeft, projectionsRight, projectionMergeConfig);
takeProjections(projectionMergeConfig.getRight(), mergedProjections, matchedProjections, projectionsRight, projectionsLeft, projectionsRight, projectionMergeConfig);
}
}
LOGGER.trace("Merged projections (before default): {}", mergedProjections);
LOGGER.trace("Matched projections (before default): {}", matchedProjections);
if (defaultProjectionMergeConfig != null) {
takeUnmatchedProjections(defaultProjectionMergeConfig.getLeft(), mergedProjections, matchedProjections, projectionsLeft);
takeUnmatchedProjections(defaultProjectionMergeConfig.getRight(), mergedProjections, matchedProjections, projectionsRight);
}
LOGGER.trace("Merged projections: {}", mergedProjections);
checkConflict(mergedProjections);
for (ShadowType mergedProjection : mergedProjections) {
PrismReferenceValue leftLinkRef = findLinkRef(objectLeft, mergedProjection);
if (leftLinkRef == null) {
PrismReferenceValue linkRefRight = findLinkRef(objectRight, mergedProjection);
LOGGER.trace("Moving projection right->left: {}", mergedProjection);
addUnlinkDelta(rightLinkDelta, linkRefRight);
addLinkDelta(leftLinkDelta, linkRefRight);
} else {
LOGGER.trace("Projection already at the left: {}", mergedProjection);
}
}
for (PrismReferenceValue leftLinkRef : getLinkRefs(objectLeft)) {
if (!hasProjection(mergedProjections, leftLinkRef)) {
LOGGER.trace("Removing left projection: {}", leftLinkRef);
addUnlinkDelta(leftLinkDelta, leftLinkRef);
} else {
LOGGER.trace("Left projection stays: {}", leftLinkRef);
}
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ProjectionMergeConfigurationType in project midpoint by Evolveum.
the class ObjectMerger method takeProjections.
private void takeProjections(MergeStategyType strategy, List<ShadowType> mergedProjections, List<ShadowType> matchedProjections, List<ShadowType> candidateProjections, List<ShadowType> projectionsLeft, List<ShadowType> projectionsRight, ProjectionMergeConfigurationType projectionMergeConfig) {
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("TAKE: Evaluating situation {}, discriminator: {}", projectionMergeConfig.getSituation(), projectionMergeConfig.getProjectionDiscriminator());
}
for (ShadowType candidateProjection : candidateProjections) {
if (projectionMatches(candidateProjection, projectionsLeft, projectionsRight, projectionMergeConfig)) {
LOGGER.trace("Projection matches {}", candidateProjection);
matchedProjections.add(candidateProjection);
if (strategy == MergeStategyType.TAKE) {
mergedProjections.add(candidateProjection);
} else if (strategy == null || strategy == MergeStategyType.IGNORE) {
// Nothing to do here
} else {
throw new UnsupportedOperationException("Merge strategy " + strategy + " is not supported");
}
} else {
LOGGER.trace("Discriminator does NOT match {}", candidateProjection);
}
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ProjectionMergeConfigurationType in project midpoint by Evolveum.
the class ObjectMerger method projectionMatches.
private boolean projectionMatches(ShadowType candidateProjection, List<ShadowType> projectionsLeft, List<ShadowType> projectionsRight, ProjectionMergeConfigurationType projectionMergeConfig) {
ShadowDiscriminatorType discriminatorType = projectionMergeConfig.getProjectionDiscriminator();
if (discriminatorType != null && !ShadowUtil.matchesPattern(candidateProjection, discriminatorType)) {
return false;
}
ProjectionMergeSituationType situationPattern = projectionMergeConfig.getSituation();
if (situationPattern != null) {
ProjectionMergeSituationType projectionSituation = determineSituation(candidateProjection, projectionsLeft, projectionsRight);
if (situationPattern != projectionSituation) {
return false;
}
}
return true;
}
Aggregations