Search in sources :

Example 6 with OperationResultStatusPresentationProperties

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());
    }
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) VariablesMap(com.evolveum.midpoint.schema.expression.VariablesMap) OperationResultStatusPresentationProperties(com.evolveum.midpoint.web.page.admin.server.dto.OperationResultStatusPresentationProperties)

Example 7 with OperationResultStatusPresentationProperties

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);
}
Also used : DisplayType(com.evolveum.midpoint.xml.ns._public.common.common_3.DisplayType) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) OperationResultStatusPresentationProperties(com.evolveum.midpoint.web.page.admin.server.dto.OperationResultStatusPresentationProperties) IconType(com.evolveum.midpoint.xml.ns._public.common.common_3.IconType) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) CompositedIconPanel(com.evolveum.midpoint.gui.impl.component.data.column.CompositedIconPanel) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) CompositedIcon(com.evolveum.midpoint.gui.impl.component.icon.CompositedIcon) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) CompositedIconBuilder(com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

Example 8 with OperationResultStatusPresentationProperties

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));
        }
    }
}
Also used : OperationResultStatusPresentationProperties(com.evolveum.midpoint.web.page.admin.server.dto.OperationResultStatusPresentationProperties)

Aggregations

OperationResultStatusPresentationProperties (com.evolveum.midpoint.web.page.admin.server.dto.OperationResultStatusPresentationProperties)8 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)6 VariablesMap (com.evolveum.midpoint.schema.expression.VariablesMap)3 Task (com.evolveum.midpoint.task.api.Task)3 PageOperationResult (com.evolveum.midpoint.web.page.error.PageOperationResult)3 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)2 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)1 CompositedIconPanel (com.evolveum.midpoint.gui.impl.component.data.column.CompositedIconPanel)1 CompositedIcon (com.evolveum.midpoint.gui.impl.component.icon.CompositedIcon)1 CompositedIconBuilder (com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder)1 OperationResultStatus (com.evolveum.midpoint.schema.result.OperationResultStatus)1 CommunicationException (com.evolveum.midpoint.util.exception.CommunicationException)1 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)1 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)1 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)1 DisplayType (com.evolveum.midpoint.xml.ns._public.common.common_3.DisplayType)1 IconType (com.evolveum.midpoint.xml.ns._public.common.common_3.IconType)1 RestartResponseException (org.apache.wicket.RestartResponseException)1 Label (org.apache.wicket.markup.html.basic.Label)1 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)1