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);
}
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;
}
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;
}
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));
}
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());
}
Aggregations