Examples of GuidedDecisionTable


Examples of org.drools.ide.common.client.modeldriven.dt.GuidedDecisionTable


  }

  public void testUpdateModify() {
    GuidedDecisionTable dt = new GuidedDecisionTable();
    ConditionCol c = new ConditionCol();
    c.boundName = "x";
    c.factType = "Context";
    c.constraintValueType = ISingleFieldConstraint.TYPE_LITERAL;
    dt.conditionCols.add(c);
View Full Code Here

Examples of org.drools.ide.common.client.modeldriven.dt.GuidedDecisionTable

    GuidedDTXMLPersistence.getInstance();
  }

  public void testRoundTrip() {

    GuidedDecisionTable dt = new GuidedDecisionTable();

    dt.actionCols.add(new ActionInsertFactCol());
    ActionSetFieldCol set = new ActionSetFieldCol();
    set.factField = "foo";
    dt.actionCols.add(set);

    dt.getMetadataCols().add(new MetadataCol());

    dt.attributeCols.add(new AttributeCol());

    dt.conditionCols.add(new ConditionCol());

    dt.data = new String[][] {
        new String[] {"hola"}
    };
    dt.tableName = "blah";
    dt.descriptionWidth = 42;


    String xml = GuidedDTXMLPersistence.getInstance().marshal(dt);
    System.out.println(xml);
    assertNotNull(xml);
    assertEquals(-1, xml.indexOf("ActionSetField"));
    assertEquals(-1, xml.indexOf("ConditionCol"));
    assertEquals(-1, xml.indexOf("GuidedDecisionTable"));

    GuidedDecisionTable dt_ = GuidedDTXMLPersistence.getInstance().unmarshal(xml);
    assertNotNull(dt_);
    assertEquals(42, dt_.descriptionWidth);
    assertEquals("blah", dt_.tableName);
    assertEquals(1, dt_.getMetadataCols().size());
    assertEquals(1, dt_.attributeCols.size());
    assertEquals(2, dt_.actionCols.size());
    assertEquals(1, dt_.conditionCols.size());

  }
View Full Code Here

