Skip to content

Commit

Permalink
Migrate WfContextType to ApprovalContextType
Browse files Browse the repository at this point in the history
Also revived the implementation of change categorization
(preliminarily).
  • Loading branch information
mederly committed Jun 10, 2019
1 parent fedad73 commit 5b42cf3
Show file tree
Hide file tree
Showing 123 changed files with 705 additions and 1,204 deletions.
8 changes: 4 additions & 4 deletions config/initial-objects/040-role-enduser.xml
Expand Up @@ -175,18 +175,18 @@
</object>
</authorization>
<authorization>
<name>assignment-target-read-task</name>
<name>assignment-target-read-case</name>
<description>
Authorization that allows to read workflow status of tasks. This is used to display requests
Authorization that allows to read approval status of cases. This is used to display requests
to the end users, especially in the "My Requests" box in user dashboard.
This authorization is a temporary solution. It will be replaced by a finer-grained
permissions in the future.
</description>
<action>http://midpoint.evolveum.com/xml/ns/public/security/authorization-model-3#read</action>
<object>
<type>TaskType</type>
<type>CaseType</type>
</object>
<item>workflowContext</item>
<item>approvalContext</item>
</authorization>
<authorization>
<name>self-owned-task-read</name>
Expand Down
10 changes: 5 additions & 5 deletions config/initial-objects/041-role-approver.xml
Expand Up @@ -52,18 +52,18 @@
</object>
</authorization> -->
<authorization>
<name>tasks-read</name>
<name>cases-read</name>
<description>
Allow to see the requester of the operation that is being approved and the current delta.
In order for the approver to see other properties (e.g. history of the approvals) please allow read access
to other items as well, e.g. to the whole workflowContext.
to other items as well.
</description>
<action>http://midpoint.evolveum.com/xml/ns/public/security/authorization-model-3#read</action>
<object>
<type>TaskType</type>
<type>CaseType</type>
</object>
<item>workflowContext/requesterRef</item>
<item>workflowContext/processorSpecificState</item>
<item>requesterRef</item>
<item>approvalContext</item>
</authorization>
<authorization>
<name>users-read</name>
Expand Down
Expand Up @@ -48,7 +48,6 @@
import com.evolveum.midpoint.web.component.prism.show.SceneDto;
import com.evolveum.midpoint.web.component.prism.show.SceneUtil;
import com.evolveum.midpoint.web.page.admin.cases.PageCase;
import com.evolveum.midpoint.web.page.admin.workflow.WorkItemDetailsPanel;
import com.evolveum.midpoint.web.page.admin.workflow.dto.EvaluatedTriggerGroupDto;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import org.apache.commons.collections4.CollectionUtils;
Expand Down Expand Up @@ -3868,13 +3867,13 @@ public static SceneDto createSceneDto(CaseWorkItemType caseWorkItem, PageBase pa
return createSceneDto(CaseTypeUtil.getCase(caseWorkItem), pageBase, operation);
}

