use of org.drools.workbench.models.datamodel.workitems.PortableWorkDefinition 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.models.datamodel.workitems.PortableWorkDefinition in project drools-wb by kiegroup.
the class GuidedDecisionTableEditorServiceImplTest method checkConstructContent.
@Test
public void checkConstructContent() {
final Path path = mock(Path.class);
final Overview overview = mock(Overview.class);
final PackageDataModelOracle oracle = mock(PackageDataModelOracle.class);
when(oracle.getModuleCollectionTypes()).thenReturn(new HashMap<String, Boolean>() {
{
put("java.util.List", true);
put("java.util.Set", true);
put("java.util.Collection", true);
put("java.util.UnknownCollection", false);
}
});
final Set<PortableWorkDefinition> workItemDefinitions = new HashSet<>();
when(path.toURI()).thenReturn("default://project/src/main/resources/mypackage/dtable.gdst");
when(dataModelService.getDataModel(eq(path))).thenReturn(oracle);
when(workItemsService.loadWorkItemDefinitions(eq(path))).thenReturn(workItemDefinitions);
final GuidedDecisionTableEditorContent content = service.constructContent(path, overview);
verify(resourceOpenedEvent, times(1)).fire(any(ResourceOpenedEvent.class));
assertNotNull(content.getModel());
assertNotNull(content.getDataModel());
assertNotNull(content.getWorkItemDefinitions());
assertEquals(overview, content.getOverview());
assertEquals(3, content.getDataModel().getCollectionTypes().size());
assertTrue(content.getDataModel().getCollectionTypes().containsKey("java.util.Collection"));
assertTrue(content.getDataModel().getCollectionTypes().containsKey("java.util.List"));
assertTrue(content.getDataModel().getCollectionTypes().containsKey("java.util.Set"));
}
use of org.drools.workbench.models.datamodel.workitems.PortableWorkDefinition in project drools-wb by kiegroup.
the class ActionWorkItemSetFieldPlugin method setupWorkItems.
void setupWorkItems() {
actionWorkItems().forEach(actionCol52 -> {
final PortableWorkDefinition workItemDefinition = ((ActionWorkItemCol52) actionCol52).getWorkItemDefinition();
workItemDefinition.getResults().stream().filter(this::acceptParameterType).forEach(parameterDefinition -> {
final String key = trim((workItemDefinition.getName() + ":" + parameterDefinition.getName()));
workItems.put(key, new WorkItemParameter(workItemDefinition, parameterDefinition));
});
});
}
use of org.drools.workbench.models.datamodel.workitems.PortableWorkDefinition in project drools-wb by kiegroup.
the class AuditLogEntryCellHelperTest method getSafeHtml_ActionWorkItemExecute_Complex.
@Test
public void getSafeHtml_ActionWorkItemExecute_Complex() {
ActionWorkItemCol52 originalColumn = new ActionWorkItemCol52();
originalColumn.setHeader("action1");
originalColumn.setHideColumn(false);
ActionWorkItemCol52 newColumn = new ActionWorkItemCol52();
newColumn.setHeader("action2");
newColumn.setHideColumn(true);
PortableStringParameterDefinition param1 = new PortableStringParameterDefinition();
param1.setName("param1");
param1.setValue("value1");
PortableStringParameterDefinition param2 = new PortableStringParameterDefinition();
param2.setName("param2");
param2.setValue("value2");
PortableWorkDefinition def1 = new PortableWorkDefinition();
def1.setName("def1name");
def1.addParameter(param1);
def1.addParameter(param2);
PortableStringParameterDefinition param3 = new PortableStringParameterDefinition();
param3.setName("param3");
param3.setValue("value3");
PortableStringParameterDefinition param4 = new PortableStringParameterDefinition();
param4.setName("param1");
param4.setValue("value1");
PortableStringParameterDefinition param5 = new PortableStringParameterDefinition();
param5.setName("param5");
param5.setBinding("binding5");
PortableStringParameterDefinition param6 = new PortableStringParameterDefinition();
param6.setName("param2");
param6.setValue("value6");
PortableWorkDefinition def2 = new PortableWorkDefinition();
def2.setName("def2name");
def2.addParameter(param3);
def2.addParameter(param4);
def2.addParameter(param5);
def2.addParameter(param6);
originalColumn.setWorkItemDefinition(def1);
newColumn.setWorkItemDefinition(def2);
List<BaseColumnFieldDiff> diffs = originalColumn.diff(newColumn);
SafeHtml result = helper.getSafeHtml(new UpdateColumnAuditLogEntry("mock user", originalColumn, newColumn, diffs));
assertEquals(getActionHeaderRepre(newColumn.getHeader()) + getDiffRepre(diffs), result.asString());
}
use of org.drools.workbench.models.datamodel.workitems.PortableWorkDefinition in project drools-wb by kiegroup.
the class BaseGuidedDecisionTablePresenterTest method setupPresenter.
protected GuidedDecisionTablePresenter setupPresenter() {
final GuidedDecisionTablePresenter wrapped = new GuidedDecisionTablePresenter(identity, resourceType, ruleNameServiceCaller, decisionTableSelectedEvent, decisionTableColumnSelectedEvent, decisionTableSelectionsChangedEvent, refreshAttributesPanelEvent, refreshMetaDataPanelEvent, refreshConditionsPanelEvent, refreshActionsPanelEvent, refreshMenusEvent, notificationEvent, gridWidgetCellFactory, gridWidgetColumnFactory, oracleFactory, synchronizer, beanManager, lockManager, linkManager, clipboard, decisionTableAnalyzerProvider, enumLoaderUtilities, pluginHandler, authorizationManager, sessionInfo) {
@Override
void initialiseLockManager() {
// Do nothing for tests
}
@Override
GuidedDecisionTableRenderer makeViewRenderer() {
return renderer;
}
@Override
GuidedDecisionTableView makeView(final Set<PortableWorkDefinition> workItemDefinitions) {
return view;
}
@Override
void initialiseAuditLog() {
// Do nothing for tests
}
@Override
List<BaseColumnConverter> getConverters() {
final List<BaseColumnConverter> converters = new ArrayList<BaseColumnConverter>();
converters.add(new ActionInsertFactColumnConverter());
converters.add(new ActionRetractFactColumnConverter());
converters.add(new ActionSetFieldColumnConverter());
converters.add(new ActionWorkItemExecuteColumnConverter());
converters.add(new ActionWorkItemInsertFactColumnConverter());
converters.add(new ActionWorkItemSetFieldColumnConverter());
converters.add(new AttributeColumnConverter());
converters.add(new BRLActionVariableColumnConverter());
converters.add(new BRLConditionVariableColumnConverter());
converters.add(new ConditionColumnConverter());
converters.add(new DescriptionColumnConverter());
converters.add(new LimitedEntryColumnConverter());
converters.add(new MetaDataColumnConverter());
converters.add(new RowNumberColumnConverter());
return converters;
}
@Override
List<Synchronizer<? extends Synchronizer.MetaData, ? extends Synchronizer.MetaData, ? extends Synchronizer.MetaData, ? extends Synchronizer.MetaData, ? extends Synchronizer.MetaData>> getSynchronizers() {
final List<Synchronizer<? extends Synchronizer.MetaData, ? extends Synchronizer.MetaData, ? extends Synchronizer.MetaData, ? extends Synchronizer.MetaData, ? extends Synchronizer.MetaData>> synchronizers = new ArrayList<>();
synchronizers.add(new ActionColumnSynchronizer());
synchronizers.add(new ActionInsertFactColumnSynchronizer());
synchronizers.add(new ActionRetractFactColumnSynchronizer());
synchronizers.add(new ActionSetFieldColumnSynchronizer());
synchronizers.add(new ActionWorkItemExecuteColumnSynchronizer());
synchronizers.add(new ActionWorkItemInsertFactColumnSynchronizer());
synchronizers.add(new ActionWorkItemSetFieldColumnSynchronizer());
synchronizers.add(new AttributeColumnSynchronizer());
synchronizers.add(new BRLActionColumnSynchronizer());
synchronizers.add(new BRLConditionColumnSynchronizer());
synchronizers.add(new ConditionColumnSynchronizer());
synchronizers.add(new LimitedEntryBRLActionColumnSynchronizer());
synchronizers.add(new LimitedEntryBRLConditionColumnSynchronizer());
synchronizers.add(new MetaDataColumnSynchronizer());
synchronizers.add(new RowSynchronizer());
return synchronizers;
}
};
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, dtContent, modellerPresenter, false);
return presenter;
}
Aggregations