Problem with Join Activity Posted by pemen 20 Apr 2005 14:08 GMT-0000 The join activity seems to not working. The join activity is activate even when all the previous activities aren't completed. Is anybody has already work on this type of activity ??? Thanks
Posted by pemen 20 Apr 2005 15:25 GMT-0000 > > > The join activity seems to not working. > > The join activity is activate even when all the previous > activities aren't completed. > > > Is anybody has already work on this type of activity ??? > > > > Thanks I make a correction on the file lib/galaxia/src/API/instance.php Please test this function. !! I add a code that test, in a join activity, if there are still link activities that are not completed we STOP. function sendTo($from,$activityId,$split=false) { //1: if we are in a join check //if this instance is also in //other activity if so do //nothing $type = $this->getOne("select `type` from `".GALAXIA_TABLE_PREFIX."activities` where `activityId`=?",arrayint)$activityId; // Verify the existance of a transition if(!$this->getOne("select count(*) from `".GALAXIA_TABLE_PREFIX."transitions` where `actFromId`=? and `actToId`=?",array($from,(int)$activityId))) { trigger_error(tra('Fatal error: trying to send an instance to an activity but no transition found'),E_USER_WARNING); } //try to determine the user or * //Use the nextUser if($this->nextUser) { $putuser = $this->nextUser; } else { $candidates = Array(); $query = "select `roleId` from `".GALAXIA_TABLE_PREFIX."activity_roles` where `activityId`=?"; $result = $this->query($query,arrayint)$activityId; while ($res = $result->fetchRow()) { $roleId = $res'roleId'; $query2 = "select `user` from `".GALAXIA_TABLE_PREFIX."user_roles` where `roleId`=?"; $result2 = $this->query($query2,arrayint)$roleId; while ($res2 = $result2->fetchRow()) { $candidates[] = $res2'user'; } } if(count($candidates) == 1) { $putuser = $candidates0; } else { $putuser = '*'; } } //update the instance_activities table //if not splitting delete first //please update started,status,user if(!$split) { // $query = "delete from `".GALAXIA_TABLE_PREFIX."instance_activities` where `instanceId`=? and `activityId`=?"; // $this->query($query,arrayint)$this->instanceId,$from; } $now = date("U"); $iid = $this->instanceId; // JOIN // NEW FROM pemen // Test if the activity has previous link activity that are not completed if ($type == 'join') { $querycant = "select count(*) from `".GALAXIA_TABLE_PREFIX."transitions` tr " . "INNER JOIN ".GALAXIA_TABLE_PREFIX."instance_activities gia ON tr.actFromId=gia.activityId " . "where tr.pid=? and tr.actToId=? and gia.instanceId=? and gia.status = ?"; // if there is still link activities not completed STOP if ($nb = $this->getone($querycant, arrayint)$this->pId, $activityId, $iid, 'running') { echo 'nb en cours=' . $nb; return; } } $query="delete from `".GALAXIA_TABLE_PREFIX."instance_activities` where `instanceId`=? and `activityId`=?"; $this->query($query,arrayint)$iid,(int)$activityId; $query="insert into `".GALAXIA_TABLE_PREFIX."instance_activities`(`instanceId`,`activityId`,`user`,`status`,`started`) values(?,?,?,?,?)"; $this->query($query,arrayint)$iid,(int)$activityId,$putuser,'running',(int)$now; //we are now in a new activity $this->activities=Array(); $query = "select * from `".GALAXIA_TABLE_PREFIX."instance_activities` where `instanceId`=?"; $result = $this->query($query,arrayint)$iid; while ($res = $result->fetchRow()) { $this->activities[]=$res; } /* if ($type == 'join') { if (count($this->activities)>1) { // This instance will have to wait! return; } } */ //if the activity is not interactive then //execute the code for the activity and //complete the activity $isInteractive = $this->getOne("select `isInteractive` from `".GALAXIA_TABLE_PREFIX."activities` where `activityId`=?",arrayint)$activityId; if ($isInteractive=='n') { // Now execute the code for the activity (function defined in lib/Galaxia/config.php) galaxia_execute_activity($activityId, $iid , 1); // Reload in case the activity did some change $this->getInstance($this->instanceId); $this->complete($activityId); } }
Posted by davidsan1 26 Jul 2005 00:07 GMT-0000 I tested your function. Seems to be better but not quite there. Firstly, I had trouble copying it over because there are link embedded in the text so I had to delete those out. Secondly, for me it did stop the problem of activating the next activity after only one of many join activity were completed. However after completing all the join activities, the next next activity was not activated. (Wish I had a better grasp of the vocabulary.) Is this your experience. Any idea why I might be seeing this? Dave