Skip to content

Commit

Permalink
MID-8842 ninja - execution mode processor
Browse files Browse the repository at this point in the history
(cherry picked from commit f81dcdf)
  • Loading branch information
1azyman committed Aug 1, 2023
1 parent defb2f2 commit a1c9f67
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* 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.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.ActivityDefinitionType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivityExecutionModeDefinitionType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ExecutionModeType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType;

@SuppressWarnings("unused")
public class ExecutionModeProcessor implements UpgradeObjectProcessor<TaskType> {

@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) {
return matchParentTypeAndItemName(object, path, ActivityDefinitionType.class, ActivityDefinitionType.F_EXECUTION_MODE);
}

@Override
public boolean process(PrismObject<TaskType> object, ItemPath path) throws Exception {
ActivityDefinitionType activity = object.asObjectable().getActivity();
ExecutionModeType mode = activity.getExecutionMode();

ActivityExecutionModeDefinitionType execution = activity.getExecution();
if (execution == null) {
execution = new ActivityExecutionModeDefinitionType();
activity.setExecution(execution);
}

execution.setMode(mode);
activity.setExecutionMode(null);

return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public void test70Archetype() throws Exception {
public void test80TaskRecomputation() throws Exception {
testUpgradeValidator("task-recomputation.xml", result -> {
Assertions.assertThat(result.getItems())
.hasSize(6);
.hasSize(7);

Assertions.assertThat(result.hasChanges()).isTrue();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
<interval>10</interval>
</tracing>
</reporting>
<execution>
<mode>dryRun</mode>
</execution>
</activity>

<policyRule>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<interval>10</interval>
</tracing>
</reporting>
<executionMode>dryRun</executionMode>
</activity>
<modelOperationContext>
<state>execution</state>
Expand Down

0 comments on commit a1c9f67

Please sign in to comment.