public String getFactType() { if (this.factPattern == null){ return null; } return this.factPattern.getFactType(); }
public String getFactType() { if (this.factPattern == null){ return null; } return this.factPattern.getFactType(); }
public ExpressionUnboundFact(FactPattern fact) { super(fact.getFactType(), fact.getFactType(), fact.getFactType()); this.fact = fact; }
public ExpressionUnboundFact(FactPattern fact) { super(fact.getFactType(), fact.getFactType(), fact.getFactType()); this.fact = fact; }
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; }
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; }
private void generateFactPattern( 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.constraintList != 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() ) ); } }
private void generateFactPattern( 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.constraintList != 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() ) ); } }
private void fixConstraints(FactPattern fp, SingleFieldConstraint sfc) { sfc.setFactType( fp.getFactType() ); sfc.setFieldName( fixFieldName( sfc.getFieldName() ) ); if ( sfc.connectives == null ) { return; } for ( ConnectiveConstraint cc : sfc.connectives ) { cc.setFactType( fp.getFactType() ); cc.setFieldName( fixFieldName( cc.getFieldName() ) ); } }
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(); }
private void fixConstraints(FactPattern fp, SingleFieldConstraint sfc) { sfc.setFactType( fp.getFactType() ); sfc.setFieldName( fixFieldName( sfc.getFieldName() ) ); if ( sfc.connectives == null ) { return; } for ( ConnectiveConstraint cc : sfc.connectives ) { cc.setFactType( fp.getFactType() ); cc.setFieldName( fixFieldName( cc.getFieldName() ) ); } }
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(); }
final FactPattern p = (FactPattern) pat; if ( p.isBound() && var.equals( p.getBoundName() ) ) { return p.getFactType();
final FactPattern p = (FactPattern) pat; if ( p.isBound() && var.equals( p.getBoundName() ) ) { return p.getFactType();
final FactPattern fp = (FactPattern) p; if ( fp.isBound() && fp.getBoundName().equals( var ) ) { return fp.getFactType();
@Test public void testDataEnums3() { String pkg = "package org.test\n import org.drools.ide.common.client.modeldriven.SuggestionCompletionEngineTest.NestedClass"; SuggestionCompletionLoader loader = new SuggestionCompletionLoader(); List<String> enums = new ArrayList<String>(); enums.add( "'Fact.f1' : ['a1', 'a2'] \n 'Fact.f2' : ['def1', 'def2', 'def3'] \n 'Fact.f2[f1=a2]' : ['c1', 'c2']" ); SuggestionCompletionEngine engine = loader.getSuggestionEngine( pkg, new ArrayList<JarInputStream>(), new ArrayList<DSLTokenizedMappingFile>(), enums ); assertEquals( "String", engine.getFieldType( "NestedClass", "name" ) ); FactPattern pat = new FactPattern( "Fact" ); SingleFieldConstraint f1 = new SingleFieldConstraint( "f1" ); f1.setValue( "a1" ); pat.addConstraint( f1 ); pat.addConstraint( new SingleFieldConstraint( "f2" ) ); DropDownData data = engine.getEnums( pat.getFactType(), pat.constraintList, "f2" ); assertNotNull( data ); assertEquals( 3, data.fixedList.length ); }
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; }
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; }
@Test public void testFactPattern_Basics() { RuleModel model = new RuleModel(); model.lhs = new IPattern[1]; FactPattern fp0 = new FactPattern(); fp0.setBoundName( "$t0" ); fp0.setFactType( "FT0" ); fp0.setNegated( true ); 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( fp0.isNegated(), fp0Clone.isNegated() ); }
pat.addConstraint( sfc2 ); String[] result = sce.getEnums( pat.getFactType(), pat.constraintList, "field3" ).fixedList;