Skip to content

Commit

Permalink
MID-9533: fix for outcome column in cases table panel (support skip o…
Browse files Browse the repository at this point in the history
…utcome)
  • Loading branch information
skublik committed Mar 28, 2024
1 parent 9a49791 commit fef5d84
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ public class GuiStyleConstants {
public static final String CLASS_ICON_CONSENT = "fa fa-check-square";

public static final String CLASS_APPROVAL_OUTCOME_ICON_UNKNOWN_COLORED = "fa fa-check text-warning";
public static final String CLASS_APPROVAL_OUTCOME_ICON_UNRECOGNIZED_COLORED = "fa fa-question text-warning";
public static final String CLASS_APPROVAL_OUTCOME_ICON_APPROVED_COLORED = "fa fa-check text-success";
public static final String CLASS_APPROVAL_OUTCOME_ICON_REJECTED_COLORED = "fa fa-times text-danger";
public static final String CLASS_APPROVAL_OUTCOME_ICON_SKIPPED_COLORED = "fa fa-step-forward text-success";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import javax.xml.datatype.XMLGregorianCalendar;
import javax.xml.namespace.QName;

import com.evolveum.midpoint.web.page.admin.server.dto.ApprovalOutcomeIcon;

import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -3104,7 +3106,7 @@ public static void workItemApproveActionPerformed(AjaxRequestTarget target, Case
pageBase.showResult(result);
}

public static OperationResultStatusPresentationProperties caseOutcomeUriToIcon(String outcome) {
public static OperationResultStatusPresentationProperties caseOutcomeUriToPresentation(String outcome) {
if (outcome == null) {
return OperationResultStatusPresentationProperties.IN_PROGRESS;
} else if (QNameUtil.matchUri(outcome, SchemaConstants.MODEL_APPROVAL_OUTCOME_APPROVE)) {
Expand All @@ -3116,6 +3118,20 @@ public static OperationResultStatusPresentationProperties caseOutcomeUriToIcon(S
}
}

public static ApprovalOutcomeIcon caseOutcomeUriToIcon(String outcome) {
if (outcome == null) {
return ApprovalOutcomeIcon.IN_PROGRESS;
} else if (QNameUtil.matchUri(outcome, SchemaConstants.MODEL_APPROVAL_OUTCOME_APPROVE)) {
return ApprovalOutcomeIcon.APPROVED;
} else if (QNameUtil.matchUri(outcome, SchemaConstants.MODEL_APPROVAL_OUTCOME_REJECT)) {
return ApprovalOutcomeIcon.REJECTED;
} else if (QNameUtil.matchUri(outcome, SchemaConstants.MODEL_APPROVAL_OUTCOME_SKIP)) {
return ApprovalOutcomeIcon.SKIPPED;
} else {
return ApprovalOutcomeIcon.UNRECOGNIZED;
}
}

public static List<ObjectOrdering> createMetadataOrdering(SortParam<String> sortParam, String metadataProperty, PrismContext prismContext) {
if (sortParam != null && sortParam.getProperty() != null) {
OrderDirection order = sortParam.isAscending() ? OrderDirection.ASCENDING : OrderDirection.DESCENDING;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.prism.query.ObjectQuery;
import com.evolveum.midpoint.prism.xml.XmlTypeConverter;
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.util.ObjectTypeUtil;
import com.evolveum.midpoint.schema.util.ShadowUtil;
Expand Down Expand Up @@ -991,18 +990,20 @@ private static void processCaseOutcome(CaseType caseType, Map<DisplayType, Integ
one = 1;
}
if (CaseTypeUtil.isApprovalCase(caseType)) {
Boolean result = ApprovalUtils.approvalBooleanValueFromUri(caseType.getOutcome());
if (result == null) {
ApprovalOutcomeIcon icon;
String outcome = caseType.getOutcome();

if (StringUtils.isEmpty(outcome)) {
if (caseType.getCloseTimestamp() != null) {
return;
} else {
putDisplayTypeToMapWithCount(map, one, GuiDisplayTypeUtil.createDisplayType(ApprovalOutcomeIcon.IN_PROGRESS));
icon = ApprovalOutcomeIcon.IN_PROGRESS;
}
} else if (result) {
putDisplayTypeToMapWithCount(map, one, GuiDisplayTypeUtil.createDisplayType(ApprovalOutcomeIcon.APPROVED));
} else {
putDisplayTypeToMapWithCount(map, one, GuiDisplayTypeUtil.createDisplayType(ApprovalOutcomeIcon.REJECTED));
icon = WebComponentUtil.caseOutcomeUriToIcon(outcome);
}

putDisplayTypeToMapWithCount(map, one, GuiDisplayTypeUtil.createDisplayType(icon));
return;
}
if (CaseTypeUtil.isManualProvisioningCase(caseType)) {
Expand All @@ -1019,7 +1020,7 @@ private static void processCaseOutcome(CaseType caseType, Map<DisplayType, Integ
result = OperationResultStatusType.fromValue(caseType.getOutcome());
} catch (IllegalArgumentException e) {
putDisplayTypeToMapWithCount(map, one,
GuiDisplayTypeUtil.createDisplayType(WebComponentUtil.caseOutcomeUriToIcon(caseType.getOutcome())));
GuiDisplayTypeUtil.createDisplayType(WebComponentUtil.caseOutcomeUriToPresentation(caseType.getOutcome())));
return;
}
OperationResultStatusPresentationProperties resultStatus = OperationResultStatusPresentationProperties.parseOperationalResultStatus(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public enum ApprovalOutcomeIcon {
IN_PROGRESS(GuiStyleConstants.CLASS_APPROVAL_OUTCOME_ICON_IN_PROGRESS_COLORED, "MyRequestsPanel.inProgress"),
FUTURE(GuiStyleConstants.CLASS_APPROVAL_OUTCOME_ICON_FUTURE_COLORED, "MyRequestsPanel.future"),
CANCELLED(GuiStyleConstants.CLASS_APPROVAL_OUTCOME_ICON_CANCELLED_COLORED, "MyRequestsPanel.cancelled"),
UNRECOGNIZED(GuiStyleConstants.CLASS_APPROVAL_OUTCOME_ICON_UNRECOGNIZED_COLORED, "MyRequestsPanel.unrecognized"),
EMPTY("", ""); // to be used for cases when it won't be really displayed; reconsider this

private String icon;
Expand Down

0 comments on commit fef5d84

Please sign in to comment.