public static List<EvaluatedTriggerGroupDto> computeTriggers(WfContextType wfc, Integer stage) {
public static List<EvaluatedTriggerGroupDto> computeTriggers(ApprovalContextType wfc, Integer stage) {
List<EvaluatedTriggerGroupDto> triggers = new ArrayList<>();
if (wfc == null) {
return triggers;
}
EvaluatedTriggerGroupDto.UniquenessFilter uniquenessFilter = new EvaluatedTriggerGroupDto.UniquenessFilter();
List<List<EvaluatedPolicyRuleType>> rulesPerStageList = WfContextUtil.getRulesPerStage(wfc);
List<List<EvaluatedPolicyRuleType>> rulesPerStageList = ApprovalContextUtil.getRulesPerStage(wfc);
for (int i = 0; i < rulesPerStageList.size(); i++) {
Integer stageNumber = i + 1;
boolean highlighted = stageNumber.equals(stage);
Expand All @@ -3885,19 +3884,15 @@ public static List<EvaluatedTriggerGroupDto> computeTriggers(WfContextType wfc,
}

public static SceneDto createSceneDto(CaseType caseObject, PageBase pageBase, String operation){
if (caseObject == null || caseObject.getWorkflowContext() == null) {
return null;
}
if (!(caseObject.getWorkflowContext().getProcessorSpecificState() instanceof WfPrimaryChangeProcessorStateType)) {
if (caseObject == null || caseObject.getApprovalContext() == null) {
return null;
}
ObjectReferenceType objectRef = caseObject.getObjectRef();
WfPrimaryChangeProcessorStateType state = (WfPrimaryChangeProcessorStateType) caseObject.getWorkflowContext().getProcessorSpecificState();

OperationResult result = new OperationResult(operation);
Task task = pageBase.createSimpleTask(operation);
try {
Scene deltasScene = SceneUtil.visualizeObjectTreeDeltas(state.getDeltasToProcess(), "pageWorkItem.delta",
Scene deltasScene = SceneUtil.visualizeObjectTreeDeltas(caseObject.getApprovalContext().getDeltasToApprove(), "pageWorkItem.delta",
pageBase.getPrismContext(), pageBase.getModelInteractionService(), objectRef, task, result);
return new SceneDto(deltasScene);
} catch (SchemaException | ExpressionEvaluationException ex){
Expand Down
Expand Up @@ -29,14 +29,10 @@
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.util.CaseTypeUtil;
import com.evolveum.midpoint.schema.util.ShadowUtil;
import com.evolveum.midpoint.schema.util.WfContextUtil;
import com.evolveum.midpoint.schema.util.ApprovalContextUtil;
import com.evolveum.midpoint.web.component.DateLabelComponent;
import com.evolveum.midpoint.web.component.util.SelectableBean;
import com.evolveum.midpoint.web.component.wf.WorkItemsPanel;
import com.evolveum.midpoint.web.page.admin.cases.CaseWorkItemListWithDetailsPanel;
import com.evolveum.midpoint.web.page.admin.workflow.dto.WorkItemDto;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import com.evolveum.prism.xml.ns._public.types_3.PolyStringType;
import org.apache.commons.lang.StringUtils;
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
Expand Down Expand Up @@ -458,12 +454,12 @@ public static List<IColumn<PrismContainerValueWrapper<CaseWorkItemType>, String>
@Override
public void populateItem(Item<ICellPopulator<PrismContainerValueWrapper<CaseWorkItemType>>> cellItem,
String componentId, IModel<PrismContainerValueWrapper<CaseWorkItemType>> rowModel) {
cellItem.add(new Label(componentId, WfContextUtil.getStageInfo(unwrapRowModel(rowModel))));
cellItem.add(new Label(componentId, ApprovalContextUtil.getStageInfo(unwrapRowModel(rowModel))));
}

@Override
public IModel<String> getDataModel(IModel<PrismContainerValueWrapper<CaseWorkItemType>> rowModel) {
return Model.of(WfContextUtil.getStageInfo(unwrapRowModel(rowModel)));
return Model.of(ApprovalContextUtil.getStageInfo(unwrapRowModel(rowModel)));
}


Expand Down Expand Up @@ -610,12 +606,12 @@ public IModel<String> getDataModel(IModel<PrismContainerValueWrapper<CaseWorkIte
@Override
public void populateItem(Item<ICellPopulator<PrismContainerValueWrapper<CaseWorkItemType>>> cellItem,
String componentId, IModel<PrismContainerValueWrapper<CaseWorkItemType>> rowModel) {
cellItem.add(new Label(componentId, WfContextUtil.getEscalationLevelInfo(unwrapRowModel(rowModel))));
cellItem.add(new Label(componentId, ApprovalContextUtil.getEscalationLevelInfo(unwrapRowModel(rowModel))));
}

@Override
public IModel<String> getDataModel(IModel<PrismContainerValueWrapper<CaseWorkItemType>> rowModel) {
return Model.of(WfContextUtil.getEscalationLevelInfo(unwrapRowModel(rowModel)));
return Model.of(ApprovalContextUtil.getEscalationLevelInfo(unwrapRowModel(rowModel)));
}
});
return columns;
Expand Down
Expand Up @@ -18,7 +18,7 @@

import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.schema.util.WfContextUtil;
import com.evolveum.midpoint.schema.util.ApprovalContextUtil;
import com.evolveum.midpoint.web.component.data.column.ImagePanel;
import com.evolveum.midpoint.web.component.util.VisibleBehaviour;
import com.evolveum.midpoint.web.page.admin.server.dto.ApprovalOutcomeIcon;
Expand Down Expand Up @@ -211,7 +211,7 @@ private String getStageNameLabel(ApprovalStageExecutionInformationDto stage, int
sb.append(getString("ApprovalProcessExecutionInformationPanel.stage"));
if (stage.getStageName() != null || stage.getStageDisplayName() != null) {
sb.append(": ");
sb.append(WfContextUtil.getStageInfo(stageNumber, numberOfStages, stage.getStageName(), stage.getStageDisplayName()));
sb.append(ApprovalContextUtil.getStageInfo(stageNumber, numberOfStages, stage.getStageName(), stage.getStageDisplayName()));
return sb.toString();
} else {
sb.append(" ").append(stageNumber).append("/").append(numberOfStages);
Expand Down
Expand Up @@ -16,12 +16,9 @@

package com.evolveum.midpoint.web.component.wf;

import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.xml.ns._public.common.common_3.WfContextType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ApprovalContextType;
import org.apache.wicket.Component;

import java.util.stream.Collectors;

/**
* @author mederly
*/
Expand All @@ -30,7 +27,7 @@ public class WfGuiUtil {
/**
* Creates localized process instance name from the workflow context (if possible); otherwise returns null.
*/
public static String getLocalizedProcessName(WfContextType wfc, Component component) {
public static String getLocalizedProcessName(ApprovalContextType wfc, Component component) {
// if (wfc != null && !wfc.getLocalizableProcessInstanceName().isEmpty()) {
// return wfc.getLocalizableProcessInstanceName().stream()
// .map(p -> WebComponentUtil.resolveLocalizableMessage(p, component))
Expand All @@ -41,7 +38,7 @@ public static String getLocalizedProcessName(WfContextType wfc, Component compon
return null; // todo get from the CaseType
}

public static String getLocalizedTaskName(WfContextType wfc, Component component) {
public static String getLocalizedTaskName(ApprovalContextType wfc, Component component) {
// if (wfc != null && wfc.getLocalizableTaskName() != null) {
// return WebComponentUtil.resolveLocalizableMessage(wfc.getLocalizableTaskName(), component);
// } else {
Expand Down
Expand Up @@ -221,7 +221,7 @@ private IModel<String> createWorkItemNameModel(IModel<WorkItemDto> workItemDtoMo
return new ReadOnlyModel<>(() -> {
WorkItemDto workItemDto = workItemDtoModel.getObject();
return defaultIfNull(
WfGuiUtil.getLocalizedProcessName(workItemDto.getWorkflowContext(), WorkItemsPanel.this),
WfGuiUtil.getLocalizedProcessName(workItemDto.getApprovalContext(), WorkItemsPanel.this),
workItemDto.getName());
});
}
Expand Down
Expand Up @@ -18,32 +18,28 @@

import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.gui.api.model.ReadOnlyModel;
import com.evolveum.midpoint.schema.util.WfContextUtil;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.component.wf.DecisionsPanel;
import com.evolveum.midpoint.web.page.admin.workflow.dto.DecisionDto;
import com.evolveum.midpoint.web.session.UserProfileStorage;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ItemApprovalProcessStateType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.WfContextType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ApprovalContextType;
import org.apache.wicket.model.IModel;

import java.util.ArrayList;
import java.util.List;

import static org.apache.commons.collections.CollectionUtils.addIgnoreNull;

/**
* @author mederly
*/
public class ItemApprovalHistoryPanel extends BasePanel<WfContextType> {
public class ItemApprovalHistoryPanel extends BasePanel<ApprovalContextType> {
private static final long serialVersionUID = 1L;

private static final Trace LOGGER = TraceManager.getTrace(ItemApprovalHistoryPanel.class);

private static final String ID_DECISIONS_DONE = "decisionsDone";

public ItemApprovalHistoryPanel(String id, IModel<WfContextType> model, UserProfileStorage.TableId tableId, int pageSize) {
public ItemApprovalHistoryPanel(String id, IModel<ApprovalContextType> model, UserProfileStorage.TableId tableId, int pageSize) {
super(id, model);
initLayout(tableId, pageSize);
}
Expand All @@ -52,8 +48,8 @@ private void initLayout(UserProfileStorage.TableId tableId, int pageSize) {

add(new DecisionsPanel(ID_DECISIONS_DONE, new ReadOnlyModel<>(() -> {
List<DecisionDto> rv = new ArrayList<>();
WfContextType wfContextType = getModelObject();
if (wfContextType == null) {
ApprovalContextType approvalContext = getModelObject();
if (approvalContext == null) {
return rv;
}
// TODO
Expand Down
Expand Up @@ -19,17 +19,15 @@
import com.evolveum.midpoint.gui.api.page.PageBase;
import com.evolveum.midpoint.gui.api.prism.PrismObjectWrapper;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.schema.util.WfContextUtil;
import com.evolveum.midpoint.schema.util.ApprovalContextUtil;
import com.evolveum.midpoint.web.component.form.Form;
import com.evolveum.midpoint.web.component.objectdetails.AbstractObjectTabPanel;
import com.evolveum.midpoint.web.component.util.VisibleBehaviour;
import com.evolveum.midpoint.web.component.wf.DecisionsPanel;
import com.evolveum.midpoint.web.component.wf.SwitchableApprovalProcessPreviewsPanel;
import com.evolveum.midpoint.web.component.wf.processes.itemApproval.ItemApprovalHistoryPanel;
import com.evolveum.midpoint.web.page.admin.workflow.dto.DecisionDto;
import com.evolveum.midpoint.web.session.UserProfileStorage;
import com.evolveum.midpoint.xml.ns._public.common.common_3.CaseType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ItemApprovalProcessStateType;
import org.apache.commons.collections.CollectionUtils;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.model.Model;
Expand Down Expand Up @@ -60,7 +58,7 @@ protected void onInitialize(){

private void initLayout(){
SwitchableApprovalProcessPreviewsPanel approvalPanel = new SwitchableApprovalProcessPreviewsPanel(ID_APPROVAL_CASE_PANEL, Model.of(getObjectWrapper().getOid()),
Model.of(WfContextUtil.isInStageBeforeLastOne(getObjectWrapper().getObject().asObjectable())), getPageBase());
Model.of(ApprovalContextUtil.isInStageBeforeLastOne(getObjectWrapper().getObject().asObjectable())), getPageBase());
approvalPanel.setOutputMarkupId(true);
add(approvalPanel);

Expand Down Expand Up @@ -88,11 +86,11 @@ public List<DecisionDto> calculateDecisionList() {
if (parentCase.getEvent() != null && !parentCase.getEvent().isEmpty()) {
parentCase.getEvent().forEach(e -> CollectionUtils.addIgnoreNull(rv, DecisionDto.create(e, ApprovalCaseTabPanel.this.getPageBase())));
} else {
ItemApprovalProcessStateType instanceState = WfContextUtil.getItemApprovalProcessInfo(parentCase.getWorkflowContext());
if (instanceState != null) {
//todo where we can take decisions now?
// instanceState.getDecisions().forEach(d -> CollectionUtils.addIgnoreNull(rv, DecisionDto.create(d)));
}
//ItemApprovalProcessStateType instanceState = WfContextUtil.getItemApprovalProcessInfo(parentCase.getApprovalContext());
// if (instanceState != null) {
// //todo where we can take decisions now?
//// instanceState.getDecisions().forEach(d -> CollectionUtils.addIgnoreNull(rv, DecisionDto.create(d)));
// }
}
return rv;
}
Expand Down
Expand Up @@ -16,41 +16,14 @@
package com.evolveum.midpoint.web.page.admin.cases;

import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.gui.api.component.DisplayNamePanel;
import com.evolveum.midpoint.gui.api.prism.PrismContainerWrapper;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.gui.impl.component.MultivalueContainerDetailsPanel;
import com.evolveum.midpoint.gui.impl.component.MultivalueContainerListPanel;
import com.evolveum.midpoint.gui.impl.component.MultivalueContainerListPanelWithDetailsPanel;
import com.evolveum.midpoint.gui.impl.factory.ItemRealValueModel;
import com.evolveum.midpoint.gui.impl.prism.PrismContainerValueWrapper;
import com.evolveum.midpoint.gui.impl.session.ObjectTabStorage;
import com.evolveum.midpoint.model.api.AssignmentCandidatesSpecification;
import com.evolveum.midpoint.model.api.AssignmentObjectRelation;
import com.evolveum.midpoint.prism.PrismContainerDefinition;
import com.evolveum.midpoint.prism.query.ObjectQuery;
import com.evolveum.midpoint.schema.util.CaseWorkItemUtil;
import com.evolveum.midpoint.schema.util.WfContextUtil;
import com.evolveum.midpoint.web.component.data.column.LinkColumn;
import com.evolveum.midpoint.web.component.prism.*;
import com.evolveum.midpoint.web.component.search.SearchItemDefinition;
import com.evolveum.midpoint.web.session.UserProfileStorage;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.CaseType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.CaseWorkItemType;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator;
import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
import org.apache.wicket.extensions.markup.html.repeater.data.table.export.AbstractExportableColumn;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;

import java.util.ArrayList;
import java.util.List;

/**
* Created by honchar.
Expand Down
Expand Up @@ -19,7 +19,7 @@
import com.evolveum.midpoint.certification.api.OutcomeUtils;
import com.evolveum.midpoint.gui.api.page.PageBase;
import com.evolveum.midpoint.schema.util.CertCampaignTypeUtil;
import com.evolveum.midpoint.schema.util.WfContextUtil;
import com.evolveum.midpoint.schema.util.ApprovalContextUtil;
import com.evolveum.midpoint.schema.util.WorkItemTypeUtil;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationResponseType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationWorkItemType;
Expand Down Expand Up @@ -67,11 +67,11 @@ public long getWorkItemId() {
}

public Integer getEscalationLevelNumber() {
int n = WfContextUtil.getEscalationLevelNumber(workItem);
int n = ApprovalContextUtil.getEscalationLevelNumber(workItem);
return n != 0 ? n : null;
}

public String getEscalationLevelInfo() {
return WfContextUtil.getEscalationLevelInfo(workItem);
return ApprovalContextUtil.getEscalationLevelInfo(workItem);
}
}

0 comments on commit 5b42cf3

Please sign in to comment.