Search in sources :

Example 26 with ActionUpdateNode

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

the class GuidedDecisionTreeDRLPersistenceMarshallingTest method testSingleRule_ActionSetZeroFields.

@Test
public void testSingleRule_ActionSetZeroFields() throws Exception {
    final String expected = "rule \"test_0\"" + "when\n" + "  $p : Person( )\n" + "then\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);
    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) 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) Test(org.junit.Test)

Example 27 with ActionUpdateNode

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

the class GuidedDecisionTreeDRLPersistenceMarshallingTest method testSingleRule_ActionSetActionRetract.

@Test
public void testSingleRule_ActionSetActionRetract() throws Exception {
    final String expected = "rule \"test_0\"" + "when\n" + "  $p : Person( )\n" + "then\n" + "  $p.setAge( 25 );\n" + "  retract( $p );\n" + "end";
    final GuidedDecisionTree model = new GuidedDecisionTree();
    model.setTreeName("test");
    final TypeNode type = new TypeNodeImpl("Person");
    type.setBinding("$p");
    model.setRoot(type);
    final ActionUpdateNode action1 = new ActionUpdateNodeImpl(type);
    action1.setModify(false);
    action1.getFieldValues().add(new ActionFieldValueImpl("age", new IntegerValue(25)));
    type.addChild(action1);
    final ActionRetractNode action2 = new ActionRetractNodeImpl(type);
    action1.addChild(action2);
    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) ActionRetractNode(org.drools.workbench.models.guided.dtree.shared.model.nodes.ActionRetractNode) ActionUpdateNodeImpl(org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.ActionUpdateNodeImpl) ActionRetractNodeImpl(org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.ActionRetractNodeImpl) 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 28 with ActionUpdateNode

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

the class GuidedDecisionTreeDRLPersistenceMarshallingTest method testSingleRule_ActionModify.

@Test
public void testSingleRule_ActionModify() throws Exception {
    final String expected = "rule \"test_0\"" + "when\n" + "  $p : Person( )\n" + "then\n" + "  modify( $p ) {\n" + "    setAge( 25 )\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)));
    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) Test(org.junit.Test)

Example 29 with ActionUpdateNode

use of org.drools.workbench.models.guided.dtree.shared.model.nodes.ActionUpdateNode 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 30 with ActionUpdateNode

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

the class GuidedDecisionTreePalette method setDataModelOracle.

public void setDataModelOracle(final AsyncPackageDataModelOracle oracle, final boolean isReadOnly) {
    this.oracle = PortablePreconditions.checkNotNull("oracle", oracle);
    clear();
    // Add types and constraints
    for (String className : oracle.getFactTypes()) {
        add(makePanelGroup(className, isReadOnly));
    }
    // Add actions
    final GuidedDecisionTreePaletteGroup paletteGroup = new GuidedDecisionTreePaletteGroup();
    if (oracle.getFactTypes().length > 0) {
        final String className = oracle.getFactTypes()[0];
        final ActionInsertNode an1 = new ActionInsertNodeImpl(className);
        paletteGroup.addStencil(actionInsertNodeFactory, stencilBuilder, new ActionInsertFactoryHelper(an1, isReadOnly), isReadOnly);
    }
    final ActionUpdateNode an2 = new ActionUpdateNodeImpl();
    paletteGroup.addStencil(actionUpdateNodeFactory, stencilBuilder, new ActionUpdateFactoryHelper(an2, isReadOnly), isReadOnly);
    final ActionRetractNode an3 = new ActionRetractNodeImpl();
    paletteGroup.addStencil(actionRetractNodeFactory, stencilBuilder, new ActionRetractFactoryHelper(an3, isReadOnly), isReadOnly);
    add(new PanelGroup() {

        {
            final PanelCollapse collapse = new PanelCollapse() {

                {
                    add(new PanelBody() {

                        {
                            add(paletteGroup);
                        }
                    });
                }
            };
            add(new PanelHeader() {

                {
                    setDataToggle(Toggle.COLLAPSE);
                    setDataParent(getId());
                    setDataTargetWidget(collapse);
                    add(new Heading(HeadingSize.H4) {

                        {
                            setText(GuidedDecisionTreeConstants.INSTANCE.actionsPaletteGroup());
                        }
                    });
                }
            });
            add(collapse);
        }
    });
}
Also used : ActionInsertNode(org.drools.workbench.models.guided.dtree.shared.model.nodes.ActionInsertNode) Heading(org.gwtbootstrap3.client.ui.Heading) ActionRetractFactoryHelper(org.drools.workbench.screens.guided.dtree.client.widget.factories.ActionRetractFactoryHelper) ActionUpdateFactoryHelper(org.drools.workbench.screens.guided.dtree.client.widget.factories.ActionUpdateFactoryHelper) ActionRetractNode(org.drools.workbench.models.guided.dtree.shared.model.nodes.ActionRetractNode) ActionInsertFactoryHelper(org.drools.workbench.screens.guided.dtree.client.widget.factories.ActionInsertFactoryHelper) ActionInsertNodeImpl(org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.ActionInsertNodeImpl) ActionRetractNodeImpl(org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.ActionRetractNodeImpl) PanelBody(org.gwtbootstrap3.client.ui.PanelBody) PanelHeader(org.gwtbootstrap3.client.ui.PanelHeader) ActionUpdateNode(org.drools.workbench.models.guided.dtree.shared.model.nodes.ActionUpdateNode) ActionUpdateNodeImpl(org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.ActionUpdateNodeImpl) PanelGroup(org.gwtbootstrap3.client.ui.PanelGroup) PanelCollapse(org.gwtbootstrap3.client.ui.PanelCollapse)

Aggregations

ActionUpdateNode (org.drools.workbench.models.guided.dtree.shared.model.nodes.ActionUpdateNode)31 TypeNode (org.drools.workbench.models.guided.dtree.shared.model.nodes.TypeNode)29 ActionUpdateNodeImpl (org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.ActionUpdateNodeImpl)28 GuidedDecisionTree (org.drools.workbench.models.guided.dtree.shared.model.GuidedDecisionTree)25 TypeNodeImpl (org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.TypeNodeImpl)25 Test (org.junit.Test)25 ActionFieldValueImpl (org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.ActionFieldValueImpl)22 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)17 ActionRetractNode (org.drools.workbench.models.guided.dtree.shared.model.nodes.ActionRetractNode)9 BigInteger (java.math.BigInteger)8 ConstraintNode (org.drools.workbench.models.guided.dtree.shared.model.nodes.ConstraintNode)8 ActionRetractNodeImpl (org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.ActionRetractNodeImpl)6 ActionInsertNode (org.drools.workbench.models.guided.dtree.shared.model.nodes.ActionInsertNode)5 DateValue (org.drools.workbench.models.guided.dtree.shared.model.values.impl.DateValue)5 StringValue (org.drools.workbench.models.guided.dtree.shared.model.values.impl.StringValue)5 Calendar (java.util.Calendar)4 ConstraintNodeImpl (org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.ConstraintNodeImpl)4 Node (org.drools.workbench.models.guided.dtree.shared.model.nodes.Node)3 Date (java.util.Date)2