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

Examples of org.drools.ide.common.client.modeldriven.brl.ExpressionFormLine


        FactPattern fp0 = new FactPattern();
        fp0.setBoundName( "$t0" );
        fp0.setFactType( "FT0" );

        SingleFieldConstraint sfc0 = new SingleFieldConstraint();
        ExpressionFormLine efl0 = new ExpressionFormLine();
        efl0.setBinding( "$efl0" );
        ExpressionText efl0p0 = new ExpressionText( "efl0p0" );
        efl0.appendPart( efl0p0 );
        sfc0.setExpressionValue( efl0 );
        fp0.addConstraint( sfc0 );

        model.lhs[0] = fp0;

        RuleModelCloneVisitor cloneVisitor = new RuleModelCloneVisitor();
        RuleModel clone = cloneVisitor.visitRuleModel( model );

        assertEquals( 1,
                      clone.lhs.length );
        assertNotSame( model.lhs[0],
                       clone.lhs[0] );
        assertNotNull( clone.lhs[0] );
        assertTrue( clone.lhs[0] instanceof FactPattern );
        FactPattern fp0Clone = (FactPattern) clone.lhs[0];
        assertEquals( fp0.getBoundName(),
                      fp0Clone.getBoundName() );
        assertEquals( fp0.getFactType(),
                      fp0Clone.getFactType() );

        assertEquals( 1,
                      fp0Clone.constraintList.constraints.length );

        assertNotSame( fp0.constraintList.constraints[0],
                       fp0Clone.constraintList.constraints[0] );
        assertNotNull( fp0Clone.constraintList.constraints[0] );
        assertTrue( fp0Clone.constraintList.constraints[0] instanceof SingleFieldConstraint );
        SingleFieldConstraint sfc0Clone = (SingleFieldConstraint) fp0Clone.constraintList.constraints[0];

        assertNotSame( sfc0.getExpressionValue(),
                       sfc0Clone.getExpressionValue() );
        assertNotNull( sfc0Clone.getExpressionValue() );
        assertTrue( sfc0Clone.getExpressionValue() instanceof ExpressionFormLine );
        ExpressionFormLine efl0Clone = (ExpressionFormLine) sfc0Clone.getExpressionValue();

        assertEquals( 1,
                      sfc0Clone.getExpressionValue().getParts().size() );
        assertTrue( sfc0Clone.getExpressionValue().getParts().get( 0 ) instanceof ExpressionText );
        ExpressionText efl0p0Clone = (ExpressionText) sfc0Clone.getExpressionValue().getParts().get( 0 );
        assertEquals( efl0p0.getClassType(),
                      efl0p0Clone.getClassType() );
        assertEquals( efl0p0.getName(),
                      efl0p0Clone.getName() );
        assertEquals( efl0p0.getGenericType(),
                      efl0p0Clone.getGenericType() );
        assertEquals( efl0p0.getParametricType(),
                      efl0p0Clone.getParametricType() );

        assertEquals( efl0.getBinding(),
                      efl0Clone.getBinding() );
        assertEquals( efl0.getClassType(),
                      efl0Clone.getClassType() );
        assertEquals( efl0.getFieldName(),
                      efl0Clone.getFieldName() );
        assertEquals( efl0.getGenericType(),
                      efl0Clone.getGenericType() );
        assertEquals( efl0.getParametricType(),
                      efl0Clone.getParametricType() );
        assertEquals( efl0.getCurrentName(),
                      efl0Clone.getCurrentName() );
    }
