Search in sources :

Example 1 with GuidedDecisionTableEditorContent

use of org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent in project drools-wb by kiegroup.

the class GuidedDecisionTableEditorServiceImpl method constructContent.

@Override
protected GuidedDecisionTableEditorContent constructContent(Path path, Overview overview) {
    final GuidedDecisionTable52 model = load(path);
    final PackageDataModelOracle oracle = dataModelService.getDataModel(path);
    final PackageDataModelOracleBaselinePayload dataModel = new PackageDataModelOracleBaselinePayload();
    // Get FQCN's used by model
    final GuidedDecisionTableModelVisitor visitor = new GuidedDecisionTableModelVisitor(model);
    final Set<String> consumedFQCNs = visitor.getConsumedModelClasses();
    // Get FQCN's used by Globals
    consumedFQCNs.addAll(oracle.getPackageGlobals().values());
    // Get FQCN's of collections defined in project settings
    // they can be used in From Collect expressions
    consumedFQCNs.addAll(oracle.getModuleCollectionTypes().entrySet().stream().filter(entry -> entry.getValue()).map(entry -> entry.getKey()).collect(Collectors.toSet()));
    DataModelOracleUtilities.populateDataModel(oracle, dataModel, consumedFQCNs);
    final Set<PortableWorkDefinition> workItemDefinitions = workItemsService.loadWorkItemDefinitions(path);
    // Signal opening to interested parties
    resourceOpenedEvent.fire(new ResourceOpenedEvent(path, safeSessionInfo));
    return new GuidedDecisionTableEditorContent(model, workItemDefinitions, overview, dataModel);
}
Also used : PackageDataModelOracleBaselinePayload(org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload) GuidedDecisionTableEditorService(org.drools.workbench.screens.guided.dtable.service.GuidedDecisionTableEditorService) GuidedDecisionTableEditorContent(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent) ValidationMessage(org.guvnor.common.services.shared.validation.model.ValidationMessage) PackageDataModelOracle(org.kie.soup.project.datamodel.oracle.PackageDataModelOracle) Files(org.uberfire.java.nio.file.Files) Paths(org.uberfire.backend.server.util.Paths) PathFactory(org.uberfire.backend.vfs.PathFactory) ExceptionUtilities(org.guvnor.common.services.backend.exceptions.ExceptionUtilities) Overview(org.guvnor.common.services.shared.metadata.model.Overview) KieModuleService(org.kie.workbench.common.services.shared.project.KieModuleService) Service(org.jboss.errai.bus.server.annotations.Service) SafeSessionInfo(org.guvnor.common.services.backend.config.SafeSessionInfo) SessionInfo(org.uberfire.rpc.SessionInfo) FileExtensionFilter(org.guvnor.common.services.backend.file.FileExtensionFilter) PortableWorkDefinition(org.drools.workbench.models.datamodel.workitems.PortableWorkDefinition) RenameService(org.uberfire.ext.editor.commons.service.RenameService) DeleteService(org.uberfire.ext.editor.commons.service.DeleteService) GuidedDecisionTableEditorGraphModel(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel) SaveAndRenameServiceImpl(org.uberfire.ext.editor.commons.backend.service.SaveAndRenameServiceImpl) Set(java.util.Set) Collectors(java.util.stream.Collectors) ResourceOpenedEvent(org.uberfire.workbench.events.ResourceOpenedEvent) GenericValidator(org.guvnor.common.services.backend.validation.GenericValidator) List(java.util.List) VersionRecord(org.uberfire.java.nio.base.version.VersionRecord) PostConstruct(javax.annotation.PostConstruct) DirectoryStream(org.uberfire.java.nio.file.DirectoryStream) ApplicationScoped(javax.enterprise.context.ApplicationScoped) GuidedDTableGraphResourceTypeDefinition(org.drools.workbench.screens.guided.dtable.type.GuidedDTableGraphResourceTypeDefinition) CopyService(org.uberfire.ext.editor.commons.service.CopyService) WorkItemsEditorService(org.drools.workbench.screens.workitems.service.WorkItemsEditorService) Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) Package(org.guvnor.common.services.project.model.Package) HashSet(java.util.HashSet) Inject(javax.inject.Inject) CommentedOptionFactory(org.guvnor.common.services.backend.util.CommentedOptionFactory) Named(javax.inject.Named) KieService(org.kie.workbench.common.services.backend.service.KieService) Path(org.uberfire.backend.vfs.Path) Event(javax.enterprise.event.Event) DataModelService(org.kie.workbench.common.services.datamodel.backend.server.service.DataModelService) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) DataModelOracleUtilities(org.kie.workbench.common.services.datamodel.backend.server.DataModelOracleUtilities) GuidedDecisionTableGraphEditorService(org.drools.workbench.screens.guided.dtable.service.GuidedDecisionTableGraphEditorService) XLSConversionResult(org.drools.workbench.screens.guided.dtable.shared.XLSConversionResult) IOService(org.uberfire.io.IOService) FileAlreadyExistsException(org.uberfire.java.nio.file.FileAlreadyExistsException) GuidedDTXMLPersistence(org.drools.workbench.models.guided.dtable.backend.GuidedDTXMLPersistence) VersionRecordService(org.uberfire.ext.editor.commons.backend.version.VersionRecordService) DecisionTableGuidedToDecisionTableXLSConverter(org.drools.workbench.screens.guided.dtable.backend.server.conversion.DecisionTableGuidedToDecisionTableXLSConverter) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) PackageDataModelOracleBaselinePayload(org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload) PackageDataModelOracle(org.kie.soup.project.datamodel.oracle.PackageDataModelOracle) PortableWorkDefinition(org.drools.workbench.models.datamodel.workitems.PortableWorkDefinition) GuidedDecisionTableEditorContent(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent) ResourceOpenedEvent(org.uberfire.workbench.events.ResourceOpenedEvent)

