Package org.drools.workbench.models.guided.dtable.backend.util

Examples of org.drools.workbench.models.guided.dtable.backend.util.GuidedDTTemplateDataProvider


        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 );
        p.doActions( allColumns,
                     allActions,
                     rowDataProvider0,
                     dtRowData0,
                     rm );

        assertEquals( 2,
                      rm.rhs.length );
        assertEquals( "Baddie",
                      ( (ActionInsertFact) rm.rhs[ 0 ] ).getFactType() );
        assertEquals( "Smurf",
                      ( (ActionInsertFact) rm.rhs[ 1 ] ).getFactType() );

        // examine the first action
        ActionInsertFact result0Action1 = (ActionInsertFact) rm.rhs[ 0 ];
        assertEquals( 1,
                      result0Action1.getFieldValues().length );

        ActionFieldValue result0Action1FieldValue1 = (ActionFieldValue) result0Action1.getFieldValues()[ 0 ];
        assertEquals( DataType.TYPE_STRING,
                      result0Action1FieldValue1.getType() );
        assertEquals( "name",
                      result0Action1FieldValue1.getField() );
        assertEquals( "Gargamel",
                      result0Action1FieldValue1.getValue() );

        // examine the second action
        ActionInsertFact result0Action2 = (ActionInsertFact) rm.rhs[ 1 ];
        assertEquals( 2,
                      result0Action2.getFieldValues().length );

        ActionFieldValue result0Action2FieldValue1 = (ActionFieldValue) result0Action2.getFieldValues()[ 0 ];
        assertEquals( DataType.TYPE_STRING,
                      result0Action2FieldValue1.getType() );
        assertEquals( "name",
                      result0Action2FieldValue1.getField() );
        assertEquals( "$name",
                      result0Action2FieldValue1.getValue() );

        ActionFieldValue result0Action2FieldValue2 = (ActionFieldValue) result0Action2.getFieldValues()[ 1 ];
        assertEquals( DataType.TYPE_NUMERIC_INTEGER,
                      result0Action2FieldValue2.getType() );
        assertEquals( "age",
                      result0Action2FieldValue2.getField() );
        assertEquals( "$age",
                      result0Action2FieldValue2.getValue() );

        //Row 1
        List<DTCellValue52> dtRowData1 = DataUtilities.makeDataRowList( data[ 1 ] );
        TemplateDataProvider rowDataProvider1 = new GuidedDTTemplateDataProvider( allColumns,
                                                                                  dtRowData1 );
        p.doActions( allColumns,
                     allActions,
                     rowDataProvider1,
                     dtRowData1,
                     rm );

        assertEquals( 2,
                      rm.rhs.length );
        assertEquals( "Baddie",
                      ( (ActionInsertFact) rm.rhs[ 0 ] ).getFactType() );
        assertEquals( "Smurf",
                      ( (ActionInsertFact) rm.rhs[ 1 ] ).getFactType() );

        // examine the first action
        ActionInsertFact result1Action1 = (ActionInsertFact) rm.rhs[ 0 ];
        assertEquals( 1,
                      result1Action1.getFieldValues().length );

        ActionFieldValue result1Action1FieldValue1 = (ActionFieldValue) result1Action1.getFieldValues()[ 0 ];
        assertEquals( DataType.TYPE_STRING,
                      result1Action1FieldValue1.getType() );
        assertEquals( "name",
                      result1Action1FieldValue1.getField() );
        assertEquals( "Gargamel",
                      result1Action1FieldValue1.getValue() );

        // examine the second action
        ActionInsertFact result1Action2 = (ActionInsertFact) rm.rhs[ 1 ];
        assertEquals( 2,
                      result1Action2.getFieldValues().length );

        ActionFieldValue result1Action2FieldValue1 = (ActionFieldValue) result1Action2.getFieldValues()[ 0 ];
        assertEquals( DataType.TYPE_STRING,
                      result1Action2FieldValue1.getType() );
        assertEquals( "name",
                      result1Action2FieldValue1.getField() );
        assertEquals( "$name",
                      result1Action2FieldValue1.getValue() );

        ActionFieldValue result1Action2FieldValue2 = (ActionFieldValue) result1Action2.getFieldValues()[ 1 ];
        assertEquals( DataType.TYPE_NUMERIC_INTEGER,
                      result1Action2FieldValue2.getType() );
        assertEquals( "age",
                      result1Action2FieldValue2.getField() );
        assertEquals( "$age",
                      result1Action2FieldValue2.getValue() );

        //Row 2
        List<DTCellValue52> dtRowData2 = DataUtilities.makeDataRowList( data[ 2 ] );
        TemplateDataProvider rowDataProvider2 = new GuidedDTTemplateDataProvider( allColumns,
                                                                                  dtRowData2 );
        p.doActions( allColumns,
                     allActions,
                     rowDataProvider2,
                     dtRowData2,
View Full Code Here


        for ( int i = 0; i < data.size(); i++ ) {

            List<DTCellValue52> row = data.get( i );

            //Specialised BRDRLPersistence provider than can handle template key expansion
            TemplateDataProvider rowDataProvider = new GuidedDTTemplateDataProvider( allColumns,
                                                                                     row );

            Integer num = (Integer) row.get( 0 ).getNumericValue();
            String desc = row.get( 1 ).getStringValue();
View Full Code Here

        //When using a TemplateDataProvider the assumption is that we
        //have a "complete" decision table including AnalysisCol52
        allColumns.add( new AnalysisCol52() );

        List<DTCellValue52> rowData = DataUtilities.makeDataRowList( row );
        TemplateDataProvider rowDataProvider = new GuidedDTTemplateDataProvider( allColumns,
                                                                                 rowData );

        p.doConditions( allColumns,
                        allPatterns,
                        rowDataProvider,
View Full Code Here

        //When using a TemplateDataProvider the assumption is that we
        //have a "complete" decision table including AnalysisCol52
        allColumns.add( new AnalysisCol52() );

        List<DTCellValue52> rowData = DataUtilities.makeDataRowList( row );
        TemplateDataProvider rowDataProvider = new GuidedDTTemplateDataProvider( allColumns,
                                                                                 rowData );

        RuleModel rm = new RuleModel();

        p.doConditions( allColumns,
View Full Code Here

        //When using a TemplateDataProvider the assumption is that we
        //have a "complete" decision table including AnalysisCol52
        allColumns.add( new AnalysisCol52() );

        List<DTCellValue52> rowData = DataUtilities.makeDataRowList( row );
        TemplateDataProvider rowDataProvider = new GuidedDTTemplateDataProvider( allColumns,
                                                                                 rowData );

        RuleModel rm = new RuleModel();

        p.doConditions( allColumns,
View Full Code Here

        //When using a TemplateDataProvider the assumption is that we
        //have a "complete" decision table including AnalysisCol52
        allColumns.add( new AnalysisCol52() );

        TemplateDataProvider rowDataProvider0 = new GuidedDTTemplateDataProvider( allColumns,
                                                                                  rowDTModel0 );

        p.doConditions( allColumns,
                        allPatterns,
                        rowDataProvider0,
                        rowDTModel0,
                        DataUtilities.makeDataLists( data ),
                        rm );
        String drl0 = RuleModelDRLPersistenceImpl.getInstance().marshal( rm );

        assertEquals( 2,
                      rm.lhs.length );
        assertEquals( "Person",
                      ( (FactPattern) rm.lhs[ 0 ] ).getFactType() );
        assertEquals( "p1",
                      ( (FactPattern) rm.lhs[ 0 ] ).getBoundName() );

        assertEquals( "Person",
                      ( (FactPattern) rm.lhs[ 1 ] ).getFactType() );
        assertEquals( "p2",
                      ( (FactPattern) rm.lhs[ 1 ] ).getBoundName() );
        assertTrue( drl0.indexOf( "p1 : Person( alive == true )" ) > 0 );
        assertTrue( drl0.indexOf( "p2 : Person( alive != false )" ) > 0 );

        TemplateDataProvider rowDataProvider1 = new GuidedDTTemplateDataProvider( allColumns,
                                                                                  rowDTModel1 );

        p.doConditions( allColumns,
                        allPatterns,
                        rowDataProvider1,
View Full Code Here

        //When using a TemplateDataProvider the assumption is that we
        //have a "complete" decision table including AnalysisCol52
        allColumns.add( new AnalysisCol52() );

        TemplateDataProvider rowDataProvider0 = new GuidedDTTemplateDataProvider( allColumns,
                                                                                  rowDTModel0 );

        p.doConditions( allColumns,
                        allPatterns,
                        rowDataProvider0,
                        rowDTModel0,
                        DataUtilities.makeDataLists( data ),
                        rm );
        String drl0 = RuleModelDRLPersistenceImpl.getInstance().marshal( rm );

        assertEquals( 2,
                      rm.lhs.length );
        assertEquals( "Person",
                      ( (FactPattern) rm.lhs[ 0 ] ).getFactType() );
        assertEquals( "p1",
                      ( (FactPattern) rm.lhs[ 0 ] ).getBoundName() );

        assertEquals( "Person",
                      ( (FactPattern) rm.lhs[ 1 ] ).getFactType() );
        assertEquals( "p2",
                      ( (FactPattern) rm.lhs[ 1 ] ).getBoundName() );
        assertTrue( drl0.indexOf( "p1 : Person( dateOfBirth == \"01-Jan-1980\" )" ) > 0 );
        assertTrue( drl0.indexOf( "p2 : Person( dateOfBirth != \"20-Jun-1985\" )" ) > 0 );

        TemplateDataProvider rowDataProvider1 = new GuidedDTTemplateDataProvider( allColumns,
                                                                                  rowDTModel1 );

        p.doConditions( allColumns,
                        allPatterns,
                        rowDataProvider1,
                        rowDTModel1,
                        DataUtilities.makeDataLists( data ),
                        rm );
        String drl1 = RuleModelDRLPersistenceImpl.getInstance().marshal( rm );

        assertEquals( 2,
                      rm.lhs.length );
        assertEquals( "Person",
                      ( (FactPattern) rm.lhs[ 0 ] ).getFactType() );
        assertEquals( "p1",
                      ( (FactPattern) rm.lhs[ 0 ] ).getBoundName() );

        assertEquals( "Person",
                      ( (FactPattern) rm.lhs[ 1 ] ).getFactType() );
        assertEquals( "p2",
                      ( (FactPattern) rm.lhs[ 1 ] ).getBoundName() );
        assertTrue( drl1.indexOf( "p1 : Person( dateOfBirth == \"01-Feb-1981\" )" ) > 0 );
        assertTrue( drl1.indexOf( "p2 : Person( dateOfBirth != \"21-Jun-1986\" )" ) > 0 );

        TemplateDataProvider rowDataProvider2 = new GuidedDTTemplateDataProvider( allColumns,
                                                                                  rowDTModel2 );

        p.doConditions( allColumns,
                        allPatterns,
                        rowDataProvider2,
View Full Code Here

        //When using a TemplateDataProvider the assumption is that we
        //have a "complete" decision table including AnalysisCol52
        allColumns.add( new AnalysisCol52() );

        TemplateDataProvider rowDataProvider0 = new GuidedDTTemplateDataProvider( allColumns,
                                                                                  rowDTModel0 );

        p.doConditions( allColumns,
                        allPatterns,
                        rowDataProvider0,
                        rowDTModel0,
                        DataUtilities.makeDataLists( data ),
                        rm );
        String drl0 = RuleModelDRLPersistenceImpl.getInstance().marshal( rm );

        assertEquals( 2,
                      rm.lhs.length );
        assertEquals( "Person",
                      ( (FactPattern) rm.lhs[ 0 ] ).getFactType() );
        assertEquals( "p1",
                      ( (FactPattern) rm.lhs[ 0 ] ).getBoundName() );

        assertEquals( "Person",
                      ( (FactPattern) rm.lhs[ 1 ] ).getFactType() );
        assertEquals( "p2",
                      ( (FactPattern) rm.lhs[ 1 ] ).getBoundName() );
        assertTrue( drl0.indexOf( "p1 : Person( age == 1 )" ) > 0 );
        assertTrue( drl0.indexOf( "p2 : Person( age != 1 )" ) > 0 );

        TemplateDataProvider rowDataProvider1 = new GuidedDTTemplateDataProvider( allColumns,
                                                                                  rowDTModel1 );

        p.doConditions( allColumns,
                        allPatterns,
                        rowDataProvider1,
                        rowDTModel1,
                        DataUtilities.makeDataLists( data ),
                        rm );
        String drl1 = RuleModelDRLPersistenceImpl.getInstance().marshal( rm );

        assertEquals( 2,
                      rm.lhs.length );
        assertEquals( "Person",
                      ( (FactPattern) rm.lhs[ 0 ] ).getFactType() );
        assertEquals( "p1",
                      ( (FactPattern) rm.lhs[ 0 ] ).getBoundName() );

        assertEquals( "Person",
                      ( (FactPattern) rm.lhs[ 1 ] ).getFactType() );
        assertEquals( "p2",
                      ( (FactPattern) rm.lhs[ 1 ] ).getBoundName() );
        assertTrue( drl1.indexOf( "p1 : Person( age == 2 )" ) > 0 );
        assertTrue( drl1.indexOf( "p2 : Person( age != 2 )" ) > 0 );

        TemplateDataProvider rowDataProvider2 = new GuidedDTTemplateDataProvider( allColumns,
                                                                                  rowDTModel2 );

        p.doConditions( allColumns,
                        allPatterns,
                        rowDataProvider2,
View Full Code Here

        //When using a TemplateDataProvider the assumption is that we
        //have a "complete" decision table including AnalysisCol52
        allColumns.add( new AnalysisCol52() );

        TemplateDataProvider rowDataProvider0 = new GuidedDTTemplateDataProvider( allColumns,
                                                                                  rowDTModel0 );

        p.doConditions( allColumns,
                        allPatterns,
                        rowDataProvider0,
                        rowDTModel0,
                        DataUtilities.makeDataLists( data ),
                        rm );
        String drl0 = RuleModelDRLPersistenceImpl.getInstance().marshal( rm );

        assertEquals( 2,
                      rm.lhs.length );
        assertEquals( "Person",
                      ( (FactPattern) rm.lhs[ 0 ] ).getFactType() );
        assertEquals( "p1",
                      ( (FactPattern) rm.lhs[ 0 ] ).getBoundName() );

        assertEquals( "Person",
                      ( (FactPattern) rm.lhs[ 1 ] ).getFactType() );
        assertEquals( "p2",
                      ( (FactPattern) rm.lhs[ 1 ] ).getBoundName() );
        assertTrue( drl0.indexOf( "p1 : Person( name == \"Michael1\" )" ) > 0 );
        assertTrue( drl0.indexOf( "p2 : Person( name != \"Michael1\" )" ) > 0 );

        TemplateDataProvider rowDataProvider1 = new GuidedDTTemplateDataProvider( allColumns,
                                                                                  rowDTModel1 );

        p.doConditions( allColumns,
                        allPatterns,
                        rowDataProvider1,
                        rowDTModel1,
                        DataUtilities.makeDataLists( data ),
                        rm );
        String drl1 = RuleModelDRLPersistenceImpl.getInstance().marshal( rm );

        assertEquals( 2,
                      rm.lhs.length );
        assertEquals( "Person",
                      ( (FactPattern) rm.lhs[ 0 ] ).getFactType() );
        assertEquals( "p1",
                      ( (FactPattern) rm.lhs[ 0 ] ).getBoundName() );

        assertEquals( "Person",
                      ( (FactPattern) rm.lhs[ 1 ] ).getFactType() );
        assertEquals( "p2",
                      ( (FactPattern) rm.lhs[ 1 ] ).getBoundName() );
        assertTrue( drl1.indexOf( "p1 : Person( name == \"Michael2\" )" ) > 0 );
        assertTrue( drl1.indexOf( "p2 : Person( name != \"Michael2\" )" ) > 0 );

        TemplateDataProvider rowDataProvider2 = new GuidedDTTemplateDataProvider( allColumns,
                                                                                  rowDTModel2 );

        p.doConditions( allColumns,
                        allPatterns,
                        rowDataProvider2,
View Full Code Here

        //When using a TemplateDataProvider the assumption is that we
        //have a "complete" decision table including AnalysisCol52
        allColumns.add( new AnalysisCol52() );

        List<DTCellValue52> rowData = DataUtilities.makeDataRowList( row );
        TemplateDataProvider rowDataProvider = new GuidedDTTemplateDataProvider( allColumns,
                                                                                 rowData );

        p.doConditions( allColumns,
                        allPatterns,
                        rowDataProvider,
View Full Code Here

TOP

Related Classes of org.drools.workbench.models.guided.dtable.backend.util.GuidedDTTemplateDataProvider

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.