Skip to content

Commit

Permalink
[DROOLS-7296] Implement from entry-point (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
tkobayas authored and rgdoliveira committed Oct 24, 2024
1 parent baaa0c1 commit cee921d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ DRL_INIT : 'init';
DRL_ACTION : 'action';
DRL_REVERSE : 'reverse';
DRL_RESULT : 'result';
DRL_ENTRY_POINT : 'entry-point';

DRL_SALIENCE : 'salience';
DRL_ENABLED : 'enabled';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ mapEntry
*/
patternSource : fromExpression
| fromAccumulate
| fromEntryPoint
;

fromExpression : conditionalOrExpression ;
Expand All @@ -291,6 +292,7 @@ accumulateFunction := label? ID parameters
*/
accumulateFunction : label? IDENTIFIER LPAREN drlExpression RPAREN;

fromEntryPoint : DRL_ENTRY_POINT stringId ;

/*
lhsExists := EXISTS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.drools.drl.ast.descr.AnnotationDescr;
import org.drools.drl.ast.descr.AttributeDescr;
import org.drools.drl.ast.descr.BaseDescr;
import org.drools.drl.ast.descr.EntryPointDescr;
import org.drools.drl.ast.descr.ExistsDescr;
import org.drools.drl.ast.descr.ExprConstraintDescr;
import org.drools.drl.ast.descr.FromDescr;
Expand Down Expand Up @@ -296,6 +297,11 @@ public AccumulateDescr.AccumulateFunctionCallDescr visitAccumulateFunction(DRLPa
return new AccumulateDescr.AccumulateFunctionCallDescr(function, bind, false, params);
}

@Override
public EntryPointDescr visitFromEntryPoint(DRLParser.FromEntryPointContext ctx) {
return new EntryPointDescr(safeStripStringDelimiters(ctx.stringId().getText()));
}

@Override
public List<ExprConstraintDescr> visitConstraints(DRLParser.ConstraintsContext ctx) {
if (ctx == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2902,7 +2902,6 @@ public void parse_RuleWithLHSNesting() throws Exception {
assertThat(g.getObjectType()).isEqualTo("G");
}

@Disabled("Priority : High | Implement from entry-point")
@Test
public void parse_EntryPoint() throws Exception {
final String text = "rule X when StockTick( symbol==\"ACME\") from entry-point StreamA then end";
Expand All @@ -2923,7 +2922,6 @@ public void parse_EntryPoint() throws Exception {
assertThat(entry.getEntryId()).isEqualTo("StreamA");
}

@Disabled("Priority : High | Implement from entry-point")
@Test
public void parse_EntryPoint2() throws Exception {
final String text = "rule X when StockTick( symbol==\"ACME\") from entry-point \"StreamA\" then end";
Expand Down

0 comments on commit cee921d

Please sign in to comment.