Package org.drools.workbench.models.datamodel.workitems

Examples of org.drools.workbench.models.datamodel.workitems.PortableWorkDefinition


        allColumns.add( new RowNumberCol52() );
        allColumns.add( new DescriptionCol52() );
        List<ActionCol52> cols = new ArrayList<ActionCol52>();

        ActionWorkItemCol52 awi = new ActionWorkItemCol52();
        PortableWorkDefinition pwd = new PortableWorkDefinition();
        pwd.setName( "WorkItem" );
        awi.setWorkItemDefinition( pwd );

        PortableBooleanParameterDefinition p1 = new PortableBooleanParameterDefinition();
        p1.setName( "BooleanResult" );
        pwd.addResult( p1 );

        PortableFloatParameterDefinition p2 = new PortableFloatParameterDefinition();
        p2.setName( "FloatResult" );
        pwd.addResult( p2 );

        PortableIntegerParameterDefinition p3 = new PortableIntegerParameterDefinition();
        p3.setName( "IntegerResult" );
        pwd.addResult( p3 );

        PortableStringParameterDefinition p4 = new PortableStringParameterDefinition();
        p4.setName( "StringResult" );
        pwd.addResult( p4 );

        cols.add( awi );

        ActionWorkItemSetFieldCol52 asf1 = new ActionWorkItemSetFieldCol52();
        asf1.setBoundName( "$r" );
        asf1.setFactField( "ResultBooleanField" );
        asf1.setType( DataType.TYPE_BOOLEAN );
        asf1.setWorkItemName( "WorkItem" );
        asf1.setWorkItemResultParameterName( "BooleanResult" );
        asf1.setParameterClassName( Boolean.class.getName() );
        cols.add( asf1 );

        ActionWorkItemSetFieldCol52 asf2 = new ActionWorkItemSetFieldCol52();
        asf2.setBoundName( "$r" );
        asf2.setFactField( "ResultFloatField" );
        asf2.setType( DataType.TYPE_NUMERIC_FLOAT );
        asf2.setWorkItemName( "WorkItem" );
        asf2.setWorkItemResultParameterName( "FloatResult" );
        asf2.setParameterClassName( Float.class.getName() );
        cols.add( asf2 );

        ActionWorkItemSetFieldCol52 asf3 = new ActionWorkItemSetFieldCol52();
        asf3.setBoundName( "$r" );
        asf3.setFactField( "ResultIntegerField" );
        asf3.setType( DataType.TYPE_NUMERIC_INTEGER );
        asf3.setWorkItemName( "WorkItem" );
        asf3.setWorkItemResultParameterName( "IntegerResult" );
        asf3.setParameterClassName( Integer.class.getName() );
        cols.add( asf3 );

        ActionWorkItemSetFieldCol52 asf4 = new ActionWorkItemSetFieldCol52();
        asf4.setBoundName( "$r" );
        asf4.setFactField( "ResultStringField" );
        asf4.setType( DataType.TYPE_STRING );
        asf4.setWorkItemName( "WorkItem" );
        asf4.setWorkItemResultParameterName( "StringResult" );
        asf4.setParameterClassName( String.class.getName() );
        cols.add( asf4 );

        RuleModel rm = new RuleModel();
        allColumns.addAll( cols );

        //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.doActions( allColumns,
                     cols,
                     rowDataProvider,
                     rowData,
                     rm );
        assertEquals( 2,
                      rm.rhs.length );

        //Examine RuleModel actions
        ActionExecuteWorkItem aw = (ActionExecuteWorkItem) rm.rhs[ 0 ];
        assertNotNull( aw );

        ActionSetField asf = (ActionSetField) rm.rhs[ 1 ];
        assertNotNull( asf );

        //Check ActionExecuteWorkItem
        PortableWorkDefinition mpwd = aw.getWorkDefinition();
        assertNotNull( mpwd );

        assertEquals( 4,
                      mpwd.getResults().size() );

        PortableBooleanParameterDefinition mp1 = (PortableBooleanParameterDefinition) mpwd.getResult( "BooleanResult" );
        assertNotNull( mp1 );

        PortableFloatParameterDefinition mp2 = (PortableFloatParameterDefinition) mpwd.getResult( "FloatResult" );
        assertNotNull( mp2 );

        PortableIntegerParameterDefinition mp3 = (PortableIntegerParameterDefinition) mpwd.getResult( "IntegerResult" );
        assertNotNull( mp3 );

        PortableStringParameterDefinition mp4 = (PortableStringParameterDefinition) mpwd.getResult( "StringResult" );
        assertNotNull( mp4 );

        //Check ActionSetField
        assertEquals( asf.getVariable(),
                      "$r" );