Examples of org.drools.ide.common.client.modeldriven.dt.GuidedDecisionTable

  }

  public void testBackwardsCompatability() throws Exception {
    String xml = BRLPersistenceTest.loadResource("ExistingDecisionTable.xml");
    GuidedDecisionTable dt_ = GuidedDTXMLPersistence.getInstance().unmarshal(xml);
    assertNotNull(dt_);
    assertEquals(42, dt_.descriptionWidth);
    assertEquals("blah", dt_.tableName);
    assertEquals(1, dt_.getMetadataCols().size());
    assertEquals(1, dt_.attributeCols.size());
    assertEquals(2, dt_.actionCols.size());
    assertEquals(1, dt_.conditionCols.size());

    assertTrue(dt_.actionCols.get(1) instanceof ActionSetFieldCol );
View Full Code Here

Examples of org.drools.ide.common.client.modeldriven.dt.GuidedDecisionTable

//
//
//
//  }
    public void testValueLists() {
        GuidedDecisionTable dt = new GuidedDecisionTable();

        //add cols for LHS
        ConditionCol c1 = new ConditionCol();
        c1.boundName = "c1";
        c1.factType = "Driver";
        c1.factField = "name";
        c1.constraintValueType = ISingleFieldConstraint.TYPE_LITERAL;
        dt.conditionCols.add(c1);

        ConditionCol c1_ = new ConditionCol();
        c1_.boundName = "c1";
        c1_.factType = "Driver";
        c1_.factField = "name";
        c1_.constraintValueType = ISingleFieldConstraint.TYPE_RET_VALUE;

        dt.conditionCols.add(c1_);

        ConditionCol c1__ = new ConditionCol();
        c1__.boundName = "c1";
        c1__.factType = "Driver";
        c1__.factField = "name";
        c1__.constraintValueType = ISingleFieldConstraint.TYPE_LITERAL;
        c1__.valueList = "one,two,three";
        dt.conditionCols.add(c1__);

        ConditionCol c2 = new ConditionCol();
        c2.boundName = "c2";
        c2.factType = "Driver";
        c2.factField = "nothing";
        c2.constraintValueType = ISingleFieldConstraint.TYPE_LITERAL;
        dt.conditionCols.add(c2);


        ActionSetFieldCol asf = new ActionSetFieldCol();
        asf.boundName = "c1";
        asf.factField = "name";
        dt.actionCols.add(asf);

        ActionInsertFactCol ins = new ActionInsertFactCol();
        ins.boundName = "x";
        ins.factField = "rating";
        ins.factType = "Person";
        dt.actionCols.add(ins);

        ActionInsertFactCol ins_ = new ActionInsertFactCol();
        ins_.boundName = "x";
        ins_.factField = "rating";
        ins_.factType = "Person";
        ins_.valueList = "one,two,three";
        dt.actionCols.add(ins_);

        ActionSetFieldCol asf_ = new ActionSetFieldCol();
        asf_.boundName = "c1";
        asf_.factField = "goo";
        dt.actionCols.add(asf_);

        ActionSetFieldCol asf__ = new ActionSetFieldCol();
        asf__.boundName = "c1";
        asf__.factField = "goo";
        asf__.valueList = "one,two,three";
        dt.actionCols.add(asf__);


        SuggestionCompletionEngine sce = new SuggestionCompletionEngine();
        sce.putDataEnumList("Driver.name", new String[]{"bob", "michael"});
        sce.putDataEnumList("Person.rating", new String[]{"1", "2"});




        String[] r = dt.getValueList(c1, sce);
        assertEquals(2, r.length);
        assertEquals("bob", r[0]);
        assertEquals("michael", r[1]);

        assertEquals(0, dt.getValueList(c1_, sce).length);

        r = dt.getValueList(c1__, sce);
        assertEquals(3, r.length);
        assertEquals("one", r[0]);
        assertEquals("two", r[1]);
        assertEquals("three", r[2]);

        assertEquals(0, dt.getValueList(c2, sce).length);

        r = dt.getValueList(asf, sce);
        assertEquals(2, r.length);
        assertEquals("bob", r[0]);
        assertEquals("michael", r[1]);

        r = dt.getValueList(ins, sce);
        assertEquals(2, r.length);
        assertEquals("1", r[0]);
        assertEquals("2", r[1]);

        r = dt.getValueList(ins_, sce);
        assertEquals(3, r.length);
        assertEquals("one", r[0]);
        assertEquals("two", r[1]);
        assertEquals("three", r[2]);

        assertEquals(0, dt.getValueList(asf_, sce).length);


        r = dt.getValueList(asf__, sce);
        assertEquals(3, r.length);
        assertEquals("one", r[0]);
        assertEquals("two", r[1]);
        assertEquals("three", r[2]);

        AttributeCol at = new AttributeCol();
        at.attr = "no-loop";
        dt.attributeCols.add(at);

        r = dt.getValueList(at, sce);
        assertEquals(2, r.length);
        assertEquals("true", r[0]);
        assertEquals("false", r[1]);

        at.attr = "enabled";
        assertEquals(2, dt.getValueList(at, sce).length);

        at.attr = "salience";
        assertEquals(0, dt.getValueList(at, sce).length);

    }
View Full Code Here

Examples of org.drools.ide.common.client.modeldriven.dt.GuidedDecisionTable

                            new ModelField("name", String.class.getName(), FIELD_CLASS_TYPE.REGULAR_CLASS, SuggestionCompletionEngine.TYPE_STRING)
                        });
            }
        });

        GuidedDecisionTable dt = new GuidedDecisionTable();

        AttributeCol at = new AttributeCol();
        at.attr = "salience";
        AttributeCol at_ = new AttributeCol();
        at_.attr = "enabled";

        dt.attributeCols.add(at);
        dt.attributeCols.add(at_);

        ConditionCol c1 = new ConditionCol();
        c1.boundName = "c1";
        c1.factType = "Driver";
        c1.factField = "name";
        c1.operator = "==";
        c1.constraintValueType = ISingleFieldConstraint.TYPE_LITERAL;
        dt.conditionCols.add(c1);

        ConditionCol c1_ = new ConditionCol();
        c1_.boundName = "c1";
        c1_.factType = "Driver";
        c1_.factField = "age";
        c1_.operator = "==";
        c1_.constraintValueType = ISingleFieldConstraint.TYPE_LITERAL;
        dt.conditionCols.add(c1_);

        ConditionCol c2 = new ConditionCol();
        c2.boundName = "c1";
        c2.factType = "Driver";
        c2.factField = "age";
        c2.constraintValueType = ISingleFieldConstraint.TYPE_LITERAL;
        dt.conditionCols.add(c2);

        ActionSetFieldCol a = new ActionSetFieldCol();
        a.boundName = "c1";
        a.factField = "name";
        dt.actionCols.add(a);

        ActionSetFieldCol a2 = new ActionSetFieldCol();
        a2.boundName = "c1";
        a2.factField = "age";
        dt.actionCols.add(a2);

        ActionInsertFactCol ins = new ActionInsertFactCol();
        ins.boundName = "x";
        ins.factType = "Driver";
        ins.factField = "name";
        dt.actionCols.add(ins);

        ActionInsertFactCol ins_ = new ActionInsertFactCol();
        ins_.boundName = "x";
        ins_.factType = "Driver";
        ins_.factField = "age";
        dt.actionCols.add(ins_);

        assertTrue(dt.isNumeric(at, sce));
        assertFalse(dt.isNumeric(at_, sce));
        assertFalse(dt.isNumeric(c1, sce));
        assertTrue(dt.isNumeric(c1_, sce));
        assertFalse(dt.isNumeric(a, sce));
        assertTrue(dt.isNumeric(a2, sce));
        assertFalse(dt.isNumeric(ins, sce));
        assertTrue(dt.isNumeric(ins_, sce));
        assertFalse(dt.isNumeric(c2, sce));



    }
