Search in sources :

Example 56 with ConstraintNode

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

the class GuidedDecisionTreeDRLPersistenceMarshallingTest method testValue_String.

@Test
public void testValue_String() throws Exception {
    final String expected = "rule \"test_0\"" + "when\n" + "  Person( stringField == \"Michael\" )\n" + "then\n" + "end";
    final GuidedDecisionTree model = new GuidedDecisionTree();
    model.setTreeName("test");
    final TypeNode type = new TypeNodeImpl("Person");
    final ConstraintNode c1 = new ConstraintNodeImpl("Person", "stringField", "==", new StringValue("Michael"));
    model.setRoot(type);
    type.addChild(c1);
    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) GuidedDecisionTree(org.drools.workbench.models.guided.dtree.shared.model.GuidedDecisionTree) TypeNode(org.drools.workbench.models.guided.dtree.shared.model.nodes.TypeNode) StringValue(org.drools.workbench.models.guided.dtree.shared.model.values.impl.StringValue) Test(org.junit.Test)

Example 57 with ConstraintNode

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

the class GuidedDecisionTreeDRLPersistenceMarshallingTest method testValue_Short.

@Test
public void testValue_Short() throws Exception {
    final String expected = "rule \"test_0\"" + "when\n" + "  Person( shortField == 1000 )\n" + "then\n" + "end";
    final GuidedDecisionTree model = new GuidedDecisionTree();
    model.setTreeName("test");
    final TypeNode type = new TypeNodeImpl("Person");
    final ConstraintNode c1 = new ConstraintNodeImpl("Person", "shortField", "==", new ShortValue(new Short("1000")));
    model.setRoot(type);
    type.addChild(c1);
    final String drl = GuidedDecisionTreeDRLPersistence.getInstance().marshal(model);
    assertEqualsIgnoreWhitespace(expected, drl);
}
Also used : ConstraintNodeImpl(org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.ConstraintNodeImpl) ShortValue(org.drools.workbench.models.guided.dtree.shared.model.values.impl.ShortValue) ConstraintNode(org.drools.workbench.models.guided.dtree.shared.model.nodes.ConstraintNode) TypeNodeImpl(org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.TypeNodeImpl) GuidedDecisionTree(org.drools.workbench.models.guided.dtree.shared.model.GuidedDecisionTree) TypeNode(org.drools.workbench.models.guided.dtree.shared.model.nodes.TypeNode) Test(org.junit.Test)

Example 58 with ConstraintNode

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

the class GuidedDecisionTreeDRLPersistenceMarshallingTest method testMultipleRules_2Rules.

@Test
public void testMultipleRules_2Rules() throws Exception {
    final String expected = "rule \"test_0\"" + "when\n" + "  Person( name == \"Michael\" )\n" + "then\n" + "end" + "rule \"test_1\"" + "when\n" + "  Person( age == 41 )\n" + "then\n" + "end";
    final GuidedDecisionTree model = new GuidedDecisionTree();
    model.setTreeName("test");
    final TypeNode type = new TypeNodeImpl("Person");
    final ConstraintNode c1 = new ConstraintNodeImpl("Person", "name", "==", new StringValue("Michael"));
    final ConstraintNode c2 = new ConstraintNodeImpl("Person", "age", "==", new IntegerValue(41));
    model.setRoot(type);
    type.addChild(c1);
    type.addChild(c2);
    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) IntegerValue(org.drools.workbench.models.guided.dtree.shared.model.values.impl.IntegerValue) BigIntegerValue(org.drools.workbench.models.guided.dtree.shared.model.values.impl.BigIntegerValue) GuidedDecisionTree(org.drools.workbench.models.guided.dtree.shared.model.GuidedDecisionTree) TypeNode(org.drools.workbench.models.guided.dtree.shared.model.nodes.TypeNode) StringValue(org.drools.workbench.models.guided.dtree.shared.model.values.impl.StringValue) Test(org.junit.Test)

Example 59 with ConstraintNode

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

the class GuidedDecisionTreeEditorPresenter method editModelNode.