View Full Code Here


        allColumns.add( new RowNumberCol52() );
        allColumns.add( new DescriptionCol52() );
        List<ActionCol52> cols = new ArrayList<ActionCol52>();

        ActionWorkItemCol52 awi = new ActionWorkItemCol52();
        PortableWorkDefinition pwd = new PortableWorkDefinition();
        pwd.setName( "WorkItem" );
        awi.setWorkItemDefinition( pwd );

        PortableBooleanParameterDefinition p1 = new PortableBooleanParameterDefinition();
        p1.setName( "BooleanResult" );
        pwd.addResult( p1 );

        PortableFloatParameterDefinition p2 = new PortableFloatParameterDefinition();
        p2.setName( "FloatResult" );
        pwd.addResult( p2 );

        cols.add( awi );

        ActionWorkItemSetFieldCol52 asf1 = new ActionWorkItemSetFieldCol52();
        asf1.setBoundName( "$r" );
        asf1.setFactField( "ResultBooleanField" );
        asf1.setType( DataType.TYPE_BOOLEAN );
        asf1.setWorkItemName( "WorkItem" );
        asf1.setWorkItemResultParameterName( "BooleanResult" );
        asf1.setParameterClassName( Boolean.class.getName() );
        cols.add( asf1 );

        ActionWorkItemSetFieldCol52 asf2 = new ActionWorkItemSetFieldCol52();
        asf2.setBoundName( "$r" );
        asf2.setFactField( "ResultFloatField" );
        asf2.setType( DataType.TYPE_NUMERIC_FLOAT );
        asf2.setWorkItemName( "WorkItem" );
        asf2.setWorkItemResultParameterName( "FloatResult" );
        asf2.setParameterClassName( Float.class.getName() );
        cols.add( asf2 );

        RuleModel rm = new RuleModel();
        allColumns.addAll( cols );

        //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.doActions( allColumns,
                     cols,
                     rowDataProvider,
                     rowData,
                     rm );
        assertEquals( 2,
                      rm.rhs.length );

        //Examine RuleModel actions
        ActionExecuteWorkItem aw = (ActionExecuteWorkItem) rm.rhs[ 0 ];
        assertNotNull( aw );

        ActionSetField asf = (ActionSetField) rm.rhs[ 1 ];
        assertNotNull( asf );

        //Check ActionExecuteWorkItem
        PortableWorkDefinition mpwd = aw.getWorkDefinition();
        assertNotNull( mpwd );

        assertEquals( 2,
                      mpwd.getResults().size() );

        PortableBooleanParameterDefinition mp1 = (PortableBooleanParameterDefinition) mpwd.getResult( "BooleanResult" );
        assertNotNull( mp1 );

        PortableFloatParameterDefinition mp2 = (PortableFloatParameterDefinition) mpwd.getResult( "FloatResult" );
        assertNotNull( mp2 );

        //Check ActionSetField
        assertEquals( asf.getVariable(),
                      "$r" );
