Examples of GuidedDecisionTable


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

  }

    @Test
    public void testBackwardsCompatability() throws Exception {
    String xml = BRLPersistenceTest.loadResource("ExistingDecisionTable.xml");
    GuidedDecisionTable dt_ = GuidedDTXMLPersistence.getInstance().unmarshal(xml);
    assertNotNull(dt_);
    assertEquals("blah", dt_.getTableName());
    assertEquals(1, dt_.getMetadataCols().size());
    assertEquals(1, dt_.getAttributeCols().size());
    assertEquals(2, dt_.getActionCols().size());
    assertEquals(1, dt_.getConditionCols().size());

    assertTrue(dt_.getActionCols().get(1) instanceof ActionSetFieldCol );
    ActionSetFieldCol asf = (ActionSetFieldCol) dt_.getActionCols().get(1);
    assertEquals("foo", asf.getFactField());
    assertEquals(false, asf.isUpdate());
  }
View Full Code Here

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

public class GuidedDTDRLPersistenceTest {

    @Test
    public void test2Rules() throws Exception {
        GuidedDecisionTable dt = new GuidedDecisionTable();
        dt.setTableName( "michael" );

        AttributeCol attr = new AttributeCol();
        attr.setAttribute( "salience" );
        attr.setDefaultValue( "66" );
        dt.getAttributeCols().add( attr );

        ConditionCol con = new ConditionCol();
        con.setBoundName( "f1" );
        con.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
        con.setFactField( "age" );
        con.setFactType( "Driver" );
        con.setHeader( "Driver f1 age" );
        con.setOperator( "==" );
        dt.getConditionCols().add( con );

        ConditionCol con2 = new ConditionCol();
        con2.setBoundName( "f1" );
        con2.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
        con2.setFactField( "name" );
        con2.setFactType( "Driver" );
        con2.setHeader( "Driver f1 name" );
        con2.setOperator( "==" );
        dt.getConditionCols().add( con2 );

        ConditionCol con3 = new ConditionCol();
        con3.setBoundName( "f1" );
        con3.setConstraintValueType( BaseSingleFieldConstraint.TYPE_RET_VALUE );
        con3.setFactField( "rating" );
        con3.setFactType( "Driver" );
        con3.setHeader( "Driver rating" );
        con3.setOperator( "==" );
        dt.getConditionCols().add( con3 );

        ConditionCol con4 = new ConditionCol();
        con4.setBoundName( "f2" );
        con4.setConstraintValueType( BaseSingleFieldConstraint.TYPE_PREDICATE );
        con4.setFactType( "Driver" );
        con4.setHeader( "Driver 2 pimp" );
        con4.setFactField( "(not needed)" );
        dt.getConditionCols().add( con4 );

        ActionInsertFactCol ins = new ActionInsertFactCol();
        ins.setBoundName( "ins" );
        ins.setFactType( "Cheese" );
        ins.setFactField( "price" );
        ins.setType( SuggestionCompletionEngine.TYPE_NUMERIC );
        dt.getActionCols().add( ins );

        ActionRetractFactCol ret = new ActionRetractFactCol();
        ret.setBoundName( "f2" );
        dt.getActionCols().add( ret );

        ActionSetFieldCol set = new ActionSetFieldCol();
        set.setBoundName( "f1" );
        set.setFactField( "goo1" );
        set.setType( SuggestionCompletionEngine.TYPE_STRING );
        dt.getActionCols().add( set );

        ActionSetFieldCol set2 = new ActionSetFieldCol();
        set2.setBoundName( "f1" );
        set2.setFactField( "goo2" );
        set2.setDefaultValue( "whee" );
        set2.setType( SuggestionCompletionEngine.TYPE_STRING );
        dt.getActionCols().add( set2 );

        dt.setData( new String[][]{
                new String[]{"1", "desc", "42", "33", "michael", "age * 0.2", "age > 7", "6.60", "true", "gooVal1", null},
                new String[]{"2", "desc", "", "39", "bob", "age * 0.3", "age > 7", "6.60", "", "gooVal1", ""}
        } );

        GuidedDTDRLPersistence p = GuidedDTDRLPersistence.getInstance();
View Full Code Here

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

    }

