Search in sources :

Example 36 with AsyncPackageDataModelOracle

use of org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle in project drools-wb by kiegroup.

the class BaseWidgetFactory method factory.

protected DTCellValueWidgetFactory factory() {
    final GuidedDecisionTable52 model = getPlugin().getPresenter().getModel();
    final AsyncPackageDataModelOracle oracle = getPlugin().getPresenter().getDataModelOracle();
    final boolean allowEmptyValues = model.getTableFormat() == GuidedDecisionTable52.TableFormat.EXTENDED_ENTRY;
    return DTCellValueWidgetFactory.getInstance(model, oracle, false, allowEmptyValues);
}
Also used : AsyncPackageDataModelOracle(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)

Example 37 with AsyncPackageDataModelOracle

use of org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle in project drools-wb by kiegroup.

the class BaseGuidedDecisionTablePresenterTest method makeDecisionTable.

protected GuidedDecisionTableView.Presenter makeDecisionTable(final Path originalPath, final ObservablePath path, final PlaceRequest placeRequest, final GuidedDecisionTableEditorContent content) {
    final GuidedDecisionTableView.Presenter dtPresenter = mock(GuidedDecisionTableView.Presenter.class);
    final AsyncPackageDataModelOracle oracle = mock(AsyncPackageDataModelOracle.class);
    final Overview overview = mock(Overview.class);
    final GuidedDecisionTablePresenter.Access access = new GuidedDecisionTablePresenter.Access();
    when(dtService.loadContent(eq(path))).thenReturn(content);
    when(modeller.addDecisionTable(eq(path), eq(placeRequest), eq(content), any(Boolean.class), any(Double.class), any(Double.class))).thenReturn(dtPresenter);
    when(path.getOriginal()).thenReturn(originalPath);
    when(dtPresenter.getLatestPath()).thenReturn(path);
    when(dtPresenter.getCurrentPath()).thenReturn(path);
    when(dtPresenter.getPlaceRequest()).thenReturn(placeRequest);
    when(dtPresenter.getModel()).thenReturn(content.getModel());
    when(dtPresenter.getDataModelOracle()).thenReturn(oracle);
    when(dtPresenter.getOverview()).thenReturn(overview);
    when(dtPresenter.getAccess()).thenReturn(access);
    when(dtPresenter.getView()).thenReturn(mock(GuidedDecisionTableView.class));
    when(overview.getMetadata()).thenReturn(mock(Metadata.class));
    return dtPresenter;
}
Also used : AsyncPackageDataModelOracle(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle) GuidedDecisionTablePresenter(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTablePresenter) Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) Overview(org.guvnor.common.services.shared.metadata.model.Overview) GuidedDecisionTableView(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView)

Example 38 with AsyncPackageDataModelOracle

use of org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle in project drools-wb by kiegroup.

the class BaseGuidedDecisionTableEditorPresenterTest method testActivateDocument.

@Test
public void testActivateDocument() {
    final GuidedDecisionTableView.Presenter dtPresenter = mock(GuidedDecisionTableView.Presenter.class);
    final Overview overview = mock(Overview.class);
    final AsyncPackageDataModelOracle oracle = mock(AsyncPackageDataModelOracle.class);
    final GuidedDecisionTable52 model = mock(GuidedDecisionTable52.class);
    final Imports imports = mock(Imports.class);
    final GuidedDecisionTablePresenter.Access access = mock(GuidedDecisionTablePresenter.Access.class);
    final MultiPageEditor pageEditor = mock(MultiPageEditor.class);
    final boolean isEditable = true;
    doReturn(overview).when(dtPresenter).getOverview();
    doReturn(oracle).when(dtPresenter).getDataModelOracle();
    doReturn(model).when(dtPresenter).getModel();
    doReturn(imports).when(model).getImports();
    doReturn(access).when(dtPresenter).getAccess();
    doReturn(isEditable).when(access).isEditable();
    doReturn(pageEditor).when(presenter).getKieEditorWrapperMultiPage();
    doNothing().when(presenter).activateDocument(any(), any(), any(), any(), anyBoolean());
    presenter.activateDocument(dtPresenter);
    verify(dtPresenter).activate();
    verify(presenter).enableMenus(true);
    verify(presenter).addColumnsTab();
    verify(presenter).enableColumnsTab(dtPresenter);
    verify(presenter).activateDocument(dtPresenter, overview, oracle, imports, !isEditable);
}
Also used : AsyncPackageDataModelOracle(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) GuidedDecisionTablePresenter(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTablePresenter) Overview(org.guvnor.common.services.shared.metadata.model.Overview) MultiPageEditor(org.uberfire.client.workbench.widgets.multipage.MultiPageEditor) Imports(org.kie.soup.project.datamodel.imports.Imports) GuidedDecisionTableView(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView) Test(org.junit.Test)