View Full Code Here

        allColumns.add( new RowNumberCol52() );
        allColumns.add( new DescriptionCol52() );
        List<ActionCol52> cols = new ArrayList<ActionCol52>();

        ActionWorkItemCol52 awi = new ActionWorkItemCol52();
        PortableWorkDefinition pwd = new PortableWorkDefinition();
        pwd.setName( "WorkItem" );
        awi.setWorkItemDefinition( pwd );

        PortableBooleanParameterDefinition p1 = new PortableBooleanParameterDefinition();
        p1.setName( "BooleanResult" );
        pwd.addResult( p1 );

        PortableFloatParameterDefinition p2 = new PortableFloatParameterDefinition();
        p2.setName( "FloatResult" );
        pwd.addResult( p2 );

        PortableIntegerParameterDefinition p3 = new PortableIntegerParameterDefinition();
        p3.setName( "IntegerResult" );
        pwd.addResult( p3 );

        PortableStringParameterDefinition p4 = new PortableStringParameterDefinition();
        p4.setName( "StringResult" );
        pwd.addResult( p4 );

        cols.add( awi );

        ActionWorkItemInsertFactCol52 asf1 = new ActionWorkItemInsertFactCol52();
        asf1.setBoundName( "$r" );
        asf1.setFactField( "ResultBooleanField" );
        asf1.setType( DataType.TYPE_BOOLEAN );
        asf1.setWorkItemName( "WorkItem" );
        asf1.setWorkItemResultParameterName( "BooleanResult" );
        asf1.setParameterClassName( Boolean.class.getName() );
        cols.add( asf1 );

        ActionWorkItemInsertFactCol52 asf2 = new ActionWorkItemInsertFactCol52();
        asf2.setBoundName( "$r" );
        asf2.setFactField( "ResultFloatField" );
        asf2.setType( DataType.TYPE_NUMERIC_FLOAT );
        asf2.setWorkItemName( "WorkItem" );
        asf2.setWorkItemResultParameterName( "FloatResult" );
        asf2.setParameterClassName( Float.class.getName() );
        cols.add( asf2 );

        ActionWorkItemInsertFactCol52 asf3 = new ActionWorkItemInsertFactCol52();
        asf3.setBoundName( "$r" );
        asf3.setFactField( "ResultIntegerField" );
        asf3.setType( DataType.TYPE_NUMERIC_INTEGER );
        asf3.setWorkItemName( "WorkItem" );
        asf3.setWorkItemResultParameterName( "IntegerResult" );
        asf3.setParameterClassName( Integer.class.getName() );
        cols.add( asf3 );

        ActionWorkItemInsertFactCol52 asf4 = new ActionWorkItemInsertFactCol52();
        asf4.setBoundName( "$r" );
        asf4.setFactField( "ResultStringField" );
        asf4.setType( DataType.TYPE_STRING );
        asf4.setWorkItemName( "WorkItem" );
        asf4.setWorkItemResultParameterName( "StringResult" );
        asf4.setParameterClassName( String.class.getName() );
        cols.add( asf4 );

        RuleModel rm = new RuleModel();
        allColumns.addAll( cols );

        //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.doActions( allColumns,
                     cols,
                     rowDataProvider,
                     rowData,
                     rm );
        assertEquals( 2,
                      rm.rhs.length );

        //Examine RuleModel actions
        ActionExecuteWorkItem aw = (ActionExecuteWorkItem) rm.rhs[ 0 ];
        assertNotNull( aw );

        ActionInsertFact aif = (ActionInsertFact) rm.rhs[ 1 ];
        assertNotNull( aif );

        //Check ActionExecuteWorkItem
        PortableWorkDefinition mpwd = aw.getWorkDefinition();
        assertNotNull( mpwd );

        assertEquals( 4,
                      mpwd.getResults().size() );

        PortableBooleanParameterDefinition mp1 = (PortableBooleanParameterDefinition) mpwd.getResult( "BooleanResult" );
        assertNotNull( mp1 );

        PortableFloatParameterDefinition mp2 = (PortableFloatParameterDefinition) mpwd.getResult( "FloatResult" );
        assertNotNull( mp2 );

        PortableIntegerParameterDefinition mp3 = (PortableIntegerParameterDefinition) mpwd.getResult( "IntegerResult" );
        assertNotNull( mp3 );

        PortableStringParameterDefinition mp4 = (PortableStringParameterDefinition) mpwd.getResult( "StringResult" );
        assertNotNull( mp4 );

        //Check ActionInsertFact
        assertEquals( aif.getBoundName(),
                      "$r" );
