public Pattern52 getPattern(ConditionCol52 col) { for ( CompositeColumn< ? > cc : conditionPatterns ) { if ( cc instanceof Pattern52 ) { Pattern52 p = (Pattern52) cc; if ( p.getChildColumns().contains( col ) ) { return p; } } } return new Pattern52(); }
@Override public List<String> getBoundVariablesInScope(BaseSingleFieldConstraint con) { Set<String> variables = new HashSet<String>(); for ( CompositeColumn< ? extends BaseColumn> col : dtable.getConditions() ) { if ( col instanceof Pattern52 ) { Pattern52 p = (Pattern52) col; if ( p.isBound() ) { variables.add( p.getBoundName() ); } for ( ConditionCol52 cc : p.getChildColumns() ) { if ( cc.isBound() ) { variables.add( cc.getBinding() ); } } } else if ( col instanceof BRLConditionColumn ) { //Delegate to super class's implementation RuleModel rm = new RuleModel(); BRLConditionColumn brl = (BRLConditionColumn) col; rm.lhs = brl.getDefinition().toArray( new IPattern[brl.getDefinition().size()] ); variables.addAll( rm.getBoundVariablesInScope( con ) ); } } variables.addAll( super.getBoundVariablesInScope( con ) ); return new ArrayList<String>( variables ); }
public String getBoundFactType(String boundName) { for ( CompositeColumn< ? > cc : this.conditionPatterns ) { if ( cc instanceof Pattern52 ) { Pattern52 p = (Pattern52) cc; if ( p.isBound() && p.getBoundName().equals( boundName ) ) { return p.getFactType(); } } else if ( cc instanceof BRLConditionColumn ) { BRLConditionColumn brl = (BRLConditionColumn) cc; for ( IPattern p : brl.getDefinition() ) { if ( p instanceof FactPattern ) { FactPattern fp = (FactPattern) p; if ( fp.isBound() && fp.getBoundName().equals( boundName ) ) { return fp.getFactType(); } } } } } return new String(); }
@Override public List<String> getLHSBoundFacts() { Set<String> facts = new HashSet<String>(); for ( CompositeColumn< ? extends BaseColumn> col : dtable.getConditions() ) { if ( col instanceof Pattern52 ) { Pattern52 p = (Pattern52) col; if ( p.isBound() ) { facts.add( p.getBoundName() ); } } 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() ) { facts.add( fp.getBoundName() ); } } } } } facts.addAll( super.getLHSBoundFacts() ); return new ArrayList<String>( facts ); }
Pattern52 p = uniquePatterns.get( boundName ); if ( p == null ) { p = new Pattern52(); p.setBoundName( boundName ); p.setFactType( c.factType ); patterns.add( p ); uniquePatterns.put( boundName, p ); if ( p.getFactType() != null && !p.getFactType().equals( c.factType ) ) { throw new IllegalArgumentException( "Inconsistent FactTypes for ConditionCols bound to '" + boundName + "' detected." ); p.getChildColumns().add( makeNewColumn( c ) );
RuleModel rm) { List<ConditionCol52> cols = pattern.getChildColumns(); pattern.getBoundName() ); 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 );
tsdt.getConditionPattern( "z1" ).getBoundName() ); assertEquals( "Driver", tsdt.getConditionPattern( "z1" ).getFactType() ); tsdt.getConditionPattern( "f1" ).getBoundName() ); assertEquals( "Person", tsdt.getConditionPattern( "f1" ).getFactType() ); tsdt.getConditionPattern( "f2" ).getBoundName() ); assertEquals( "Person2", tsdt.getConditionPattern( "f2" ).getFactType() ); tsdt.getConditionPattern( "z1" ).getChildColumns().size() ); tsdt.getConditionPattern( "f1" ).getChildColumns().size() ); tsdt.getConditionPattern( "f2" ).getChildColumns().size() ); tsdt.getConditionPattern( "z1" ).getChildColumns().get( 0 ).getConstraintValueType() ); assertEquals( "age", tsdt.getConditionPattern( "z1" ).getChildColumns().get( 0 ).getFactField() ); assertEquals( "Driver", tsdt.getPattern( tsdt.getConditionPattern( "z1" ).getChildColumns().get( 0 ) ).getFactType() ); assertEquals( "Driver z1 age", tsdt.getConditionPattern( "z1" ).getChildColumns().get( 0 ).getHeader() ); assertEquals( "==", tsdt.getConditionPattern( "z1" ).getChildColumns().get( 0 ).getOperator() ); tsdt.getConditionPattern( "z1" ).getChildColumns().get( 1 ).getConstraintValueType() );
if ( col instanceof Pattern52 ) { Pattern52 p = (Pattern52) col; if ( p.isBound() && p.getBoundName().equals( var ) ) { return p.getFactType(); for ( ConditionCol52 cc : p.getChildColumns() ) { if ( cc.isBound() && cc.getBinding().equals( var ) ) { return cc.getFieldType();
Pattern52 p1 = new Pattern52(); p1.setFactType( "Baddie" ); con.setFactField( "name" ); con.setOperator( "==" ); p1.getChildColumns().add( con );
dt.setTableName( "limited-entry" ); Pattern52 p1 = new Pattern52(); p1.setBoundName( "p1" ); p1.setFactType( "Smurf" ); dt.getConditions().add( p1 );
@Override public String getFactType() { return pattern.getFactType(); }
@Override public String getBoundName() { return pattern.getBoundName(); }
@Override public FieldConstraint getLHSBoundField(String var) { for ( CompositeColumn< ? extends BaseColumn> col : dtable.getConditions() ) { if ( col instanceof Pattern52 ) { Pattern52 p = (Pattern52) col; for ( ConditionCol52 cc : p.getChildColumns() ) { if ( cc.isBound() && cc.getBinding().equals( var ) ) { return new ConditionCol52FieldConstraintAdaptor( cc ); } } } 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; } } } } } } return super.getLHSBoundField( var ); }
@Override public boolean isNegated() { return pattern.isNegated(); }
@Override public boolean isBound() { return pattern.isBound(); }
Pattern52 p = uniquePatterns.get( boundName ); if ( p == null ) { p = new Pattern52(); p.setBoundName( boundName ); p.setFactType( c.factType ); patterns.add( p ); uniquePatterns.put( boundName, p ); if ( p.getFactType() != null && !p.getFactType().equals( c.factType ) ) { throw new IllegalArgumentException( "Inconsistent FactTypes for ConditionCols bound to '" + boundName + "' detected." ); p.getChildColumns().add( makeNewColumn( c ) );
RuleModel rm) { List<ConditionCol52> cols = pattern.getChildColumns(); pattern.getBoundName() ); 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 );
tsdt.getConditionPattern( "f1" ).getBoundName() ); assertEquals( "Driver", tsdt.getConditionPattern( "f1" ).getFactType() ); tsdt.getConditionPattern( "f2" ).getBoundName() ); assertEquals( "Driver", tsdt.getConditionPattern( "f2" ).getFactType() ); tsdt.getConditionPattern( "f1" ).getChildColumns().size() ); tsdt.getConditionPattern( "f2" ).getChildColumns().size() ); tsdt.getConditionPattern( "f1" ).getChildColumns().get( 0 ).getConstraintValueType() ); assertEquals( "age", tsdt.getConditionPattern( "f1" ).getChildColumns().get( 0 ).getFactField() ); assertEquals( "Driver", tsdt.getPattern( tsdt.getConditionPattern( "f1" ).getChildColumns().get( 0 ) ).getFactType() ); assertEquals( "Driver f1 age", tsdt.getConditionPattern( "f1" ).getChildColumns().get( 0 ).getHeader() ); assertEquals( "==", tsdt.getConditionPattern( "f1" ).getChildColumns().get( 0 ).getOperator() ); tsdt.getConditionPattern( "f1" ).getChildColumns().get( 1 ).getConstraintValueType() ); assertEquals( "name", tsdt.getConditionPattern( "f1" ).getChildColumns().get( 1 ).getFactField() ); assertEquals( "Driver", tsdt.getPattern( tsdt.getConditionPattern( "f1" ).getChildColumns().get( 1 ) ).getFactType() ); assertEquals( "Driver f1 name", tsdt.getConditionPattern( "f1" ).getChildColumns().get( 1 ).getHeader() );
if ( col instanceof Pattern52 ) { Pattern52 p = (Pattern52) col; if ( p.isBound() && p.getBoundName().equals( var ) ) { return p.getFactType(); for ( ConditionCol52 cc : p.getChildColumns() ) { if ( cc.isBound() && cc.getBinding().equals( var ) ) { return cc.getFieldType();
Pattern52 p1 = new Pattern52(); p1.setFactType( "Baddie" ); con.setFactField( "name" ); con.setOperator( "==" ); p1.getChildColumns().add( con );