Package org.drools.workbench.models.commons.shared.rule

Examples of org.drools.workbench.models.commons.shared.rule.ActionFieldValue


        //Setup RuleModel columns (new BRLActionColumn being added)
        BRLRuleModel model = new BRLRuleModel( dt );
        ActionInsertFact aif = new ActionInsertFact( "Person" );
        aif.setBoundName( "$aif" );
        aif.addFieldValue( new ActionFieldValue( "rating",
                                                 null,
                                                 DataType.TYPE_STRING ) );
        aif.getFieldValues()[ 0 ].setNature( BaseSingleFieldConstraint.TYPE_LITERAL );
        model.addRhsItem( aif );
View Full Code Here


        dt.getActionCols().add( ins );

        BRLActionColumn brlAction = new BRLActionColumn();
        ActionInsertFact aif1 = new ActionInsertFact( "Person" );
        aif1.setBoundName( "$aif" );
        aif1.addFieldValue( new ActionFieldValue( "rating",
                                                  null,
                                                  DataType.TYPE_STRING ) );
        aif1.getFieldValues()[ 0 ].setNature( BaseSingleFieldConstraint.TYPE_LITERAL );

        brlAction.getDefinition().add( aif1 );
        dt.getActionCols().add( brlAction );

        //Setup RuleModel columns (existing BRLActionColumn being edited)
        BRLRuleModel model = new BRLRuleModel( dt );
        ActionInsertFact aif2 = new ActionInsertFact( "Person" );
        aif2.setBoundName( "$aif" );
        aif2.addFieldValue( new ActionFieldValue( "rating",
                                                  null,
                                                  DataType.TYPE_STRING ) );
        aif2.getFieldValues()[ 0 ].setNature( BaseSingleFieldConstraint.TYPE_LITERAL );
        model.addRhsItem( aif2 );
View Full Code Here

        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
View Full Code Here

        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 );
View Full Code Here

        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 );
View Full Code Here

        assertEquals( asf.getVariable(),
                      "$r" );
        assertEquals( 4,
                      asf.getFieldValues().length );

        ActionFieldValue fv1 = asf.getFieldValues()[ 0 ];
        assertNotNull( fv1 );
        assertTrue( fv1 instanceof ActionWorkItemFieldValue );
        ActionWorkItemFieldValue wifv1 = (ActionWorkItemFieldValue) fv1;
        assertEquals( "ResultBooleanField",
                      wifv1.getField() );
        assertEquals( DataType.TYPE_BOOLEAN,
                      wifv1.getType() );
        assertEquals( "WorkItem",
                      wifv1.getWorkItemName() );
        assertEquals( "BooleanResult",
                      wifv1.getWorkItemParameterName() );
        assertEquals( Boolean.class.getName(),
                      wifv1.getWorkItemParameterClassName() );

        ActionFieldValue fv2 = asf.getFieldValues()[ 1 ];
        assertNotNull( fv2 );
        assertTrue( fv2 instanceof ActionWorkItemFieldValue );
        ActionWorkItemFieldValue wifv2 = (ActionWorkItemFieldValue) fv2;
        assertEquals( "ResultFloatField",
                      wifv2.getField() );
        assertEquals( DataType.TYPE_NUMERIC_FLOAT,
                      wifv2.getType() );
        assertEquals( "WorkItem",
                      wifv2.getWorkItemName() );
        assertEquals( "FloatResult",
                      wifv2.getWorkItemParameterName() );
        assertEquals( Float.class.getName(),
                      wifv2.getWorkItemParameterClassName() );

        ActionFieldValue fv3 = asf.getFieldValues()[ 2 ];
        assertNotNull( fv3 );
        assertTrue( fv3 instanceof ActionWorkItemFieldValue );
        ActionWorkItemFieldValue wifv3 = (ActionWorkItemFieldValue) fv3;
        assertEquals( "ResultIntegerField",
                      wifv3.getField() );
        assertEquals( DataType.TYPE_NUMERIC_INTEGER,
                      wifv3.getType() );
        assertEquals( "WorkItem",
                      wifv3.getWorkItemName() );
        assertEquals( "IntegerResult",
                      wifv3.getWorkItemParameterName() );
        assertEquals( Integer.class.getName(),
                      wifv3.getWorkItemParameterClassName() );

        ActionFieldValue fv4 = asf.getFieldValues()[ 3 ];
        assertNotNull( fv4 );
        assertTrue( fv4 instanceof ActionWorkItemFieldValue );
        ActionWorkItemFieldValue wifv4 = (ActionWorkItemFieldValue) fv4;
        assertEquals( "ResultStringField",
                      wifv4.getField() );