View Full Code Here

        allColumns.add( new RowNumberCol52() );
        allColumns.add( new DescriptionCol52() );
        List<ActionCol52> cols = new ArrayList<ActionCol52>();

        ActionWorkItemCol52 awi = new ActionWorkItemCol52();
        PortableWorkDefinition pwd = new PortableWorkDefinition();
        pwd.setName( "WorkItem" );
        awi.setWorkItemDefinition( pwd );

        PortableBooleanParameterDefinition p1 = new PortableBooleanParameterDefinition();
        p1.setName( "BooleanResult" );
        pwd.addResult( p1 );

        PortableFloatParameterDefinition p2 = new PortableFloatParameterDefinition();
        p2.setName( "FloatResult" );
        pwd.addResult( p2 );

        cols.add( awi );

        ActionWorkItemInsertFactCol52 asf1 = new ActionWorkItemInsertFactCol52();
        asf1.setBoundName( "$r" );
        asf1.setFactField( "ResultBooleanField" );
        asf1.setType( DataType.TYPE_BOOLEAN );
        asf1.setWorkItemName( "WorkItem" );
        asf1.setWorkItemResultParameterName( "BooleanResult" );
        asf1.setParameterClassName( Boolean.class.getName() );
        cols.add( asf1 );

        ActionWorkItemInsertFactCol52 asf2 = new ActionWorkItemInsertFactCol52();
        asf2.setBoundName( "$r" );
        asf2.setFactField( "ResultFloatField" );
        asf2.setType( DataType.TYPE_NUMERIC_FLOAT );
        asf2.setWorkItemName( "WorkItem" );
        asf2.setWorkItemResultParameterName( "FloatResult" );
        asf2.setParameterClassName( Float.class.getName() );
        cols.add( asf2 );

        RuleModel rm = new RuleModel();
        allColumns.addAll( cols );

        //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.doActions( allColumns,
                     cols,
                     rowDataProvider,
                     rowData,
                     rm );
        assertEquals( 2,
                      rm.rhs.length );

        //Examine RuleModel actions
        ActionExecuteWorkItem aw = (ActionExecuteWorkItem) rm.rhs[ 0 ];
        assertNotNull( aw );

        ActionInsertFact aif = (ActionInsertFact) rm.rhs[ 1 ];
        assertNotNull( aif );

        //Check ActionExecuteWorkItem
        PortableWorkDefinition mpwd = aw.getWorkDefinition();
        assertNotNull( mpwd );

        assertEquals( 2,
                      mpwd.getResults().size() );

        PortableBooleanParameterDefinition mp1 = (PortableBooleanParameterDefinition) mpwd.getResult( "BooleanResult" );
        assertNotNull( mp1 );

        PortableFloatParameterDefinition mp2 = (PortableFloatParameterDefinition) mpwd.getResult( "FloatResult" );
        assertNotNull( mp2 );

        //Check ActionInsertFact
        assertEquals( aif.getBoundName(),
                      "$r" );
