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

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


                }
            } else if ( col instanceof BRLConditionColumn ) {
                BRLConditionColumn brl = (BRLConditionColumn) col;
                for ( IPattern p : brl.getDefinition() ) {
                    if ( p instanceof FactPattern ) {
                        final FactPattern fp = (FactPattern) p;
                        for ( FieldConstraint fc : fp.getFieldConstraints() ) {
                            List<String> fieldBindings = getFieldBinding( fc );
                            if ( fieldBindings.contains( var ) ) {
                                return fc;
                            }
                        }
View Full Code Here


            } else if ( col instanceof BRLConditionColumn ) {
                BRLConditionColumn brl = (BRLConditionColumn) col;
                for ( IPattern p : brl.getDefinition() ) {
                    if ( p instanceof FactPattern ) {
                        final FactPattern fp = (FactPattern) p;
                        if ( fp.isBound() && fp.getBoundName().equals( var ) ) {
                            return fp.getFactType();
                        }
                        for ( FieldConstraint fc : fp.getFieldConstraints() ) {
                            String type = getFieldBinding( fc,
                                                           var );
                            if ( type != null ) {
                                return type;
                            }
View Full Code Here

            } else if ( col instanceof BRLConditionColumn ) {
                BRLConditionColumn brl = (BRLConditionColumn) col;
                for ( IPattern p : brl.getDefinition() ) {
                    if ( p instanceof FactPattern ) {
                        final FactPattern fp = (FactPattern) p;
                        if ( fp.isBound() && var.equals( fp.getBoundName() ) ) {
                            return fp;
                        }
                        for ( FieldConstraint fc : fp.getFieldConstraints() ) {
                            List<String> fieldBindings = getFieldBinding( fc );
                            if ( fieldBindings.contains( var ) ) {
                                return fp;
                            }
                        }
View Full Code Here

            } else if ( col instanceof BRLConditionColumn ) {
                BRLConditionColumn brl = (BRLConditionColumn) col;
                for ( IPattern p : brl.getDefinition() ) {
                    if ( p instanceof FactPattern ) {
                        FactPattern fp = (FactPattern) p;
                        if ( fp.isBound() ) {
                            variables.add( fp.getBoundName() );
                        }

                        for ( FieldConstraint fc : fp.getFieldConstraints() ) {
                            if ( fc instanceof SingleFieldConstraintEBLeftSide ) {
                                SingleFieldConstraintEBLeftSide exp = (SingleFieldConstraintEBLeftSide) fc;
                                if ( exp.getExpressionLeftSide() != null && exp.getExpressionLeftSide().isBound() ) {
                                    variables.add( exp.getExpressionLeftSide().getBinding() );
                                }
View Full Code Here

                IPattern ifp = findByFactPattern( patterns,
                                                  pattern.getBoundName() );

                //If the pattern does not exist create one suitable
                if ( ifp == null ) {
                    FactPattern fp = new FactPattern( pattern.getFactType() );
                    fp.setBoundName( pattern.getBoundName() );
                    fp.setNegated( pattern.isNegated() );
                    fp.setWindow( pattern.getWindow() );
                    if ( pattern.getEntryPointName() != null && pattern.getEntryPointName().length() > 0 ) {
                        FromEntryPointFactPattern fep = new FromEntryPointFactPattern();
                        fep.setEntryPointName( pattern.getEntryPointName() );
                        fep.setFactPattern( fp );
                        patterns.add( fep );
                        ifp = fep;
                    } else {
                        patterns.add( fp );
                        ifp = fp;
                    }
                }

                //Extract the FactPattern from the IFactPattern
                FactPattern fp;
                if ( ifp instanceof FactPattern ) {
                    fp = (FactPattern) ifp;
                } else if ( ifp instanceof FromEntryPointFactPattern ) {
                    FromEntryPointFactPattern fep = (FromEntryPointFactPattern) ifp;
                    fp = fep.getFactPattern();
                } else {
                    throw new IllegalArgumentException( "Inexpected IFactPattern implementation found." );
                }

                //Add the constraint from this cell
                switch ( c.getConstraintValueType() ) {
                    case BaseSingleFieldConstraint.TYPE_LITERAL :
                    case BaseSingleFieldConstraint.TYPE_RET_VALUE :
                        if ( !isOtherwise ) {
                            FieldConstraint fc = makeSingleFieldConstraint( c,
                                                                            cell );
                            fp.addConstraint( fc );
                        } else {
                            FieldConstraint fc = makeSingleFieldConstraint( c,
                                                                            allColumns,
                                                                            data );
                            fp.addConstraint( fc );
                        }
                        break;
                    case BaseSingleFieldConstraint.TYPE_PREDICATE :
                        SingleFieldConstraint pred = new SingleFieldConstraint();
                        pred.setConstraintValueType( c.getConstraintValueType() );
                        if ( c.getFactField() != null
                             && c.getFactField().indexOf( "$param" ) > -1 ) {
                            // handle interpolation
                            pred.setValue( c.getFactField().replace( "$param",
                                                                     cell ) );
                        } else {
                            pred.setValue( cell );
                        }
                        fp.addConstraint( pred );
                        break;
                    default :
                        throw new IllegalArgumentException( "Unknown constraintValueType: "
                                                            + c.getConstraintValueType() );
                }
View Full Code Here

            return null;
        }

        for ( IPattern ifp : patterns ) {
            if ( ifp instanceof FactPattern ) {
                FactPattern fp = (FactPattern) ifp;
                if ( fp.getBoundName() != null && fp.getBoundName().equals( boundName ) ) {
                    return fp;
                }
            } else if ( ifp instanceof FromEntryPointFactPattern ) {
                FromEntryPointFactPattern fefp = (FromEntryPointFactPattern) ifp;
                FactPattern fp = fefp.getFactPattern();
                if ( fp.getBoundName() != null && fp.getBoundName().equals( boundName ) ) {
                    return fp;
                }
            }
        }
        return null;
View Full Code Here

        if (getCompletion().isGlobalVariable(set.variable)) {
            this.fieldCompletions = getCompletion()
                    .getFieldCompletionsForGlobalVariable(set.variable);
            this.variableClass = (String) getCompletion().getGlobalVariable(set.variable);
        } else {
            FactPattern pattern = rule.getBoundFact(set.variable);
            this.fieldCompletions = getCompletion().getFieldCompletions(
                    pattern.getFactType());
            this.isBoundFact = true;
            this.variableClass = pattern.getFactType();
        }

        GridLayout l = new GridLayout();
        l.numColumns = 6;
        l.marginBottom = 0;
View Full Code Here

        clone.setValue( value.getValue() );
        return clone;
    }

    private FactPattern visitFactPattern(FactPattern pattern) {
        FactPattern clone = new FactPattern();
        clone.setBoundName( pattern.getBoundName() );
        clone.setFactType( pattern.getFactType() );
        clone.setNegated( pattern.isNegated() );

        CEPWindow cloneCEPWindow = new CEPWindow();
        cloneCEPWindow.setOperator( pattern.getWindow().getOperator() );
        cloneCEPWindow.setParameters( cloneCEPWindowParameters( pattern.getWindow() ) );
        clone.setWindow( cloneCEPWindow );

        for ( FieldConstraint fc : pattern.getFieldConstraints() ) {
            clone.addConstraint( (FieldConstraint) visit( fc ) );
        }
        return clone;
    }
View Full Code Here

        RuleModel m = (RuleModel) rule.content;
        assertNotNull( m );
        m.name = "testBRL";

        FactPattern p = new FactPattern( "Person" );
        p.setBoundName( "p" );
        SingleFieldConstraint con = new SingleFieldConstraint();
        con.setFieldName( "name" );
        con.setValue( "mark" );
        con.setOperator( "==" );
        con.setConstraintValueType( SingleFieldConstraint.TYPE_LITERAL );
        con.setFieldType( SuggestionCompletionEngine.TYPE_STRING );

        p.addConstraint( con );

        m.addLhsItem( p );

        ActionSetField set = new ActionSetField( "p" );
        ActionFieldValue f = new ActionFieldValue( "name",
View Full Code Here

        assertEquals( "val3",
                      items[0] );
        assertEquals( "val4",
                      items[1] );

        FactPattern pat = new FactPattern( "Fact" );
        SingleFieldConstraint sfc = new SingleFieldConstraint( "field2" );
        pat.addConstraint( sfc );
        items = engine.getEnums( pat.getFactType(),
                                 pat.constraintList,
                                 "field2" ).fixedList;
        assertEquals( 2,
                      items.length );
        assertEquals( "val3",
View Full Code Here

TOP

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

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.