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

InstanceManager.php

00001 <?php
00002 include_once(GALAXIA_LIBRARY.'/src/ProcessManager/BaseManager.php');
00005 
00009 class InstanceManager extends BaseManager {
00010   
00015   function InstanceManager($db) 
00016   {
00017     if(!$db) {
00018       die("Invalid db object passed to InstanceManager constructor");  
00019     }
00020     $this->db = $db;  
00021   }
00022   
00023   function get_instance_activities($iid)
00024   {
00025     $query = "select ga.type,ga.isInteractive,ga.isAutoRouted,gi.pId,ga.activityId,ga.name,gi.instanceId,gi.status,gia.activityId,gia.user,gi.started,gia.status as actstatus from ".GALAXIA_TABLE_PREFIX."activities ga,".GALAXIA_TABLE_PREFIX."instances gi,".GALAXIA_TABLE_PREFIX."instance_activities gia where ga.activityId=gia.activityId and gi.instanceId=gia.instanceId and gi.instanceId=$iid";
00026     $result = $this->query($query);
00027     $ret = Array();
00028     while($res = $result->fetchRow()) {
00029       // Number of active instances
00030       $ret[] = $res;
00031     }
00032     return $ret;
00033   }
00034 
00035   function get_instance($iid)
00036   {
00037     $query = "select * from ".GALAXIA_TABLE_PREFIX."instances gi where instanceId=$iid";
00038     $result = $this->query($query);
00039     $res = $result->fetchRow();
00040     $res['workitems']=$this->getOne("select count(*) from ".GALAXIA_TABLE_PREFIX."workitems where instanceId=$iid");
00041     return $res;
00042   }
00043 
00044   function get_instance_properties($iid)
00045   {
00046     $prop = unserialize($this->getOne("select properties from ".GALAXIA_TABLE_PREFIX."instances gi where instanceId=$iid"));
00047     return $prop;
00048   }
00049   
00050   function set_instance_properties($iid,&$prop)
00051   {
00052     $props = addslashes(serialize($prop));
00053     $query = "update ".GALAXIA_TABLE_PREFIX."instances set properties='$props' where instanceId=$iid";
00054     $this->query($query);
00055   }
00056   
00057   function set_instance_owner($iid,$owner)
00058   {
00059     $query = "update ".GALAXIA_TABLE_PREFIX."instances set owner='$owner' where instanceId=$iid";
00060     $this->query($query);
00061   }
00062   
00063   function set_instance_status($iid,$status)
00064   {
00065     $query = "update ".GALAXIA_TABLE_PREFIX."instances set status='$status' where instanceId=$iid";
00066     $this->query($query); 
00067   }
00068   
00069   function set_instance_destination($iid,$activityId)
00070   {
00071     $query = "delete from ".GALAXIA_TABLE_PREFIX."instance_activities where instanceId=$iid";
00072     $this->query($query);
00073     $query = "insert into ".GALAXIA_TABLE_PREFIX."instance_activities(instanceId,activityId,user,status)
00074     values($iid,$activityId,'*','running')";
00075     $this->query($query);
00076   }
00077   
00078   function set_instance_user($iid,$activityId,$user)
00079   {
00080     $query = "update ".GALAXIA_TABLE_PREFIX."instance_activities set user='$user', status='running' where instanceId=$iid and activityId=$activityId";
00081     $this->query($query);  
00082   }
00083 
00084 }    
00085 
00086 ?>

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