Search in sources :

Example 51 with NotificationEvent

use of org.uberfire.workbench.events.NotificationEvent in project kie-wb-common by kiegroup.

the class AbstractBuildAndDeployExecutor method notifyUpdateSuccess.

protected void notifyUpdateSuccess() {
    notificationEvent.fire(new NotificationEvent(CONSTANTS.DeploySuccessfulAndContainerUpdated(), NotificationEvent.NotificationType.SUCCESS).setAutoHide(false).setNavigation(CONSTANTS.ViewDeploymentDetails(), new DefaultPlaceRequest(SERVER_MANAGEMENT)));
    finish();
}
Also used : NotificationEvent(org.uberfire.workbench.events.NotificationEvent) DefaultPlaceRequest(org.uberfire.mvp.impl.DefaultPlaceRequest)

Example 52 with NotificationEvent

use of org.uberfire.workbench.events.NotificationEvent in project kie-wb-common by kiegroup.

the class AbstractBuildAndDeployExecutor method saveContainerSpecAndMaybeStartContainer.

protected void saveContainerSpecAndMaybeStartContainer(final BuildExecutionContext context, final ContainerSpec containerSpec) {
    specManagementService.call(ignore -> {
        if (!context.isStartContainer()) {
            notificationEvent.fire(new NotificationEvent(CONSTANTS.DeploySuccessful(), NotificationEvent.NotificationType.SUCCESS).setAutoHide(false).setNavigation(CONSTANTS.ViewDeploymentDetails(), new DefaultPlaceRequest(SERVER_MANAGEMENT)));
            finish();
            return;
        }
        specManagementService.call(ignore2 -> {
            notificationEvent.fire(new NotificationEvent(CONSTANTS.DeploySuccessfulAndContainerStarted(), NotificationEvent.NotificationType.SUCCESS).setAutoHide(false).setNavigation(CONSTANTS.ViewDeploymentDetails(), new DefaultPlaceRequest(SERVER_MANAGEMENT)));
            finish();
        }, (o, throwable) -> {
            notificationEvent.fire(new NotificationEvent(CONSTANTS.DeploySuccessfulButContainerFailedToStart(), NotificationEvent.NotificationType.WARNING).setAutoHide(false).setNavigation(CONSTANTS.ViewDeploymentDetails(), new DefaultPlaceRequest(SERVER_MANAGEMENT)));
            finish();
            return false;
        }).startContainer(containerSpec);
    }, (o, throwable) -> {
        notificationEvent.fire(new NotificationEvent(CONSTANTS.DeployFailed(), NotificationEvent.NotificationType.ERROR).setAutoHide(false).setNavigation(CONSTANTS.ViewDeploymentDetails(), new DefaultPlaceRequest(SERVER_MANAGEMENT)));
        finish();
        return false;
    }).saveContainerSpec(context.getServerTemplate().getId(), containerSpec);
}
Also used : ErrorCallback(org.jboss.errai.common.client.api.ErrorCallback) ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) BuildDialog(org.kie.workbench.common.screens.projecteditor.client.build.exec.dialog.BuildDialog) KieServerMode(org.kie.server.api.model.KieServerMode) ServerTemplateList(org.kie.server.controller.api.model.spec.ServerTemplateList) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) CONSTANTS(org.kie.workbench.common.screens.projecteditor.client.resources.ProjectEditorResources.CONSTANTS) BuildExecutionContext(org.kie.workbench.common.screens.projecteditor.client.build.exec.BuildExecutionContext) DefaultPlaceRequest(org.uberfire.mvp.impl.DefaultPlaceRequest) DeploymentPopup(org.kie.workbench.common.screens.projecteditor.client.editor.DeploymentPopup) ERROR(org.uberfire.workbench.events.NotificationEvent.NotificationType.ERROR) SpecManagementService(org.kie.workbench.common.screens.server.management.service.SpecManagementService) BuildService(org.guvnor.common.services.project.builder.service.BuildService) SERVER_MANAGEMENT(org.kie.workbench.common.services.shared.resources.PerspectiveIds.SERVER_MANAGEMENT) Event(javax.enterprise.event.Event) BuildResults(org.guvnor.common.services.project.builder.model.BuildResults) AbstractExecutor(org.kie.workbench.common.screens.projecteditor.client.build.exec.impl.executors.AbstractExecutor) Predicate(java.util.function.Predicate) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback) Collectors(java.util.stream.Collectors) List(java.util.List) DeploymentMode(org.guvnor.common.services.project.service.DeploymentMode) Message(org.jboss.errai.bus.client.api.messaging.Message) Stream(java.util.stream.Stream) BuildUtils(org.kie.workbench.common.screens.projecteditor.client.build.exec.impl.executors.utils.BuildUtils) SUCCESS(org.uberfire.workbench.events.NotificationEvent.NotificationType.SUCCESS) Caller(org.jboss.errai.common.client.api.Caller) Optional(java.util.Optional) ContextValidator(org.kie.workbench.common.screens.projecteditor.client.build.exec.impl.executors.ContextValidator) Collections(java.util.Collections) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) DefaultPlaceRequest(org.uberfire.mvp.impl.DefaultPlaceRequest)

Example 53 with NotificationEvent

use of org.uberfire.workbench.events.NotificationEvent in project kie-wb-common by kiegroup.

