Search in sources :

Example 6 with ActionFieldFunction

use of org.drools.workbench.models.datamodel.rule.ActionFieldFunction in project drools by kiegroup.

the class RuleModelDRLPersistenceTest method testRHSSetMethodCallsMethodJava.

@Test
public void testRHSSetMethodCallsMethodJava() {
    String oldValue = System.getProperty("drools.dateformat");
    try {
        System.setProperty("drools.dateformat", "dd-MMM-yyyy");
        RuleModel m = new RuleModel();
        m.name = "RHS SetMethodCallsMethod";
        m.addAttribute(new RuleAttribute("dialect", "java"));
        FactPattern p = new FactPattern("Person");
        p.setBoundName("$p");
        m.addLhsItem(p);
        ActionCallMethod acm = new ActionCallMethod();
        acm.setMethodName("method");
        acm.setVariable("$p");
        acm.addFieldValue(new ActionFieldFunction("f1", "String", DataType.TYPE_STRING));
        acm.addFieldValue(new ActionFieldFunction("f2", "true", DataType.TYPE_BOOLEAN));
        acm.addFieldValue(new ActionFieldFunction("f3", "31-Jan-2012", DataType.TYPE_DATE));
        acm.addFieldValue(new ActionFieldFunction("f4", "100", DataType.TYPE_NUMERIC_INTEGER));
        acm.addFieldValue(new ActionFieldFunction("f5", "100", DataType.TYPE_NUMERIC_BIGDECIMAL));
        m.addRhsItem(acm);
        String result = RuleModelDRLPersistenceImpl.getInstance().marshal(m);
        assertTrue(result.indexOf("java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(\"dd-MMM-yyyy\");") != -1);
        assertTrue(result.indexOf("$p.method( \"String\", true, sdf.parse(\"31-Jan-2012\"), 100, new java.math.BigDecimal(\"100\") );") != -1);
        checkMarshalling(null, m);
    } finally {
        if (oldValue == null) {
            System.clearProperty("drools.dateformat");
        } else {
            System.setProperty("drools.dateformat", oldValue);
        }
    }
}
Also used : RuleAttribute(org.drools.workbench.models.datamodel.rule.RuleAttribute) ActionCallMethod(org.drools.workbench.models.datamodel.rule.ActionCallMethod) FromEntryPointFactPattern(org.drools.workbench.models.datamodel.rule.FromEntryPointFactPattern) CompositeFactPattern(org.drools.workbench.models.datamodel.rule.CompositeFactPattern) FromCollectCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern) FactPattern(org.drools.workbench.models.datamodel.rule.FactPattern) FromAccumulateCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromAccumulateCompositeFactPattern) FromCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromCompositeFactPattern) ActionFieldFunction(org.drools.workbench.models.datamodel.rule.ActionFieldFunction) RuleModel(org.drools.workbench.models.datamodel.rule.RuleModel) Test(org.junit.Test)

Example 7 with ActionFieldFunction

use of org.drools.workbench.models.datamodel.rule.ActionFieldFunction in project drools-wb by kiegroup.

the class RuleModelCloneVisitor method visitActionCallMethod.

private ActionCallMethod visitActionCallMethod(ActionCallMethod acm) {
    ActionCallMethod clone = new ActionCallMethod();
    clone.setVariable(acm.getVariable());
    clone.setState(acm.getState());
    clone.setMethodName(acm.getMethodName());
    for (ActionFieldValue aff : acm.getFieldValues()) {
        clone.addFieldValue(cloneActionFieldFunction((ActionFieldFunction) aff));
    }
    return clone;
}
Also used : ActionFieldValue(org.drools.workbench.models.datamodel.rule.ActionFieldValue) ActionCallMethod(org.drools.workbench.models.datamodel.rule.ActionCallMethod) ActionFieldFunction(org.drools.workbench.models.datamodel.rule.ActionFieldFunction)

Example 8 with ActionFieldFunction

use of org.drools.workbench.models.datamodel.rule.ActionFieldFunction in project drools-wb by kiegroup.

the class RuleModelCloneVisitor method cloneActionFieldFunction.

private ActionFieldFunction cloneActionFieldFunction(ActionFieldFunction aff) {
    ActionFieldFunction clone = new ActionFieldFunction();
    clone.setField(aff.getField());
    clone.setNature(aff.getNature());
    clone.setType(aff.getType());
    clone.setValue(aff.getValue());
    clone.setMethod(aff.getMethod());
    return clone;
}
Also used : ActionFieldFunction(org.drools.workbench.models.datamodel.rule.ActionFieldFunction)

Example 9 with ActionFieldFunction

use of org.drools.workbench.models.datamodel.rule.ActionFieldFunction in project drools-wb by kiegroup.

the class ActionCallMethodWidget method doLayout.

private void doLayout() {
    layout.clear();
    layout.setWidget(0, 0, getSetterLabel());
    FlexTable inner = new FlexTable();
    for (int i = 0; i < model.getFieldValues().length; i++) {
        ActionFieldFunction val = model.getFieldValue(i);
        inner.setWidget(i, 0, typeLabel(val.getType()));
        inner.setWidget(i, 1, valueEditor(val));
    }
    layout.setWidget(0, 1, inner);
}
Also used : FlexTable(com.google.gwt.user.client.ui.FlexTable) ActionFieldFunction(org.drools.workbench.models.datamodel.rule.ActionFieldFunction) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint)

Aggregations

ActionFieldFunction (org.drools.workbench.models.datamodel.rule.ActionFieldFunction)9 ActionCallMethod (org.drools.workbench.models.datamodel.rule.ActionCallMethod)5 CompositeFactPattern (org.drools.workbench.models.datamodel.rule.CompositeFactPattern)3 FactPattern (org.drools.workbench.models.datamodel.rule.FactPattern)3 FromAccumulateCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromAccumulateCompositeFactPattern)3 FromCollectCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern)3 FromCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromCompositeFactPattern)3 RuleAttribute (org.drools.workbench.models.datamodel.rule.RuleAttribute)3 RuleModel (org.drools.workbench.models.datamodel.rule.RuleModel)3 SingleFieldConstraint (org.drools.workbench.models.datamodel.rule.SingleFieldConstraint)3 Test (org.junit.Test)3 FromEntryPointFactPattern (org.drools.workbench.models.datamodel.rule.FromEntryPointFactPattern)2 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)1 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)1 FlexTable (com.google.gwt.user.client.ui.FlexTable)1 List (java.util.List)1 ActionFieldValue (org.drools.workbench.models.datamodel.rule.ActionFieldValue)1 ActionGlobalCollectionAdd (org.drools.workbench.models.datamodel.rule.ActionGlobalCollectionAdd)1 ActionInsertFact (org.drools.workbench.models.datamodel.rule.ActionInsertFact)1 ActionRetractFact (org.drools.workbench.models.datamodel.rule.ActionRetractFact)1