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

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


        con1.setConstraintValueType( SingleFieldConstraint.TYPE_LITERAL );
        fp1.addConstraint( con1 );
        m.addLhsItem( fp1 );

        ActionExecuteWorkItem awi = new ActionExecuteWorkItem();
        PortableWorkDefinition pwd = new PortableWorkDefinition();
        pwd.setName( "WorkItem" );
        awi.setWorkDefinition( pwd );

        PortableBooleanParameterDefinition p1 = new PortableBooleanParameterDefinition();
        p1.setName( "BooleanParameter" );
        p1.setBinding( "$b2" );
        p1.setValue( Boolean.TRUE );
        pwd.addParameter( p1 );

        PortableFloatParameterDefinition p2 = new PortableFloatParameterDefinition();
        p2.setName( "FloatParameter" );
        p2.setBinding( "$f2" );
        p2.setValue( 123.456f );
        pwd.addParameter( p2 );

        PortableIntegerParameterDefinition p3 = new PortableIntegerParameterDefinition();
        p3.setName( "IntegerParameter" );
        p3.setBinding( "$i2" );
        p3.setValue( 123 );
        pwd.addParameter( p3 );

        PortableStringParameterDefinition p4 = new PortableStringParameterDefinition();
        p4.setName( "StringParameter" );
        p4.setBinding( "$s2" );
        p4.setValue( "hello" );
        pwd.addParameter( p4 );

        m.addRhsItem( awi );

        String result = RuleModelDRLPersistenceImpl.getInstance().marshal( m );
View Full Code Here


        FactPattern fp1 = new FactPattern( "Results" );
        fp1.setBoundName( "$r" );
        m.addLhsItem( fp1 );

        ActionExecuteWorkItem awi = new ActionExecuteWorkItem();
        PortableWorkDefinition pwd = new PortableWorkDefinition();
        pwd.setName( "WorkItem" );
        awi.setWorkDefinition( 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 );

        m.addRhsItem( awi );

        ActionSetField asf = new ActionSetField();
        asf.setVariable( "$r" );
View Full Code Here

        RuleModel m = new RuleModel();
        m.name = "WorkItem";

        ActionExecuteWorkItem awi = new ActionExecuteWorkItem();
        PortableWorkDefinition pwd = new PortableWorkDefinition();
        pwd.setName( "WorkItem" );
        awi.setWorkDefinition( 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 );

        m.addRhsItem( awi );

        ActionInsertFact aif = new ActionInsertFact();
        aif.setBoundName( "$r" );
View Full Code Here

    private PortableWorkDefinition cloneWorkItemDefinition( PortableWorkDefinition pwd ) {
        if ( pwd == null ) {
            return null;
        }
        PortableWorkDefinition clone = new PortableWorkDefinition();
        clone.setName( pwd.getName() );
        clone.setDisplayName( pwd.getDisplayName() );
        clone.setParameters( cloneParameters( pwd.getParameters() ) );
        clone.setResults( cloneParameters( pwd.getResults() ) );
        return clone;
    }
View Full Code Here

    }

    private void showWorkItemParameters() {

        //Hide parameter selections if a Work Item has not been selected
        PortableWorkDefinition wid = editingCol.getWorkItemDefinition();
        if ( wid == null ) {
            this.setAttributeVisibility( workItemInputParametersIndex,
                                         false );
            return;
        }

        //Show parameters
        this.setAttributeVisibility( workItemInputParametersIndex,
                                     true );

        //Input parameters
        workItemInputParameters.setParameters( wid.getParameters() );

    }
View Full Code Here

    private PortableWorkDefinition cloneWorkItemDefinition( PortableWorkDefinition pwd ) {
        if ( pwd == null ) {
            return null;
        }
        PortableWorkDefinition clone = new PortableWorkDefinition();
        clone.setName( pwd.getName() );
        clone.setDisplayName( pwd.getDisplayName() );
        clone.setParameters( cloneParameters( pwd.getParameters() ) );
        clone.setResults( cloneParameters( pwd.getResults() ) );
        return clone;
    }
