@@ -14,48 +14,60 @@ public class CMMNPlanItemProcessor : BaseProcessFlowElementProcessor
1414 protected override Task < bool > HandleProcessFlowInstance ( ProcessFlowInstanceElement pfe , ProcessFlowInstanceExecutionContext context )
1515 {
1616 var planItem = ( CMMNPlanItem ) pfe ;
17- var processTask = ( CMMNProcessTask ) planItem . PlanItemDefinition ;
18- // TODO : check the plan definition status and execute the correct logic.
19- if ( processTask . State == CMMNTaskStates . Active )
17+ var processTask = planItem . PlanItemDefinition as CMMNProcessTask ;
18+ if ( processTask != null )
2019 {
21- planItem . Complete ( ) ;
22- return Task . FromResult ( true ) ;
20+ return HandleProcessTask ( planItem , processTask , context ) ;
2321 }
2422
25- if ( ! HandlePlanItemControl ( planItem , context ) )
26- {
27- return Task . FromResult ( false ) ;
28- }
29-
30- // TODO : execute the plan item definition.
31- planItem . Complete ( ) ;
3223 return Task . FromResult ( true ) ;
3324 }
3425
35- protected bool HandlePlanItemControl ( CMMNPlanItem pfe , ProcessFlowInstanceExecutionContext context )
26+ protected Task < bool > HandleProcessTask ( CMMNPlanItem planItem , CMMNProcessTask processTask , ProcessFlowInstanceExecutionContext context )
3627 {
37- var planItem = ( CMMNPlanItem ) pfe ;
38- if ( planItem . SEntries . Any ( ) && ! planItem . SEntries . Any ( s => CheckSEntry ( s , context ) ) )
28+ if ( planItem . ExitCriterions . Any ( ) && planItem . ExitCriterions . Any ( s => CheckCriterion ( s , context ) ) )
3929 {
40- return false ;
30+ planItem . Terminate ( ) ;
31+ return Task . FromResult ( true ) ;
4132 }
42-
43- if ( planItem . PlanItemControl != null )
33+
34+ if ( processTask . State == CMMNTaskStates . Available )
4435 {
45- if ( planItem . PlanItemControl is CMMNManualActivationRule )
36+ if ( planItem . EntryCriterions . Any ( ) && ! planItem . EntryCriterions . Any ( s => CheckCriterion ( s , context ) ) )
4637 {
47- planItem . Enable ( ) ;
48- return false ;
38+ return Task . FromResult ( true ) ;
4939 }
40+
41+ if ( planItem . PlanItemControl != null )
42+ {
43+ var manualActivationRule = planItem . PlanItemControl as CMMNManualActivationRule ;
44+ if ( manualActivationRule != null )
45+ {
46+ // Note : at the moment the ContextRef is ignored.
47+ if ( ExpressionParser . IsValid ( manualActivationRule . Expression . Body , context ) )
48+ {
49+ planItem . Enable ( ) ;
50+ return Task . FromResult ( false ) ;
51+ }
52+ }
53+ }
54+
55+ planItem . Start ( ) ;
5056 }
5157
52- planItem . Start ( ) ;
53- return true ;
58+ if ( processTask . State == CMMNTaskStates . Active )
59+ {
60+ // TODO : Execute the plan item definition.
61+ planItem . Complete ( ) ;
62+ return Task . FromResult ( true ) ;
63+ }
64+
65+ return Task . FromResult ( true ) ;
5466 }
5567
56- private bool CheckSEntry ( CMMNSEntry sEntry , ProcessFlowInstanceExecutionContext context )
68+ private bool CheckCriterion ( CMMNCriterion sCriterion , ProcessFlowInstanceExecutionContext context )
5769 {
58- foreach ( var onPart in sEntry . OnParts )
70+ foreach ( var onPart in sCriterion . SEntry . OnParts )
5971 {
6072 if ( onPart is CMMNPlanItemOnPart )
6173 {
@@ -70,9 +82,9 @@ private bool CheckSEntry(CMMNSEntry sEntry, ProcessFlowInstanceExecutionContext
7082 }
7183 }
7284
73- if ( sEntry . IfPart != null )
85+ if ( sCriterion . SEntry . IfPart != null )
7486 {
75- return ExpressionParser . IsValid ( sEntry . IfPart . Condition , context ) ;
87+ return ExpressionParser . IsValid ( sCriterion . SEntry . IfPart . Condition , context ) ;
7688 }
7789
7890 return true ;
0 commit comments