use of org.drools.workbench.models.guided.dtable.shared.model.ActionCol52 in project drools by kiegroup.
the class GuidedDTDRLPersistenceTest method testRHSExecuteWorkItemWithBindings.
@Test
public void testRHSExecuteWorkItemWithBindings() {
GuidedDTDRLPersistence p = new GuidedDTDRLPersistence();
String[] row = new String[] { "1", "desc", "true" };
List<BaseColumn> allColumns = new ArrayList<BaseColumn>();
allColumns.add(new RowNumberCol52());
allColumns.add(new DescriptionCol52());
List<ActionCol52> cols = new ArrayList<ActionCol52>();
ActionWorkItemCol52 awi = new ActionWorkItemCol52();
PortableWorkDefinition pwd = new PortableWorkDefinition();
pwd.setName("work-item");
awi.setWorkItemDefinition(pwd);
PortableBooleanParameterDefinition p1 = new PortableBooleanParameterDefinition();
p1.setName("BooleanParameter");
p1.setValue(Boolean.TRUE);
p1.setBinding("$b");
pwd.addParameter(p1);
PortableFloatParameterDefinition p2 = new PortableFloatParameterDefinition();
p2.setName("FloatParameter");
p2.setValue(123.456f);
p2.setBinding("$f");
pwd.addParameter(p2);
PortableIntegerParameterDefinition p3 = new PortableIntegerParameterDefinition();
p3.setName("IntegerParameter");
p3.setValue(123);
p3.setBinding("$i");
pwd.addParameter(p3);
PortableStringParameterDefinition p4 = new PortableStringParameterDefinition();
p4.setName("StringParameter");
p4.setValue("hello");
p4.setBinding("$s");
pwd.addParameter(p4);
cols.add(awi);
RuleModel rm = new RuleModel();
allColumns.addAll(cols);
List<DTCellValue52> rowData = DataUtilities.makeDataRowList(row);
TemplateDataProvider rowDataProvider = new GuidedDTTemplateDataProvider(allColumns, rowData);
p.doActions(allColumns, cols, rowDataProvider, rowData, rm);
assertEquals(1, rm.rhs.length);
// Examine RuleModel action
ActionExecuteWorkItem aw = (ActionExecuteWorkItem) rm.rhs[0];
assertNotNull(aw);
PortableWorkDefinition mpwd = aw.getWorkDefinition();
assertNotNull(mpwd);
assertEquals(4, mpwd.getParameters().size());
PortableBooleanParameterDefinition mp1 = (PortableBooleanParameterDefinition) mpwd.getParameter("BooleanParameter");
assertNotNull(mp1);
assertEquals(Boolean.TRUE, mp1.getValue());
assertEquals("$b", mp1.getBinding());
PortableFloatParameterDefinition mp2 = (PortableFloatParameterDefinition) mpwd.getParameter("FloatParameter");
assertNotNull(mp2);
assertEquals(new Float(123.456f), mp2.getValue());
assertEquals("$f", mp2.getBinding());
PortableIntegerParameterDefinition mp3 = (PortableIntegerParameterDefinition) mpwd.getParameter("IntegerParameter");
assertNotNull(mp3);
assertEquals(new Integer(123), mp3.getValue());
assertEquals("$i", mp3.getBinding());
PortableStringParameterDefinition mp4 = (PortableStringParameterDefinition) mpwd.getParameter("StringParameter");
assertNotNull(mp4);
assertEquals("hello", mp4.getValue());
assertEquals("$s", mp4.getBinding());
}
use of org.drools.workbench.models.guided.dtable.shared.model.ActionCol52 in project drools-wb by kiegroup.
the class RuleBuilder method resolveColumns.
private void resolveColumns() throws BuildException {
int columnIndex = 0;
for (final BaseColumn baseColumn : model.getExpandedColumns()) {
if (baseColumn instanceof ConditionCol52) {
final Condition condition = builderFactory.getConditionBuilder().with((ConditionCol52) baseColumn).with(rule).with(row).with(columnIndex).build();
rule.getConditions().add(condition);
} else if (baseColumn instanceof ActionCol52) {
final Action action = builderFactory.getActionBuilder().with(rule).with((ActionCol52) baseColumn).with(row).with(columnIndex).build();
rule.getActions().add(action);
}
columnIndex++;
}
}
use of org.drools.workbench.models.guided.dtable.shared.model.ActionCol52 in project drools-wb by kiegroup.
the class GuidedDecisionTablePresenter method onDeleteSelectedColumns.
@Override
public void onDeleteSelectedColumns() {
if (isReadOnly()) {
return;
}
final Set<Integer> selectedColumnIndexes = getSelectedColumnIndexes();
final Set<BaseColumn> columnsToDelete = new HashSet<>();
for (int selectedColumnIndex : selectedColumnIndexes) {
final int columnIndex = findUiColumnIndex(selectedColumnIndex);
final BaseColumn column = model.getExpandedColumns().get(columnIndex);
if (!(column instanceof RowNumberCol52 || column instanceof DescriptionCol52)) {
columnsToDelete.add(column);
}
}
for (BaseColumn columnToDelete : columnsToDelete) {
if (columnToDelete instanceof AttributeCol52) {
try {
deleteColumn((AttributeCol52) columnToDelete);
} catch (VetoException veto) {
getModellerPresenter().getView().showGenericVetoMessage();
}
} else if (columnToDelete instanceof MetadataCol52) {
try {
deleteColumn((MetadataCol52) columnToDelete);
} catch (VetoException veto) {
getModellerPresenter().getView().showGenericVetoMessage();
}
} else if (columnToDelete instanceof ConditionCol52) {
try {
deleteColumn((ConditionCol52) columnToDelete);
} catch (VetoException veto) {
getModellerPresenter().getView().showUnableToDeleteColumnMessage((ConditionCol52) columnsToDelete);
}
} else if (columnToDelete instanceof ActionCol52) {
try {
deleteColumn((ActionCol52) columnToDelete);
} catch (VetoException veto) {
getModellerPresenter().getView().showUnableToDeleteColumnMessage((ActionCol52) columnsToDelete);
}
}
}
}
use of org.drools.workbench.models.guided.dtable.shared.model.ActionCol52 in project drools-wb by kiegroup.
the class GuidedDecisionTableModelVisitor method getConsumedModelClasses.
public Set<String> getConsumedModelClasses() {
final Set<String> factTypes = new HashSet<String>();
// Extract Fact Types from model
for (CompositeColumn<?> cc : model.getConditions()) {
if (cc instanceof BRLConditionColumn) {
final List<IPattern> definition = ((BRLConditionColumn) cc).getDefinition();
factTypes.addAll(getConditionFactTypesFromRuleModel(definition));
} else if (cc instanceof Pattern52) {
factTypes.add(((Pattern52) cc).getFactType());
}
}
for (ActionCol52 c : model.getActionCols()) {
if (c instanceof BRLActionColumn) {
final List<IAction> definition = ((BRLActionColumn) c).getDefinition();
factTypes.addAll(getActionFactTypesFromRuleModel(definition));
} else if (c instanceof ActionInsertFactCol52) {
factTypes.add(((ActionInsertFactCol52) c).getFactType());
}
}
// Convert Fact Types into Fully Qualified Class Names
final Set<String> fullyQualifiedClassNames = new HashSet<String>();
for (String factType : factTypes) {
fullyQualifiedClassNames.add(convertToFullyQualifiedClassName(factType));
}
return fullyQualifiedClassNames;
}
use of org.drools.workbench.models.guided.dtable.shared.model.ActionCol52 in project drools-wb by kiegroup.
the class GuidedDecisionTableTheme method getModelColumnType.
ModelColumnType getModelColumnType(final GridColumn<?> uiColumn) {
final int uiColumnIndex = uiModel.getColumns().indexOf(uiColumn);
final BaseColumn modelColumn = model.getExpandedColumns().get(uiColumnIndex);
if (modelColumn instanceof RowNumberCol52) {
return ModelColumnType.ROW_NUMBER;
} else if (modelColumn instanceof DescriptionCol52) {
return ModelColumnType.DESCRIPTION;
} else if (modelColumn instanceof MetadataCol52) {
return ModelColumnType.METADATA;
} else if (modelColumn instanceof AttributeCol52) {
return ModelColumnType.ATTRIBUTE;
} else if (modelColumn instanceof ConditionCol52) {
return ModelColumnType.CONDITION;
} else if (modelColumn instanceof ActionCol52) {
return ModelColumnType.ACTION;
}
// proof rendering than throw an exception.
return ModelColumnType.UNKNOWN;
}
Aggregations