use of com.evolveum.midpoint.web.page.admin.server.dto.OperationResultStatusPresentationProperties in project midpoint by Evolveum.
the class ReportObjectsListPanel method evaluateExpression.
@Override
protected Collection evaluateExpression(C rowValue, com.evolveum.midpoint.prism.Item<?, ?> columnItem, ExpressionType expression, GuiObjectColumnType customColumn) {
Task task = getPageBase().createSimpleTask(OPERATION_EVALUATE_EXPRESSION);
OperationResult result = task.getResult();
try {
VariablesMap variablesMap = new VariablesMap();
if (columnItem == null) {
variablesMap.put(ExpressionConstants.VAR_INPUT, null, String.class);
} else {
variablesMap.put(ExpressionConstants.VAR_INPUT, columnItem, columnItem.getDefinition());
}
processVariables(variablesMap);
if (!variablesMap.containsKey(ExpressionConstants.VAR_OBJECT)) {
variablesMap.put(ExpressionConstants.VAR_OBJECT, rowValue, rowValue.asPrismContainerValue().getDefinition());
}
Object object = getPageBase().getReportManager().evaluateScript(getReport().asPrismObject(), expression, variablesMap, "evaluate column expression", task, result);
if (object instanceof Collection) {
return (Collection) object;
}
return Collections.singletonList(object);
} catch (Exception e) {
LOGGER.error("Couldn't execute expression for {} column. Reason: {}", customColumn, e.getMessage(), e);
result.recomputeStatus();
OperationResultStatusPresentationProperties props = OperationResultStatusPresentationProperties.parseOperationalResultStatus(result.getStatus());
// TODO: this is not entirely correct
return Collections.singletonList(getPageBase().createStringResource(props.getStatusLabelKey()).getString());
}
}
use of com.evolveum.midpoint.web.page.admin.server.dto.OperationResultStatusPresentationProperties in project midpoint by Evolveum.
the class ColumnResultPanel method initLayout.
private void initLayout() {
LoadableModel<CompositedIcon> compositedIcon = new LoadableModel<CompositedIcon>() {
@Override
protected CompositedIcon load() {
OperationResult result = getModelObject();
if (result == null) {
return null;
}
String basicIconCssClass;
String title;
if (result.isEmpty()) {
DisplayType displayType = getDisplayForEmptyResult();
if (displayType == null || displayType.getIcon() == null || displayType.getIcon().getCssClass() == null) {
return null;
}
basicIconCssClass = displayType.getIcon().getCssClass();
title = WebComponentUtil.getTranslatedPolyString(displayType.getTooltip());
} else {
OperationResultStatusPresentationProperties statusProperties = OperationResultStatusPresentationProperties.parseOperationalResultStatus(result.getStatus());
basicIconCssClass = statusProperties.getIcon() + " fa-lg";
title = getPageBase().createStringResource(statusProperties.getStatusLabelKey()).getString();
}
CompositedIconBuilder builder = new CompositedIconBuilder();
String additionalCssClass = "";
Throwable cause = RepoCommonUtils.getResultExceptionIfExists(getModelObject());
if (OperationResultStatus.IN_PROGRESS.equals(result.getStatus()) && (cause instanceof CommunicationException) && isProjectionResult()) {
IconType icon = new IconType();
icon.setCssClass("fa fa-info-circle " + GuiStyleConstants.BLUE_COLOR);
builder.appendLayerIcon(icon, LayeredIconCssStyle.BOTTOM_RIGHT_STYLE);
builder.setTitle(getPageBase().createStringResource("ColumnResultPanel.message.communicationFail").getString());
additionalCssClass = "change-password-icon-result-center";
} else {
builder.setTitle(title);
}
builder.setBasicIcon(basicIconCssClass, IconCssStyle.IN_ROW_STYLE, additionalCssClass);
return builder.build();
}
};
CompositedIconPanel iconPanel = new CompositedIconPanel(ID_RESULT_ICON, compositedIcon);
iconPanel.setOutputMarkupId(true);
add(iconPanel);
AjaxButton showErrorDetailsButton = new AjaxButton(ID_DETAILS_BUTTON) {
@Override
public void onClick(AjaxRequestTarget target) {
getPageBase().showResult(ColumnResultPanel.this.getModelObject());
target.add(getPageBase().getFeedbackPanel());
}
};
showErrorDetailsButton.setOutputMarkupId(true);
showErrorDetailsButton.add(AttributeAppender.append("title", getPageBase().createStringResource("ColumnResultPanel.showDetails")));
showErrorDetailsButton.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return getModelObject() != null && RepoCommonUtils.getResultExceptionIfExists(getModelObject()) != null;
}
});
add(showErrorDetailsButton);
}
use of com.evolveum.midpoint.web.page.admin.server.dto.OperationResultStatusPresentationProperties in project midpoint by Evolveum.
the class ColumnUtils method processCaseOutcome.
private static void processCaseOutcome(CaseType caseType, Map<DisplayType, Integer> map, boolean useNullAsOne) {
if (caseType == null) {
return;
}
Integer one = null;
if (!useNullAsOne) {
one = 1;
}
if (CaseTypeUtil.isApprovalCase(caseType)) {
Boolean result = ApprovalUtils.approvalBooleanValueFromUri(caseType.getOutcome());
if (result == null) {
if (caseType.getCloseTimestamp() != null) {
return;
} else {
putDisplayTypeToMapWithCount(map, one, GuiDisplayTypeUtil.createDisplayType(ApprovalOutcomeIcon.IN_PROGRESS));
}
} else if (result) {
putDisplayTypeToMapWithCount(map, one, GuiDisplayTypeUtil.createDisplayType(ApprovalOutcomeIcon.APPROVED));
} else {
putDisplayTypeToMapWithCount(map, one, GuiDisplayTypeUtil.createDisplayType(ApprovalOutcomeIcon.REJECTED));
}
return;
}
if (CaseTypeUtil.isManualProvisioningCase(caseType)) {
if (StringUtils.isEmpty(caseType.getOutcome())) {
if (caseType.getCloseTimestamp() != null) {
putDisplayTypeToMapWithCount(map, one, GuiDisplayTypeUtil.createDisplayType(OperationResultStatusPresentationProperties.UNKNOWN));
} else {
putDisplayTypeToMapWithCount(map, one, GuiDisplayTypeUtil.createDisplayType(OperationResultStatusPresentationProperties.IN_PROGRESS));
}
} else {
OperationResultStatusType result;
try {
result = OperationResultStatusType.fromValue(caseType.getOutcome());
} catch (IllegalArgumentException e) {
putDisplayTypeToMapWithCount(map, one, GuiDisplayTypeUtil.createDisplayType(WebComponentUtil.caseOutcomeUriToIcon(caseType.getOutcome())));
return;
}
OperationResultStatusPresentationProperties resultStatus = OperationResultStatusPresentationProperties.parseOperationalResultStatus(result);
putDisplayTypeToMapWithCount(map, one, GuiDisplayTypeUtil.createDisplayType(resultStatus));
}
}
}
Aggregations