use of org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52 in project drools-wb by kiegroup.
the class ModelMetaDataEnhancerTest method conditionCol52Column.
@Test
public void conditionCol52Column() throws Exception {
final ArrayList<BaseColumn> columns = new ArrayList<>();
final ConditionCol52 conditionCol52 = new ConditionCol52();
final Pattern52 pattern52 = new Pattern52();
columns.add(conditionCol52);
when(model.getExpandedColumns()).thenReturn(columns);
when(model.getPattern(conditionCol52)).thenReturn(pattern52);
final Map<Integer, ModelMetaData> metaData = new ModelMetaDataEnhancer(model).getHeaderMetaData().getPatternsByColumnNumber();
assertEquals(1, metaData.size());
assertEquals(pattern52, metaData.get(0).getPattern());
assertEquals(PatternType.LHS, metaData.get(0).getPatternType());
}
use of org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52 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.ConditionCol52 in project drools-wb by kiegroup.
the class DefaultGuidedDecisionTableLinkManagerTest method fieldConstraintWithActionBRLFragmentFieldWithoutTemplateKey.
@Test
public void fieldConstraintWithActionBRLFragmentFieldWithoutTemplateKey() {
// Columns: Row#[0], Description[1], Action[2]
final GuidedDecisionTable52 dt1 = new GuidedDecisionTable52();
final BRLActionColumn brl = new BRLActionColumn();
final ActionInsertFact aif = new ActionInsertFact();
aif.setFactType("Fact");
aif.addFieldValue(new ActionFieldValue() {
{
setField("field");
setValue("10");
setNature(FieldNatureType.TYPE_LITERAL);
}
});
brl.setDefinition(new ArrayList<IAction>() {
{
add(aif);
}
});
brl.getChildColumns().add(new BRLActionVariableColumn("", DataType.TYPE_BOOLEAN));
dt1.getActionCols().add(brl);
// Columns: Row#[0], Description[1], Condition[2]
final GuidedDecisionTable52 dt2 = new GuidedDecisionTable52();
final Pattern52 p2 = new Pattern52();
p2.setBoundName("$f");
p2.setFactType("Fact");
final ConditionCol52 p2c1 = new ConditionCol52();
p2c1.setFactField("field");
p2.getChildColumns().add(p2c1);
dt2.getConditions().add(p2);
manager.link(dt1, dt2, (s, t) -> {
assertEquals(2, s);
assertEquals(2, t);
});
}
use of org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52 in project drools-wb by kiegroup.
the class DefaultGuidedDecisionTableLinkManagerTest method fieldConstraintLinksToActionUpdateField.
@Test
public void fieldConstraintLinksToActionUpdateField() {
// Columns: Row#[0], Description[1], Condition[2], Action[3]
final GuidedDecisionTable52 dt1 = new GuidedDecisionTable52();
final Pattern52 p1 = new Pattern52();
p1.setBoundName("$f");
p1.setFactType("Fact");
final ConditionCol52 p1c1 = new ConditionCol52();
p1c1.setFactField("field");
p1.getChildColumns().add(p1c1);
dt1.getConditions().add(p1);
final ActionSetFieldCol52 asf = new ActionSetFieldCol52();
asf.setBoundName("$f");
asf.setFactField("field");
dt1.getActionCols().add(asf);
// Columns: Row#[0], Description[1], Condition[2]
final GuidedDecisionTable52 dt2 = new GuidedDecisionTable52();
final Pattern52 p2 = new Pattern52();
p2.setBoundName("$f");
p2.setFactType("Fact");
final ConditionCol52 p2c1 = new ConditionCol52();
p2c1.setFactField("field");
p2.getChildColumns().add(p2c1);
dt2.getConditions().add(p2);
manager.link(dt1, dt2, (s, t) -> {
assertEquals(3, s);
assertEquals(2, t);
});
}
use of org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52 in project drools-wb by kiegroup.
the class GuidedDecisionTableFactory method makeTableWithConditionCol.
public static GuidedDecisionTable52 makeTableWithConditionCol(final String packageName, final Collection<Import> imports, final String tableName) {
final GuidedDecisionTable52 dt = new GuidedDecisionTable52();
dt.setPackageName(packageName);
dt.getImports().getImports().addAll(imports);
dt.setTableName(tableName);
Pattern52 p1 = new Pattern52();
p1.setBoundName("$a");
p1.setFactType("Applicant");
ConditionCol52 con1 = new ConditionCol52();
con1.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
con1.setFieldType(DataType.TYPE_NUMERIC_INTEGER);
con1.setFactField("age");
con1.setHeader("Applicant age");
con1.setOperator("==");
p1.getChildColumns().add(con1);
dt.getConditions().add(p1);
Pattern52 p2 = new Pattern52();
p2.setBoundName("$m");
p2.setFactType("Mortgage");
ConditionCol52 con2 = new ConditionCol52();
con2.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
con2.setFieldType(DataType.TYPE_NUMERIC_INTEGER);
con2.setFactField("amount");
con2.setHeader("Mortgage amount");
con2.setOperator("==");
p2.getChildColumns().add(con2);
dt.getConditions().add(p2);
dt.setData(DataUtilities.makeDataLists(new String[][] { new String[] { "1", "desc", "33", "" } }));
return dt;
}
Aggregations