From d18042b5a5a6a8d7d977168d0d40c72628075c95 Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Mon, 18 Sep 2017 15:06:36 +0200 Subject: [PATCH] Approval related triggers on PagePreviewChanges (in progress). --- .../wf/ApprovalProcessesPreviewPanel.html | 1 + .../wf/ApprovalProcessesPreviewPanel.java | 4 ++++ .../ApprovalProcessExecutionInformationDto.java | 14 ++++++++++++-- .../prism/marshaller/PrismUnmarshaller.java | 6 ++++-- .../midpoint/schema/util/WfContextUtil.java | 10 ++++++++++ .../xml/ns/public/common/common-workflows-3.xsd | 1 + .../ApprovalSchemaExecutionInformationHelper.java | 3 +++ 7 files changed, 35 insertions(+), 4 deletions(-) diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/wf/ApprovalProcessesPreviewPanel.html b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/wf/ApprovalProcessesPreviewPanel.html index 625deadbf36..a09f6677a3a 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/wf/ApprovalProcessesPreviewPanel.html +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/wf/ApprovalProcessesPreviewPanel.html @@ -24,6 +24,7 @@

+
diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/wf/ApprovalProcessesPreviewPanel.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/wf/ApprovalProcessesPreviewPanel.java index 48ad8bab2f1..c90f0838acd 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/wf/ApprovalProcessesPreviewPanel.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/wf/ApprovalProcessesPreviewPanel.java @@ -18,11 +18,13 @@ import com.evolveum.midpoint.gui.api.component.BasePanel; import com.evolveum.midpoint.gui.api.model.LoadableModel; +import com.evolveum.midpoint.web.page.admin.workflow.EvaluatedTriggerGroupPanel; import com.evolveum.midpoint.web.page.admin.workflow.dto.ApprovalProcessExecutionInformationDto; import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.markup.html.list.ListItem; import org.apache.wicket.markup.html.list.ListView; import org.apache.wicket.model.IModel; +import org.apache.wicket.model.PropertyModel; import java.util.List; @@ -34,6 +36,7 @@ public class ApprovalProcessesPreviewPanel extends BasePanel> model) { super(id, model); @@ -53,6 +56,7 @@ protected void populateItem(ListItem ite } }, false))); item.add(new ApprovalProcessExecutionInformationPanel(ID_PREVIEW, item.getModel())); + item.add(new EvaluatedTriggerGroupPanel(ID_TRIGGERS, new PropertyModel<>(item.getModel(), ApprovalProcessExecutionInformationDto.F_TRIGGERS))); } }; add(list); diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/workflow/dto/ApprovalProcessExecutionInformationDto.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/workflow/dto/ApprovalProcessExecutionInformationDto.java index 42ddfbdc0ad..5766a4363f8 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/workflow/dto/ApprovalProcessExecutionInformationDto.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/workflow/dto/ApprovalProcessExecutionInformationDto.java @@ -42,6 +42,7 @@ public class ApprovalProcessExecutionInformationDto implements Serializable { public static final String F_PROCESS_NAME = "processName"; public static final String F_TARGET_NAME = "targetName"; public static final String F_STAGES = "stages"; + public static final String F_TRIGGERS = "triggers"; private final boolean wholeProcess; // do we represent whole process or only the future stages? private final int currentStageNumber; // current stage number (0 if there's no current stage, i.e. process has not started yet) @@ -49,15 +50,18 @@ public class ApprovalProcessExecutionInformationDto implements Serializable { private final String processName; private final String targetName; private final List stages = new ArrayList<>(); + private final EvaluatedTriggerGroupDto triggers; private final boolean running; private ApprovalProcessExecutionInformationDto(boolean wholeProcess, int currentStageNumber, int numberOfStages, - String processName, String targetName, boolean running) { + String processName, String targetName, + EvaluatedTriggerGroupDto triggers, boolean running) { this.wholeProcess = wholeProcess; this.currentStageNumber = currentStageNumber; this.numberOfStages = numberOfStages; this.processName = processName; this.targetName = targetName; + this.triggers = triggers; this.running = running; } @@ -72,8 +76,10 @@ public static ApprovalProcessExecutionInformationDto createFrom(ApprovalSchemaEx String targetName = WfContextUtil.getTargetName(info); WfContextType wfc = WfContextUtil.getWorkflowContext(info); boolean running = wfc != null && wfc.getEndTimestamp() == null; + EvaluatedTriggerGroupDto triggers = EvaluatedTriggerGroupDto.create(WfContextUtil.getAllRules(info.getPolicyRules())); ApprovalProcessExecutionInformationDto rv = - new ApprovalProcessExecutionInformationDto(wholeProcess, currentStageNumber, numberOfStages, processName, targetName, running); + new ApprovalProcessExecutionInformationDto(wholeProcess, currentStageNumber, numberOfStages, processName, + targetName, triggers, running); int startingStageNumber = wholeProcess ? 1 : currentStageNumber+1; boolean reachable = true; for (int i = startingStageNumber - 1; i < numberOfStages; i++) { @@ -114,4 +120,8 @@ public String getTargetName() { public boolean isRunning() { return running; } + + public EvaluatedTriggerGroupDto getTriggers() { + return triggers; + } } diff --git a/infra/prism/src/main/java/com/evolveum/midpoint/prism/marshaller/PrismUnmarshaller.java b/infra/prism/src/main/java/com/evolveum/midpoint/prism/marshaller/PrismUnmarshaller.java index fc29b7ddaa9..3020d11c08e 100644 --- a/infra/prism/src/main/java/com/evolveum/midpoint/prism/marshaller/PrismUnmarshaller.java +++ b/infra/prism/src/main/java/com/evolveum/midpoint/prism/marshaller/PrismUnmarshaller.java @@ -222,10 +222,12 @@ private PrismContainerValue parseContainerValue(@No if (prim.isEmpty()) { return containerDef.createValue(); } else { - throw new IllegalArgumentException("Cannot parse container value from (non-empty) " + node); + pc.warnOrThrow(LOGGER, "Cannot parse container value from (non-empty) " + node); + return containerDef.createValue(); } } else { - throw new IllegalArgumentException("Cannot parse container value from " + node); + pc.warnOrThrow(LOGGER, "Cannot parse container value from " + node); + return containerDef.createValue(); } } diff --git a/infra/schema/src/main/java/com/evolveum/midpoint/schema/util/WfContextUtil.java b/infra/schema/src/main/java/com/evolveum/midpoint/schema/util/WfContextUtil.java index 21511e99afe..dfcca33a2e4 100644 --- a/infra/schema/src/main/java/com/evolveum/midpoint/schema/util/WfContextUtil.java +++ b/infra/schema/src/main/java/com/evolveum/midpoint/schema/util/WfContextUtil.java @@ -747,4 +747,14 @@ public static String getOutcome(ApprovalSchemaExecutionInformationType info) { WfContextType wfc = getWorkflowContext(info); return wfc != null ? wfc.getOutcome() : null; } + + public static List getAllRules(SchemaAttachedPolicyRulesType policyRules) { + List rv = new ArrayList<>(); + for (SchemaAttachedPolicyRuleType entry : policyRules.getEntry()) { + if (!rv.contains(entry.getRule())) { + rv.add(entry.getRule()); + } + } + return rv; + } } diff --git a/infra/schema/src/main/resources/xml/ns/public/common/common-workflows-3.xsd b/infra/schema/src/main/resources/xml/ns/public/common/common-workflows-3.xsd index 6ff147cc3a6..6a3dd601cea 100644 --- a/infra/schema/src/main/resources/xml/ns/public/common/common-workflows-3.xsd +++ b/infra/schema/src/main/resources/xml/ns/public/common/common-workflows-3.xsd @@ -278,6 +278,7 @@ + diff --git a/model/workflow-impl/src/main/java/com/evolveum/midpoint/wf/impl/ApprovalSchemaExecutionInformationHelper.java b/model/workflow-impl/src/main/java/com/evolveum/midpoint/wf/impl/ApprovalSchemaExecutionInformationHelper.java index 7fd252e0ac2..4ae4cfe37d0 100644 --- a/model/workflow-impl/src/main/java/com/evolveum/midpoint/wf/impl/ApprovalSchemaExecutionInformationHelper.java +++ b/model/workflow-impl/src/main/java/com/evolveum/midpoint/wf/impl/ApprovalSchemaExecutionInformationHelper.java @@ -134,6 +134,9 @@ private ApprovalSchemaExecutionInformationType getApprovalSchemaExecutionInforma } rv.getStage().add(stageExecution); } + if (itemApprovalState.getPolicyRules() != null) { + rv.setPolicyRules(itemApprovalState.getPolicyRules().clone()); + } return rv; }