Search in sources :

Example 1 with OpResult

use of com.evolveum.midpoint.gui.api.component.result.OpResult in project midpoint by Evolveum.

the class PageReport method createFullXmlValidator.

private IValidator<String> createFullXmlValidator() {
    return new IValidator<String>() {

        @Override
        public void validate(IValidatable<String> validatable) {
            String value = validatable.getValue();
            OperationResult result = new OperationResult(OPERATION_VALIDATE_REPORT);
            Holder<PrismObject<ReportType>> reportHolder = new Holder<>(null);
            OpResult opResult = null;
            try {
                validateObject(value, reportHolder, PrismContext.LANG_XML, true, result);
                if (!result.isAcceptable()) {
                    result.recordFatalError("Could not validate object", result.getCause());
                    opResult = OpResult.getOpResult((PageBase) getPage(), result);
                    validatable.error(new RawValidationError(opResult));
                }
            } catch (Exception e) {
                LOGGER.error("Validation problem occured." + e.getMessage());
                result.recordFatalError("Could not validate object.", e);
                try {
                    opResult = OpResult.getOpResult((PageBase) getPage(), result);
                    validatable.error(new RawValidationError(opResult));
                } catch (Exception ex) {
                    error(ex);
                }
            }
        }
    };
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) IValidator(org.apache.wicket.validation.IValidator) Holder(com.evolveum.midpoint.util.Holder) OpResult(com.evolveum.midpoint.gui.api.component.result.OpResult) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) RawValidationError(org.apache.wicket.validation.RawValidationError) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) RestartResponseException(org.apache.wicket.RestartResponseException) IValidatable(org.apache.wicket.validation.IValidatable)

Example 2 with OpResult

use of com.evolveum.midpoint.gui.api.component.result.OpResult in project midpoint by Evolveum.

the class FeedbackListView method populateItem.

@Override
protected void populateItem(final ListItem<FeedbackMessage> item) {
    final FeedbackMessage message = item.getModelObject();
    if (message.getMessage() instanceof OpResult) {
        final OpResult opResult = (OpResult) message.getMessage();
        OperationResultPanel panel = new OperationResultPanel("message", Model.of(opResult)) {

            private static final long serialVersionUID = 1L;

            @Override
            public void close(AjaxRequestTarget target) {
                super.close(target);
                message.markRendered();
            }

            protected void onAfterRender() {
                opResult.setAlreadyShown(true);
                super.onAfterRender();
            }
        };
        panel.add(new VisibleBehaviour(() -> opResult != null && !opResult.isAlreadyShown()));
        panel.setOutputMarkupId(true);
        item.add(panel);
    } else {
        message.markRendered();
        ValidationErrorPanel validationPanel = new ValidationErrorPanel("message", item.getModel()) {

            private static final long serialVersionUID = 1L;

            @Override
            public void close(AjaxRequestTarget target) {
                super.close(target);
                message.markRendered();
            }
        };
        validationPanel.setOutputMarkupId(true);
        item.add(validationPanel);
    }
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ValidationErrorPanel(com.evolveum.midpoint.gui.api.component.result.ValidationErrorPanel) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) OpResult(com.evolveum.midpoint.gui.api.component.result.OpResult) OperationResultPanel(com.evolveum.midpoint.gui.api.component.result.OperationResultPanel) FeedbackMessage(org.apache.wicket.feedback.FeedbackMessage)

Example 3 with OpResult

use of com.evolveum.midpoint.gui.api.component.result.OpResult in project midpoint by Evolveum.

the class TestConnectionMessagesPanel method initResultsModel.