Example 2 with GuidedDecisionTableEditorContent

use of org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent in project drools-wb by kiegroup.

the class BaseGuidedDecisionTablePresenterTest method setupPresenter.

protected GuidedDecisionTablePresenter setupPresenter() {
    final GuidedDecisionTablePresenter wrapped = makeGuidedDecisionTablePresenterMock();
    GuidedDecisionTablePresenter presenter = spy(wrapped);
    model = new GuidedDecisionTable52();
    final PackageDataModelOracleBaselinePayload dmoBaseline = mock(PackageDataModelOracleBaselinePayload.class);
    final Set<PortableWorkDefinition> workItemDefinitions = Collections.emptySet();
    final Overview overview = mock(Overview.class);
    dtContent = new GuidedDecisionTableEditorContent(model, workItemDefinitions, overview, dmoBaseline);
    when(oracleFactory.makeAsyncPackageDataModelOracle(any(Path.class), any(GuidedDecisionTable52.class), eq(dmoBaseline))).thenReturn(oracle);
    when(view.getLayer()).thenReturn(gridLayer);
    when(modellerPresenter.getView()).thenReturn(modellerView);
    when(modellerView.getGridLayerView()).thenReturn(gridLayer);
    when(presenter.getModellerPresenter()).thenReturn(modellerPresenter);
    presenter.setContent(dtPath, dtPlaceRequest, mock(AnalysisReportScreen.class), dtContent, modellerPresenter, false);
    return presenter;
}
Also used : ObservablePath(org.uberfire.backend.vfs.ObservablePath) Path(org.uberfire.backend.vfs.Path) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) PackageDataModelOracleBaselinePayload(org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload) PortableWorkDefinition(org.drools.workbench.models.datamodel.workitems.PortableWorkDefinition) GuidedDecisionTableEditorContent(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent) Overview(org.guvnor.common.services.shared.metadata.model.Overview) AnalysisReportScreen(org.kie.workbench.common.services.verifier.reporting.client.panel.AnalysisReportScreen)

Example 3 with GuidedDecisionTableEditorContent

use of org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent in project drools-wb by kiegroup.

the class GuidedDecisionTableModellerPresenterTest method makeDecisionTableContent.

private GuidedDecisionTableEditorContent makeDecisionTableContent() {
    final GuidedDecisionTable52 model = mock(GuidedDecisionTable52.class);
    final PackageDataModelOracleBaselinePayload dmoBaseline = mock(PackageDataModelOracleBaselinePayload.class);
    final Set<PortableWorkDefinition> workItemDefinitions = Collections.emptySet();
    final Overview overview = mock(Overview.class);
    final GuidedDecisionTableEditorContent dtContent = new GuidedDecisionTableEditorContent(model, workItemDefinitions, overview, dmoBaseline);
    return dtContent;
}
Also used : GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) PackageDataModelOracleBaselinePayload(org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload) PortableWorkDefinition(org.drools.workbench.models.datamodel.workitems.PortableWorkDefinition) GuidedDecisionTableEditorContent(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent) Overview(org.guvnor.common.services.shared.metadata.model.Overview)

Example 4 with GuidedDecisionTableEditorContent

use of org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent in project drools-wb by kiegroup.