the class AbstractBuildAndDeployExecutor method buildDeployWithoutServerTemplate.

private void buildDeployWithoutServerTemplate(final BuildExecutionContext context, final DeploymentMode mode) {
    showBuildMessage();
    buildServiceCaller.call((RemoteCallback<BuildResults>) result -> {
        if (result.getErrorMessages().isEmpty()) {
            notificationEvent.fire(new NotificationEvent(CONSTANTS.BuildSuccessful(), NotificationEvent.NotificationType.SUCCESS));
            notificationEvent.fire(new NotificationEvent(CONSTANTS.DeploymentSkippedDueToNoServerTemplateConfiguredForMode(preferedKieServerMode.name().toLowerCase()), NotificationEvent.NotificationType.WARNING).setAutoHide(false).setNavigation(CONSTANTS.ViewDeploymentDetails(), new DefaultPlaceRequest(SERVER_MANAGEMENT)));
        } else {
            notificationEvent.fire(new NotificationEvent(CONSTANTS.BuildFailed(), NotificationEvent.NotificationType.ERROR));
        }
        buildResultsEvent.fire(result);
        finish();
    }, (ErrorCallback<Message>) (message, throwable) -> {
        buildDeployWithoutServerTemplate(context, DeploymentMode.FORCED);
        return false;
    }).buildAndDeploy(context.getModule(), mode);
}
Also used : ErrorCallback(org.jboss.errai.common.client.api.ErrorCallback) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) DefaultPlaceRequest(org.uberfire.mvp.impl.DefaultPlaceRequest) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback)

Example 54 with NotificationEvent

use of org.uberfire.workbench.events.NotificationEvent in project kie-wb-common by kiegroup.

the class ContainerPresenterTest method testStartContainer.

@Test
public void testStartContainer() {
    when(runtimeManagementService.getContainersByContainerSpec(serverTemplateKey.getId(), containerSpec.getId())).thenReturn(containerSpecData);
    presenter.loadContainers(containerSpecData);
    presenter.startContainer();
    verify(view, times(2)).setContainerStartState(State.DISABLED);
    verify(view, times(2)).setContainerStopState(State.ENABLED);
    final String errorMessage = "ERROR";
    when(view.getStartContainerErrorMessage()).thenReturn(errorMessage);
    doThrow(new RuntimeException()).when(specManagementService).startContainer(containerSpecData.getContainerSpec());
    presenter.startContainer();
    verify(notification).fire(new NotificationEvent(errorMessage, NotificationEvent.NotificationType.ERROR));
    verify(view, times(3)).setContainerStartState(State.DISABLED);
    verify(view, times(3)).setContainerStopState(State.ENABLED);
    verify(view, times(3)).enableRemoveButton();
}
Also used : NotificationEvent(org.uberfire.workbench.events.NotificationEvent) Test(org.junit.Test)

Example 55 with NotificationEvent

use of org.uberfire.workbench.events.NotificationEvent in project kie-wb-common by kiegroup.

the class ContainerPresenterTest method testStopContainer.

@Test
public void testStopContainer() {
    when(runtimeManagementService.getContainersByContainerSpec(serverTemplateKey.getId(), containerSpec.getId())).thenReturn(containerSpecData);
    presenter.loadContainers(containerSpecData);
    presenter.stopContainer();
    verify(view, times(2)).setContainerStartState(State.DISABLED);
    verify(view, times(2)).setContainerStopState(State.ENABLED);
    verify(view, times(2)).enableRemoveButton();
    final String errorMessage = "ERROR";
    when(view.getStopContainerErrorMessage()).thenReturn(errorMessage);
    doThrow(new RuntimeException()).when(specManagementService).stopContainer(containerSpecData.getContainerSpec());
    presenter.stopContainer();
    verify(notification).fire(new NotificationEvent(errorMessage, NotificationEvent.NotificationType.ERROR));
    verify(view, times(3)).setContainerStartState(State.DISABLED);
    verify(view, times(3)).setContainerStopState(State.ENABLED);
}
Also used : NotificationEvent(org.uberfire.workbench.events.NotificationEvent) Test(org.junit.Test)

Aggregations

NotificationEvent (org.uberfire.workbench.events.NotificationEvent)151 Test (org.junit.Test)65 RemoteCallback (org.jboss.errai.common.client.api.RemoteCallback)34 ServerTemplate (org.kie.server.controller.api.model.spec.ServerTemplate)28 ContainerSpec (org.kie.server.controller.api.model.spec.ContainerSpec)22 ServerTemplateList (org.kie.server.controller.api.model.spec.ServerTemplateList)21 List (java.util.List)17 Path (org.uberfire.backend.vfs.Path)17 ErrorCallback (org.jboss.errai.common.client.api.ErrorCallback)16 ArrayList (java.util.ArrayList)14 Event (javax.enterprise.event.Event)14 Inject (javax.inject.Inject)12 ObservablePath (org.uberfire.backend.vfs.ObservablePath)12 PostConstruct (javax.annotation.PostConstruct)9 Observes (javax.enterprise.event.Observes)9 Caller (org.jboss.errai.common.client.api.Caller)9 Map (java.util.Map)8 Promise (elemental2.promise.Promise)7 Arrays (java.util.Arrays)7 Dependent (javax.enterprise.context.Dependent)7