/** * This will return the FactPattern that a variable is bound Eto. * @param var The bound fact variable (NOT bound field). * @return null or the FactPattern found. */ public FactPattern getLHSBoundFact( final String var ) { if ( this.lhs == null ) { return null; } for ( int i = 0; i < this.lhs.length; i++ ) { IPattern pat = this.lhs[ i ]; if ( pat instanceof FromCompositeFactPattern ) { pat = ( (FromCompositeFactPattern) pat ).getFactPattern(); } if ( pat instanceof FactPattern ) { final FactPattern p = (FactPattern) pat; if ( p.getBoundName() != null && var.equals( p.getBoundName() ) ) { return p; } } } return null; }
/** * This will return a List<String> of all FactPattern bindings * @return The bindings or an empty list if no bindings are found. */ public List<String> getLHSBoundFacts() { if ( this.lhs == null ) { return Collections.emptyList(); } final List<String> list = new ArrayList<String>(); for ( int i = 0; i < this.lhs.length; i++ ) { IPattern pat = this.lhs[ i ]; if ( pat instanceof FromCompositeFactPattern ) { pat = ( (FromCompositeFactPattern) pat ).getFactPattern(); } if ( pat instanceof FactPattern ) { final FactPattern p = (FactPattern) pat; if ( p.getBoundName() != null ) { list.add( p.getBoundName() ); } } } return list; }
/** * @param idx Remove this index from the LHS. returns false if it was NOT * allowed to remove this item (ie it is used on the RHS). */ public boolean removeLhsItem( final int idx ) { final IPattern[] newList = new IPattern[ this.lhs.length - 1 ]; int newIdx = 0; for ( int i = 0; i < this.lhs.length; i++ ) { if ( i != idx ) { newList[ newIdx ] = this.lhs[ i ]; newIdx++; } else { IPattern pat = this.lhs[ i ]; if ( pat instanceof FromCompositeFactPattern ) { pat = ( (FromCompositeFactPattern) pat ).getFactPattern(); } if ( pat instanceof FactPattern ) { final FactPattern p = (FactPattern) pat; if ( p.getBoundName() != null && isBoundFactUsed( p.getBoundName() ) ) { return false; } } } } this.lhs = newList; return true; }
public ExpressionVariable( FactPattern fact ) { super( fact.getBoundName(), fact.getFactType(), fact.getFactType() ); if ( !fact.isBound() ) { throw new RuntimeException( "the fact is not bounded: " + fact ); } this.fact = fact; }
if ( p.getBoundName() != null && var.equals( p.getBoundName() ) ) { return p;
private boolean canConditionBeDeleted( BRLConditionColumn col ) { for ( IPattern p : col.getDefinition() ) { if ( p instanceof FactPattern ) { FactPattern fp = (FactPattern) p; if ( fp.isBound() ) { if ( isBindingUsed( fp.getBoundName() ) ) { return false; } } } } return true; }
private void generateFactPattern( final FactPattern pattern ) { if ( pattern.isNegated() ) { buf.append( "not " ); } else if ( pattern.isBound() ) { bindingsPatterns.put( pattern.getBoundName(), pattern ); buf.append( pattern.getBoundName() ); buf.append( " : " ); } if ( pattern.getFactType() != null ) { buf.append( pattern.getFactType() ); } buf.append( "( " ); // top level constraints if ( pattern.getConstraintList() != null ) { generateConstraints( pattern ); } buf.append( ")" ); //Add CEP window definition CEPWindow window = pattern.getWindow(); if ( window.isDefined() ) { buf.append( " " ); buf.append( window.getOperator() ); buf.append( buildOperatorParameterDRL( window.getParameters() ) ); } }
/** * Get the data-type associated with the binding * @param var * @return The data-type, or null if the binding could not be found */ public String getLHSBindingType( final String var ) { if ( this.lhs == null ) { return null; } for ( int i = 0; i < this.lhs.length; i++ ) { IPattern pat = this.lhs[ i ]; if ( pat instanceof FromCompositeFactPattern ) { pat = ( (FromCompositeFactPattern) pat ).getFactPattern(); } if ( pat instanceof FactPattern ) { final FactPattern p = (FactPattern) pat; if ( p.isBound() && var.equals( p.getBoundName() ) ) { return p.getFactType(); } for ( FieldConstraint fc : p.getFieldConstraints() ) { String type = getFieldBinding( fc, var ); if ( type != null ) { return type; } } } } return null; }
result.add( fact.getBoundName() ); result.add( fact.getBoundName() );
if ( bindable || !( modeller.getModel().isBoundFactUsed( pattern.getBoundName() ) ) ) { HorizontalPanel varName = new HorizontalPanel(); final TextBox varTxt = new BindingTextBox(); if ( pattern.getBoundName() == null ) { varTxt.setText( "" ); } else { varTxt.setText( pattern.getBoundName() );
FactPattern fact = (FactPattern) pat; if ( fact.isBound() ) { result.add( fact.getBoundName() );
/** * This returns the pattern label. */ private Widget getPatternLabel( final FactPattern fp ) { ClickHandler click = new ClickHandler() { public void onClick( ClickEvent event ) { popupCreator.showPatternPopup( (Widget) event.getSource(), fp, null, false ); } }; String patternName = ( pattern.isBound() ) ? pattern.getFactType() + " <b>[" + pattern.getBoundName() + "]</b>" : pattern.getFactType(); String desc; if ( isAll0WithLabel ) { desc = Constants.INSTANCE.All0with( patternName ); } else { if ( pattern.getNumberOfConstraints() > 0 ) { desc = Constants.INSTANCE.ThereIsAAn0With( patternName ); } else { desc = Constants.INSTANCE.ThereIsAAn0( patternName ); } desc = anA( desc, patternName ); } return new ClickableLabel( desc, click, !this.readOnly ); }
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; }
final FactPattern fp1 = (FactPattern) m.lhs[ 0 ]; assertEquals( "$a", fp1.getBoundName() ); assertEquals( "Applicant", fp1.getFactType() ); final FactPattern fp2 = (FactPattern) m.lhs[ 2 ]; assertEquals( "$b", fp2.getBoundName() ); assertEquals( "Bananna", fp2.getFactType() );
( (FactPattern) rm.lhs[ 0 ] ).getFactType() ); assertEquals( "p1", ( (FactPattern) rm.lhs[ 0 ] ).getBoundName() ); ( (FactPattern) rm.lhs[ 1 ] ).getBoundName() );
( (FactPattern) rm.lhs[ 0 ] ).getFactType() ); assertEquals( "p1", ( (FactPattern) rm.lhs[ 0 ] ).getBoundName() );
p.getBoundName() ); assertEquals( "Applicant", p.getFactType() );
p.getBoundName() ); assertEquals( "Applicant", p.getFactType() );
p.getBoundName() ); assertEquals( "Applicant", p.getFactType() );
final FactPattern fp1 = (FactPattern) m.lhs[ 0 ]; assertEquals( "$a", fp1.getBoundName() ); assertEquals( "Applicant", fp1.getFactType() );