the class GuidedDecisionTableModellerPresenterTest method refreshingDecisionTableRetainsExistingLocation.

@Test
public void refreshingDecisionTableRetainsExistingLocation() {
    final GuidedDecisionTableView.Presenter dtPresenter = makeDecisionTable();
    final GuidedDecisionTableEditorContent dtContent = makeDecisionTableContent();
    final GuidedDecisionTableView dtView = dtPresenter.getView();
    final ObservablePath path = mock(ObservablePath.class);
    final PlaceRequest placeRequest = mock(PlaceRequest.class);
    final Point2D dtLocation = new Point2D(100, 100);
    when(dtView.getLocation()).thenReturn(dtLocation);
    final ArgumentCaptor<Command> afterRemovalCommandCaptor = ArgumentCaptor.forClass(Command.class);
    presenter.refreshDecisionTable(dtPresenter, path, placeRequest, dtContent, false);
    verify(dtView, times(1)).getLocation();
    verify(view, times(1)).removeDecisionTable(eq(dtView), afterRemovalCommandCaptor.capture());
    final Command afterRemovalCommand = afterRemovalCommandCaptor.getValue();
    assertNotNull(afterRemovalCommand);
    afterRemovalCommand.execute();
    verify(dtView, times(1)).setLocation(eq(dtLocation));
}
Also used : PlaceRequest(org.uberfire.mvp.PlaceRequest) Point2D(com.ait.lienzo.client.core.types.Point2D) Command(com.google.gwt.user.client.Command) GuidedDecisionTableEditorContent(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Test(org.junit.Test)

Example 5 with GuidedDecisionTableEditorContent

use of org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent in project drools-wb by kiegroup.

the class GuidedDecisionTableGraphEditorPresenterTest method testGetContentSupplier.

@Test
public void testGetContentSupplier() {
    final GuidedDecisionTableView.Presenter presenter = mock(GuidedDecisionTableView.Presenter.class);
    final GuidedDecisionTable52 model = mock(GuidedDecisionTable52.class);
    final Overview overview = mock(Overview.class);
    final ObservablePath currentPath = mock(ObservablePath.class);
    final ObservablePath latestPath = mock(ObservablePath.class);
    doReturn(model).when(presenter).getModel();
    doReturn(overview).when(presenter).getOverview();
    doReturn(currentPath).when(presenter).getCurrentPath();
    doReturn(latestPath).when(presenter).getLatestPath();
    doReturn(asSet(presenter)).when(this.presenter).getAvailableDecisionTables();
    final List<GuidedDecisionTableEditorContent> content = this.presenter.getContentSupplier().get();
    final GuidedDecisionTableEditorContent firstContent = content.get(0);
    assertEquals(1, content.size());
    assertEquals(model, firstContent.getModel());
    assertEquals(overview, firstContent.getOverview());
    assertEquals(currentPath, firstContent.getCurrentPath());
    assertEquals(latestPath, firstContent.getLatestPath());
}
Also used : GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) GuidedDecisionTableEditorContent(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent) Overview(org.guvnor.common.services.shared.metadata.model.Overview) GuidedDecisionTableView(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Test(org.junit.Test)

Aggregations

GuidedDecisionTableEditorContent (org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent)38 ObservablePath (org.uberfire.backend.vfs.ObservablePath)30 PlaceRequest (org.uberfire.mvp.PlaceRequest)29 Test (org.junit.Test)28 GuidedDecisionTableView (org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView)27 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)13 GuidedDecisionTablePresenter (org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTablePresenter)12 DecisionTableSelectedEvent (org.drools.workbench.screens.guided.dtable.client.widget.table.events.cdi.DecisionTableSelectedEvent)10 Path (org.uberfire.backend.vfs.Path)8 PathPlaceRequest (org.uberfire.mvp.impl.PathPlaceRequest)8 OverviewWidgetPresenter (org.kie.workbench.common.widgets.metadata.client.widget.OverviewWidgetPresenter)7 GuidedDecisionTableEditorGraphContent (org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphContent)6 Overview (org.guvnor.common.services.shared.metadata.model.Overview)6 PortableWorkDefinition (org.drools.workbench.models.datamodel.workitems.PortableWorkDefinition)5 GuidedDecisionTableGraphEntry (org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel.GuidedDecisionTableGraphEntry)5 List (java.util.List)4 Metadata (org.guvnor.common.services.shared.metadata.model.Metadata)4 PackageDataModelOracleBaselinePayload (org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload)4 PlaceGainFocusEvent (org.uberfire.client.workbench.events.PlaceGainFocusEvent)4 ArrayList (java.util.ArrayList)3