View Full Code Here


        fp0.setBoundName( "$t0" );
        fp0.setFactType( "FT0" );

        SingleFieldConstraintEBLeftSide sfc0 = new SingleFieldConstraintEBLeftSide();

        ExpressionFormLine eflhs0 = new ExpressionFormLine();
        eflhs0.setBinding( "$eflhs0" );
        ExpressionText eflhs0p0 = new ExpressionText( "eflhs0p0" );
        eflhs0.appendPart( eflhs0p0 );
        sfc0.setExpressionLeftSide( eflhs0 );

        ExpressionFormLine efl0 = new ExpressionFormLine();
        efl0.setBinding( "$efl0" );
        ExpressionText efl0p0 = new ExpressionText( "efl0p0" );
        efl0.appendPart( efl0p0 );
        sfc0.setExpressionValue( efl0 );

        fp0.addConstraint( sfc0 );

        model.lhs[0] = fp0;

        RuleModelCloneVisitor cloneVisitor = new RuleModelCloneVisitor();
        RuleModel clone = cloneVisitor.visitRuleModel( model );

        assertEquals( 1,
                      clone.lhs.length );
        assertNotSame( model.lhs[0],
                       clone.lhs[0] );
        assertNotNull( clone.lhs[0] );
        assertTrue( clone.lhs[0] instanceof FactPattern );
        FactPattern fp0Clone = (FactPattern) clone.lhs[0];
        assertEquals( fp0.getBoundName(),
                      fp0Clone.getBoundName() );
        assertEquals( fp0.getFactType(),
                      fp0Clone.getFactType() );

        assertEquals( 1,
                      fp0Clone.constraintList.constraints.length );

        assertNotSame( fp0.constraintList.constraints[0],
                       fp0Clone.constraintList.constraints[0] );
        assertNotNull( fp0Clone.constraintList.constraints[0] );
        assertTrue( fp0Clone.constraintList.constraints[0] instanceof SingleFieldConstraintEBLeftSide );
        SingleFieldConstraintEBLeftSide sfc0Clone = (SingleFieldConstraintEBLeftSide) fp0Clone.constraintList.constraints[0];

        assertNotSame( sfc0.getExpressionLeftSide(),
                       sfc0Clone.getExpressionLeftSide() );
        assertNotNull( sfc0Clone.getExpressionLeftSide() );
        assertTrue( sfc0Clone.getExpressionLeftSide() instanceof ExpressionFormLine );
        ExpressionFormLine eflhs0Clone = (ExpressionFormLine) sfc0Clone.getExpressionLeftSide();

        assertEquals( 1,
                      sfc0Clone.getExpressionLeftSide().getParts().size() );
        assertTrue( sfc0Clone.getExpressionLeftSide().getParts().get( 0 ) instanceof ExpressionText );
        ExpressionText eflhs0p0Clone = (ExpressionText) sfc0Clone.getExpressionLeftSide().getParts().get( 0 );
        assertEquals( eflhs0p0.getClassType(),
                      eflhs0p0Clone.getClassType() );
        assertEquals( eflhs0p0.getName(),
                      eflhs0p0Clone.getName() );
        assertEquals( eflhs0p0.getGenericType(),
                      eflhs0p0Clone.getGenericType() );
        assertEquals( eflhs0p0.getParametricType(),
                      eflhs0p0Clone.getParametricType() );

        assertEquals( eflhs0.getBinding(),
                      eflhs0Clone.getBinding() );
        assertEquals( eflhs0.getClassType(),
                      eflhs0Clone.getClassType() );
        assertEquals( eflhs0.getFieldName(),
                      eflhs0Clone.getFieldName() );
        assertEquals( eflhs0.getGenericType(),
                      eflhs0Clone.getGenericType() );
        assertEquals( eflhs0.getParametricType(),
                      eflhs0Clone.getParametricType() );
        assertEquals( eflhs0.getCurrentName(),
                      eflhs0Clone.getCurrentName() );

        assertNotSame( sfc0.getExpressionValue(),
                       sfc0Clone.getExpressionValue() );
        assertNotNull( sfc0Clone.getExpressionValue() );
        assertTrue( sfc0Clone.getExpressionValue() instanceof ExpressionFormLine );
        ExpressionFormLine efl0Clone = (ExpressionFormLine) sfc0Clone.getExpressionValue();

        assertEquals( 1,
                      sfc0Clone.getExpressionValue().getParts().size() );
        assertTrue( sfc0Clone.getExpressionValue().getParts().get( 0 ) instanceof ExpressionText );
        ExpressionText efl0p0Clone = (ExpressionText) sfc0Clone.getExpressionValue().getParts().get( 0 );
        assertEquals( efl0p0.getClassType(),
                      efl0p0Clone.getClassType() );
        assertEquals( efl0p0.getName(),
                      efl0p0Clone.getName() );
        assertEquals( efl0p0.getGenericType(),
                      efl0p0Clone.getGenericType() );
        assertEquals( efl0p0.getParametricType(),
                      efl0p0Clone.getParametricType() );

        assertEquals( efl0.getBinding(),
                      efl0Clone.getBinding() );
        assertEquals( efl0.getClassType(),
                      efl0Clone.getClassType() );
        assertEquals( efl0.getFieldName(),
                      efl0Clone.getFieldName() );
        assertEquals( efl0.getGenericType(),
                      efl0Clone.getGenericType() );
        assertEquals( efl0.getParametricType(),
                      efl0Clone.getParametricType() );
        assertEquals( efl0.getCurrentName(),
                      efl0Clone.getCurrentName() );
    }