public void editModelNode(final Node node, final Command callback) {
    if (node instanceof TypeNode) {
        final EditTypePopup popup = new EditTypePopup((TypeNode) node, new com.google.gwt.user.client.Command() {

            @Override
            public void execute() {
                callback.execute();
            }
        });
        popup.show();
    } else if (node instanceof ConstraintNode) {
        final EditConstraintPopup popup = new EditConstraintPopup((ConstraintNode) node, oracle, new com.google.gwt.user.client.Command() {

            @Override
            public void execute() {
                callback.execute();
            }
        });
        popup.show();
    } else if (node instanceof ActionInsertNode) {
        final EditActionInsertPopup popup = new EditActionInsertPopup((ActionInsertNode) node, oracle, new com.google.gwt.user.client.Command() {

            @Override
            public void execute() {
                callback.execute();
            }
        });
        popup.show();
    } else if (node instanceof ActionUpdateNode) {
        final EditActionUpdatePopup popup = new EditActionUpdatePopup((ActionUpdateNode) node, oracle, new com.google.gwt.user.client.Command() {

            @Override
            public void execute() {
                callback.execute();
            }
        });
        popup.show();
    } else if (node instanceof ActionRetractNode) {
        final EditActionRetractPopup popup = new EditActionRetractPopup((ActionRetractNode) node, new com.google.gwt.user.client.Command() {

            @Override
            public void execute() {
                callback.execute();
            }
        });
        popup.show();
    }
}
Also used : ActionInsertNode(org.drools.workbench.models.guided.dtree.shared.model.nodes.ActionInsertNode) EditActionUpdatePopup(org.drools.workbench.screens.guided.dtree.client.widget.popups.EditActionUpdatePopup) ActionRetractNode(org.drools.workbench.models.guided.dtree.shared.model.nodes.ActionRetractNode) EditTypePopup(org.drools.workbench.screens.guided.dtree.client.widget.popups.EditTypePopup) ConstraintNode(org.drools.workbench.models.guided.dtree.shared.model.nodes.ConstraintNode) Command(org.uberfire.mvp.Command) ActionUpdateNode(org.drools.workbench.models.guided.dtree.shared.model.nodes.ActionUpdateNode) TypeNode(org.drools.workbench.models.guided.dtree.shared.model.nodes.TypeNode) EditActionInsertPopup(org.drools.workbench.screens.guided.dtree.client.widget.popups.EditActionInsertPopup) EditConstraintPopup(org.drools.workbench.screens.guided.dtree.client.widget.popups.EditConstraintPopup) EditActionRetractPopup(org.drools.workbench.screens.guided.dtree.client.widget.popups.EditActionRetractPopup)

Example 60 with ConstraintNode

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

the class ConstraintNodeFactory method getShape.

/**
 * This returns a new Shape following a drag operation from the palette
 * @param helper
 * @return
 */
@Override
public WiresBaseShape getShape(final FactoryHelper helper) {
    final ConstraintFactoryHelper cnHelper = (ConstraintFactoryHelper) helper;
    final ConstraintNode node = cnHelper.getContext();
    // drag proxy. We need to create a new instance of the ConstraintNode for use in the Decision Tree Widget
    return new ConstraintShape(makeShape(), new ConstraintNodeImpl(node.getClassName(), node.getFieldName()), cnHelper.isReadOnly());
}
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) ConstraintShape(org.drools.workbench.screens.guided.dtree.client.widget.shapes.ConstraintShape)

Aggregations

ConstraintNode (org.drools.workbench.models.guided.dtree.shared.model.nodes.ConstraintNode)60 TypeNode (org.drools.workbench.models.guided.dtree.shared.model.nodes.TypeNode)58 ConstraintNodeImpl (org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.ConstraintNodeImpl)56 TypeNodeImpl (org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.TypeNodeImpl)53 GuidedDecisionTree (org.drools.workbench.models.guided.dtree.shared.model.GuidedDecisionTree)52 Test (org.junit.Test)52 StringValue (org.drools.workbench.models.guided.dtree.shared.model.values.impl.StringValue)20 BigIntegerValue (org.drools.workbench.models.guided.dtree.shared.model.values.impl.BigIntegerValue)17 IntegerValue (org.drools.workbench.models.guided.dtree.shared.model.values.impl.IntegerValue)15 BigInteger (java.math.BigInteger)9 ActionUpdateNode (org.drools.workbench.models.guided.dtree.shared.model.nodes.ActionUpdateNode)8 ActionRetractNode (org.drools.workbench.models.guided.dtree.shared.model.nodes.ActionRetractNode)6 ActionInsertNode (org.drools.workbench.models.guided.dtree.shared.model.nodes.ActionInsertNode)4 ActionFieldValueImpl (org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.ActionFieldValueImpl)4 ActionUpdateNodeImpl (org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.ActionUpdateNodeImpl)4 Node (org.drools.workbench.models.guided.dtree.shared.model.nodes.Node)3 BigDecimalValue (org.drools.workbench.models.guided.dtree.shared.model.values.impl.BigDecimalValue)3 BooleanValue (org.drools.workbench.models.guided.dtree.shared.model.values.impl.BooleanValue)3 ByteValue (org.drools.workbench.models.guided.dtree.shared.model.values.impl.ByteValue)3 DateValue (org.drools.workbench.models.guided.dtree.shared.model.values.impl.DateValue)3