Example 39 with AsyncPackageDataModelOracle

use of org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle in project drools-wb by kiegroup.

the class GuidedDecisionTableGraphEditorPresenterTest method checkInitialiseKieEditorTabs.

@Test
public void checkInitialiseKieEditorTabs() {
    final ObservablePath dtGraphPath = mock(ObservablePath.class);
    final PlaceRequest dtGraphPlaceRequest = mock(PlaceRequest.class);
    final GuidedDecisionTableEditorGraphContent dtGraphContent = makeDecisionTableGraphContent(0);
    when(dtGraphPath.toURI()).thenReturn("dtGraphPath");
    when(dtGraphPath.getFileName()).thenReturn("filename");
    when(dtGraphService.loadContent(eq(dtGraphPath))).thenReturn(dtGraphContent);
    when(versionRecordManager.getCurrentPath()).thenReturn(dtGraphPath);
    when(versionRecordManager.getVersion()).thenReturn("version");
    presenter.onStartup(dtGraphPath, dtGraphPlaceRequest);
    verify(kieEditorWrapperView, times(1)).clear();
    final GuidedDecisionTableView.Presenter document = mock(GuidedDecisionTableView.Presenter.class);
    final AsyncPackageDataModelOracle dmo = mock(AsyncPackageDataModelOracle.class);
    final Imports imports = mock(Imports.class);
    final boolean isReadOnly = true;
    final ArgumentCaptor<com.google.gwt.user.client.Command> onFocusCommandCaptor = ArgumentCaptor.forClass(com.google.gwt.user.client.Command.class);
    presenter.initialiseKieEditorTabs(document, dtGraphContent.getOverview(), dmo, imports, isReadOnly);
    verify(kieEditorWrapperView, times(2)).clear();
    verify(kieEditorWrapperView, times(2)).addMainEditorPage(view);
    verify(kieEditorWrapperView, times(2)).addOverviewPage(eq(overviewWidget), onFocusCommandCaptor.capture());
    verify(overviewWidget, times(2)).setContent(eq(dtGraphContent.getOverview()), any(ObservablePath.class));
    verify(kieEditorWrapperView, times(1)).addSourcePage(any(ViewDRLSourceWidget.class));
    verify(kieEditorWrapperView, times(1)).addImportsTab(eq(importsWidget));
    verify(importsWidget, times(1)).setContent(eq(dmo), eq(imports), eq(isReadOnly));
    final com.google.gwt.user.client.Command onFocusCommand = onFocusCommandCaptor.getValue();
    assertNotNull(onFocusCommand);
    onFocusCommand.execute();
    verify(overviewWidget, times(1)).refresh(eq("version"));
}
Also used : PathPlaceRequest(org.uberfire.mvp.impl.PathPlaceRequest) PlaceRequest(org.uberfire.mvp.PlaceRequest) AsyncPackageDataModelOracle(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle) Imports(org.kie.soup.project.datamodel.imports.Imports) GuidedDecisionTableView(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView) GuidedDecisionTableEditorGraphContent(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphContent) ParameterizedCommand(org.uberfire.mvp.ParameterizedCommand) Command(org.uberfire.mvp.Command) ViewDRLSourceWidget(org.kie.workbench.common.widgets.client.source.ViewDRLSourceWidget) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Test(org.junit.Test)

Example 40 with AsyncPackageDataModelOracle

use of org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle in project drools-wb by kiegroup.

the class FieldPage method forEachFactField.

void forEachFactField(Consumer<String> consumer) {
    if (hasEditingPattern()) {
        final AsyncPackageDataModelOracle oracle = presenter.getDataModelOracle();
        oracle.getFieldCompletions(factType(), getAccessor(), fieldsCallback(consumer));
    }
}
Also used : AsyncPackageDataModelOracle(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle)

Aggregations

AsyncPackageDataModelOracle (org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle)62 Test (org.junit.Test)36 ModelField (org.kie.soup.project.datamodel.oracle.ModelField)36 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)31 PackageDataModelOracleBaselinePayload (org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload)29 Path (org.uberfire.backend.vfs.Path)29 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)26 RawMVELEvaluator (org.kie.soup.project.datamodel.commons.util.RawMVELEvaluator)26 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)25 ModuleDataModelOracle (org.kie.soup.project.datamodel.oracle.ModuleDataModelOracle)24 LimitedEntryConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52)19 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)15 List (java.util.List)12 ActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52)12 ActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52)12 PackageDataModelOracle (org.kie.soup.project.datamodel.oracle.PackageDataModelOracle)11 FactPattern (org.drools.workbench.models.datamodel.rule.FactPattern)10 ArrayList (java.util.ArrayList)9 LimitedEntryActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionInsertFactCol52)9 LimitedEntryActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionSetFieldCol52)9