Skip to content
This repository has been archived by the owner on Jan 20, 2022. It is now read-only.

Commit

Permalink
Informer-interaction : replace update with modify, fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sotty committed Aug 25, 2012
1 parent fa00d73 commit 8245e48
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 18 deletions.
Expand Up @@ -491,10 +491,10 @@ then
holder.setTaskId( $tid );
holder.setOwner( $t.getOwner() );
System.out.println( "Create interactive task transition Quest' >>>>>>>>>>>" + holder + " for " + $t + " with owner " + $t.getOwner() );
insert( holder );
modify ( $t ) {
setControlQuestId( holder.getQuestionnaireId() );
setControlQuestId( holder.getQuestionnaireId() );
}
insert( holder );
end

rule "Clear Tx Qs"
Expand Down
Expand Up @@ -210,12 +210,13 @@ when
not TaskStateTransition( $tid ; )
then
retract( $alert );
$receivers.remove( 0 );
$channels.remove( 0 );
$timeouts.remove( 0 );
$bodies.remove( 0 );
System.out.println( " Interaction is NOW " + $inter );
update( $inter );
modify( $inter ) {
getReceivers().remove( 0 ),
getChannels().remove( 0 ),
getTimeouts().remove( 0 ),
getBodyTemplateIds().remove( 0 );
}
insert( new TaskStateTransition( $tid, TaskTransitions.DELEGATE, (String) $receivers.get( 0 ), new Date() ) );
insert( new TaskStateTransition( $tid, TaskTransitions.START, (String) $receivers.get( 0 ), new Date() ) );
end
Expand All @@ -233,10 +234,12 @@ when
then
System.out.println( $dest + " did not answer " + $alert );
retract( $alert );
$receivers.remove( 0 );
$channels.remove( 0 );
System.out.println( " Interaction is FAILED " + $inter );
update( $inter );

modify( $inter ) {
getReceivers().remove( 0 ),
getChannels().remove( 0 );
}
insert( new TaskStateTransition( $tid, TaskTransitions.ERROR, null, new Date() ) );
end

Expand Down
Expand Up @@ -85,8 +85,9 @@ when
$task : HumanTask( taskId == $qid, state != TaskStates.IN_PROGRESS )
then
System.out.println( "DISABLING A QUEST FOR A NOT STARTED TASK " + $qid );
$quest.setSurveyLocked( true );
update( $quest );
modify ( $quest ) {
setSurveyLocked( true );
}
end

rule "Enable Quest when HumanTask in Progress"
Expand All @@ -96,8 +97,9 @@ when
$task : HumanTask( taskId == $qid, state == TaskStates.IN_PROGRESS )
then
System.out.println( "ENABLING A QUEST FOR A STARTED TASK " + $qid );
$quest.setSurveyLocked( false );
update( $quest );
modify ( $quest ) {
setSurveyLocked( false );
}
end


Expand Down
Expand Up @@ -21,8 +21,6 @@
import org.drools.conf.AssertBehaviorOption;
import org.drools.conf.EventProcessingOption;
import org.drools.definition.type.FactType;
import org.drools.event.rule.DebugAgendaEventListener;
import org.drools.event.rule.DebugWorkingMemoryEventListener;
import org.drools.informer.Answer;
import org.drools.informer.MultipleChoiceQuestion;
import org.drools.io.impl.ClassPathResource;
Expand Down Expand Up @@ -171,7 +169,7 @@ public void run() {


try {
Thread.sleep( 2000 );
Thread.sleep( 3000 );
} catch (InterruptedException e) {
fail();
}
Expand Down Expand Up @@ -337,7 +335,7 @@ public void run() {
System.err.println( kSession.getGlobal( "list" ) );
System.err.println( kSession.getGlobal( "taskLog" ) );

assertEquals(Arrays.asList("actor1", "main1", "actor2", "alien2", "actor3"), kSession.getGlobal("list"));
assertTrue( ((List)kSession.getGlobal("list")).containsAll( Arrays.asList("actor1", "main1", "actor2", "alien2", "actor3") ) );
assertEquals( 14, ((List) kSession.getGlobal( "taskLog" )).size() );

kSession.dispose();
Expand Down

0 comments on commit 8245e48

Please sign in to comment.