Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

BaseActivity.php

00001 <?php
00002 include_once (GALAXIA_LIBRARY.'/src/common/Base.php');
00005 
00011 class BaseActivity extends Base {
00012   var $name;
00013   var $normalizedName;
00014   var $description;
00015   var $isInteractive;
00016   var $isAutoRouted;
00017   var $roles=Array();
00018   var $outbound=Array();
00019   var $inbound=Array();
00020   var $pId;
00021   var $activityId;
00022   var $type;
00023   
00024   function setDb($db)
00025   {
00026     $this->db=$db;
00027   }
00028   
00029   function BaseActivity($db)
00030   {
00031     $this->db=$db;
00032     $this->type='base';
00033   }
00034   
00035   
00040   function getActivity($activityId) 
00041   {
00042     $query = "select * from `".GALAXIA_TABLE_PREFIX."activities` where `activityId`=?";
00043     $result = $this->query($query,array($activityId));
00044     if(!$result->numRows()) return false;
00045     $res = $result->fetchRow();
00046     switch($res['type']) {
00047       case 'start':
00048         $act = new Start($this->db);  
00049         break;
00050       case 'end':
00051         $act = new End($this->db);
00052         break;
00053       case 'join':
00054         $act = new Join($this->db);
00055         break;
00056       case 'split':
00057         $act = new Split($this->db);
00058         break;
00059       case 'standalone':
00060         $act = new Standalone($this->db);
00061         break;
00062       case 'switch':
00063         $act = new SwitchActivity($this->db);
00064         break;
00065       case 'activity':
00066         $act = new Activity($this->db);
00067         break;
00068       default:
00069         trigger_error('Unknown activity type:'.$res['type'],E_USER_WARNING);
00070     }
00071     
00072     $act->setName($res['name']);
00073     $act->setProcessId($res['pId']);
00074     $act->setNormalizedName($res['normalized_name']);
00075     $act->setDescription($res['description']);
00076     $act->setIsInteractive($res['isInteractive']);
00077     $act->setIsAutoRouted($res['isAutoRouted']);
00078     $act->setActivityId($res['activityId']);
00079     $act->setType($res['type']);
00080     
00081     //Now get forward transitions 
00082     
00083     //Now get backward transitions
00084     
00085     //Now get roles
00086     $query = "select `roleId` from `".GALAXIA_TABLE_PREFIX."activity_roles` where `activityId`=?";
00087     $result=$this->query($query,array($res['activityId']));
00088     while($res = $result->fetchRow()) {
00089       $this->roles[] = $res['roleId'];
00090     }
00091     $act->setRoles($this->roles);
00092     return $act;
00093   }
00094   
00096   function getUserRoles($user) {
00097     $query = "select `roleId` from `".GALAXIA_TABLE_PREFIX."user_roles` where `user`=?";
00098     $result=$this->query($query,array($user));
00099     $ret = Array();
00100     while($res = $result->fetchRow()) {
00101       $ret[] = $res['roleId'];
00102     }
00103     return $ret;
00104   }
00105 
00108   function getActivityRoleNames() {
00109     $aid = $this->activityId;
00110     $query = "select gr.`roleId`, `name` from `".GALAXIA_TABLE_PREFIX."activity_roles` gar, `".GALAXIA_TABLE_PREFIX."roles` gr where gar.`roleId`=gr.`roleId` and gar.`activityId`=?";
00111     $result=$this->query($query,array($aid));
00112     $ret = Array();
00113     while($res = $result->fetchRow()) {
00114       $ret[] = $res;
00115     }
00116     return $ret;
00117   }
00118   
00120   function getNormalizedName() {
00121     return $this->normalizedName;
00122   }
00123 
00125   function setNormalizedName($name) {
00126     $this->normalizedName=$name;
00127   }
00128   
00130   function setName($name) {
00131     $this->name=$name;
00132   }
00133   
00135   function getName() {
00136     return $this->name;
00137   }
00138   
00140   function setDescription($desc) {
00141     $this->description=$desc;
00142   }
00143   
00145   function getDescription() {
00146     return $this->description;
00147   }
00148   
00150   function setType($type) {
00151     $this->type=$type;
00152   }
00153   
00155   function getType() {
00156     return $this->type;
00157   }
00158 
00160   function setIsInteractive($is) {
00161     $this->isInteractive=$is;
00162   }
00163   
00165   function isInteractive() {
00166     return $this->isInteractive == 'y';
00167   }
00168   
00170   function setIsAutoRouted($is) {
00171     $this->isAutoRouted = $is;
00172   }
00173   
00175   function isAutoRouted() {
00176     return $this->isAutoRouted == 'y';
00177   }
00178 
00180   function setProcessId($pid) {
00181     $this->pId=$pid;
00182   }
00183   
00185   function getProcessId() {
00186     return $this->pId;
00187   }
00188 
00190   function getActivityId() {
00191     return $this->activityId;
00192   }  
00193   
00195   function setActivityId($id) {
00196     $this->activityId=$id;
00197   }
00198   
00200   function getRoles() {
00201     return $this->roles;
00202   }
00203   
00206   function setRoles($roles) {
00207     $this->roles = $roles;
00208   }
00209   
00212   function checkUserRole($user,$rolename) {
00213     $aid = $this->activityId;
00214     return $this->getOne("select count(*) from `".GALAXIA_TABLE_PREFIX."activity_roles` gar, `".GALAXIA_TABLE_PREFIX."user_roles` gur, `".GALAXIA_TABLE_PREFIX."roles` gr where gar.`roleId`=gr.`roleId` and gur.`roleId`=gr.`roleId` and gar.`activityId`=? and gur.`user`=? and gr.`name`=?",array($aid, $user, $rolename));
00215   }
00216 
00217 }
00218 ?>

Generated on Mon Jun 7 16:37:37 2004 for Galaxia by doxygen 1.3.4