Ignore:
Timestamp:
08/07/09 16:06:07 (15 years ago)
Author:
gbisotto
Message:

Ticket #609 - Modificada a classe Factory e ProcessFactory? para automatizaro acesso ao objetos

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sandbox/workflow/2.0/inc/class.workflow_processmanager.inc.php

    r795 r1293  
    2626                        'database_user', 
    2727                        'database_password' 
    28                 );  
     28                ); 
    2929           /** 
    3030                 * Constructor 
     
    3434                function workflow_processmanager() 
    3535                { 
    36                         parent::ProcessManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID); 
     36                        parent::ProcessManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID); 
    3737                        $this->workflow_acl = CreateObject('workflow.workflow_acl'); 
    38                          
     38 
    3939                        /* allow regular users to see the process graph */ 
    4040                        if ($_GET['menuaction'] == "workflow.ui_adminactivities.show_graph") 
     
    6767                        { 
    6868                                $proc_name = $this->_normalize_name($data['name'],$data['version']); 
    69                                 foreach($data['templates'] as $tpl)  
     69                                foreach($data['templates'] as $tpl) 
    7070                                { 
    7171                                        $full_fname = GALAXIA_PROCESSES.SEP.$proc_name.SEP.'code'.SEP.'templates'.SEP.$tpl['name']; 
    7272                                        if (file_exists($full_fname)) unlink($full_fname); 
    73                                          
     73 
    7474                                        $fp = fopen($full_fname,"w"); 
    7575                                fwrite($fp, $tpl['code']); 
     
    7777                                } 
    7878 
    79                                 foreach($data['includes'] as $inc)  
     79                                foreach($data['includes'] as $inc) 
    8080                                { 
    8181                                        $full_fname = GALAXIA_PROCESSES.SEP.$proc_name.SEP.'code'.SEP.$inc['name']; 
    8282                                        if (file_exists($full_fname)) unlink($full_fname); 
    83                                          
     83 
    8484                                        $fp = fopen($full_fname,"w"); 
    8585                                fwrite($fp, $inc['code']); 
     
    111111                } 
    112112 
    113                 /**  
     113                /** 
    114114        * Creates an XML representation of a process. 
    115115                * Original from ProcessManager Class 
     
    124124                        if (!isset($this->jobManager)) 
    125125                                $this->jobManager = new JobManager($this->db); 
    126                  
     126 
    127127                        //if (!(isset($this->activity_manager)))  $this->activity_manager = new ActivityManager($this->db); 
    128128                        // <process> 
     
    151151                        //Loop on config values 
    152152                        $out.='  <configs>'."\n"; 
    153                         foreach($proc_info['config'] as $res) {       
     153                        foreach($proc_info['config'] as $res) { 
    154154                          $name = $res['wf_config_name']; 
    155155                          $value_int = $res['wf_config_value_int']; 
    156156                          $value = $res['wf_config_value']; 
    157                           if (array_search($name,$this->not_export_attributes) === false)  
     157                          if (array_search($name,$this->not_export_attributes) === false) 
    158158                          { 
    159159                                $out.='    <config>'."\n"; 
     
    167167 
    168168                        // Now loop over activities 
    169                          
     169 
    170170                        $act_list = $this->activity_manager->list_activities($pId, 0, -1, 'wf_name__asc', '','',false); 
    171171                        $out.='  <activities>'."\n"; 
    172                         foreach($act_list['data'] as $res) {       
     172                        foreach($act_list['data'] as $res) { 
    173173                          $name = $res['wf_normalized_name']; 
    174174                          $out.='    <activity>'."\n"; 
     
    193193                                  $out.='        <role>'.htmlspecialchars($role['wf_name']).'</role>'."\n"; 
    194194                                } 
    195                           }   
     195                          } 
    196196                          $out.='      </roles>'."\n"; 
    197197                          $out.='      <agents>'."\n"; 
     
    216216                                $out.='           </agent_datas>'."\n"; 
    217217                                $out.='        </agent>'."\n"; 
    218                           }   
     218                          } 
    219219                          $out.='      </agents>'."\n"; 
    220220 
     
    238238                                $out.='      ]]></template>'; 
    239239                          } 
    240                           $out.='    </activity>'."\n";     
     240                          $out.='    </activity>'."\n"; 
    241241                        } 
    242242                        $out.='  </activities>'."\n"; 
    243                          
     243 
    244244                        //export all templates 
    245                         $base_path = GALAXIA_PROCESSES.SEP.$wf_procname.SEP.'code'.SEP.'templates';      
    246                         $handle = opendir($base_path);  
     245                        $base_path = GALAXIA_PROCESSES.SEP.$wf_procname.SEP.'code'.SEP.'templates'; 
     246                        $handle = opendir($base_path); 
    247247                        $out.='  <templates>'."\n"; 
    248248                        while (false !== ($name = readdir($handle))) 
     
    263263                                fclose($fp); 
    264264                                $out.='      ]]></code>'; 
    265                                 $out.='    </template>'."\n";     
     265                                $out.='    </template>'."\n"; 
    266266                        } 
    267267                        $out.='  </templates>'."\n"; 
    268268 
    269                         //export all includes  
    270                         $base_path = GALAXIA_PROCESSES.SEP.$wf_procname.SEP.'code';      
    271                         $handle = opendir($base_path);  
     269                        //export all includes 
     270                        $base_path = GALAXIA_PROCESSES.SEP.$wf_procname.SEP.'code'; 
     271                        $handle = opendir($base_path); 
    272272                        $out.='  <includes>'."\n"; 
    273273                        while (false !== ($name = readdir($handle))) 
     
    291291                                fclose($fp); 
    292292                                $out.='      ]]></code>'; 
    293                                 $out.='    </include>'."\n";     
     293                                $out.='    </include>'."\n"; 
    294294                        } 
    295295                        $out.='  </includes>'."\n"; 
     
    314314                        $out .= "  </jobs>\n"; 
    315315 
    316                         //export all resources  
     316                        //export all resources 
    317317                        $base_path = GALAXIA_PROCESSES . SEP . $wf_procname . SEP . 'resources'; 
    318                         $handle = opendir($base_path);  
     318                        $handle = opendir($base_path); 
    319319                        $out.='  <resources>'."\n"; 
    320320                        while (false !== ($name = readdir($handle))) 
    321                         {  
     321                        { 
    322322                                if (is_dir($base_path.SEP.$name)) 
    323323                                        continue; 
     
    348348                          $out.='       <to>'.htmlspecialchars($tran['wf_act_to_name']).'</to>'."\n"; 
    349349                          $out.='     </transition>'."\n"; 
    350                         }      
     350                        } 
    351351                        $out.='  </transitions>'."\n"; 
    352352                        $out.= '</process>'."\n"; 
    353                          
     353 
    354354                        //$fp = fopen(GALAXIA_PROCESSES."/$wf_procname/$wf_procname.xml","w"); 
    355355                        //fwrite($fp,$out); 
     
    360360                /** 
    361361                 * Creates  a process PHP data structure from its XML representation 
    362                  *  
    363                  * Unserialize process data   
     362                 * 
     363                 * Unserialize process data 
    364364                 * @access public 
    365365                 * @return void 
    366366                 */ 
    367                 function unserialize_process(&$xml)  
     367                function unserialize_process(&$xml) 
    368368                { 
    369369                        // Create SAX parser assign this object as base for handlers 
    370370                        // handlers are private methods defined below. 
    371371                        // keep contexts and parse 
    372                         $this->parser = xml_parser_create("ISO-8859-1");  
     372                        $this->parser = xml_parser_create("ISO-8859-1"); 
    373373                        xml_parser_set_option($this->parser,XML_OPTION_CASE_FOLDING,0); 
    374374                        //xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE, 1); 
     
    376376                        xml_set_element_handler($this->parser, '_start_element_handler', '_end_element_handler'); 
    377377                        xml_set_character_data_handler($this->parser, '_data_handler'); 
    378                           
     378 
    379379                        $aux=Array( 
    380380                          'name'=>'root', 
    381381                          'children'=>Array(), 
    382382                          'parent' => 0, 
    383                           'data'=>'',  
     383                          'data'=>'', 
    384384                          'attribs'     => Array(), 
    385385                        ); 
    386                          
     386 
    387387                        $this->tree[0]=$aux; 
    388388                        $this->current=0; 
    389                          
     389 
    390390                        if (!xml_parse($this->parser, $xml, true)) { 
    391391                           $error = sprintf("XML error: %s at line %d", 
     
    395395                           $this->error[] = $error; 
    396396                        } 
    397                         xml_parser_free($this->parser);    
     397                        xml_parser_free($this->parser); 
    398398                        // Now that we have the tree we can do interesting things 
    399                          
     399 
    400400                        $process=Array(); 
    401401                        $activities=Array(); 
     
    406406                          $z=$this->tree[1]['children'][$i]; 
    407407                          $name = trim($this->tree[$z]['name']); 
    408                            
     408 
    409409                          //config values 
    410410                          if ($name=='configs') { 
     
    422422                                        $configs[]=$aux; 
    423423                                  } 
    424                                 }       
     424                                } 
    425425                          } 
    426426                          //activities 
     
    453453                                                  ); 
    454454                                                } 
    455                                           }  
    456                                           elseif ($name=='agents')  
     455                                          } 
     456                                          elseif ($name=='agents') 
    457457                                          { 
    458458                                                $agents=Array(); 
    459                                                 for($l=0;$l<count($this->tree[$z3]['children']);$l++)  
     459                                                for($l=0;$l<count($this->tree[$z3]['children']);$l++) 
    460460                                                { 
    461461                                                  $z4 = $this->tree[$z3]['children'][$l]; 
     
    472472                                                          // data will be the agent_type or an array for agent_datas 
    473473                                                          $data = trim($this->tree[$z5]['data']); 
    474                                                           if ($name=='agent_type')  
     474                                                          if ($name=='agent_type') 
    475475                                                          { 
    476476                                                                $agent['wf_agent_type']=$data; 
    477                                                           }  
    478                                                           elseif ($name=='agent_datas')  
     477                                                          } 
     478                                                          elseif ($name=='agent_datas') 
    479479                                                          { 
    480480                                                                for($n=0;$n<count($this->tree[$z5]['children']);$n++) 
     
    618618                        return $process; 
    619619                  } 
    620                    
     620 
    621621                /** 
    622622                 * Creates a new process PHP data structure from its XML representation 
    623                  * unserial  
     623                 * unserial 
    624624                 * @access public 
    625625                 * @return void 
     
    641641                /** 
    642642                 * Remove process 
    643                  * @param int $pId process id  
    644                  * @access public 
    645                  * @return string  
     643                 * @param int $pId process id 
     644                 * @access public 
     645                 * @return string 
    646646                 */ 
    647647                  function remove_process($pId) 
     
    653653                /** 
    654654                 * Replace_process 
    655                  *  
    656                  * @param int      $pid     process id  
    657                  * @param array    $vars  
     655                 * 
     656                 * @param int      $pid     process id 
     657                 * @param array    $vars 
    658658                 * @param boolean  $create 
    659                  *    
     659                 * 
    660660                 * @access public 
    661661                 * @return int new id 
     
    671671 
    672672                        return $id; 
    673           }      
     673          } 
    674674        } 
    675675?> 
Note: See TracChangeset for help on using the changeset viewer.