Search in sources :

Example 16 with ActionFieldValueImpl

use of org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.ActionFieldValueImpl in project drools-wb by kiegroup.

the class EditActionUpdatePopup method onAddFieldValueButtonClick.

@UiHandler("addFieldValueButton")
void onAddFieldValueButtonClick(final ClickEvent event) {
    final ActionFieldValue afv = new ActionFieldValueImpl();
    final ActionFieldValueEditor afvEditor = new ActionFieldValueEditor(clone.getBoundNode().getClassName(), afv, clone.getFieldValues(), oracle, onDeleteCallback);
    containerFieldValues.add(afvEditor);
    clone.getFieldValues().add(afv);
}
Also used : ActionFieldValue(org.drools.workbench.models.guided.dtree.shared.model.nodes.ActionFieldValue) ActionFieldValueImpl(org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.ActionFieldValueImpl) UiHandler(com.google.gwt.uibinder.client.UiHandler)

Example 17 with ActionFieldValueImpl

use of org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.ActionFieldValueImpl in project drools by kiegroup.

the class GuidedDecisionTreeDRLPersistenceMarshallingTest method testSingleRule_ActionSetDateFieldValue.

@Test
public void testSingleRule_ActionSetDateFieldValue() throws Exception {
    final String expected = "rule \"test_0\"" + "when\n" + "  $p : Person()\n" + "then\n" + "  java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(\"dd-MMM-yyyy\");\n" + "  $p.setDateOfBirth( sdf.parse(\"15-Jul-1985\") );\n" + "end";
    final GuidedDecisionTree model = new GuidedDecisionTree();
    model.setTreeName("test");
    final TypeNode type = new TypeNodeImpl("Person");
    type.setBinding("$p");
    model.setRoot(type);
    final ActionUpdateNode action = new ActionUpdateNodeImpl(type);
    action.setModify(false);
    final Calendar dob = Calendar.getInstance();
    dob.set(Calendar.YEAR, 1985);
    dob.set(Calendar.MONTH, 6);
    dob.set(Calendar.DATE, 15);
    action.getFieldValues().add(new ActionFieldValueImpl("dateOfBirth", new DateValue(dob.getTime())));
    type.addChild(action);
    final String drl = GuidedDecisionTreeDRLPersistence.getInstance().marshal(model);
    assertEqualsIgnoreWhitespace(expected, drl);
}
Also used : TypeNodeImpl(org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.TypeNodeImpl) ActionUpdateNode(org.drools.workbench.models.guided.dtree.shared.model.nodes.ActionUpdateNode) DateValue(org.drools.workbench.models.guided.dtree.shared.model.values.impl.DateValue) Calendar(java.util.Calendar) ActionUpdateNodeImpl(org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.ActionUpdateNodeImpl) GuidedDecisionTree(org.drools.workbench.models.guided.dtree.shared.model.GuidedDecisionTree) TypeNode(org.drools.workbench.models.guided.dtree.shared.model.nodes.TypeNode) ActionFieldValueImpl(org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.ActionFieldValueImpl) Test(org.junit.Test)

Example 18 with ActionFieldValueImpl

use of org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.ActionFieldValueImpl in project drools by kiegroup.

the class GuidedDecisionTreeDRLPersistenceMarshallingTest method testSingleRule_ActionSetWithConstraint.

@Test
public void testSingleRule_ActionSetWithConstraint() throws Exception {
    final String expected = "rule \"test_0\"" + "when\n" + "  $p : Person( $n : name )\n" + "then\n" + "  $p.setAge( 25 );\n" + "end";
    final GuidedDecisionTree model = new GuidedDecisionTree();
    model.setTreeName("test");
    final TypeNode type = new TypeNodeImpl("Person");
    type.setBinding("$p");
    final ConstraintNode c1 = new ConstraintNodeImpl("Person", "name");
    c1.setBinding("$n");
    model.setRoot(type);
    type.addChild(c1);
    final ActionUpdateNode action = new ActionUpdateNodeImpl(type);
    action.setModify(false);
    action.getFieldValues().add(new ActionFieldValueImpl("age", new IntegerValue(25)));
    c1.addChild(action);
    final String drl = GuidedDecisionTreeDRLPersistence.getInstance().marshal(model);
    assertEqualsIgnoreWhitespace(expected, drl);
}
Also used : ConstraintNodeImpl(org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.ConstraintNodeImpl) ConstraintNode(org.drools.workbench.models.guided.dtree.shared.model.nodes.ConstraintNode) TypeNodeImpl(org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.TypeNodeImpl) ActionUpdateNode(org.drools.workbench.models.guided.dtree.shared.model.nodes.ActionUpdateNode) IntegerValue(org.drools.workbench.models.guided.dtree.shared.model.values.impl.IntegerValue) BigIntegerValue(org.drools.workbench.models.guided.dtree.shared.model.values.impl.BigIntegerValue) ActionUpdateNodeImpl(org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.ActionUpdateNodeImpl) GuidedDecisionTree(org.drools.workbench.models.guided.dtree.shared.model.GuidedDecisionTree) TypeNode(org.drools.workbench.models.guided.dtree.shared.model.nodes.TypeNode) ActionFieldValueImpl(org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.ActionFieldValueImpl) Test(org.junit.Test)

Example 19 with ActionFieldValueImpl

use of org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.ActionFieldValueImpl in project drools by kiegroup.

the class GuidedDecisionTreeDRLPersistenceMarshallingTest method testSingleRule_ActionInsertLogical.

