Package org.drools.workbench.models.guided.dtable.shared.model

Examples of org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52


    @Test
    //This test checks a Decision Table involving BRL columns is correctly converted into DRL
    public void testLHSWithBRLColumn_ParseToDRL_MultiplePatterns() {

        GuidedDecisionTable52 dtable = new GuidedDecisionTable52();

        //Row 0 should become an IPattern in the resulting RuleModel as it contains getValue()s for all Template fields in the BRL Column
        //Row 1 should *NOT* become an IPattern in the resulting RuleModel as it does *NOT* contain getValue()s for all Template fields in the BRL Column
        //Row 2 should *NOT* become an IPattern in the resulting RuleModel as it does *NOT* contain getValue()s for all Template fields in the BRL Column
        String[][] data = new String[][]{
                new String[]{ "1", "desc", "Pupa", "50" },
                new String[]{ "2", "desc", "", "50" },
                new String[]{ "3", "desc", "Pupa", "" }
        };

        //Simple (mandatory) columns
        dtable.setRowNumberCol( new RowNumberCol52() );
        dtable.setDescriptionCol( new DescriptionCol52() );

        //BRL Column
        BRLConditionColumn brl1 = new BRLConditionColumn();

        //BRL Column definition
        List<IPattern> brl1Definition = new ArrayList<IPattern>();
        FactPattern brl1DefinitionFactPattern1 = new FactPattern( "Baddie" );

        SingleFieldConstraint brl1DefinitionFactPattern1Constraint1 = new SingleFieldConstraint();
        brl1DefinitionFactPattern1Constraint1.setFieldType( DataType.TYPE_STRING );
        brl1DefinitionFactPattern1Constraint1.setConstraintValueType( SingleFieldConstraint.TYPE_LITERAL );
        brl1DefinitionFactPattern1Constraint1.setFieldName( "name" );
        brl1DefinitionFactPattern1Constraint1.setOperator( "==" );
        brl1DefinitionFactPattern1Constraint1.setValue( "Gargamel" );
        brl1DefinitionFactPattern1.addConstraint( brl1DefinitionFactPattern1Constraint1 );

        brl1Definition.add( brl1DefinitionFactPattern1 );

        FactPattern brl1DefinitionFactPattern2 = new FactPattern( "Smurf" );

        SingleFieldConstraint brl1DefinitionFactPattern2Constraint1 = new SingleFieldConstraint();
        brl1DefinitionFactPattern2Constraint1.setFieldType( DataType.TYPE_STRING );
        brl1DefinitionFactPattern2Constraint1.setConstraintValueType( SingleFieldConstraint.TYPE_TEMPLATE );
        brl1DefinitionFactPattern2Constraint1.setFieldName( "name" );
        brl1DefinitionFactPattern2Constraint1.setOperator( "==" );
        brl1DefinitionFactPattern2Constraint1.setValue( "$name" );
        brl1DefinitionFactPattern2.addConstraint( brl1DefinitionFactPattern2Constraint1 );

        SingleFieldConstraint brl1DefinitionFactPattern2Constraint2 = new SingleFieldConstraint();
        brl1DefinitionFactPattern2Constraint2.setFieldType( DataType.TYPE_NUMERIC_INTEGER );
        brl1DefinitionFactPattern2Constraint2.setConstraintValueType( SingleFieldConstraint.TYPE_TEMPLATE );
        brl1DefinitionFactPattern2Constraint2.setFieldName( "age" );
        brl1DefinitionFactPattern2Constraint2.setOperator( "==" );
        brl1DefinitionFactPattern2Constraint2.setValue( "$age" );
        brl1DefinitionFactPattern2.addConstraint( brl1DefinitionFactPattern2Constraint2 );

        brl1Definition.add( brl1DefinitionFactPattern2 );

        brl1.setDefinition( brl1Definition );

        //Setup BRL column bindings
        BRLConditionVariableColumn brl1Variable1 = new BRLConditionVariableColumn( "$name",
                                                                                   DataType.TYPE_STRING,
                                                                                   "Person",
                                                                                   "name" );
        brl1.getChildColumns().add( brl1Variable1 );
        BRLConditionVariableColumn brl1Variable2 = new BRLConditionVariableColumn( "$age",
                                                                                   DataType.TYPE_NUMERIC_INTEGER,
                                                                                   "Person",
                                                                                   "age" );
        brl1.getChildColumns().add( brl1Variable2 );

        dtable.getConditions().add( brl1 );
        dtable.setData( DataUtilities.makeDataLists( data ) );

        //Now to test conversion
        int ruleStartIndex;
        int pattern1StartIndex;
        int pattern2StartIndex;
View Full Code Here


    @Test
    //This test checks a Decision Table involving BRL columns is correctly converted into DRL
    public void testLHSWithBRLColumn_ParseToDRL_NoVariables() {

        GuidedDecisionTable52 dtable = new GuidedDecisionTable52();

        //Row 0 should become an IPattern in the resulting RuleModel as it contains getValue()s for all Template fields in the BRL Column
        //Row 1 should *NOT* become an IPattern in the resulting RuleModel as it does *NOT* contain getValue()s for all Template fields in the BRL Column
        //Row 2 should *NOT* become an IPattern in the resulting RuleModel as it does *NOT* contain getValue()s for all Template fields in the BRL Column
        Object[][] data = new Object[][]{
                new Object[]{ "1", "desc", Boolean.TRUE },
                new Object[]{ "2", "desc", Boolean.FALSE }
        };

        //Simple (mandatory) columns
        dtable.setRowNumberCol( new RowNumberCol52() );
        dtable.setDescriptionCol( new DescriptionCol52() );

        //BRL Column
        BRLConditionColumn brl1 = new BRLConditionColumn();

        //BRL Column definition
        List<IPattern> brl1Definition = new ArrayList<IPattern>();
        FactPattern brl1DefinitionFactPattern1 = new FactPattern( "Baddie" );

        SingleFieldConstraint brl1DefinitionFactPattern1Constraint1 = new SingleFieldConstraint();
        brl1DefinitionFactPattern1Constraint1.setFieldType( DataType.TYPE_STRING );
        brl1DefinitionFactPattern1Constraint1.setConstraintValueType( SingleFieldConstraint.TYPE_LITERAL );
        brl1DefinitionFactPattern1Constraint1.setFieldName( "name" );
        brl1DefinitionFactPattern1Constraint1.setOperator( "==" );
        brl1DefinitionFactPattern1Constraint1.setValue( "Gargamel" );
        brl1DefinitionFactPattern1.addConstraint( brl1DefinitionFactPattern1Constraint1 );

        brl1Definition.add( brl1DefinitionFactPattern1 );

        brl1.setDefinition( brl1Definition );

        //Setup BRL column bindings
        BRLConditionVariableColumn brl1Variable1 = new BRLConditionVariableColumn( "",
                                                                                   DataType.TYPE_BOOLEAN );
        brl1.getChildColumns().add( brl1Variable1 );

        dtable.getConditions().add( brl1 );
        dtable.setData( DataUtilities.makeDataLists( data ) );

        //Now to test conversion
        int ruleStartIndex;
        int pattern1StartIndex;
        GuidedDTDRLPersistence p = GuidedDTDRLPersistence.getInstance();
View Full Code Here

    @Test
    //This test checks a Decision Table involving BRL columns is correctly converted into a RuleModel
    public void testRHSWithBRLColumn_ParseToRuleModel() {

        GuidedDecisionTable52 dtable = new GuidedDecisionTable52();

        GuidedDTDRLPersistence p = new GuidedDTDRLPersistence();

        //Row 0 should become an IPattern in the resulting RuleModel as it contains getValue()s for all Template fields in the BRL Column
        //Row 1 should *NOT* become an IPattern in the resulting RuleModel as it does *NOT* contain getValue()s for all Template fields in the BRL Column
        //Row 2 should *NOT* become an IPattern in the resulting RuleModel as it does *NOT* contain getValue()s for all Template fields in the BRL Column
        String[][] data = new String[][]{
                new String[]{ "1", "desc", "Gargamel", "Pupa", "50" },
                new String[]{ "2", "desc", "Gargamel", "", "50" },
                new String[]{ "3", "desc", "Gargamel", "Pupa", "" }
        };

        //Simple (mandatory) columns
        dtable.setRowNumberCol( new RowNumberCol52() );
        dtable.setDescriptionCol( new DescriptionCol52() );

        //Simple Action
        ActionInsertFactCol52 a1 = new ActionInsertFactCol52();
        a1.setBoundName( "$b" );
        a1.setFactType( "Baddie" );
        a1.setFactField( "name" );
        a1.setType( DataType.TYPE_STRING );

        dtable.getActionCols().add( a1 );

        //BRL Column
        BRLActionColumn brl1 = new BRLActionColumn();

        //BRL Column definition
        List<IAction> brl1Definition = new ArrayList<IAction>();
        ActionInsertFact brl1DefinitionAction1 = new ActionInsertFact( "Smurf" );
        ActionFieldValue brl1DefinitionAction1FieldValue1 = new ActionFieldValue( "name",
                                                                                  "$name",
                                                                                  DataType.TYPE_STRING );
        brl1DefinitionAction1FieldValue1.setNature( BaseSingleFieldConstraint.TYPE_TEMPLATE );
        brl1DefinitionAction1.addFieldValue( brl1DefinitionAction1FieldValue1 );
        ActionFieldValue brl1DefinitionAction1FieldValue2 = new ActionFieldValue( "age",
                                                                                  "$age",
                                                                                  DataType.TYPE_NUMERIC_INTEGER );
        brl1DefinitionAction1FieldValue2.setNature( BaseSingleFieldConstraint.TYPE_TEMPLATE );
        brl1DefinitionAction1.addFieldValue( brl1DefinitionAction1FieldValue2 );
        brl1Definition.add( brl1DefinitionAction1 );
        brl1.setDefinition( brl1Definition );

        //Setup BRL column bindings
        BRLActionVariableColumn brl1Variable1 = new BRLActionVariableColumn( "$name",
                                                                             DataType.TYPE_STRING,
                                                                             "Person",
                                                                             "name" );
        brl1.getChildColumns().add( brl1Variable1 );
        BRLActionVariableColumn brl1Variable2 = new BRLActionVariableColumn( "$age",
                                                                             DataType.TYPE_NUMERIC_INTEGER,
                                                                             "Person",
                                                                             "age" );
        brl1.getChildColumns().add( brl1Variable2 );

        dtable.getActionCols().add( brl1 );

        //Now to test conversion
        RuleModel rm = new RuleModel();
        List<BaseColumn> allColumns = dtable.getExpandedColumns();
        List<ActionCol52> allActions = dtable.getActionCols();

        //Row 0
        List<DTCellValue52> dtRowData0 = DataUtilities.makeDataRowList( data[ 0 ] );
        TemplateDataProvider rowDataProvider0 = new GuidedDTTemplateDataProvider( allColumns,
                                                                                  dtRowData0 );
View Full Code Here

    @Test
    //This test checks a Decision Table involving BRL columns is correctly converted into DRL
    public void testRHSWithBRLColumn_ParseToDRL() {

        GuidedDecisionTable52 dtable = new GuidedDecisionTable52();

        //Row 0 should become an IPattern in the resulting RuleModel as it contains getValue()s for all Template fields in the BRL Column
        //Row 1 should *NOT* become an IPattern in the resulting RuleModel as it does *NOT* contain getValue()s for all Template fields in the BRL Column
        //Row 2 should *NOT* become an IPattern in the resulting RuleModel as it does *NOT* contain getValue()s for all Template fields in the BRL Column
        String[][] data = new String[][]{
                new String[]{ "1", "desc", "Gargamel", "Pupa", "50" },
                new String[]{ "2", "desc", "Gargamel", "", "50" },
                new String[]{ "3", "desc", "Gargamel", "Pupa", "" }
        };

        //Simple (mandatory) columns
        dtable.setRowNumberCol( new RowNumberCol52() );
        dtable.setDescriptionCol( new DescriptionCol52() );

        //Simple Action
        ActionInsertFactCol52 a1 = new ActionInsertFactCol52();
        a1.setBoundName( "$b" );
        a1.setFactType( "Baddie" );
        a1.setFactField( "name" );
        a1.setType( DataType.TYPE_STRING );

        dtable.getActionCols().add( a1 );

        //BRL Column
        BRLActionColumn brl1 = new BRLActionColumn();

        //BRL Column definition
        List<IAction> brl1Definition = new ArrayList<IAction>();
        ActionInsertFact brl1DefinitionAction1 = new ActionInsertFact( "Smurf" );
        ActionFieldValue brl1DefinitionAction1FieldValue1 = new ActionFieldValue( "name",
                                                                                  "$name",
                                                                                  DataType.TYPE_STRING );
        brl1DefinitionAction1FieldValue1.setNature( BaseSingleFieldConstraint.TYPE_TEMPLATE );
        brl1DefinitionAction1.addFieldValue( brl1DefinitionAction1FieldValue1 );
        ActionFieldValue brl1DefinitionAction1FieldValue2 = new ActionFieldValue( "age",
                                                                                  "$age",
                                                                                  DataType.TYPE_NUMERIC_INTEGER );
        brl1DefinitionAction1FieldValue2.setNature( BaseSingleFieldConstraint.TYPE_TEMPLATE );
        brl1DefinitionAction1.addFieldValue( brl1DefinitionAction1FieldValue2 );
        brl1Definition.add( brl1DefinitionAction1 );
        brl1.setDefinition( brl1Definition );

        //Setup BRL column bindings
        BRLActionVariableColumn brl1Variable1 = new BRLActionVariableColumn( "$name",
                                                                             DataType.TYPE_STRING,
                                                                             "Person",
                                                                             "name" );
        brl1.getChildColumns().add( brl1Variable1 );
        BRLActionVariableColumn brl1Variable2 = new BRLActionVariableColumn( "$age",
                                                                             DataType.TYPE_NUMERIC_INTEGER,
                                                                             "Person",
                                                                             "age" );
        brl1.getChildColumns().add( brl1Variable2 );

        dtable.getActionCols().add( brl1 );
        dtable.setData( DataUtilities.makeDataLists( data ) );

        //Now to test conversion
        int ruleStartIndex;
        int action1StartIndex;
        int action2StartIndex;
View Full Code Here

    @Test
    //This test checks a Decision Table involving BRL columns is correctly converted into DRL
    public void testRHSWithBRLColumn_ParseToDRL_MultipleActions() {

        GuidedDecisionTable52 dtable = new GuidedDecisionTable52();

        //Row 0 should become an IPattern in the resulting RuleModel as it contains getValue()s for all Template fields in the BRL Column
        //Row 1 should *NOT* become an IPattern in the resulting RuleModel as it does *NOT* contain getValue()s for all Template fields in the BRL Column
        //Row 2 should *NOT* become an IPattern in the resulting RuleModel as it does *NOT* contain getValue()s for all Template fields in the BRL Column
        String[][] data = new String[][]{
                new String[]{ "1", "desc", "Pupa", "50" },
                new String[]{ "2", "desc", "", "50" },
                new String[]{ "3", "desc", "Pupa", "" }
        };

        //Simple (mandatory) columns
        dtable.setRowNumberCol( new RowNumberCol52() );
        dtable.setDescriptionCol( new DescriptionCol52() );

        //BRL Column
        BRLActionColumn brl1 = new BRLActionColumn();

        //BRL Column definition
        List<IAction> brl1Definition = new ArrayList<IAction>();
        ActionInsertFact brl1DefinitionAction1 = new ActionInsertFact( "Baddie" );
        ActionFieldValue brl1DefinitionAction1FieldValue1 = new ActionFieldValue( "name",
                                                                                  "Gargamel",
                                                                                  DataType.TYPE_STRING );
        brl1DefinitionAction1FieldValue1.setNature( BaseSingleFieldConstraint.TYPE_LITERAL );
        brl1DefinitionAction1.addFieldValue( brl1DefinitionAction1FieldValue1 );
        brl1Definition.add( brl1DefinitionAction1 );

        ActionInsertFact brl1DefinitionAction2 = new ActionInsertFact( "Smurf" );
        ActionFieldValue brl1DefinitionAction2FieldValue1 = new ActionFieldValue( "name",
                                                                                  "$name",
                                                                                  DataType.TYPE_STRING );
        brl1DefinitionAction2FieldValue1.setNature( BaseSingleFieldConstraint.TYPE_TEMPLATE );
        brl1DefinitionAction2.addFieldValue( brl1DefinitionAction2FieldValue1 );
        ActionFieldValue brl1DefinitionAction2FieldValue2 = new ActionFieldValue( "age",
                                                                                  "$age",
                                                                                  DataType.TYPE_NUMERIC_INTEGER );
        brl1DefinitionAction2FieldValue2.setNature( BaseSingleFieldConstraint.TYPE_TEMPLATE );
        brl1DefinitionAction2.addFieldValue( brl1DefinitionAction2FieldValue2 );
        brl1Definition.add( brl1DefinitionAction2 );

        brl1.setDefinition( brl1Definition );

        //Setup BRL column bindings
        BRLActionVariableColumn brl1Variable1 = new BRLActionVariableColumn( "$name",
                                                                             DataType.TYPE_STRING,
                                                                             "Person",
                                                                             "name" );
        brl1.getChildColumns().add( brl1Variable1 );
        BRLActionVariableColumn brl1Variable2 = new BRLActionVariableColumn( "$age",
                                                                             DataType.TYPE_NUMERIC_INTEGER,
                                                                             "Person",
                                                                             "age" );
        brl1.getChildColumns().add( brl1Variable2 );

        dtable.getActionCols().add( brl1 );
        dtable.setData( DataUtilities.makeDataLists( data ) );

        //Now to test conversion
        int ruleStartIndex;
        int action1StartIndex;
        int action2StartIndex;
View Full Code Here

    @Test
    //This test checks a Decision Table involving BRL columns is correctly converted into DRL
    public void testRHSWithBRLColumn_ParseToDRL_NoVariables() {

        GuidedDecisionTable52 dtable = new GuidedDecisionTable52();

        Object[][] data = new Object[][]{
                new Object[]{ "1", "desc", Boolean.TRUE },
                new Object[]{ "2", "desc", Boolean.FALSE }
        };

        //Simple (mandatory) columns
        dtable.setRowNumberCol( new RowNumberCol52() );
        dtable.setDescriptionCol( new DescriptionCol52() );

        //BRL Column
        BRLActionColumn brl1 = new BRLActionColumn();

        //BRL Column definition
        List<IAction> brl1Definition = new ArrayList<IAction>();
        ActionInsertFact brl1DefinitionAction1 = new ActionInsertFact( "Baddie" );
        ActionFieldValue brl1DefinitionAction1FieldValue1 = new ActionFieldValue( "name",
                                                                                  "Gargamel",
                                                                                  DataType.TYPE_STRING );
        brl1DefinitionAction1FieldValue1.setNature( BaseSingleFieldConstraint.TYPE_LITERAL );
        brl1DefinitionAction1.addFieldValue( brl1DefinitionAction1FieldValue1 );
        brl1Definition.add( brl1DefinitionAction1 );

        brl1.setDefinition( brl1Definition );

        //Setup BRL column bindings
        BRLActionVariableColumn brl1Variable1 = new BRLActionVariableColumn( "",
                                                                             DataType.TYPE_BOOLEAN );
        brl1.getChildColumns().add( brl1Variable1 );

        dtable.getActionCols().add( brl1 );
        dtable.setData( DataUtilities.makeDataLists( data ) );

        //Now to test conversion
        int ruleStartIndex;
        int action1StartIndex;
        GuidedDTDRLPersistence p = GuidedDTDRLPersistence.getInstance();
View Full Code Here

        assertTrue( action1StartIndex == -1 );
    }

    @Test
    public void testPackageNameAndImports() throws Exception {
        GuidedDecisionTable52 dt = new GuidedDecisionTable52();
        dt.setPackageName( "org.drools.guvnor.models.guided.dtable.backend" );
        dt.getImports().addImport( new Import( "java.lang.String" ) );

        dt.setTableName( "michael" );

        Pattern52 p1 = new Pattern52();
        p1.setBoundName( "f1" );
        p1.setFactType( "Driver" );

        ConditionCol52 con = new ConditionCol52();
        con.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
        con.setFactField( "age" );
        con.setHeader( "Driver f1 age" );
        con.setOperator( "==" );
        p1.getChildColumns().add( con );

        dt.getConditions().add( p1 );

        dt.setData( DataUtilities.makeDataLists( new String[][]{
                new String[]{ "1", "desc", "42" }
        } ) );

        GuidedDTDRLPersistence p = GuidedDTDRLPersistence.getInstance();
        String drl = p.marshal( dt );
View Full Code Here

public class GuidedDTDRLPersistenceTest {

    @Test
    public void test2Rules() throws Exception {
        GuidedDecisionTable52 dt = new GuidedDecisionTable52();

        dt.setTableName( "michael" );

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

        Pattern52 p1 = new Pattern52();
        p1.setBoundName( "f1" );
        p1.setFactType( "Driver" );

        ConditionCol52 con = new ConditionCol52();
        con.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
        con.setFactField( "age" );
        con.setHeader( "Driver f1 age" );
        con.setOperator( "==" );
        p1.getChildColumns().add( con );

        ConditionCol52 con2 = new ConditionCol52();
        con2.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
        con2.setFactField( "name" );
        con2.setHeader( "Driver f1 name" );
        con2.setOperator( "==" );
        p1.getChildColumns().add( con2 );

        ConditionCol52 con3 = new ConditionCol52();
        con3.setConstraintValueType( BaseSingleFieldConstraint.TYPE_RET_VALUE );
        con3.setFactField( "rating" );
        con3.setHeader( "Driver rating" );
        con3.setOperator( "==" );
        p1.getChildColumns().add( con3 );

        dt.getConditions().add( p1 );

        Pattern52 p2 = new Pattern52();
        p2.setBoundName( "f2" );
        p2.setFactType( "Driver" );

        ConditionCol52 con4 = new ConditionCol52();
        con4.setConstraintValueType( BaseSingleFieldConstraint.TYPE_PREDICATE );
        con4.setHeader( "Driver 2 pimp" );
        con4.setFactField( "(not needed)" );
        p2.getChildColumns().add( con4 );

        dt.getConditions().add( p2 );

        ActionInsertFactCol52 ins = new ActionInsertFactCol52();
        ins.setBoundName( "ins" );
        ins.setFactType( "Cheese" );
        ins.setFactField( "price" );
        ins.setType( DataType.TYPE_NUMERIC_INTEGER );
        dt.getActionCols().add( ins );

        ActionRetractFactCol52 ret = new ActionRetractFactCol52();
        dt.getActionCols().add( ret );

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

        ActionSetFieldCol52 set2 = new ActionSetFieldCol52();
        set2.setBoundName( "f1" );
        set2.setFactField( "goo2" );
        set2.setDefaultValue( new DTCellValue52( "whee" ) );
        set2.setType( DataType.TYPE_STRING );
        dt.getActionCols().add( set2 );

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

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

        assertFalse( p.validCell( "  " ) );
    }

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

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

        Pattern52 p1 = new Pattern52();
        p1.setBoundName( "f1" );
        p1.setFactType( "Driver" );

        ConditionCol52 con = new ConditionCol52();
        con.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
        con.setFactField( "age" );
        con.setHeader( "Driver f1 age" );
        con.setOperator( "==" );
        p1.getChildColumns().add( con );

        ConditionCol52 con2 = new ConditionCol52();
        con2.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
        con2.setFactField( "name" );
        con2.setHeader( "Driver f1 name" );
        con2.setOperator( "in" );
        p1.getChildColumns().add( con2 );

        ConditionCol52 con3 = new ConditionCol52();
        con3.setConstraintValueType( BaseSingleFieldConstraint.TYPE_RET_VALUE );
        con3.setFactField( "rating" );
        con3.setHeader( "Driver rating" );
        con3.setOperator( "==" );
        p1.getChildColumns().add( con3 );

        ConditionCol52 con4 = new ConditionCol52();
        con4.setConstraintValueType( BaseSingleFieldConstraint.TYPE_PREDICATE );
        con4.setHeader( "Driver 2 pimp" );
        con4.setFactField( "(not needed)" );
        p1.getChildColumns().add( con4 );

        dt.getConditions().add( p1 );

        ActionInsertFactCol52 ins = new ActionInsertFactCol52();
        ins.setBoundName( "ins" );
        ins.setFactType( "Cheese" );
        ins.setFactField( "price" );
        ins.setType( DataType.TYPE_NUMERIC_INTEGER );
        dt.getActionCols().add( ins );

        ActionRetractFactCol52 ret = new ActionRetractFactCol52();
        dt.getActionCols().add( ret );

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

        ActionSetFieldCol52 set2 = new ActionSetFieldCol52();
        set2.setBoundName( "f1" );
        set2.setFactField( "goo2" );
        set2.setDefaultValue( new DTCellValue52( "whee" ) );
        set2.setType( DataType.TYPE_STRING );
        dt.getActionCols().add( set2 );

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

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

    }

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

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

        Pattern52 p1 = new Pattern52();
        p1.setBoundName( "f1" );
        p1.setFactType( "Driver" );

        ConditionCol52 con = new ConditionCol52();
        con.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
        con.setFactField( "age" );
        con.setHeader( "Driver f1 age" );
        con.setOperator( "==" );
        p1.getChildColumns().add( con );

        ConditionCol52 con2 = new ConditionCol52();
        con2.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
        con2.setFactField( "name" );
        con2.setHeader( "Driver f1 name" );
        con2.setOperator( "==" );
        p1.getChildColumns().add( con2 );

        ConditionCol52 con3 = new ConditionCol52();
        con3.setConstraintValueType( BaseSingleFieldConstraint.TYPE_RET_VALUE );
        con3.setFactField( "rating" );
        con3.setHeader( "Driver rating" );
        con3.setOperator( "==" );
        p1.getChildColumns().add( con3 );

        dt.getConditions().add( p1 );

        Pattern52 p2 = new Pattern52();
        p2.setBoundName( "f2" );
        p2.setFactType( "Driver" );

        ConditionCol52 con4 = new ConditionCol52();
        con4.setConstraintValueType( BaseSingleFieldConstraint.TYPE_PREDICATE );
        con4.setHeader( "Driver 2 pimp" );
        con4.setFactField( "this.hasSomething($param)" );
        p2.getChildColumns().add( con4 );

        dt.getConditions().add( p2 );

        ActionInsertFactCol52 ins = new ActionInsertFactCol52();
        ins.setBoundName( "ins" );
        ins.setFactType( "Cheese" );
        ins.setFactField( "price" );
        ins.setType( DataType.TYPE_NUMERIC_INTEGER );
        dt.getActionCols().add( ins );

        ActionRetractFactCol52 ret = new ActionRetractFactCol52();
        dt.getActionCols().add( ret );

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

        ActionSetFieldCol52 set2 = new ActionSetFieldCol52();
        set2.setBoundName( "f1" );
        set2.setFactField( "goo2" );
        set2.setDefaultValue( new DTCellValue52( "whee" ) );
        set2.setType( DataType.TYPE_STRING );
        dt.getActionCols().add( set2 );

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

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

TOP

Related Classes of org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52

Copyright © 2018 www.massapicom. 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.