Search in sources :

Example 11 with ActionInsertNodeImpl

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

the class GuidedDecisionTreeDRLPersistenceMarshallingTest method testSingleRule_ActionInsert.

@Test
public void testSingleRule_ActionInsert() throws Exception {
    final String expected = "rule \"test_0\"" + "when\n" + "  Person( )\n" + "then\n" + "  Person $var0 = new Person();\n" + "  $var0.setAge( 25 );\n" + "  insert( $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(false);
    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 12 with ActionInsertNodeImpl

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

ActionInsertNode (org.drools.workbench.models.guided.dtree.shared.model.nodes.ActionInsertNode)12 ActionInsertNodeImpl (org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.ActionInsertNodeImpl)12 TypeNode (org.drools.workbench.models.guided.dtree.shared.model.nodes.TypeNode)9 ActionFieldValueImpl (org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.ActionFieldValueImpl)9 GuidedDecisionTree (org.drools.workbench.models.guided.dtree.shared.model.GuidedDecisionTree)8 TypeNodeImpl (org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.TypeNodeImpl)8 Test (org.junit.Test)8 BigIntegerValue (org.drools.workbench.models.guided.dtree.shared.model.values.impl.BigIntegerValue)5 DateValue (org.drools.workbench.models.guided.dtree.shared.model.values.impl.DateValue)5 IntegerValue (org.drools.workbench.models.guided.dtree.shared.model.values.impl.IntegerValue)5 Calendar (java.util.Calendar)4 BigInteger (java.math.BigInteger)2 Date (java.util.Date)2 ActionRetractNode (org.drools.workbench.models.guided.dtree.shared.model.nodes.ActionRetractNode)2 ActionUpdateNode (org.drools.workbench.models.guided.dtree.shared.model.nodes.ActionUpdateNode)2 ActionRetractNodeImpl (org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.ActionRetractNodeImpl)2 ActionUpdateNodeImpl (org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.ActionUpdateNodeImpl)2 ArrayList (java.util.ArrayList)1 ActionInsertFact (org.drools.workbench.models.datamodel.rule.ActionInsertFact)1 ActionInsertLogicalFact (org.drools.workbench.models.datamodel.rule.ActionInsertLogicalFact)1