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 GuidedDecisionTableFactory method makeTableWithBRLFragmentActionCol.
public static GuidedDecisionTable52 makeTableWithBRLFragmentActionCol(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);
final BRLActionColumn brl = new BRLActionColumn();
final ActionInsertFact ifc1 = new ActionInsertFact();
ifc1.setFactType("Applicant");
ifc1.setBoundName("$a");
final ActionFieldValue afv1 = new ActionFieldValue();
afv1.setNature(FieldNatureType.TYPE_TEMPLATE);
afv1.setField("age");
afv1.setValue("f1");
ifc1.addFieldValue(afv1);
final ActionInsertFact ifc2 = new ActionInsertFact();
ifc2.setFactType("Mortgage");
ifc2.setBoundName("$m");
final ActionFieldValue afv2 = new ActionFieldValue();
afv2.setNature(FieldNatureType.TYPE_TEMPLATE);
afv2.setField("amount");
afv2.setValue("f2");
ifc2.addFieldValue(afv2);
final ActionSetField asf = new ActionSetField();
asf.setVariable("$a");
asf.addFieldValue(new ActionFieldValue("age", "33", DataType.TYPE_NUMERIC_INTEGER));
final ActionUpdateField auf = new ActionUpdateField();
asf.setVariable("$m");
asf.addFieldValue(new ActionFieldValue("amount", "10000", DataType.TYPE_NUMERIC_INTEGER));
brl.getDefinition().add(ifc1);
brl.getDefinition().add(ifc2);
brl.getChildColumns().add(new BRLActionVariableColumn("f1", DataType.TYPE_NUMERIC_INTEGER));
brl.getChildColumns().add(new BRLActionVariableColumn("f2", DataType.TYPE_NUMERIC_INTEGER));
brl.getDefinition().add(asf);
brl.getDefinition().add(auf);
dt.getConditions().add(brl);
dt.setData(DataUtilities.makeDataLists(new String[][] { new String[] { "1", "", "desc", "33", "" } }));
return dt;
}
Aggregations