View Full Code Here

        RuleModel model = new RuleModel();

        model.lhs = new IPattern[1];
        FromAccumulateCompositeFactPattern fp0 = new FromAccumulateCompositeFactPattern();
        fp0.setActionCode( "fp0.actionCode" );
        ExpressionFormLine efl0 = new ExpressionFormLine();
        efl0.setBinding( "$efl0" );
        ExpressionText efl0p0 = new ExpressionText( "efl0p0" );
        efl0.appendPart( efl0p0 );
        fp0.setExpression( efl0 );
        FactPattern fp0FactPattern = new FactPattern( "fp0FactPattern" );
        fp0.setFactPattern( fp0FactPattern );
        fp0.setFunction( "fp0.function" );
        fp0.setInitCode( "fp0.initCode" );
        fp0.setResultCode( "fp0.resultCode" );
        fp0.setReverseCode( "fp0.reverseCode" );
        FactPattern fp0SourcePattern = new FactPattern( "fp0SourcePattern" );
        fp0.setSourcePattern( fp0SourcePattern );

        model.lhs[0] = fp0;

        RuleModelCloneVisitor cloneVisitor = new RuleModelCloneVisitor();
        RuleModel clone = cloneVisitor.visitRuleModel( model );

        assertEquals( 1,
                      clone.lhs.length );
        assertNotSame( model.lhs[0],
                       clone.lhs[0] );
        assertNotNull( clone.lhs[0] );
        assertTrue( clone.lhs[0] instanceof FromAccumulateCompositeFactPattern );
        FromAccumulateCompositeFactPattern fp0Clone = (FromAccumulateCompositeFactPattern) clone.lhs[0];
        assertEquals( fp0.getActionCode(),
                      fp0Clone.getActionCode() );
        assertEquals( fp0.getFunction(),
                      fp0Clone.getFunction() );
        assertEquals( fp0.getInitCode(),
                      fp0Clone.getInitCode() );
        assertEquals( fp0.getResultCode(),
                      fp0Clone.getResultCode() );
        assertEquals( fp0.getReverseCode(),
                      fp0Clone.getReverseCode() );

        assertNotSame( fp0.getExpression(),
                       fp0Clone.getExpression() );
        assertNotNull( fp0Clone.getExpression() );
        assertTrue( fp0Clone.getExpression() instanceof ExpressionFormLine );
        ExpressionFormLine efl0Clone = (ExpressionFormLine) fp0Clone.getExpression();

        assertEquals( 1,
                      fp0Clone.getExpression().getParts().size() );
        assertTrue( fp0Clone.getExpression().getParts().get( 0 ) instanceof ExpressionText );
        ExpressionText efl0p0Clone = (ExpressionText) fp0Clone.getExpression().getParts().get( 0 );
        assertEquals( efl0p0.getClassType(),
                      efl0p0Clone.getClassType() );
        assertEquals( efl0p0.getName(),
                      efl0p0Clone.getName() );
        assertEquals( efl0p0.getGenericType(),
                      efl0p0Clone.getGenericType() );
        assertEquals( efl0p0.getParametricType(),
                      efl0p0Clone.getParametricType() );

        assertEquals( efl0.getBinding(),
                      efl0Clone.getBinding() );
        assertEquals( efl0.getClassType(),
                      efl0Clone.getClassType() );
        assertEquals( efl0.getFieldName(),
                      efl0Clone.getFieldName() );
        assertEquals( efl0.getGenericType(),
                      efl0Clone.getGenericType() );
        assertEquals( efl0.getParametricType(),
                      efl0Clone.getParametricType() );
        assertEquals( efl0.getCurrentName(),
                      efl0Clone.getCurrentName() );

        assertNotSame( fp0.getFactPattern(),
                       fp0Clone.getFactPattern() );
        assertNotNull( fp0Clone.getFactPattern() );
        assertTrue( fp0Clone.getFactPattern() instanceof FactPattern );