private void initResultsModel(String resourceOid) {
    OperationResult result = new OperationResult(OPERATION_TEST_CONNECTION);
    List<OpResult> resourceResultsDto = new ArrayList<>();
    List<ConnectorStruct> connectorStructs = new ArrayList<>();
    if (StringUtils.isNotEmpty(resourceOid)) {
        Task task = parentPage.createSimpleTask(OPERATION_TEST_CONNECTION);
        try {
            result = parentPage.getModelService().testResource(resourceOid, task);
        } catch (ObjectNotFoundException e) {
            result.recordFatalError(getString("TestConnectionMessagesPanel.message.testConnection.fatalError"), e);
        }
        for (OperationResult subresult : result.getSubresults()) {
            if (isConnectorResult(subresult)) {
                ConnectorStruct connectorStruct = new ConnectorStruct();
                connectorStruct.connectorName = subresult.getParamSingle(OperationResult.PARAM_NAME);
                if (connectorStruct.connectorName == null) {
                    connectorStruct.connectorName = "";
                }
                connectorStruct.connectorResultsDto = new ArrayList<>();
                for (OperationResult subsubresult : subresult.getSubresults()) {
                    if (isKnownResult(subsubresult)) {
                        connectorStruct.connectorResultsDto.add(OpResult.getOpResult(parentPage, subsubresult));
                    }
                }
                connectorStructs.add(connectorStruct);
            } else if (isKnownResult(subresult)) {
                // resource operation
                resourceResultsDto.add(OpResult.getOpResult(parentPage, subresult));
            }
        }
        if (result.isSuccess()) {
            result.recomputeStatus();
        }
    }
    modelResourceResults = new ListModel<>(resourceResultsDto);
    connectorResourceResults = new ListModel<>(connectorStructs);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OpResult(com.evolveum.midpoint.gui.api.component.result.OpResult) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Example 4 with OpResult

use of com.evolveum.midpoint.gui.api.component.result.OpResult in project midpoint by Evolveum.

the class TestConnectionMessagesPanel method initLayout.

private void initLayout() {
    setOutputMarkupId(true);
    WebMarkupContainer messagesPanel = new WebMarkupContainer(ID_MESSAGES_PANEL);
    messagesPanel.setOutputMarkupId(true);
    add(messagesPanel);
    ListView<ConnectorStruct> connectorView = new ListView<ConnectorStruct>(ID_CONNECTOR_MESSAGES_PANEL, connectorResourceResults) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<ConnectorStruct> item) {
            Label connectorNameLabel = new Label(ID_CONNECTOR_NAME, item.getModelObject().connectorName);
            item.add(connectorNameLabel);
            RepeatingView connectorResultView = new RepeatingView(ID_CONNECTOR_MESSAGES);
            List<OpResult> resultsDto = item.getModelObject().connectorResultsDto;
            if (resultsDto != null) {
                initResultsPanel(connectorResultView, resultsDto, parentPage);
            }
            item.add(connectorResultView);
        }
    };
    messagesPanel.add(connectorView);
    RepeatingView resultView = new RepeatingView(ID_RESOURCE_MESSAGES);
    if (modelResourceResults.getObject() != null) {
        initResultsPanel(resultView, modelResourceResults.getObject(), parentPage);
    }
    resultView.setOutputMarkupId(true);
    messagesPanel.add(resultView);
}
Also used : ListView(org.apache.wicket.markup.html.list.ListView) OpResult(com.evolveum.midpoint.gui.api.component.result.OpResult) Label(org.apache.wicket.markup.html.basic.Label) RepeatingView(org.apache.wicket.markup.repeater.RepeatingView) ListItem(org.apache.wicket.markup.html.list.ListItem) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Example 5 with OpResult

use of com.evolveum.midpoint.gui.api.component.result.OpResult in project midpoint by Evolveum.

the class TestConnectionMessagesPanel method initResultsPanel.

public void initResultsPanel(RepeatingView resultView, List<OpResult> opresults, Page parentPage) {
    for (OpResult result : opresults) {
        OperationResultPanel resultPanel = new OperationResultPanel(resultView.newChildId(), new Model<>(result));
        resultPanel.add(new VisibleBehaviour(() -> result != null));
        resultPanel.setOutputMarkupId(true);
        resultView.add(resultPanel);
    }
}
Also used : VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) OpResult(com.evolveum.midpoint.gui.api.component.result.OpResult) OperationResultPanel(com.evolveum.midpoint.gui.api.component.result.OperationResultPanel)

Aggregations

OpResult (com.evolveum.midpoint.gui.api.component.result.OpResult)8 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)4 OperationResultPanel (com.evolveum.midpoint.gui.api.component.result.OperationResultPanel)3 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)3 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)3 ValidationErrorPanel (com.evolveum.midpoint.gui.api.component.result.ValidationErrorPanel)1 ReadOnlyModel (com.evolveum.midpoint.gui.api.model.ReadOnlyModel)1 PageBase (com.evolveum.midpoint.gui.api.page.PageBase)1 PrismObject (com.evolveum.midpoint.prism.PrismObject)1 Task (com.evolveum.midpoint.task.api.Task)1 Holder (com.evolveum.midpoint.util.Holder)1 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)1 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)1 BoxedTablePanel (com.evolveum.midpoint.web.component.data.BoxedTablePanel)1 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)1 SelectableListDataProvider (com.evolveum.midpoint.web.component.util.SelectableListDataProvider)1 TaskType (com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType)1 ArrayList (java.util.ArrayList)1 RestartResponseException (org.apache.wicket.RestartResponseException)1 AjaxFallbackLink (org.apache.wicket.ajax.markup.html.AjaxFallbackLink)1