    @Test
    public void testInterpolate() {
        GuidedDecisionTable dt = new GuidedDecisionTable();
        dt.setTableName( "michael" );

        AttributeCol attr = new AttributeCol();
        attr.setAttribute( "salience" );
        attr.setDefaultValue( "66" );
        dt.getAttributeCols().add( attr );

        ConditionCol con = new ConditionCol();
        con.setBoundName( "f1" );
        con.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
        con.setFactField( "age" );
        con.setFactType( "Driver" );
        con.setHeader( "Driver f1 age" );
        con.setOperator( "==" );
        dt.getConditionCols().add( con );

        ConditionCol con2 = new ConditionCol();
        con2.setBoundName( "f1" );
        con2.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
        con2.setFactField( "name" );
        con2.setFactType( "Driver" );
        con2.setHeader( "Driver f1 name" );
        con2.setOperator( "==" );
        dt.getConditionCols().add( con2 );

        ConditionCol con3 = new ConditionCol();
        con3.setBoundName( "f1" );
        con3.setConstraintValueType( BaseSingleFieldConstraint.TYPE_RET_VALUE );
        con3.setFactField( "rating" );
        con3.setFactType( "Driver" );
        con3.setHeader( "Driver rating" );
        con3.setOperator( "==" );
        dt.getConditionCols().add( con3 );

        ConditionCol con4 = new ConditionCol();
        con4.setBoundName( "f2" );
        con4.setConstraintValueType( BaseSingleFieldConstraint.TYPE_PREDICATE );
        con4.setFactType( "Driver" );
        con4.setHeader( "Driver 2 pimp" );
        con4.setFactField( "this.hasSomething($param)" );
        dt.getConditionCols().add( con4 );

        ActionInsertFactCol ins = new ActionInsertFactCol();
        ins.setBoundName( "ins" );
        ins.setFactType( "Cheese" );
        ins.setFactField( "price" );
        ins.setType( SuggestionCompletionEngine.TYPE_NUMERIC );
        dt.getActionCols().add( ins );

        ActionRetractFactCol ret = new ActionRetractFactCol();
        ret.setBoundName( "f2" );
        dt.getActionCols().add( ret );

        ActionSetFieldCol set = new ActionSetFieldCol();
        set.setBoundName( "f1" );
        set.setFactField( "goo1" );
        set.setType( SuggestionCompletionEngine.TYPE_STRING );
        dt.getActionCols().add( set );

        ActionSetFieldCol set2 = new ActionSetFieldCol();
        set2.setBoundName( "f1" );
        set2.setFactField( "goo2" );
        set2.setDefaultValue( "whee" );
        set2.setType( SuggestionCompletionEngine.TYPE_STRING );
        dt.getActionCols().add( set2 );

        dt.setData( new String[][]{
                new String[]{"1", "desc", "42", "33", "michael", "age * 0.2", "BAM", "6.60", "true", "gooVal1", null},
                new String[]{"2", "desc", "", "39", "bob", "age * 0.3", "BAM", "6.60", "", "gooVal1", ""}
        } );

        GuidedDTDRLPersistence p = GuidedDTDRLPersistence.getInstance();
View Full Code Here

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

    }

    @Test
    public void testInOperator() {
        GuidedDecisionTable dt = new GuidedDecisionTable();
        dt.setTableName( "michael" );

        AttributeCol attr = new AttributeCol();
        attr.setAttribute( "salience" );
        attr.setDefaultValue( "66" );
        dt.getAttributeCols().add( attr );

        ConditionCol con = new ConditionCol();
        con.setBoundName( "f1" );
        con.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
        con.setFactField( "age" );
        con.setFactType( "Driver" );
        con.setHeader( "Driver f1 age" );
        con.setOperator( "==" );
        dt.getConditionCols().add( con );

        ConditionCol con2 = new ConditionCol();
        con2.setBoundName( "f1" );
        con2.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
        con2.setFactField( "name" );
        con2.setFactType( "Driver" );
        con2.setHeader( "Driver f1 name" );
        con2.setOperator( "in" );
        dt.getConditionCols().add( con2 );

        ConditionCol con3 = new ConditionCol();
        con3.setBoundName( "f1" );
        con3.setConstraintValueType( BaseSingleFieldConstraint.TYPE_RET_VALUE );
        con3.setFactField( "rating" );
        con3.setFactType( "Driver" );
        con3.setHeader( "Driver rating" );
        con3.setOperator( "==" );
        dt.getConditionCols().add( con3 );

        ConditionCol con4 = new ConditionCol();
        con4.setBoundName( "f2" );
        con4.setConstraintValueType( BaseSingleFieldConstraint.TYPE_PREDICATE );
        con4.setFactType( "Driver" );
        con4.setHeader( "Driver 2 pimp" );
        con4.setFactField( "(not needed)" );
        dt.getConditionCols().add( con4 );

        ActionInsertFactCol ins = new ActionInsertFactCol();
        ins.setBoundName( "ins" );
        ins.setFactType( "Cheese" );
        ins.setFactField( "price" );
        ins.setType( SuggestionCompletionEngine.TYPE_NUMERIC );
        dt.getActionCols().add( ins );

        ActionRetractFactCol ret = new ActionRetractFactCol();
        ret.setBoundName( "f2" );
        dt.getActionCols().add( ret );

        ActionSetFieldCol set = new ActionSetFieldCol();
        set.setBoundName( "f1" );
        set.setFactField( "goo1" );
        set.setType( SuggestionCompletionEngine.TYPE_STRING );
        dt.getActionCols().add( set );

        ActionSetFieldCol set2 = new ActionSetFieldCol();
        set2.setBoundName( "f1" );
        set2.setFactField( "goo2" );
        set2.setDefaultValue( "whee" );
        set2.setType( SuggestionCompletionEngine.TYPE_STRING );
        dt.getActionCols().add( set2 );

        dt.setData( new String[][]{
                new String[]{"1", "desc", "42", "33", "michael, manik", "age * 0.2", "age > 7", "6.60", "true", "gooVal1", null},
                new String[]{"2", "desc", "", "39", "bob, frank", "age * 0.3", "age > 7", "6.60", "", "gooVal1", ""}
        } );

        GuidedDTDRLPersistence p = GuidedDTDRLPersistence.getInstance();
View Full Code Here

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

    }