View Full Code Here

    public void testFromCollectCompositeFactPattern() {
        RuleModel model = new RuleModel();

        model.lhs = new IPattern[1];
        FromCollectCompositeFactPattern fp0 = new FromCollectCompositeFactPattern();
        ExpressionFormLine efl0 = new ExpressionFormLine();
        efl0.setBinding( "$efl0" );
        ExpressionText efl0p0 = new ExpressionText( "efl0p0" );
        efl0.appendPart( efl0p0 );
        fp0.setExpression( efl0 );
        FactPattern fp0FactPattern = new FactPattern( "fp0FactPattern" );
        fp0.setFactPattern( fp0FactPattern );
        FactPattern fp0RightPattern = new FactPattern( "fp0RightPattern" );
        fp0.setRightPattern( fp0RightPattern );

        model.lhs[0] = fp0;

        RuleModelCloneVisitor cloneVisitor = new RuleModelCloneVisitor();
        RuleModel clone = cloneVisitor.visitRuleModel( model );

        assertEquals( 1,
                      clone.lhs.length );
        assertNotSame( model.lhs[0],
                       clone.lhs[0] );
        assertNotNull( clone.lhs[0] );
        assertTrue( clone.lhs[0] instanceof FromCollectCompositeFactPattern );
        FromCollectCompositeFactPattern fp0Clone = (FromCollectCompositeFactPattern) clone.lhs[0];

        assertNotSame( fp0.getExpression(),
                       fp0Clone.getExpression() );
        assertNotNull( fp0Clone.getExpression() );
        assertTrue( fp0Clone.getExpression() instanceof ExpressionFormLine );
        ExpressionFormLine efl0Clone = (ExpressionFormLine) fp0Clone.getExpression();

        assertEquals( 1,
                      fp0Clone.getExpression().getParts().size() );
        assertTrue( fp0Clone.getExpression().getParts().get( 0 ) instanceof ExpressionText );
        ExpressionText efl0p0Clone = (ExpressionText) fp0Clone.getExpression().getParts().get( 0 );
        assertEquals( efl0p0.getClassType(),
                      efl0p0Clone.getClassType() );
        assertEquals( efl0p0.getName(),
                      efl0p0Clone.getName() );
        assertEquals( efl0p0.getGenericType(),
                      efl0p0Clone.getGenericType() );
        assertEquals( efl0p0.getParametricType(),
                      efl0p0Clone.getParametricType() );

        assertEquals( efl0.getBinding(),
                      efl0Clone.getBinding() );
        assertEquals( efl0.getClassType(),
                      efl0Clone.getClassType() );
        assertEquals( efl0.getFieldName(),
                      efl0Clone.getFieldName() );
        assertEquals( efl0.getGenericType(),
                      efl0Clone.getGenericType() );
        assertEquals( efl0.getParametricType(),
                      efl0Clone.getParametricType() );
        assertEquals( efl0.getCurrentName(),
                      efl0Clone.getCurrentName() );

        assertNotSame( fp0.getFactPattern(),
                       fp0Clone.getFactPattern() );
        assertNotNull( fp0Clone.getFactPattern() );
        assertTrue( fp0Clone.getFactPattern() instanceof FactPattern );
View Full Code Here

    public void testFromCompositeFactPattern() {
        RuleModel model = new RuleModel();

        model.lhs = new IPattern[1];
        FromCompositeFactPattern fp0 = new FromCompositeFactPattern();
        ExpressionFormLine efl0 = new ExpressionFormLine();
        efl0.setBinding( "$efl0" );
        ExpressionText efl0p0 = new ExpressionText( "efl0p0" );
        efl0.appendPart( efl0p0 );
        fp0.setExpression( efl0 );
        FactPattern fp0FactPattern = new FactPattern( "fp0FactPattern" );
        fp0.setFactPattern( fp0FactPattern );

        model.lhs[0] = fp0;

        RuleModelCloneVisitor cloneVisitor = new RuleModelCloneVisitor();
        RuleModel clone = cloneVisitor.visitRuleModel( model );

        assertEquals( 1,
                      clone.lhs.length );
        assertNotSame( model.lhs[0],
                       clone.lhs[0] );
        assertNotNull( clone.lhs[0] );
        assertTrue( clone.lhs[0] instanceof FromCompositeFactPattern );
        FromCompositeFactPattern fp0Clone = (FromCompositeFactPattern) clone.lhs[0];

        assertNotSame( fp0.getExpression(),
                       fp0Clone.getExpression() );
        assertNotNull( fp0Clone.getExpression() );
        assertTrue( fp0Clone.getExpression() instanceof ExpressionFormLine );
        ExpressionFormLine efl0Clone = (ExpressionFormLine) fp0Clone.getExpression();

        assertEquals( 1,
                      fp0Clone.getExpression().getParts().size() );
        assertTrue( fp0Clone.getExpression().getParts().get( 0 ) instanceof ExpressionText );
        ExpressionText efl0p0Clone = (ExpressionText) fp0Clone.getExpression().getParts().get( 0 );
        assertEquals( efl0p0.getClassType(),
                      efl0p0Clone.getClassType() );
        assertEquals( efl0p0.getName(),
                      efl0p0Clone.getName() );
        assertEquals( efl0p0.getGenericType(),
                      efl0p0Clone.getGenericType() );
        assertEquals( efl0p0.getParametricType(),
                      efl0p0Clone.getParametricType() );

        assertEquals( efl0.getBinding(),
                      efl0Clone.getBinding() );
        assertEquals( efl0.getClassType(),
                      efl0Clone.getClassType() );
        assertEquals( efl0.getFieldName(),
                      efl0Clone.getFieldName() );
        assertEquals( efl0.getGenericType(),
                      efl0Clone.getGenericType() );
        assertEquals( efl0.getParametricType(),
                      efl0Clone.getParametricType() );
        assertEquals( efl0.getCurrentName(),
                      efl0Clone.getCurrentName() );

        assertNotSame( fp0.getFactPattern(),
                       fp0Clone.getFactPattern() );
        assertNotNull( fp0Clone.getFactPattern() );
        assertTrue( fp0Clone.getFactPattern() instanceof FactPattern );
View Full Code Here

                                                                 "java.lang.Object",
                                                                 SuggestionCompletionEngine.TYPE_OBJECT );
            }
            if ( "first".equals( value ) ) {
                collectionIndex.putParam( "index",
                                          new ExpressionFormLine( new ExpressionText( "0" ) ) );
                expression.appendPart( collectionIndex );
            } else if ( "last".equals( value ) ) {
                ExpressionFormLine index = new ExpressionFormLine( expression );
                index.appendPart( new ExpressionMethod( "size",
                                                        "int",
                                                        SuggestionCompletionEngine.TYPE_NUMERIC ) );
                index.appendPart( new ExpressionText( "-1" ) );

                collectionIndex.putParam( "index",
                                          index );
                expression.appendPart( collectionIndex );
            }
