Package org.drools.ide.common.client.modeldriven.dt

Examples of org.drools.ide.common.client.modeldriven.dt.ActionInsertFactCol


    @Test
    public void testRoundTrip() {

        TypeSafeGuidedDecisionTable dt = new TypeSafeGuidedDecisionTable();

        dt.getActionCols().add( new ActionInsertFactCol() );
        ActionSetFieldCol set = new ActionSetFieldCol();
        set.setFactField( "foo" );
        dt.getActionCols().add( set );

        dt.getMetadataCols().add( new MetadataCol() );
View Full Code Here


        con4.setFactType( "Driver" );
        con4.setHeader( "Driver 2 pimp" );
        con4.setFactField( "(not needed)" );
        dt.getConditionCols().add( con4 );

        ActionInsertFactCol ins = new ActionInsertFactCol();
        ins.setBoundName( "ins" );
        ins.setFactType( "Cheese" );
        ins.setFactField( "price" );
        ins.setType( SuggestionCompletionEngine.TYPE_NUMERIC );
        dt.getActionCols().add( ins );

        ActionRetractFactCol ret = new ActionRetractFactCol();
        ret.setBoundName( "f2" );
        dt.getActionCols().add( ret );

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

        ActionSetFieldCol set2 = new ActionSetFieldCol();
        set2.setBoundName( "f1" );
        set2.setFactField( "goo2" );
        set2.setDefaultValue( "whee" );
        set2.setType( SuggestionCompletionEngine.TYPE_STRING );
        dt.getActionCols().add( set2 );

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

        TypeSafeGuidedDecisionTable tsdt = RepositoryUpgradeHelper.convertGuidedDTModel( dt );

        assertEquals( "michael",
                      tsdt.getTableName() );

        assertEquals( 1,
                      tsdt.getMetadataCols().size() );
        assertEquals( "legacy",
                      tsdt.getMetadataCols().get( 0 ).getMetadata() );
        assertEquals( "yes",
                      tsdt.getMetadataCols().get( 0 ).getDefaultValue() );

        assertEquals( 1,
                      tsdt.getAttributeCols().size() );
        assertEquals( "salience",
                      tsdt.getAttributeCols().get( 0 ).getAttribute() );
        assertEquals( "66",
                      tsdt.getAttributeCols().get( 0 ).getDefaultValue() );

        assertEquals( 4,
                      tsdt.getConditionCols().size() );

        assertEquals( "f1",
                      tsdt.getConditionCols().get( 0 ).getBoundName() );
        assertEquals( BaseSingleFieldConstraint.TYPE_LITERAL,
                      tsdt.getConditionCols().get( 0 ).getConstraintValueType() );
        assertEquals( "age",
                      tsdt.getConditionCols().get( 0 ).getFactField() );
        assertEquals( "Driver",
                      tsdt.getConditionCols().get( 0 ).getFactType() );
        assertEquals( "Driver f1 age",
                      tsdt.getConditionCols().get( 0 ).getHeader() );
        assertEquals( "==",
                      tsdt.getConditionCols().get( 0 ).getOperator() );

        assertEquals( "f1",
                      tsdt.getConditionCols().get( 1 ).getBoundName() );
        assertEquals( BaseSingleFieldConstraint.TYPE_LITERAL,
                      tsdt.getConditionCols().get( 1 ).getConstraintValueType() );
        assertEquals( "name",
                      tsdt.getConditionCols().get( 1 ).getFactField() );
        assertEquals( "Driver",
                      tsdt.getConditionCols().get( 1 ).getFactType() );
        assertEquals( "Driver f1 name",
                      tsdt.getConditionCols().get( 1 ).getHeader() );
        assertEquals( "==",
                      tsdt.getConditionCols().get( 1 ).getOperator() );

        assertEquals( "f1",
                      tsdt.getConditionCols().get( 2 ).getBoundName() );
        assertEquals( BaseSingleFieldConstraint.TYPE_RET_VALUE,
                      tsdt.getConditionCols().get( 2 ).getConstraintValueType() );
        assertEquals( "rating",
                      tsdt.getConditionCols().get( 2 ).getFactField() );
        assertEquals( "Driver",
                      tsdt.getConditionCols().get( 2 ).getFactType() );
        assertEquals( "Driver rating",
                      tsdt.getConditionCols().get( 2 ).getHeader() );
        assertEquals( "==",
                      tsdt.getConditionCols().get( 2 ).getOperator() );

        assertEquals( "f2",
                      tsdt.getConditionCols().get( 3 ).getBoundName() );
        assertEquals( BaseSingleFieldConstraint.TYPE_PREDICATE,
                      tsdt.getConditionCols().get( 3 ).getConstraintValueType() );
        assertEquals( "(not needed)",
                      tsdt.getConditionCols().get( 3 ).getFactField() );
        assertEquals( "Driver",
                      tsdt.getConditionCols().get( 3 ).getFactType() );
        assertEquals( "Driver 2 pimp",
                      tsdt.getConditionCols().get( 3 ).getHeader() );

        assertEquals( 4,
                      tsdt.getActionCols().size() );

        ActionInsertFactCol a1 = (ActionInsertFactCol) tsdt.getActionCols().get( 0 );
        assertEquals( "ins",
                      a1.getBoundName() );
        assertEquals( "Cheese",
                      a1.getFactType() );
        assertEquals( "price",
                      a1.getFactField() );
        assertEquals( SuggestionCompletionEngine.TYPE_NUMERIC,
                      a1.getType() );

        ActionRetractFactCol a2 = (ActionRetractFactCol) tsdt.getActionCols().get( 1 );
        assertEquals( "f2",
                      a2.getBoundName() );

View Full Code Here

                              final ActionInsertFactCol col,
                              final boolean isNew) {
        this.setModal( false );
        this.dtable = dtable;
        this.sce = sce;
        this.editingCol = new ActionInsertFactCol();
        editingCol.setBoundName( col.getBoundName() );
        editingCol.setType( col.getType() );
        editingCol.setFactField( col.getFactField() );
        editingCol.setFactType( col.getFactType() );
        editingCol.setHeader( col.getHeader() );
View Full Code Here

        ListBox patterns = new ListBox();

        for ( Object o : dtable.getModel().getActionCols() ) {
            ActionCol col = (ActionCol) o;
            if ( col instanceof ActionInsertFactCol ) {
                ActionInsertFactCol c = (ActionInsertFactCol) col;
                if ( !vars.contains( c.getBoundName() ) ) {
                    patterns.addItem( c.getFactType() + " [" + c.getBoundName()
                                              + "]",
                                      c.getFactType() + " " + c.getBoundName() );
                    vars.add( c.getBoundName() );
                }
            }

        }
View Full Code Here

        con4.factType = "Driver";
        con4.header = "Driver 2 pimp";
        con4.factField = "(not needed)";
        dt.conditionCols.add( con4 );

        ActionInsertFactCol ins = new ActionInsertFactCol();
        ins.boundName = "ins";
        ins.factType = "Cheese";
        ins.factField = "price";
        ins.type = SuggestionCompletionEngine.TYPE_NUMERIC;
        dt.actionCols.add( ins );
View Full Code Here

        con4.factType = "Person";
        con4.header = "Person f2 not needed";
        con4.factField = "(not needed)";
        dt.conditionCols.add( con4 );

        ActionInsertFactCol ins = new ActionInsertFactCol();
        ins.boundName = "ins";
        ins.factType = "Cheese";
        ins.factField = "price";
        ins.type = SuggestionCompletionEngine.TYPE_NUMERIC;
        dt.actionCols.add( ins );
View Full Code Here

            if ( !validCell( cell ) ) {
                cell = c.getDefaultValue();
            }
            if ( validCell( cell ) ) {
                if ( c instanceof ActionInsertFactCol ) {
                    ActionInsertFactCol ac = (ActionInsertFactCol) c;
                    LabelledAction a = findByLabelledAction( actions,
                                                             ac.getBoundName() );
                    if ( a == null ) {
                        a = new LabelledAction();
                        a.boundName = ac.getBoundName();
                        ActionInsertFact ins = new ActionInsertFact( ac.getFactType() );
                        ins.setBoundName( ac.getBoundName() );
                        a.action = ins;
                        actions.add( a );
                    }
                    ActionInsertFact ins = (ActionInsertFact) a.action;
                    ActionFieldValue val = new ActionFieldValue( ac.getFactField(),
                                                                 cell,
                                                                 ac.getType() );
                    ins.addFieldValue( val );
                } else if ( c instanceof ActionRetractFactCol ) {
                    ActionRetractFactCol rf = (ActionRetractFactCol) c;
                    LabelledAction a = findByLabelledAction( actions,
                                                             rf.getBoundName() );
View Full Code Here

        con4.factType = "Driver";
        con4.header = "Driver 2 pimp";
        con4.factField = "(not needed)";
        dt.conditionCols.add( con4 );

        ActionInsertFactCol ins = new ActionInsertFactCol();
        ins.boundName = "ins";
        ins.factType = "Cheese";
        ins.factField = "price";
        ins.type = SuggestionCompletionEngine.TYPE_NUMERIC_INTEGER;
        dt.actionCols.add( ins );
View Full Code Here

        con4.factType = "Person";
        con4.header = "Person f2 not needed";
        con4.factField = "(not needed)";
        dt.conditionCols.add( con4 );

        ActionInsertFactCol ins = new ActionInsertFactCol();
        ins.boundName = "ins";
        ins.factType = "Cheese";
        ins.factField = "price";
        ins.type = SuggestionCompletionEngine.TYPE_NUMERIC_INTEGER;
        dt.actionCols.add( ins );
View Full Code Here

                cell = c.getDefaultValue();
            }

            if ( validCell( cell ) ) {
                if ( c instanceof ActionInsertFactCol ) {
                    ActionInsertFactCol ac = (ActionInsertFactCol) c;
                    LabelledAction a = findByLabelledAction( actions,
                                                             ac.getBoundName() );
                    if ( a == null ) {
                        a = new LabelledAction();
                        a.boundName = ac.getBoundName();
                        if ( !ac.isInsertLogical() ) {
                            ActionInsertFact ins = new ActionInsertFact( ac.getFactType() );
                            ins.setBoundName( ac.getBoundName() );
                            a.action = ins;
                        } else {
                            ActionInsertLogicalFact ins = new ActionInsertLogicalFact( ac.getFactType() );
                            ins.setBoundName( ac.getBoundName() );
                            a.action = ins;
                        }
                        actions.add( a );
                    }
                    ActionInsertFact ins = (ActionInsertFact) a.action;
                    ActionFieldValue val = new ActionFieldValue( ac.getFactField(),
                                                                 cell,
                                                                 ac.getType() );
                    ins.addFieldValue( val );
                } else if ( c instanceof ActionRetractFactCol ) {
                    ActionRetractFactCol rf = (ActionRetractFactCol) c;
                    LabelledAction a = findByLabelledAction( actions,
                                                             rf.getBoundName() );
View Full Code Here

TOP

Related Classes of org.drools.ide.common.client.modeldriven.dt.ActionInsertFactCol

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.