Skip to content

Commit

Permalink
MID-8842 ninja - followOn processor
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Jul 24, 2023
1 parent 808c592 commit 7efbd98
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* Copyright (C) 2010-2023 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.schema.validator.processor;

import com.evolveum.midpoint.prism.Item;
import com.evolveum.midpoint.prism.PrismContainerValue;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.schema.validator.UpgradeObjectProcessor;
import com.evolveum.midpoint.schema.validator.UpgradePhase;
import com.evolveum.midpoint.schema.validator.UpgradePriority;
import com.evolveum.midpoint.schema.validator.UpgradeType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.IdMatchCorrelatorType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;

@SuppressWarnings("unused")
public class FollowOnProcessor implements UpgradeObjectProcessor<ObjectType> {

@Override
public UpgradePhase getPhase() {
return UpgradePhase.BEFORE;
}

@Override
public UpgradePriority getPriority() {
return UpgradePriority.NECESSARY;
}

@Override
public UpgradeType getType() {
return UpgradeType.SEAMLESS;
}

@Override
public boolean isApplicable(PrismObject<?> object, ItemPath path) {
Item item = object.findItem(path);
if (item == null) {
return false;
}

PrismContainerValue value = item.getParent();
if (!(value.getRealValue() instanceof IdMatchCorrelatorType)) {
return false;
}

return true;
}

@Override
public boolean process(PrismObject<ObjectType> object, ItemPath path) throws Exception {
Item<?, ?> followOn = object.findItem(path);

PrismContainerValue<?> correlator = followOn.getParent();
IdMatchCorrelatorType idMatchCorrelator = (IdMatchCorrelatorType) correlator.asContainerable();
idMatchCorrelator.followOn(null);

return true;
}
}
10 changes: 10 additions & 0 deletions infra/schema/src/test/resources/validator/expected/resource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@

<schemaHandling>
<objectType id="1">
<correlation>
<correlators>
<idMatch id="5">
<name>asdf</name>
</idMatch>
<idMatch id="6">
<name>jklo</name>
</idMatch>
</correlators>
</correlation>
<synchronization>
<defaultSettings>
</defaultSettings>
Expand Down
16 changes: 16 additions & 0 deletions infra/schema/src/test/resources/validator/processor/resource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,22 @@

<schemaHandling>
<objectType id="1">
<correlation>
<correlators>
<idMatch id="5">
<name>asdf</name>
<followOn>
<none></none>
</followOn>
</idMatch>
<idMatch id="6">
<name>jklo</name>
<followOn>
<none></none>
</followOn>
</idMatch>
</correlators>
</correlation>
<synchronization>
<defaultSettings>
<executeOptions>
Expand Down

0 comments on commit 7efbd98

Please sign in to comment.