Search in sources :

Example 6 with ServiceCanceledException

use of org.jowidgets.cap.common.api.exception.ServiceCanceledException in project jo-client-platform by jo-source.

the class PasteLinkCommand method createResultCallback.

private IResultCallback<List<IBeanDto>> createResultCallback(final List<IBeanProxy<SOURCE_BEAN_TYPE>> selection, final IExecutionContext executionContext) {
    return new AbstractUiResultCallback<List<IBeanDto>>() {

        @Override
        protected void finishedUi(final List<IBeanDto> result) {
            for (final IBeanProxy<SOURCE_BEAN_TYPE> bean : selection) {
                bean.setExecutionTask(null);
            }
            if (linkedModel != null) {
                if (Cardinality.LESS_OR_EQUAL_ONE.equals(linkedCardinality)) {
                    linkedModel.removeAllBeans();
                }
                for (final IBeanDto resultBean : result) {
                    linkedModel.addBeanDto(resultBean);
                }
            }
            executionObservable.fireAfterExecutionSuccess(executionContext, result);
        }

        @Override
        protected void exceptionUi(final Throwable exception) {
            int beanIndex = 0;
            for (final IBeanProxy<SOURCE_BEAN_TYPE> bean : selection) {
                bean.setExecutionTask(null);
                if (!(exception instanceof ServiceCanceledException)) {
                    bean.addMessage(exceptionConverter.convert(getShortErrorMessage(), selection, beanIndex++, bean, exception));
                }
            }
            executionObservable.fireAfterExecutionError(executionContext, exception);
        }

        private String getShortErrorMessage() {
            final String actionText = executionContext.getAction().getText().replaceAll("\\.", "").trim();
            return MessageReplacer.replace(SHORT_ERROR.get(), actionText);
        }
    };
}
Also used : AbstractUiResultCallback(org.jowidgets.cap.ui.tools.execution.AbstractUiResultCallback) IBeanDto(org.jowidgets.cap.common.api.bean.IBeanDto) LinkedList(java.util.LinkedList) List(java.util.List) ServiceCanceledException(org.jowidgets.cap.common.api.exception.ServiceCanceledException)

Aggregations

ServiceCanceledException (org.jowidgets.cap.common.api.exception.ServiceCanceledException)6 LinkedList (java.util.LinkedList)3 List (java.util.List)2 IBeanDto (org.jowidgets.cap.common.api.bean.IBeanDto)2 AbstractUiResultCallback (org.jowidgets.cap.ui.tools.execution.AbstractUiResultCallback)2 HashMap (java.util.HashMap)1 BeansValidationException (org.jowidgets.cap.common.api.exception.BeansValidationException)1 KeyType (org.jowidgets.cap.common.api.exception.BeansValidationException.KeyType)1 ServiceInterruptedException (org.jowidgets.cap.common.api.exception.ServiceInterruptedException)1 IExecutionCallback (org.jowidgets.cap.common.api.execution.IExecutionCallback)1 IResultCallback (org.jowidgets.cap.common.api.execution.IResultCallback)1 UserQuestionResult (org.jowidgets.cap.common.api.execution.UserQuestionResult)1 IBeanValidationResult (org.jowidgets.cap.common.api.validation.IBeanValidationResult)1 IExecutionTask (org.jowidgets.cap.ui.api.execution.IExecutionTask)1 IBeanFormBluePrint (org.jowidgets.cap.ui.api.widgets.IBeanFormBluePrint)1 IBeanLinkDialogBluePrint (org.jowidgets.cap.ui.api.widgets.IBeanLinkDialogBluePrint)1 IBeanLinkPanelBluePrint (org.jowidgets.cap.ui.api.widgets.IBeanLinkPanelBluePrint)1 IBeanTableBluePrint (org.jowidgets.cap.ui.api.widgets.IBeanTableBluePrint)1 IServiceProvider (org.jowidgets.service.api.IServiceProvider)1 DefaultServiceProviderHolder (org.jowidgets.service.tools.DefaultServiceProviderHolder)1