Skip to content

Commit

Permalink
Fixing projection handling in object merge (MID-3460)
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed Oct 27, 2016
1 parent 77c0041 commit 3057a90
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 18 deletions.
Expand Up @@ -411,25 +411,30 @@ private <O extends ObjectType> List<ShadowType> getProjections(PrismObject<O> ob
private void takeProjections(MergeStategyType strategy, List<ShadowType> mergedProjections,
List<ShadowType> matchedProjections, List<ShadowType> candidateProjections,
ShadowDiscriminatorType discriminatorType) {
if (strategy == MergeStategyType.TAKE) {

LOGGER.trace("TAKE: Evaluating discriminator: {}", discriminatorType);

for (ShadowType candidateProjection: candidateProjections) {
if (ShadowUtil.matchesPattern(candidateProjection, discriminatorType)) {
LOGGER.trace("Discriminator matches {}", candidateProjection);

LOGGER.trace("TAKE: Evaluating discriminator: {}", discriminatorType);

for (ShadowType candidateProjection: candidateProjections) {
if (ShadowUtil.matchesPattern(candidateProjection, discriminatorType)) {
LOGGER.trace("Discriminator matches {}", candidateProjection);
matchedProjections.add(candidateProjection);

if (strategy == MergeStategyType.TAKE) {
mergedProjections.add(candidateProjection);
matchedProjections.add(candidateProjection);

} else if (strategy == null || strategy == MergeStategyType.IGNORE) {
// Nothing to do here

} else {
LOGGER.trace("Discriminator does NOT match {}", candidateProjection);
throw new UnsupportedOperationException("Merge strategy "+strategy+" is not supported");
}

} else {
LOGGER.trace("Discriminator does NOT match {}", candidateProjection);
}

} else if (strategy == null || strategy == MergeStategyType.IGNORE) {
return;
} else {
throw new UnsupportedOperationException("Merge strategy "+strategy+" is not supported");
}


}

private void takeUnmatchedProjections(MergeStategyType strategy, List<ShadowType> mergedProjections,
Expand Down
Expand Up @@ -274,10 +274,10 @@ public void test110MergeGuybrushJackPreviewDelta() throws Exception {
PrismAsserts.assertNoItemDelta(delta, UserType.F_LINK_REF);

ObjectDelta<UserType> leftLinkDelta = deltas.getLeftLinkDelta();
PrismAsserts.assertEmpty("leftLinkDelta", leftLinkDelta);
PrismAsserts.assertReferenceAdd(leftLinkDelta, UserType.F_LINK_REF, jackDummyAccountRedOid);

ObjectDelta<UserType> rightLinkDelta = deltas.getRightLinkDelta();
PrismAsserts.assertEmpty("rightLinkDelta", rightLinkDelta);
PrismAsserts.assertReferenceDelete(rightLinkDelta, UserType.F_LINK_REF, jackDummyAccountRedOid);
}

/**
Expand Down
Expand Up @@ -227,13 +227,14 @@
<right>take</right>
</item>
<projection>
<right>take</right>
<left>take</left>
<projectionDiscriminator>
<resourceRef oid="10000000-0000-0000-0000-00000000c204"/> <!-- CYAN -->
<resourceRef oid="10000000-0000-0000-0000-000000000004"/> <!-- dummy -->
</projectionDiscriminator>
</projection>
<projection>
<left>take</left>
<right>take</right>
</projection>
<default>
<right>take</right>
Expand Down

0 comments on commit 3057a90

Please sign in to comment.