View Full Code Here

Examples of org.drools.ide.common.client.modeldriven.dt.GuidedDecisionTable


    }

    public void testNoConstraintLists() {
        GuidedDecisionTable dt = new GuidedDecisionTable();

        //add cols for LHS
        ConditionCol c1 = new ConditionCol();
        c1.boundName = "c1";
        c1.factType = "Driver";
        c1.constraintValueType = ISingleFieldConstraint.TYPE_LITERAL;
        dt.conditionCols.add(c1);

        ConditionCol c2 = new ConditionCol();
        c2.boundName = "c2";
        c2.factType = "Driver";
        c2.constraintValueType = ISingleFieldConstraint.TYPE_LITERAL;
        c2.valueList = "a,b,c";
        dt.conditionCols.add(c2);


        SuggestionCompletionEngine sce = new SuggestionCompletionEngine();
        sce.putDataEnumList("Driver.name", new String[]{"bob", "michael"});

        assertEquals(0, dt.getValueList(c1, sce).length);
        assertEquals(3, dt.getValueList(c2, sce).length);


    }
View Full Code Here

Examples of org.drools.workbench.models.guided.dtable.shared.model.legacy.GuidedDecisionTable

        //Upgrade DTModel to new class
        Object model = xt.fromXML( xml );
        GuidedDecisionTable52 newDTModel;
        if ( model instanceof GuidedDecisionTable ) {
            GuidedDecisionTable legacyDTModel = (GuidedDecisionTable) model;
            newDTModel = upgrader1.upgrade( legacyDTModel );
        } else {
            newDTModel = (GuidedDecisionTable52) model;
        }
View Full Code Here

Examples of org.drools.workbench.models.guided.dtable.shared.model.legacy.GuidedDecisionTable

        //Upgrade DTModel to new class
        Object model = xt.fromXML( xml );
        GuidedDecisionTable52 newDTModel;
        if ( model instanceof GuidedDecisionTable ) {
            GuidedDecisionTable legacyDTModel = (GuidedDecisionTable) model;
            newDTModel = upgrader1.upgrade( legacyDTModel );
        } else {
            newDTModel = (GuidedDecisionTable52) model;
        }
View Full Code Here

Examples of org.drools.workbench.models.guided.dtable.shared.model.legacy.GuidedDecisionTable

    private GuidedDecisionTableUpgradeHelper1 upgrader = new GuidedDecisionTableUpgradeHelper1();

    @Test
    public void testConversion() {

        GuidedDecisionTable dt = new GuidedDecisionTable();
        dt.tableName = "michael";

        MetadataCol md = new MetadataCol();
        md.attr = "legacy";
        md.defaultValue = "yes";
View Full Code Here

Examples of org.drools.workbench.models.guided.dtable.shared.model.legacy.GuidedDecisionTable

    }

    @Test
    public void testConversionPatternGrouping() {

        GuidedDecisionTable dt = new GuidedDecisionTable();
        dt.tableName = "michael";

        MetadataCol md = new MetadataCol();
        md.attr = "legacy";
        md.defaultValue = "yes";
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.