public RuleModel unmarshalUsingDSL( final String str, final List<String> globals, final String... dsls ) { return getRuleModel( parseDSLs( preprocessDRL(str), dsls ).registerGlobals( globals ) ); }
/** * @see BRLPersistence#unmarshal(String) */ public RuleModel unmarshal( String str ) { return getRuleModel( preprocessDRL(str) ); }
private int parseNonDrlInLhs( RuleModel m, ExpandedDRLInfo expandedDRLInfo, int lineCounter) { lineCounter++; lineCounter = parseDslInLhs(m, expandedDRLInfo, lineCounter); lineCounter = parseFreeForm(m, expandedDRLInfo, lineCounter); return lineCounter; }
@Test public void testNotMultiPatterns() throws Exception { RuleModel m = getCompositeFOL( CompositeFactPattern.COMPOSITE_TYPE_NOT ); String result = BRDRLPersistence.getInstance().marshal( m ); assertTrue( result.indexOf( "not (Person( age == 42 ) and Person( age == 43 ))" ) > 0 ); checkMarshallUnmarshall( result, m ); }
@Test public void testFieldBindingWithNoConstraints() { // to satisfy JBRULES-850 RuleModel m = getModelWithNoConstraints(); String s = BRDRLPersistence.getInstance().marshal( m ); // System.out.println(s); assertTrue( s.contains( "Person( f1 : age)" ) ); checkMarshallUnmarshall( s, m ); }
@Override public String getSource( final Path path, final RuleModel model ) { return new StringBuilder().append( BRDRLPersistence.getInstance().marshal( model ) ).toString(); }
private Expr parseExpr( String expr ) { List<String> splittedExpr = splitExpression( expr ); if ( splittedExpr.size() == 1 ) { String singleExpr = splittedExpr.get( 0 ); if ( singleExpr.startsWith( "(" ) ) { return parseExpr( singleExpr.substring( 1 ) ); } else if ( singleExpr.startsWith( "eval" ) ) { return new EvalExpr( unwrapParenthesis( singleExpr ) ); } else { return new SimpleExpr( singleExpr ); } } ComplexExpr complexExpr = new ComplexExpr( splittedExpr.get( 1 ) ); for ( int i = 0; i < splittedExpr.size(); i += 2 ) { complexExpr.subExprs.add( parseExpr( splittedExpr.get( i ) ) ); } return complexExpr; }
private void checkMarshallUnmarshall( String expected, RuleModel m ) { String drl = brlPersistence.marshal( m ); assertNotNull( drl ); if ( expected != null ) { assertEqualsIgnoreWhitespace( expected, drl ); } RuleModel unmarshalledModel = brlPersistence.unmarshal( drl ); if ( expected != null ) { assertEqualsIgnoreWhitespace( expected, brlPersistence.marshal( unmarshalledModel ) ); } else { assertEquals( drl, brlPersistence.marshal( unmarshalledModel ) ); } }
public static DRLConstraintValueBuilder getBuilder(String dialect) { if ( BRDRLPersistence.DEFAULT_DIALECT.equalsIgnoreCase( dialect ) ) { return new MvelDRLConstraintValueBuilder(); } return new JavaDRLConstraintValueBuilder(); }
public void visitActionInsertFact( final ActionInsertFact action ) { this.generateInsertCall( action, false ); }
public void visitFromCompositeFactPattern( final FromCompositeFactPattern pattern ) { visitFromCompositeFactPattern( pattern, false ); }
public void visitFromEntryPointFactPattern( final FromEntryPointFactPattern pattern ) { visitFromEntryPointFactPattern( pattern, false ); }
protected LHSPatternVisitor getLHSPatternVisitor( final boolean isDSLEnhanced, final StringBuilder buf, final String nestedIndentation, final boolean isNegated ) { return new LHSPatternVisitor( isDSLEnhanced, bindingsPatterns, bindingsFields, constraintValueBuilder, buf, nestedIndentation, isNegated ); }
protected RHSActionVisitor getRHSActionVisitor( final boolean isDSLEnhanced, final StringBuilder buf, final String indentation ) { return new RHSActionVisitor( isDSLEnhanced, bindingsPatterns, bindingsFields, constraintValueBuilder, buf, indentation ); }
public void visitFromCollectCompositeFactPattern( final FromCollectCompositeFactPattern pattern ) { visitFromCollectCompositeFactPattern( pattern, false ); }
public void visitFromAccumulateCompositeFactPattern( final FromAccumulateCompositeFactPattern pattern ) { visitFromAccumulateCompositeFactPattern( pattern, false ); }
public String marshal( final RuleModel model ) { return marshalRule( model ); }
@Test public void testExistsMultiPatterns() throws Exception { RuleModel m = getCompositeFOL( CompositeFactPattern.COMPOSITE_TYPE_EXISTS ); String result = BRDRLPersistence.getInstance().marshal( m ); assertTrue( result.indexOf( "exists (Person( age == 42 ) and Person( age == 43 ))" ) > 0 ); checkMarshallUnmarshall( result, m ); }
@Override public String getSource( final Path path, final RuleModel model ) { return new StringBuilder().append( BRDRLPersistence.getInstance().marshal( model ) ).toString(); }
public void visitActionInsertLogicalFact( final ActionInsertLogicalFact action ) { this.generateInsertCall( action, true ); }