View Full Code Here

            ebBtn.addClickHandler( new ClickHandler() {
                public void onClick(ClickEvent event) {
                    SingleFieldConstraintEBLeftSide con = new SingleFieldConstraintEBLeftSide();
                    con.setConstraintValueType( SingleFieldConstraint.TYPE_UNDEFINED );
                    pattern.addConstraint( con );
                    con.setExpressionLeftSide( new ExpressionFormLine( new ExpressionUnboundFact( pattern ) ) );
                    modeller.refreshWidget();
                    popup.hide();
                }
            } );
            popup.addAttribute( constants.ExpressionEditor(),
View Full Code Here

        }
        return clone;
    }

    private ExpressionFormLine visitExpressionFormLine(ExpressionFormLine efl) {
        ExpressionFormLine clone = new ExpressionFormLine( efl );
        clone.setBinding( efl.getBinding() );
        return clone;
    }
View Full Code Here

                                                                 "java.lang.Object",
                                                                 SuggestionCompletionEngine.TYPE_OBJECT );
            }
            if ( "first".equals( value ) ) {
                collectionIndex.putParam( "index",
                                          new ExpressionFormLine( new ExpressionText( "0" ) ) );
                expression.appendPart( collectionIndex );
            } else if ( "last".equals( value ) ) {
                ExpressionFormLine index = new ExpressionFormLine( expression );
                index.appendPart( new ExpressionMethod( "size",
                                                        "int",
                                                        SuggestionCompletionEngine.TYPE_NUMERIC ) );
                index.appendPart( new ExpressionText( "-1" ) );

                collectionIndex.putParam( "index",
                                          index );
                expression.appendPart( collectionIndex );
            }
View Full Code Here

                collectionIndex = new ExpressionCollectionIndex("get", getCurrentParametricType(), factName);
            } else {
                collectionIndex = new ExpressionCollectionIndex("get", "java.lang.Object", SuggestionCompletionEngine.TYPE_OBJECT);
            }
            if ("first".equals(value)) {
                collectionIndex.putParam("index", new ExpressionFormLine(new ExpressionText("0")));
                expression.appendPart(collectionIndex);
            } else if ("last".equals(value)) {
                ExpressionFormLine index = new ExpressionFormLine(expression);
                index.appendPart(new ExpressionMethod("size", "int", SuggestionCompletionEngine.TYPE_NUMERIC));
                index.appendPart(new ExpressionText("-1"));

                collectionIndex.putParam("index", index);
                expression.appendPart(collectionIndex);
            }
        }
View Full Code Here

TOP

Related Classes of org.drools.ide.common.client.modeldriven.brl.ExpressionFormLine

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.