Ignore:
Timestamp:
04/19/10 18:18:22 (14 years ago)
Author:
viani
Message:

Ticket #609 - Reconstrução da classe factory do workflow

Location:
trunk/workflow/inc/engine/src/common
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/workflow/inc/engine/src/common/Base.php

    r2195 r2591  
    3939        var $child_name = 'Base'; 
    4040 
     41        /** 
     42         * @var object $db_shared_obj The database abstraction object shared between 
     43         *                                                    all instances of this class. 
     44         * @acess private 
     45         * @static 
     46         */ 
     47        private static $db_shared_obj = null; 
     48 
    4149  /** 
    4250   * Constructor receiving a database abstraction object 
     
    4654   * @access public 
    4755   */ 
    48   function Base(&$db) 
     56  function Base() 
    4957  { 
    50     if(!$db) { 
     58        /** 
     59         * New Stuff! 
     60         * We decided to get here the database object. In a recent past, 
     61         * all the classes that specialize this one passed a db object. 
     62         * Now, to simplify and save memory, we store the database object 
     63         * into a single and static atribute shared among each instance 
     64         * of this class. 
     65         * 
     66         * To prevent to modify all sub-classes to use "self::$db" instead 
     67         * of "this->db", we made a very tiny workaround here. In the first 
     68         * instantiation of this class, we instantiate the database object 
     69         * and store it into 'self::$db_shared_obj'. Any subsequent 
     70         * instantiations will just point to the static one. 
     71         */ 
     72        if (!self::$db_shared_obj) 
     73                self::$db_shared_obj = &Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID; 
     74 
     75        $this->db = &self::$db_shared_obj; 
     76 
     77 
     78    if(!$this->db) { 
    5179      die('Invalid db object passed to '.$this->child_name.' constructor'); 
    5280    } 
    5381    //Force transactionnal mysql (Innodb) -> mysqlt 
    54     if ($db->databaseType=='mysql') 
     82    if ($this->db->databaseType=='mysql') 
    5583    { 
    5684        $GLOBALS['phpgw']->db->disconnect(); 
    57         $db = $GLOBALS['phpgw']->db->connect( 
     85        $this->db = $GLOBALS['phpgw']->db->connect( 
    5886                        $GLOBALS['phpgw_info']['server']['db_name'], 
    5987                        $GLOBALS['phpgw_info']['server']['db_host'], 
     
    6492                ); 
    6593    } 
    66     $this->db = &$db; 
    6794  } 
    6895 
  • trunk/workflow/inc/engine/src/common/WfRuntime.php

    r795 r2591  
    8686   * @access public 
    8787   */ 
    88   function WfRuntime(&$db)  
     88  function WfRuntime()  
    8989  { 
    9090    $this->child_name = 'WfRuntime'; 
    91     parent::Base($db); 
    92     require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'API'.SEP.'BaseActivity.php'); 
    93     require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'API'.SEP.'Process.php'); 
    94     require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'API'.SEP.'Instance.php'); 
    95     require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'common'.SEP.'WfSecurity.php'); 
    96      
     91    parent::Base(); 
     92 
    9793    //first the activity is not set 
    9894    $this->activity = null; 
    99     $this->instance = new Instance($this->db); 
    100     $this->process = new Process($this->db); 
    101     $this->security = new WfSecurity($this->db);  
     95    $this->instance = &Factory::newInstance('Instance'); 
     96    $this->process = &Factory::newInstance('Process'); 
     97    $this->security = &Factory::getInstance('WfSecurity'); 
    10298  } 
    10399 
     
    276272      return false; 
    277273    } 
    278     $base_activity = new BaseActivity($this->db); 
     274    $base_activity = &Factory::newInstance('BaseActivity'); 
    279275    $this->activity =& $base_activity->getActivity($activity_id, $with_roles, $with_agents); 
    280276    if (!$this->activity) 
     
    10911087    $workflow = $GLOBALS['workflow']; 
    10921088    unset($_REQUEST['iid']); 
    1093     $run_activity = CreateObject('workflow.run_activity'); 
     1089    $run_activity = Factory::getInstance('run_activity'); 
    10941090    $run_activity->runtime->instance->parentInstanceId = $this->instance_id; 
    10951091    $run_activity->runtime->instance->parentActivityId = $this->activity_id; 
  • trunk/workflow/inc/engine/src/common/WfSecurity.php

    r795 r2591  
    2323   * @access public 
    2424   */ 
    25   function WfSecurity(&$db)  
     25  function WfSecurity()  
    2626  { 
    2727    $this->child_name = 'WfSecurity'; 
    28     parent::Base($db); 
    29     require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'API'.SEP.'Instance.php'); 
    30     require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'API'.SEP.'Process.php'); 
    31     require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'API'.SEP.'BaseActivity.php'); 
     28    parent::Base(); 
    3229  } 
    3330 
     
    5855      ); 
    5956      //check theses values for this process and store the result for this object life duration 
    60       $myProcess = new Process($this->db); 
     57      $myProcess = &Factory::newInstance('Process'); 
    6158      $myProcess->getProcess($pId); 
    6259      $this->processesConfig[$pId] = $myProcess->getConfigValues($arrayConf); 
     
    7875  function checkUserAccess($user, $activity_id, $readonly=false)  
    7976  { 
     77        /* if activity is non-interactive is not necessary checking user access */ 
     78        $activity = &Factory::getInstance('BaseActivity')->getActivity($activity_id); 
     79        if (!$activity->isInteractive()) 
     80                return true; 
     81 
    8082    //group mapping, warning groups and user can have the same id 
    8183    if ($user[0] != 'p') 
     
    577579      if (!(isset($this->pm))) 
    578580      { 
    579         require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'ProcessManager'.SEP.'ProcessManager.php'); 
    580         $this->pm = new ProcessManager($this->db); 
     581        $this->pm = &Factory::newInstance('ProcessManager'); 
    581582      } 
    582583      //$this->error[] = 'DEBUG: checking to see if there is no view activities on process :'.$pId.':'.$this->pm->get_process_view_activity($pId); 
Note: See TracChangeset for help on using the changeset viewer.