View Full Code Here

        assertEquals( asf.getVariable(),
                      "$r" );
        assertEquals( 1,
                      asf.getFieldValues().length );

        ActionFieldValue fv1 = asf.getFieldValues()[ 0 ];
        assertNotNull( fv1 );
        assertTrue( fv1 instanceof ActionWorkItemFieldValue );
        ActionWorkItemFieldValue wifv1 = (ActionWorkItemFieldValue) fv1;
        assertEquals( "ResultBooleanField",
                      wifv1.getField() );
View Full Code Here

        assertEquals( aif.getBoundName(),
                      "$r" );
        assertEquals( 4,
                      aif.getFieldValues().length );

        ActionFieldValue fv1 = aif.getFieldValues()[ 0 ];
        assertNotNull( fv1 );
        assertTrue( fv1 instanceof ActionWorkItemFieldValue );
        ActionWorkItemFieldValue wifv1 = (ActionWorkItemFieldValue) fv1;
        assertEquals( "ResultBooleanField",
                      wifv1.getField() );
        assertEquals( DataType.TYPE_BOOLEAN,
                      wifv1.getType() );
        assertEquals( "WorkItem",
                      wifv1.getWorkItemName() );
        assertEquals( "BooleanResult",
                      wifv1.getWorkItemParameterName() );
        assertEquals( Boolean.class.getName(),
                      wifv1.getWorkItemParameterClassName() );

        ActionFieldValue fv2 = aif.getFieldValues()[ 1 ];
        assertNotNull( fv2 );
        assertTrue( fv2 instanceof ActionWorkItemFieldValue );
        ActionWorkItemFieldValue wifv2 = (ActionWorkItemFieldValue) fv2;
        assertEquals( "ResultFloatField",
                      wifv2.getField() );
        assertEquals( DataType.TYPE_NUMERIC_FLOAT,
                      wifv2.getType() );
        assertEquals( "WorkItem",
                      wifv2.getWorkItemName() );
        assertEquals( "FloatResult",
                      wifv2.getWorkItemParameterName() );
        assertEquals( Float.class.getName(),
                      wifv2.getWorkItemParameterClassName() );

        ActionFieldValue fv3 = aif.getFieldValues()[ 2 ];
        assertNotNull( fv3 );
        assertTrue( fv3 instanceof ActionWorkItemFieldValue );
        ActionWorkItemFieldValue wifv3 = (ActionWorkItemFieldValue) fv3;
        assertEquals( "ResultIntegerField",
                      wifv3.getField() );
        assertEquals( DataType.TYPE_NUMERIC_INTEGER,
                      wifv3.getType() );
        assertEquals( "WorkItem",
                      wifv3.getWorkItemName() );
        assertEquals( "IntegerResult",
                      wifv3.getWorkItemParameterName() );
        assertEquals( Integer.class.getName(),
                      wifv3.getWorkItemParameterClassName() );

        ActionFieldValue fv4 = aif.getFieldValues()[ 3 ];
        assertNotNull( fv4 );
        assertTrue( fv4 instanceof ActionWorkItemFieldValue );
        ActionWorkItemFieldValue wifv4 = (ActionWorkItemFieldValue) fv4;
        assertEquals( "ResultStringField",
                      wifv4.getField() );
View Full Code Here

        assertEquals( aif.getBoundName(),
                      "$r" );
        assertEquals( 1,
                      aif.getFieldValues().length );

        ActionFieldValue fv1 = aif.getFieldValues()[ 0 ];
        assertNotNull( fv1 );
        assertTrue( fv1 instanceof ActionWorkItemFieldValue );
        ActionWorkItemFieldValue wifv1 = (ActionWorkItemFieldValue) fv1;
        assertEquals( "ResultBooleanField",
                      wifv1.getField() );
View Full Code Here

        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 );
        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( 1,
                      rm.rhs.length );
        assertEquals( "Baddie",
                      ( (ActionInsertFact) rm.rhs[ 0 ] ).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() );

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

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

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

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

    }
View Full Code Here

TOP

Related Classes of org.drools.workbench.models.commons.shared.rule.ActionFieldValue

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.