View Full Code Here

                           String rhs,
                           boolean isJavaDialect,
                           Map<String, String> boundParams,
                           ExpandedDRLInfo expandedDRLInfo,
                           PackageDataModelOracle dmo ) {
        PortableWorkDefinition pwd = null;
        Map<String, List<String>> setStatements = new HashMap<String, List<String>>();
        Map<String, Integer> setStatementsPosition = new HashMap<String, Integer>();
        Map<String, String> factsType = new HashMap<String, String>();

        int lineCounter = -1;
        String[] lines = rhs.split( "\n" );
        for ( String line : lines ) {
            lineCounter++;
            if ( expandedDRLInfo.hasDsl ) {
                String dslLine = expandedDRLInfo.dslStatementsInRhs.get( lineCounter );
                while ( dslLine != null ) {
                    m.addRhsItem( toDSLSentence( expandedDRLInfo.rhsDslPatterns, dslLine ) );
                    dslLine = expandedDRLInfo.dslStatementsInRhs.get( ++lineCounter );
                }
            }
            line = line.trim();
            if ( line.startsWith( "insertLogical" ) ) {
                String fact = unwrapParenthesis( line );
                String type = getStatementType( fact, factsType );
                if ( type != null ) {
                    ActionInsertLogicalFact action = new ActionInsertLogicalFact( type );
                    m.addRhsItem( action );
                    if ( factsType.containsKey( fact ) ) {
                        addSettersToAction( setStatements,
                                            fact,
                                            action,
                                            boundParams,
                                            dmo,
                                            m.getImports(),
                                            isJavaDialect );
                    }
                }
            } else if ( line.startsWith( "insert" ) ) {
                String fact = unwrapParenthesis( line );
                String type = getStatementType( fact, factsType );
                if ( type != null ) {
                    ActionInsertFact action = new ActionInsertFact( type );
                    m.addRhsItem( action );
                    if ( factsType.containsKey( fact ) ) {
                        action.setBoundName( fact );
                        addSettersToAction( setStatements,
                                            fact,
                                            action,
                                            boundParams,
                                            dmo,
                                            m.getImports(),
                                            isJavaDialect );
                    }
                }
            } else if ( line.startsWith( "update" ) ) {
                String variable = unwrapParenthesis( line );
                ActionUpdateField action = new ActionUpdateField();
                action.setVariable( variable );
                m.addRhsItem( action );
                addSettersToAction( setStatements,
                                    variable,
                                    action,
                                    boundParams,
                                    dmo,
                                    m.getImports(),
                                    isJavaDialect );
            } else if ( line.startsWith( "retract" ) ) {
                String variable = unwrapParenthesis( line );
                m.addRhsItem( new ActionRetractFact( variable ) );
            } else if ( line.startsWith( "org.drools.core.process.instance.impl.WorkItemImpl wiWorkItem" ) ) {
                ActionExecuteWorkItem awi = new ActionExecuteWorkItem();
                pwd = new PortableWorkDefinition();
                pwd.setName( "WorkItem" );
                awi.setWorkDefinition( pwd );
                m.addRhsItem( awi );
            } else if ( line.startsWith( "wiWorkItem.getParameters().put" ) ) {
                String statement = line.substring( "wiWorkItem.getParameters().put".length() );
                statement = unwrapParenthesis( statement );
                int commaPos = statement.indexOf( ',' );
                String name = statement.substring( 0, commaPos ).trim();
                String value = statement.substring( commaPos + 1 ).trim();
                pwd.addParameter( buildPortableParameterDefinition( name, value, boundParams ) );
            } else if ( line.startsWith( "wim.internalExecuteWorkItem" ) || line.startsWith( "wiWorkItem.setName" ) ) {
                // ignore
            } else {
                int dotPos = line.indexOf( '.' );
                int argStart = line.indexOf( '(' );
View Full Code Here

        //Get list of Work Items executed by Actions
        List<PortableWorkDefinition> actionWorkItems = new ArrayList<PortableWorkDefinition>();
        for ( ActionCol52 ac : model.getActionCols() ) {
            if ( ac instanceof ActionWorkItemCol52 ) {
                PortableWorkDefinition pwd = ( (ActionWorkItemCol52) ac ).getWorkItemDefinition();
                actionWorkItems.add( pwd );
            }
        }

        //Populate list of available result parameters
        if ( actionWorkItems.size() == 0 ) {
            workItemResultParameters.setEnabled( false );
            workItemResultParameters.addItem( GuidedDecisionTableConstants.INSTANCE.NoWorkItemsAvailable() );
            editingCol.setWorkItemName( null );
            editingCol.setWorkItemResultParameterName( null );
            editingCol.setParameterClassName( null );
        } else {
            int selectedItemIndex = -1;
            String selectedItemKey = editingCol.getWorkItemName() + "" + editingCol.getWorkItemResultParameterName();
            workItemResultParameters.setEnabled( true && !isReadOnly );
            for ( PortableWorkDefinition pwd : actionWorkItems ) {
                for ( PortableParameterDefinition ppd : pwd.getResults() ) {
                    if ( acceptParameterType( ppd ) ) {
                        String key = pwd.getName() + "" + ppd.getName();
                        String parameterDisplayName = pwd.getDisplayName() + "" + ppd.getName();

                        //Pre-select item if applicable
                        if ( key.equals( selectedItemKey ) ) {
                            selectedItemIndex = workItemResultParameters.getItemCount();
                        }
View Full Code Here

TOP

Related Classes of org.drools.workbench.models.datamodel.workitems.PortableWorkDefinition

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.