Search in sources :

Example 1 with SaveInProgressEvent

use of org.uberfire.client.mvp.SaveInProgressEvent in project drools-wb by kiegroup.

the class GuidedDecisionTableGraphEditorPresenter method saveDocumentGraphEntries.

void saveDocumentGraphEntries() {
    final Set<GuidedDecisionTableView.Presenter> allDecisionTables = new HashSet<>(modeller.getAvailableDecisionTables());
    savePopUpPresenter.show(editorPath, (commitMessage) -> {
        editorView.showSaving();
        saveGraphLatch = new SaveGraphLatch(allDecisionTables.size(), commitMessage);
        if (allDecisionTables.isEmpty()) {
            saveGraphLatch.saveDocumentGraph();
        } else {
            allDecisionTables.stream().forEach((dtPresenter) -> {
                saveGraphLatch.saveDocumentGraphEntry(dtPresenter);
                saveInProgressEvent.fire(new SaveInProgressEvent(dtPresenter.getLatestPath()));
            });
        }
    });
}
Also used : GuidedDecisionTablePresenter(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTablePresenter) OverviewWidgetPresenter(org.kie.workbench.common.widgets.metadata.client.widget.OverviewWidgetPresenter) SaveInProgressEvent(org.uberfire.client.mvp.SaveInProgressEvent) HashSet(java.util.HashSet)

Example 2 with SaveInProgressEvent

use of org.uberfire.client.mvp.SaveInProgressEvent in project drools-wb by kiegroup.

the class GuidedDecisionTableGraphEditorPresenterTest method checkSaveDocumentGraphEntries.

@Test
public void checkSaveDocumentGraphEntries() {
    final ObservablePath dtGraphPath = mock(ObservablePath.class);
    final PathPlaceRequest dtGraphPlaceRequest = mock(PathPlaceRequest.class);
    final GuidedDecisionTableEditorGraphContent dtGraphContent = makeDecisionTableGraphContent();
    final ObservablePath dtPath1 = mock(ObservablePath.class);
    final PlaceRequest dtPlaceRequest1 = mock(PlaceRequest.class);
    final GuidedDecisionTableEditorContent dtContent1 = makeDecisionTableContent();
    final GuidedDecisionTableView.Presenter dtPresenter1 = makeDecisionTable(dtPath1, dtPath1, dtPlaceRequest1, dtContent1);
    final ObservablePath dtPath2 = mock(ObservablePath.class);
    final PlaceRequest dtPlaceRequest2 = mock(PlaceRequest.class);
    final GuidedDecisionTableEditorContent dtContent2 = makeDecisionTableContent();
    final GuidedDecisionTableView.Presenter dtPresenter2 = makeDecisionTable(dtPath2, dtPath2, dtPlaceRequest2, dtContent2);
    when(dtPath1.toURI()).thenReturn("dtPath1");
    when(dtPath2.toURI()).thenReturn("dtPath2");
    when(dtGraphPath.toURI()).thenReturn("dtGraphPath");
    when(dtGraphPath.getFileName()).thenReturn("filename");
    when(dtService.loadContent(eq(dtPath1))).thenReturn(dtContent1);
    when(dtService.loadContent(eq(dtPath2))).thenReturn(dtContent2);
    when(dtGraphService.loadContent(eq(dtGraphPath))).thenReturn(dtGraphContent);
    when(versionRecordManager.getCurrentPath()).thenReturn(dtGraphPath);
    when(modeller.addDecisionTable(any(ObservablePath.class), any(PlaceRequest.class), eq(dtContent1), any(Boolean.class), any(Double.class), any(Double.class))).thenReturn(dtPresenter1);
    when(modeller.addDecisionTable(any(ObservablePath.class), any(PlaceRequest.class), eq(dtContent2), any(Boolean.class), any(Double.class), any(Double.class))).thenReturn(dtPresenter2);
    when(modeller.getAvailableDecisionTables()).thenReturn(new HashSet<GuidedDecisionTableView.Presenter>() {

        {
            add(dtPresenter1);
            add(dtPresenter2);
        }
    });
    presenter.onStartup(dtGraphPath, dtGraphPlaceRequest);
    presenter.saveDocumentGraphEntries();
    verify(savePopUpPresenter, times(1)).show(any(Path.class), commitMessageCommandCaptor.capture());
    final ParameterizedCommand<String> commitMessageCommand = commitMessageCommandCaptor.getValue();
    assertNotNull(commitMessageCommand);
    commitMessageCommand.execute("message");
    verify(view, times(1)).showSaving();
    verify(saveInProgressEvent, times(2)).fire(any(SaveInProgressEvent.class));
    verify(dtGraphService, times(1)).save(eq(dtGraphPath), any(GuidedDecisionTableEditorGraphModel.class), any(Metadata.class), eq("message"));
    verify(dtService, times(1)).save(eq(dtPath2), any(GuidedDecisionTable52.class), any(Metadata.class), eq("message"));
    verify(dtService, times(1)).save(eq(dtPath2), any(GuidedDecisionTable52.class), any(Metadata.class), eq("message"));
    verify(notificationEvent, times(1)).fire(any(NotificationEvent.class));
    verify(dtPresenter1, times(1)).setConcurrentUpdateSessionInfo(eq(null));
    verify(dtPresenter2, times(1)).setConcurrentUpdateSessionInfo(eq(null));
    assertNull(presenter.concurrentUpdateSessionInfo);
}
Also used : PathPlaceRequest(org.uberfire.mvp.impl.PathPlaceRequest) PlaceRequest(org.uberfire.mvp.PlaceRequest) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Path(org.uberfire.backend.vfs.Path) GuidedDecisionTableEditorGraphModel(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) GuidedDecisionTableEditorContent(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent) Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) GuidedDecisionTableView(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView) GuidedDecisionTableEditorGraphContent(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphContent) GuidedDecisionTablePresenter(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTablePresenter) OverviewWidgetPresenter(org.kie.workbench.common.widgets.metadata.client.widget.OverviewWidgetPresenter) PathPlaceRequest(org.uberfire.mvp.impl.PathPlaceRequest) SaveInProgressEvent(org.uberfire.client.mvp.SaveInProgressEvent) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Test(org.junit.Test)

