Permalink
Browse files

Informer : replace update with modify

  • Loading branch information...
1 parent f21353f commit fa00d73e91f73a269c1ceaef8def9026a488cc3d @sotty sotty committed Aug 8, 2012
@@ -69,7 +69,7 @@ when
active == false )
then
modify ( $item ) {
- setActive(true);
+ setActive( true );
}
end
@@ -83,7 +83,7 @@ when
active == true )
then
modify ( $item ) {
- setActive(false);
+ setActive( false );
}
end
@@ -101,7 +101,7 @@ when
active == true )
then
modify ( $item ) {
- setActive(true);
+ setActive( true );
}
end
@@ -117,7 +117,7 @@ when
active == true )
then
modify ( $item ) {
- setActive(false);
+ setActive( false );
}
end
@@ -166,7 +166,7 @@ rule "deactivate orphan InvalidAnswers"
salience 2 // before: "propagate readonly from group to questions or subgroups"
when
$invalidAnswer : InvalidAnswer( active == true )
- not ( exists Question( id == $invalidAnswer.questionId ) )
+ not Question( id == $invalidAnswer.questionId )
then
modify ( $invalidAnswer ) {
setActive( false );
@@ -64,12 +64,16 @@ declare SurveyableMarker
id : String @key
end
+declare ISurveyable end
+
+declare trait ISurveyableTrait extends ISurveyable end
+
rule "SurveyableMarker"
salience 100
when
- ISurveyable( $id : questionnaireId, surveyEnabled == true )
+ $i : ISurveyable( $id : questionnaireId, surveyEnabled == true )
not SurveyableMarker( id == $id )
then
insert( new SurveyableMarker($id) );
@@ -225,7 +229,7 @@ rule "Clean Rules"
salience -999
when
$rh : ResourceHolder( $id : id, $res : res )
- not ISurveyable( questionnaireId == $id, surveyEnabled == true )
+ not ISurveyable( questionnaireId == $id, surveyEnabled == true )
eval ( kAgent != null )
then
ChangeSetImpl changeSet = new ChangeSetImpl();
@@ -238,8 +242,8 @@ end
rule "Cleanup"
salience -100
when
- SurveyableMarker( $id : id )
- not ISurveyable( questionnaireId == $id, surveyEnabled == true )
+ SurveyableMarker( $id : id )
+ not ISurveyable( questionnaireId == $id, surveyEnabled == true )
$obj : InformerObject( context == $id )
then
retract( $obj );
@@ -249,7 +253,7 @@ rule "Cleanup_final"
salience -110
when
$marker : SurveyableMarker( $id : id )
- not ISurveyable( questionnaireId == $id, surveyEnabled == true )
+ not ISurveyable( questionnaireId == $id, surveyEnabled == true )
then
retract( $marker );
end
@@ -48,7 +48,6 @@ then
modify ( $question ) {
setAnswer( $answer );
}
-
end
@@ -64,8 +63,6 @@ then
Object propertyValue = DomainModelSupport.answerToObject( $question.getBasicAnswerType(), $answer, PropertyUtils.getPropertyType( $object, $property ) );
PropertyUtils.setProperty( $object, $property, propertyValue );
-
-
modify ( $association ) {
setLastAnswer( $answer );
}
@@ -83,5 +80,5 @@ when
not Object( this == $obj )
)
then
- retract($assoc);
+ retract( $assoc );
end
@@ -24,7 +24,7 @@ when
$quest : Questionnaire( id == $ctx, itemList not contains $noteId )
then
modify ( $quest ) {
- addItem($noteId);
+ addItem( $noteId );
}
end
@@ -38,6 +38,6 @@ when
not Item( id == $itemId )
then
modify ( $quest ) {
- removeItem($itemId);
+ removeItem( $itemId );
}
end
@@ -33,7 +33,7 @@ when
then
modify ( $ans ) {
setQuestionId( $qid );
- }
+ }
end
@@ -43,7 +43,7 @@ when
Answer( questionId : questionId )
$invalidAnswer : InvalidAnswer( questionId == questionId )
then
- retract($invalidAnswer);
+ retract( $invalidAnswer );
end
@@ -68,8 +68,8 @@ when
then
retract( $answer );
modify ( $question ) {
- fit( null, $basicAnswerType );
- }
+ fit( null, $basicAnswerType );
+ }
end
@@ -78,16 +78,16 @@ end
rule "copy new answers into the corresponding questions"
salience 30 // before: "discard invalid multiple choice answers"
when
- answer : Answer( questionId : questionId, answerValue : value != null );
+ answer : Answer( questionId : questionId, answerValue : value != null )
$question : Question( id == questionId, basicAnswerType : basicAnswerType,
finalAnswer == false || lastAnswer == null )
then
retract(answer);
try {
modify ( $question ) {
- fit( answerValue,basicAnswerType );
- }
+ fit( answerValue, basicAnswerType );
+ }
} catch (NumberFormatException e) {
InvalidAnswer invalidAnswer = new InvalidAnswer(questionId,
"invalid",
@@ -106,13 +106,13 @@ salience 20 // before: "copy question answers to the underlying domain model"
when
$question : MultipleChoiceQuestion( questionId : id, answered == true, $answers : answerItems != null, $possibleAnswers : possibleAnswers )
$s : String() from $answers
- not PossibleAnswer( value == $s ) from $possibleAnswers
+ not PossibleAnswer( value == $s ) from $possibleAnswers
then
InvalidAnswer invalidAnswer = new InvalidAnswer( questionId,
- "invalid",
- $answers + " is not a possible answer ");
+ "invalid",
+ $answers + " is not a possible answer " );
insertLogical( invalidAnswer );
- modify ($question) {
+ modify ( $question ) {
setAnswer( null );
}
end
@@ -122,8 +122,8 @@ end
rule "retract orphan answers"
salience -1 // after: any rules that create questions
when
- $answer : Answer(questionId : questionId);
- not ( exists Question(id == questionId) );
+ $answer : Answer( questionId : questionId );
+ not Question( id == questionId )
then
retract($answer);
end
@@ -132,7 +132,7 @@ end
rule "required questions answered"
salience -1 // after: any rules that create questions
when
- $question : Question( required == true, answered == false );
+ $question : Question( required == true, answered == false )
then
InvalidAnswer invalidAnswer = new InvalidAnswer($question.getId(), "You must answer this question");
invalidAnswer.setType("invalid");
@@ -142,7 +142,7 @@ end
rule "questions missing answers"
salience -1 // after: any rules that create questions
when
- $question : Question( required == false, answered == false );
+ $question : Question( required == false, answered == false )
then
InvalidAnswer invalidAnswer = new InvalidAnswer($question.getId(), "You must answer this question");
invalidAnswer.setType("missing");
@@ -163,20 +163,20 @@ 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 )
+ exists InvalidAnswer()
then
modify ( $quest ) {
- setInvalidAnswers( true );
- }
+ setInvalidAnswers( true );
+ }
end
rule "doesn't have invalid answers"
salience -2 // after: any rules that create invalid answers
when
$quest : Questionnaire( invalidAnswers == true )
- not ( exists InvalidAnswer() )
+ not InvalidAnswer()
then
modify ( $quest ) {
setInvalidAnswers( false );

0 comments on commit fa00d73

Please sign in to comment.