@Test
public void testSingleRule_ActionInsertLogical() throws Exception {
    final String expected = "rule \"test_0\"" + "when\n" + "  Person( )\n" + "then\n" + "  Person $var0 = new Person();\n" + "  $var0.setAge( 25 );\n" + "  insertLogical( $var0 );\n" + "end";
    final GuidedDecisionTree model = new GuidedDecisionTree();
    model.setTreeName("test");
    final TypeNode type = new TypeNodeImpl("Person");
    model.setRoot(type);
    final ActionInsertNode action = new ActionInsertNodeImpl("Person");
    action.setLogicalInsertion(true);
    action.getFieldValues().add(new ActionFieldValueImpl("age", new IntegerValue(25)));
    type.addChild(action);
    final String drl = GuidedDecisionTreeDRLPersistence.getInstance().marshal(model);
    assertEqualsIgnoreWhitespace(expected, drl);
}
Also used : ActionInsertNode(org.drools.workbench.models.guided.dtree.shared.model.nodes.ActionInsertNode) TypeNodeImpl(org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.TypeNodeImpl) IntegerValue(org.drools.workbench.models.guided.dtree.shared.model.values.impl.IntegerValue) BigIntegerValue(org.drools.workbench.models.guided.dtree.shared.model.values.impl.BigIntegerValue) ActionInsertNodeImpl(org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.ActionInsertNodeImpl) GuidedDecisionTree(org.drools.workbench.models.guided.dtree.shared.model.GuidedDecisionTree) TypeNode(org.drools.workbench.models.guided.dtree.shared.model.nodes.TypeNode) ActionFieldValueImpl(org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.ActionFieldValueImpl) Test(org.junit.Test)

Example 20 with ActionFieldValueImpl

use of org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.ActionFieldValueImpl in project drools by kiegroup.

the class GuidedDecisionTreeDRLPersistenceMarshallingTest method testSingleRule_ActionModifyMultipleFields.

@Test
public void testSingleRule_ActionModifyMultipleFields() throws Exception {
    final String expected = "rule \"test_0\"" + "when\n" + "  $p : Person( )\n" + "then\n" + "  modify( $p ) {\n" + "    setAge( 25 ), \n" + "    setName( \"Michael\" )\n" + "  }\n" + "end";
    final GuidedDecisionTree model = new GuidedDecisionTree();
    model.setTreeName("test");
    final TypeNode type = new TypeNodeImpl("Person");
    type.setBinding("$p");
    model.setRoot(type);
    final ActionUpdateNode action = new ActionUpdateNodeImpl(type);
    action.setModify(true);
    action.getFieldValues().add(new ActionFieldValueImpl("age", new IntegerValue(25)));
    action.getFieldValues().add(new ActionFieldValueImpl("name", new StringValue("Michael")));
    type.addChild(action);
    final String drl = GuidedDecisionTreeDRLPersistence.getInstance().marshal(model);
    assertEqualsIgnoreWhitespace(expected, drl);
}
Also used : TypeNodeImpl(org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.TypeNodeImpl) ActionUpdateNode(org.drools.workbench.models.guided.dtree.shared.model.nodes.ActionUpdateNode) IntegerValue(org.drools.workbench.models.guided.dtree.shared.model.values.impl.IntegerValue) BigIntegerValue(org.drools.workbench.models.guided.dtree.shared.model.values.impl.BigIntegerValue) ActionUpdateNodeImpl(org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.ActionUpdateNodeImpl) GuidedDecisionTree(org.drools.workbench.models.guided.dtree.shared.model.GuidedDecisionTree) TypeNode(org.drools.workbench.models.guided.dtree.shared.model.nodes.TypeNode) ActionFieldValueImpl(org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.ActionFieldValueImpl) StringValue(org.drools.workbench.models.guided.dtree.shared.model.values.impl.StringValue) Test(org.junit.Test)

Aggregations

ActionFieldValueImpl (org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.ActionFieldValueImpl)32 TypeNode (org.drools.workbench.models.guided.dtree.shared.model.nodes.TypeNode)30 GuidedDecisionTree (org.drools.workbench.models.guided.dtree.shared.model.GuidedDecisionTree)29 TypeNodeImpl (org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.TypeNodeImpl)29 Test (org.junit.Test)29 ActionUpdateNode (org.drools.workbench.models.guided.dtree.shared.model.nodes.ActionUpdateNode)22 ActionUpdateNodeImpl (org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.ActionUpdateNodeImpl)22 BigIntegerValue (org.drools.workbench.models.guided.dtree.shared.model.values.impl.BigIntegerValue)21 IntegerValue (org.drools.workbench.models.guided.dtree.shared.model.values.impl.IntegerValue)21 BigInteger (java.math.BigInteger)10 ActionInsertNode (org.drools.workbench.models.guided.dtree.shared.model.nodes.ActionInsertNode)9 ActionInsertNodeImpl (org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.ActionInsertNodeImpl)9 DateValue (org.drools.workbench.models.guided.dtree.shared.model.values.impl.DateValue)9 Calendar (java.util.Calendar)8 ActionRetractNode (org.drools.workbench.models.guided.dtree.shared.model.nodes.ActionRetractNode)5 ConstraintNode (org.drools.workbench.models.guided.dtree.shared.model.nodes.ConstraintNode)5 ActionRetractNodeImpl (org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.ActionRetractNodeImpl)5 StringValue (org.drools.workbench.models.guided.dtree.shared.model.values.impl.StringValue)5 Date (java.util.Date)4 ConstraintNodeImpl (org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.ConstraintNodeImpl)4