use of org.drools.workbench.models.datamodel.rule.ActionInsertFact in project drools-wb by kiegroup.
the class RuleModellerWidgetFactory method getWidget.
public RuleModellerWidget getWidget(RuleModeller ruleModeller, EventBus eventBus, IAction action, Boolean readOnly) {
if (action instanceof ActionCallMethod) {
return new ActionCallMethodWidget(ruleModeller, eventBus, (ActionCallMethod) action, readOnly);
}
if (action instanceof ActionSetField) {
return new ActionSetFieldWidget(ruleModeller, eventBus, (ActionSetField) action, readOnly);
}
if (action instanceof ActionInsertFact) {
return new ActionInsertFactWidget(ruleModeller, eventBus, (ActionInsertFact) action, readOnly);
}
if (action instanceof ActionRetractFact) {
return new ActionRetractFactWidget(ruleModeller, eventBus, (ActionRetractFact) action, readOnly);
}
if (action instanceof DSLSentence) {
RuleModellerWidget w = new DSLSentenceWidget(ruleModeller, eventBus, (DSLSentence) action, readOnly);
return w;
}
if (action instanceof FreeFormLine) {
return new FreeFormLineWidget(ruleModeller, eventBus, (FreeFormLine) action, readOnly);
}
if (action instanceof ActionGlobalCollectionAdd) {
return new GlobalCollectionAddWidget(ruleModeller, eventBus, (ActionGlobalCollectionAdd) action, readOnly);
}
// All hardcoded action widgets have been checked, perform a plugin lookup
List<RuleModellerActionPlugin> matchingActionPlugins = actionPlugins.stream().filter(p -> p.accept(action)).collect(Collectors.toList());
if (matchingActionPlugins.size() > 1) {
throw new IllegalStateException("Ambigious " + RuleModellerActionPlugin.class.getName() + " implementations for action " + action);
}
if (matchingActionPlugins.size() == 1) {
RuleModellerActionPlugin actionPlugin = matchingActionPlugins.get(0);
RuleModellerWidget ruleModellerWidget = actionPlugin.createWidget(ruleModeller, eventBus, action, readOnly);
return ruleModellerWidget;
}
// NON-NLS
throw new RuntimeException("I don't know what type of action is: " + action);
}
use of org.drools.workbench.models.datamodel.rule.ActionInsertFact in project drools-wb by kiegroup.
the class ModelFieldUtilTest method filtering.
@Test
public void filtering() {
when(field1.getName()).thenReturn("field1");
when(field2.getName()).thenReturn("field2");
final ActionFieldList afl = new ActionInsertFact();
final ActionFieldValue afv = new ActionFieldValue();
afv.setField("field1");
afl.addFieldValue(afv);
final ModelField[] result = ModelFieldUtil.getAvailableFieldCompletions(new ModelField[] { field1, field2 }, afl);
assertEquals(1, result.length);
assertEquals(field2, result[0]);
}
use of org.drools.workbench.models.datamodel.rule.ActionInsertFact in project drools-wb by kiegroup.
the class ModelFieldUtilTest method emptyActionFieldList.
@Test
public void emptyActionFieldList() {
final ModelField[] result = ModelFieldUtil.getAvailableFieldCompletions(new ModelField[] { field1 }, new ActionInsertFact());
assertEquals(1, result.length);
assertEquals(field1, result[0]);
}
Aggregations