Search in sources :

Example 81 with ActionInsertFact

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]);
}
Also used : ActionFieldList(org.drools.workbench.models.datamodel.rule.ActionFieldList) ModelField(org.kie.soup.project.datamodel.oracle.ModelField) ActionFieldValue(org.drools.workbench.models.datamodel.rule.ActionFieldValue) ActionInsertFact(org.drools.workbench.models.datamodel.rule.ActionInsertFact) Test(org.junit.Test)

Example 82 with ActionInsertFact

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;
}
Also used : BRLActionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn) ActionSetField(org.drools.workbench.models.datamodel.rule.ActionSetField) ActionUpdateField(org.drools.workbench.models.datamodel.rule.ActionUpdateField) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) ActionFieldValue(org.drools.workbench.models.datamodel.rule.ActionFieldValue) ActionInsertFact(org.drools.workbench.models.datamodel.rule.ActionInsertFact) BRLActionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn)

Aggregations

ActionInsertFact (org.drools.workbench.models.datamodel.rule.ActionInsertFact)82 Test (org.junit.Test)64 ActionFieldValue (org.drools.workbench.models.datamodel.rule.ActionFieldValue)50 RuleModel (org.drools.workbench.models.datamodel.rule.RuleModel)47 FactPattern (org.drools.workbench.models.datamodel.rule.FactPattern)43 CompositeFactPattern (org.drools.workbench.models.datamodel.rule.CompositeFactPattern)42 FromCollectCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern)39 FromAccumulateCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromAccumulateCompositeFactPattern)34 FromCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromCompositeFactPattern)34 SingleFieldConstraint (org.drools.workbench.models.datamodel.rule.SingleFieldConstraint)34 BaseSingleFieldConstraint (org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint)32 FromEntryPointFactPattern (org.drools.workbench.models.datamodel.rule.FromEntryPointFactPattern)24 IAction (org.drools.workbench.models.datamodel.rule.IAction)18 BRLActionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn)15 BRLActionVariableColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn)13 IPattern (org.drools.workbench.models.datamodel.rule.IPattern)12 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)12 ArrayList (java.util.ArrayList)11 CompositeFieldConstraint (org.drools.workbench.models.datamodel.rule.CompositeFieldConstraint)10 RuleAttribute (org.drools.workbench.models.datamodel.rule.RuleAttribute)10