Example 3 with SaveInProgressEvent

use of org.uberfire.client.mvp.SaveInProgressEvent in project drools-wb by kiegroup.

the class GuidedDecisionTableGraphEditorPresenterTest method checkSaveDocumentGraphEntriesEmptyGraph.

@Test
public void checkSaveDocumentGraphEntriesEmptyGraph() {
    final ObservablePath dtGraphPath = mock(ObservablePath.class);
    final PathPlaceRequest dtGraphPlaceRequest = mock(PathPlaceRequest.class);
    final GuidedDecisionTableEditorGraphContent dtGraphContent = makeDecisionTableGraphContent();
    when(dtGraphPath.toURI()).thenReturn("dtGraphPath");
    when(dtGraphPath.getFileName()).thenReturn("filename");
    when(dtGraphService.loadContent(eq(dtGraphPath))).thenReturn(dtGraphContent);
    when(versionRecordManager.getCurrentPath()).thenReturn(dtGraphPath);
    when(modeller.getAvailableDecisionTables()).thenReturn(new HashSet<>());
    presenter.onStartup(dtGraphPath, dtGraphPlaceRequest);
    presenter.saveDocumentGraphEntries();
    verify(savePopUpPresenter, times(1)).show(any(Path.class), commitMessageCommandCaptor.capture());
    final ParameterizedCommand<String> commitMessageCommand = commitMessageCommandCaptor.getValue();
    assertNotNull(commitMessageCommand);
    commitMessageCommand.execute("message");
    verify(view, times(1)).showSaving();
    verify(saveInProgressEvent, never()).fire(any(SaveInProgressEvent.class));
    verify(dtGraphService, times(1)).save(eq(dtGraphPath), any(GuidedDecisionTableEditorGraphModel.class), any(Metadata.class), eq("message"));
    final ArgumentCaptor<NotificationEvent> notification = ArgumentCaptor.forClass(NotificationEvent.class);
    verify(notificationEvent, times(1)).fire(notification.capture());
    assertEquals(CommonConstants.INSTANCE.ItemSavedSuccessfully(), notification.getValue().getNotification());
    assertNull(presenter.concurrentUpdateSessionInfo);
}
Also used : ObservablePath(org.uberfire.backend.vfs.ObservablePath) Path(org.uberfire.backend.vfs.Path) GuidedDecisionTableEditorGraphContent(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphContent) GuidedDecisionTableEditorGraphModel(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel) PathPlaceRequest(org.uberfire.mvp.impl.PathPlaceRequest) SaveInProgressEvent(org.uberfire.client.mvp.SaveInProgressEvent) Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Test(org.junit.Test)

Aggregations

SaveInProgressEvent (org.uberfire.client.mvp.SaveInProgressEvent)3 GuidedDecisionTablePresenter (org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTablePresenter)2 GuidedDecisionTableEditorGraphContent (org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphContent)2 GuidedDecisionTableEditorGraphModel (org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel)2 Metadata (org.guvnor.common.services.shared.metadata.model.Metadata)2 Test (org.junit.Test)2 OverviewWidgetPresenter (org.kie.workbench.common.widgets.metadata.client.widget.OverviewWidgetPresenter)2 ObservablePath (org.uberfire.backend.vfs.ObservablePath)2 Path (org.uberfire.backend.vfs.Path)2 PathPlaceRequest (org.uberfire.mvp.impl.PathPlaceRequest)2 NotificationEvent (org.uberfire.workbench.events.NotificationEvent)2 HashSet (java.util.HashSet)1 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)1 GuidedDecisionTableView (org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView)1 GuidedDecisionTableEditorContent (org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent)1 PlaceRequest (org.uberfire.mvp.PlaceRequest)1