0

I want to List< String > name of Control_Exam_List() << is List< String >

but It had condition form $scheduleCheck.

then I used "from" function but still not work.

Drools Rule

rule "People List"
  salience 5
  when
    $scheduleCheck : Schedule( )
    $controlExamList : Control_Exam_List( ) 
       from accumulate( $scheduleCECheck : Schedule( ) from $scheduleCheck ,
                        init( Control_Exam_List CEL = new Control_Exam_List(); ),
                        action( CEL.addData($scheduleCECheck.getControl1());
                                CEL.addData($scheduleCECheck.getControl2());
                                CEL.addData($scheduleCECheck.getControl3()); ),
                        result( CEL ) )
    $schedule : Schedule( date == $scheduleCheck.getDate() &&
                  $scheduleCheck.getStarttime() >= starttime && <= endtime)
  then
    for( String str: $controlExamList.getCode() /* get List <String>*/ ){
      System.out.println( str );
    }
end
  • You'll have to describe what the rule should do; "still not work" is not a good question. The three occurrences of `Schedule()` can't be right. Especially `Schedule() from $scheduleCheck` where the latter is bound to a `Schedule` fact is pointless. Also, the constraint in the last `Schedule` pattern is rather strange. – laune Apr 03 '14 at 06:54
  • 1. $scheduleCheck << Schedule() 2. $schedule << Condition 3. $controlExamList << Accumulate Rigth? –  Apr 03 '14 at 08:09
  • No - this is out of context. Also, where is `$scheduleCECheck` bound? Where is the definition of what should be done by this rule? – laune Apr 03 '14 at 12:23
  • Sorry - `$scheduleCECheck` is Schedule() in accumulate.The condition,I want name of control1,control2,control3 in `Schedule()` from duration in `$schedule` –  Apr 03 '14 at 17:39
  • What is the purpose of the first `Schedule` pattern? What is the purpose of the last `Schedule` pattern? I don't see a "duration" anywhere. Which Schedule objects should contribute to the resulting List? - This is the last time I'm asking you to completely and unambiguosly state the requirement of this rule. - If your English isn't up to the task you may have to get a little help from your friends ;-) – laune Apr 04 '14 at 08:33

1 Answers1

0
rule "People List"
  salience 5
  when
    $scheduleCheck : Schedule( )
    $schedule : Schedule( date == $scheduleCheck.getDate() &&
                  $scheduleCheck.getStarttime() >= starttime && <= endtime)
    $controlExamList : Control_Exam_List( ) 
       from accumulate( $scheduleCECheck : Schedule( 
                        date == $scheduleCheck.getDate() ||
                        $scheduleCheck.getStarttime() == starttime || == endtime ) ,
            init( Control_Exam_List CEL = new Control_Exam_List(); ),
            action( CEL.addData($scheduleCECheck.getControl1());
                    CEL.addData($scheduleCECheck.getControl2());
                    CEL.addData($scheduleCECheck.getControl3()); ),
            result( CEL ) )
  then
    for( String str: $controlExamList.getCode() /* get List <String>*/ ){
      System.out.println( str );
    }
end