Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Informer: rule logic fixes

  • Loading branch information...
commit 5fb4331b418cd768f380575abc45ba3fd5a29aec 1 parent 67e5fdd
@sotty sotty authored
View
2  drools-informer/drools-informer-core/src/main/resources/org/drools/informer/Annotations.drl
@@ -127,6 +127,7 @@ then
modify ( $qst ) {
+ addAvailableItem( q.getId() ),
addItem( q.getId() );
}
insert( q );
@@ -164,6 +165,7 @@ then
modify ( $qst ) {
+ addAvailableItem( mcq.getId() ),
addItem( mcq.getId() );
}
insert( mcq );
View
25 drools-informer/drools-informer-core/src/main/resources/org/drools/informer/Question.drl
@@ -92,12 +92,12 @@ then
InvalidAnswer invalidAnswer = new InvalidAnswer(questionId,
"invalid",
"This is not a valid number");
- insert(invalidAnswer);
+ insert( invalidAnswer );
} catch (ParseException e) {
InvalidAnswer invalidAnswer = new InvalidAnswer(questionId,
"invalid",
"This is not a valid value");
- insert(invalidAnswer);
+ insert( invalidAnswer );
}
end
@@ -125,7 +125,7 @@ when
$answer : Answer( questionId : questionId );
not Question( id == questionId )
then
- retract($answer);
+ retract( $answer );
end
@@ -144,9 +144,9 @@ salience -1 // after: any rules that create questions
when
$question : Question( required == false, answered == false ) @watch(*)
then
- InvalidAnswer invalidAnswer = new InvalidAnswer($question.getId(), "You must answer this question");
+ InvalidAnswer invalidAnswer = new InvalidAnswer( $question.getId(), "You must answer this question" );
invalidAnswer.setType("missing");
- insertLogical(invalidAnswer);
+ insertLogical( invalidAnswer );
end
rule "invalid ansewer severity"
@@ -163,24 +163,23 @@ end
rule "has invalid answers"
salience -2 // after: any rules that create invalid answers
when
- $quest : Questionnaire( invalidAnswers == false )
- exists InvalidAnswer()
+ $quest : Questionnaire( invalidAnswers == false, $items : items )
+ exists InvalidAnswer( questionId memberOf $items )
then
modify ( $quest ) {
setInvalidAnswers( true );
}
end
-
-rule "doesn't have invalid answers"
+rule "has no invalid answers"
salience -2 // after: any rules that create invalid answers
when
- $quest : Questionnaire( invalidAnswers == true )
- not InvalidAnswer()
+ $quest : Questionnaire( invalidAnswers == true, $items : items )
+ not InvalidAnswer( questionId memberOf $items )
then
modify ( $quest ) {
- setInvalidAnswers( false );
- }
+ setInvalidAnswers( false );
+ }
end
View
9 drools-informer/drools-informer-core/src/main/resources/org/drools/informer/Status.drl
@@ -54,7 +54,7 @@ query includes( Group $master, String $qid )
and
$inner := Group( id memberOf $list ) @watch( * )
and
- ?includes( $inner, $qid ; )
+ includes( $inner, $qid ; )
)
end
@@ -64,7 +64,7 @@ query size( String $formId, long $num )
Set( $num := size ) from accumulate (
$q : Question( $qid : id ) @watch( * )
and
- ?includes( $quest, $qid ; )
+ includes( $quest, $qid ; )
,
collectSet ( $q )
)
@@ -82,6 +82,7 @@ end
rule "Questionnaire Size"
+salience -5
when
$quest : Questionnaire( $formId : id )
size( $formId, $num ; )
@@ -114,7 +115,9 @@ when
accumulate (
$q : Question( $qid : id, lastAnswer != null ) @watch( * )
and
- ?includes( $quest, $qid; )
+ not InvalidAnswer( questionId == $qid )
+ and
+ includes( $quest, $qid; )
,
$num : count ( $q )
)
Please sign in to comment.
Something went wrong with that request. Please try again.