View Full Code Here

    }

    private void showWorkItemParameters() {

        //Hide parameter selections if a Work Item has not been selected
        PortableWorkDefinition wid = editingCol.getWorkItemDefinition();
        if ( wid == null ) {
            this.setAttributeVisibility( workItemInputParametersIndex,
                                         false );
            return;
        }

        //Show parameters
        this.setAttributeVisibility( workItemInputParametersIndex,
                                     true );

        //Input parameters
        workItemInputParameters.setParameters( wid.getParameters() );

    }
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

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

        ActionWorkItemCol52 awi = new ActionWorkItemCol52();
        PortableWorkDefinition pwd = new PortableWorkDefinition();
        pwd.setName( "work-item" );
        awi.setWorkItemDefinition( pwd );

        PortableBooleanParameterDefinition p1 = new PortableBooleanParameterDefinition();
        p1.setName( "BooleanParameter" );
        p1.setValue( Boolean.TRUE );
        pwd.addParameter( p1 );

        PortableFloatParameterDefinition p2 = new PortableFloatParameterDefinition();
        p2.setName( "FloatParameter" );
        p2.setValue( 123.456f );
        pwd.addParameter( p2 );

        PortableIntegerParameterDefinition p3 = new PortableIntegerParameterDefinition();
        p3.setName( "IntegerParameter" );
        p3.setValue( 123 );
        pwd.addParameter( p3 );

        PortableStringParameterDefinition p4 = new PortableStringParameterDefinition();
        p4.setName( "StringParameter" );
        p4.setValue( "hello" );
        pwd.addParameter( p4 );

        cols.add( awi );

        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( 1,
                      rm.rhs.length );

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

        PortableWorkDefinition mpwd = aw.getWorkDefinition();
        assertNotNull( mpwd );

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

        PortableBooleanParameterDefinition mp1 = (PortableBooleanParameterDefinition) mpwd.getParameter( "BooleanParameter" );
        assertNotNull( mp1 );
        assertEquals( Boolean.TRUE,
                      mp1.getValue() );

        PortableFloatParameterDefinition mp2 = (PortableFloatParameterDefinition) mpwd.getParameter( "FloatParameter" );
        assertNotNull( mp2 );
        assertEquals( new Float( 123.456f ),
                      mp2.getValue() );

        PortableIntegerParameterDefinition mp3 = (PortableIntegerParameterDefinition) mpwd.getParameter( "IntegerParameter" );
        assertNotNull( mp3 );
        assertEquals( new Integer( 123 ),
                      mp3.getValue() );

        PortableStringParameterDefinition mp4 = (PortableStringParameterDefinition) mpwd.getParameter( "StringParameter" );
        assertNotNull( mp4 );
        assertEquals( "hello",
                      mp4.getValue() );

    }
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( "work-item" );
        awi.setWorkItemDefinition( pwd );

        PortableBooleanParameterDefinition p1 = new PortableBooleanParameterDefinition();
        p1.setName( "BooleanParameter" );
        p1.setValue( Boolean.TRUE );
        p1.setBinding( "$b" );
        pwd.addParameter( p1 );

        PortableFloatParameterDefinition p2 = new PortableFloatParameterDefinition();
        p2.setName( "FloatParameter" );
        p2.setValue( 123.456f );
        p2.setBinding( "$f" );
        pwd.addParameter( p2 );

        PortableIntegerParameterDefinition p3 = new PortableIntegerParameterDefinition();
        p3.setName( "IntegerParameter" );
        p3.setValue( 123 );
        p3.setBinding( "$i" );
        pwd.addParameter( p3 );

        PortableStringParameterDefinition p4 = new PortableStringParameterDefinition();
        p4.setName( "StringParameter" );
        p4.setValue( "hello" );
        p4.setBinding( "$s" );
        pwd.addParameter( p4 );

        cols.add( awi );

        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( 1,
                      rm.rhs.length );

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

        PortableWorkDefinition mpwd = aw.getWorkDefinition();
        assertNotNull( mpwd );

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

        PortableBooleanParameterDefinition mp1 = (PortableBooleanParameterDefinition) mpwd.getParameter( "BooleanParameter" );
        assertNotNull( mp1 );
        assertEquals( Boolean.TRUE,
                      mp1.getValue() );
        assertEquals( "$b",
                      mp1.getBinding() );

        PortableFloatParameterDefinition mp2 = (PortableFloatParameterDefinition) mpwd.getParameter( "FloatParameter" );
        assertNotNull( mp2 );
        assertEquals( new Float( 123.456f ),
                      mp2.getValue() );
        assertEquals( "$f",
                      mp2.getBinding() );

        PortableIntegerParameterDefinition mp3 = (PortableIntegerParameterDefinition) mpwd.getParameter( "IntegerParameter" );
        assertNotNull( mp3 );
        assertEquals( new Integer( 123 ),
                      mp3.getValue() );
        assertEquals( "$i",
                      mp3.getBinding() );

        PortableStringParameterDefinition mp4 = (PortableStringParameterDefinition) mpwd.getParameter( "StringParameter" );
        assertNotNull( mp4 );
        assertEquals( "hello",
                      mp4.getValue() );
        assertEquals( "$s",
                      mp4.getBinding() );
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.