    @Test
    public void testNoConstraints() {
        GuidedDecisionTable dt = new GuidedDecisionTable();
        ConditionCol c = new ConditionCol();
        c.setBoundName( "x" );
        c.setFactType( "Context" );
        c.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
        dt.getConditionCols().add( c );
        ActionSetFieldCol asf = new ActionSetFieldCol();
        asf.setBoundName( "x" );
        asf.setFactField( "age" );
        asf.setType( "String" );

        dt.getActionCols().add( asf );

        String[][] data = new String[][]{
                new String[]{"1", "desc", "y", "old"}
        };
        dt.setData( data );

        String drl = GuidedDTDRLPersistence.getInstance().marshal( dt );

        // System.err.println(drl);

        assertTrue( drl.indexOf( "Context( )" ) > -1 );
        assertTrue( drl.indexOf( "x.setAge" ) > drl.indexOf( "Context( )" ) );
        assertFalse( drl.indexOf( "update( x );" ) > -1 );

        dt.setData( new String[][]{
                new String[]{"1", "desc", "", "old"}
            } );
        drl = GuidedDTDRLPersistence.getInstance().marshal( dt );
        assertEquals( -1,
                      drl.indexOf( "Context( )" ) );
View Full Code Here

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

    }

    @Test
    public void testUpdateModify() {
        GuidedDecisionTable dt = new GuidedDecisionTable();
        ConditionCol c = new ConditionCol();
        c.setBoundName( "x" );
        c.setFactType( "Context" );
        c.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
        dt.getConditionCols().add( c );
        ActionSetFieldCol asf = new ActionSetFieldCol();
        asf.setBoundName( "x" );
        asf.setFactField( "age" );
        asf.setType( "String" );
        asf.setUpdate( true );

        dt.getActionCols().add( asf );

        String[][] data = new String[][]{
                new String[]{"1", "desc", "y", "old"}
        };
        dt.setData( data );

        String drl = GuidedDTDRLPersistence.getInstance().marshal( dt );

        System.err.println( drl );

        assertTrue( drl.indexOf( "Context( )" ) > -1 );
        assertTrue( drl.indexOf( "x.setAge" ) > drl.indexOf( "Context( )" ) );

        dt.setData( new String[][]{
                new String[]{"1", "desc", "", "old"}
            } );
        drl = GuidedDTDRLPersistence.getInstance().marshal( dt );
        assertEquals( -1,
                      drl.indexOf( "Context( )" ) );
View Full Code Here

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

public class GuidedDTDRLPersistenceTest extends TestCase {


  public void test2Rules() throws Exception {
    GuidedDecisionTable dt = new GuidedDecisionTable();
    dt.tableName = "michael";

    AttributeCol attr = new AttributeCol();
    attr.attr = "salience";
        attr.defaultValue = "66";
View Full Code Here

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

  }


    public void testInterpolate() {
        GuidedDecisionTable dt = new GuidedDecisionTable();
        dt.tableName = "michael";

        AttributeCol attr = new AttributeCol();
        attr.attr = "salience";
        attr.defaultValue = "66";
View Full Code Here

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

       
    }


    public void testInOperator() {
        GuidedDecisionTable dt = new GuidedDecisionTable();
        dt.tableName = "michael";

        AttributeCol attr = new AttributeCol();
        attr.attr = "salience";
        attr.defaultValue = "66";
View Full Code Here

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


  }

  public void testNoConstraints() {
    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
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.