Ignore:
Timestamp:
05/26/10 10:12:22 (14 years ago)
Author:
viani
Message:

Ticket #950 - Merged 2589:2838 /trunk/workflow/ em /sandbox/workflow/trunk/

Location:
sandbox/workflow/trunk/inc/local/classes
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sandbox/workflow/trunk/inc/local/classes/class.wf_engine.php

    r2466 r2858  
    192192        { 
    193193                $WFInstance = &Factory::getInstance('wf_instance'); 
    194                 $preOutput = $WFInstance->getChildren($instanceID, $activityID); 
     194                $preOutput = $WFInstance->getChildren($instanceID); 
    195195                $output = array(); 
    196196                foreach ($preOutput as $childInstance) 
  • sandbox/workflow/trunk/inc/local/classes/class.wf_instance.php

    r2466 r2858  
    250250 
    251251        /** 
    252         * Busca as instâncias filhas de uma instância 
    253         * Se os parâmetros não forem informados, retorna instâncias filhas das instância atual. 
    254         * @param int $instanceID O ID da instância pai (não obrigatório). 
    255         * @param int $activityID O ID da atividade corrente da instância pai 
    256         * @return array As instâncias filhas do par instância/atividade atual 
    257         * @access public 
    258         */ 
    259         public function getChildren($instanceID = null, $activityID = null) 
     252        * This method gets all children instances of the given instance. 
     253        * If there is no parameter, it gets the children instances of the current instance 
     254        * @param int $instanceID Dad instance's identification. 
     255        * @return array Array with the children instances, or false 
     256        * @access public 
     257        */ 
     258        public function getChildren($instanceID = null) 
    260259        { 
    261260                $output = array(); 
    262261                if (is_null($instanceID)) 
    263262                        $instanceID = $GLOBALS['workflow']['wf_runtime']->instance_id; 
    264                 if (is_null($activityID)) 
    265                         $activityID = $GLOBALS['workflow']['wf_runtime']->activity_id; 
    266  
    267                 /* check instanceID */ 
    268                 if (!$this->checkInstanceAccess($instanceID, $activityID)) 
     263 
     264                /* check instanceID */ 
     265                if (!$this->checkInstanceAccess($instanceID)) 
    269266                        return $output; 
    270267 
    271268                /* build the SQL query */ 
    272                 $query = 'SELECT i.wf_instance_id AS wf_instance_id, ia.wf_activity_id AS wf_activity_id, ia.wf_started AS wf_started, i.wf_name AS wf_name, i.wf_status AS wf_status, ia.wf_user AS wf_user, ir.wf_parent_lock AS wf_parent_lock '; 
    273                 $query .= 'FROM egw_wf_interinstance_relations ir, egw_wf_instances i LEFT JOIN egw_wf_instance_activities ia ON (ia.wf_instance_id = i.wf_instance_id)'; 
    274                 $query .= 'WHERE (ir.wf_child_instance_id = i.wf_instance_id) AND (ir.wf_parent_instance_id = ?) AND (ir.wf_parent_activity_id = ?)'; 
    275  
    276                 $result = $this->db->query($query, array($instanceID, $activityID)); 
     269                $query = 'SELECT i.wf_instance_id AS wf_instance_id, ' . 
     270                                 '       ia.wf_activity_id AS wf_activity_id, ' . 
     271                                 '       i.wf_started AS wf_started, ' . 
     272                                 '       i.wf_name AS wf_name, ' . 
     273                                 '       i.wf_status AS wf_status, ' . 
     274                                 '       ia.wf_user AS wf_user, ' . 
     275                                 '       ir.wf_parent_lock AS wf_parent_lock ' . 
     276                                 ' FROM egw_wf_interinstance_relations ir, egw_wf_instances i ' . 
     277                                 '  LEFT JOIN egw_wf_instance_activities ia ' . 
     278                                 '  ON (ia.wf_instance_id = i.wf_instance_id) ' . 
     279                                 ' WHERE ' . 
     280                                 '  (ir.wf_child_instance_id = i.wf_instance_id) AND (ir.wf_parent_instance_id = ?) '; 
     281 
     282                $result = $this->db->query($query, array($instanceID)); 
    277283                $output = $result->GetArray(-1); 
    278284 
  • sandbox/workflow/trunk/inc/local/classes/class.wf_natural.php

    r795 r2858  
    11<?php 
    2         require_once(PHPGW_SERVER_ROOT.SEP.'workflow'.SEP.'inc'.SEP.'natural'.SEP.'class.natural.php'); 
     2/**************************************************************************\ 
     3* eGroupWare                                                               * 
     4* http://www.egroupware.org                                                * 
     5* --------------------------------------------                             * 
     6*  This program is free software; you can redistribute it and/or modify it * 
     7*  under the terms of the GNU General Public License as published by the   * 
     8*  Free Software Foundation; either version 2 of the License, or (at your  * 
     9*  option) any later version.                                              * 
     10\**************************************************************************/ 
     11 
     12require_once(PHPGW_SERVER_ROOT.SEP.'workflow'.SEP.'inc'.SEP.'natural'.SEP.'class.natural.php'); 
     13 
     14/** 
     15 * Mainframe connection to workflow 
     16 * 
     17 * TODO - This class should be removed from here. Its based on a not 
     18 * public protocol, thus cannot be used for everybody. 
     19 * 
     20 * @package Workflow 
     21 * @subpackage local 
     22 * @license http://www.gnu.org/copyleft/gpl.html GPL 
     23 * @author Everton Flávio Rufino Seára 
     24 */ 
     25class wf_natural extends Natural 
     26{ 
    327 
    428        /** 
    5         * Mainframe connection to workflow 
    6         * @author Everton Flávio Rufino Seára 
    7         * @package Workflow 
    8         * @subpackage local 
    9         * @license http://www.gnu.org/copyleft/gpl.html GPL 
    10         **/ 
     29         * @var object Log Object 
     30         * @access private 
     31         */ 
     32        private $logger = null; 
    1133 
    12         class wf_natural extends Natural 
     34        function __construct() 
    1335        { 
     36                parent::Natural(); 
    1437 
    15                 function __construct() 
    16                 { 
    17                         parent::Natural(); 
     38                $natconf = array( 
     39                                        'mainframe_ip'                  => '', 
     40                                        'mainframe_port'                => '', 
     41                                        'mainframe_key'                 => '', 
     42                                        'mainframe_password'    => '', 
     43                                        'mainframe_environment' => '' 
     44                ); 
    1845 
    19                         $natconf = array( 
    20                                                 'mainframe_ip'                  => '', 
    21                                                 'mainframe_port'                => '', 
    22                                                 'mainframe_key'                 => '', 
    23                                                 'mainframe_password'    => '', 
    24                                                 'mainframe_environment' => '' 
    25                         ); 
     46                $nat_conf_values = &Factory::getInstance('workflow_wfruntime')->getConfigValues($natconf); 
    2647 
    27                         $nat_conf_values = $GLOBALS['workflow']['wf_runtime']->getConfigValues($natconf); 
     48                $this->setIPAddress($nat_conf_values['mainframe_ip']); 
     49                $this->setServerPort($nat_conf_values['mainframe_port']); 
     50                $this->setKey($nat_conf_values['mainframe_key']); 
     51                $this->setPassword($nat_conf_values['mainframe_password']); 
     52                $this->setApplication($nat_conf_values['mainframe_environment']); 
    2853 
    29                         $this->setIPAddress($nat_conf_values['mainframe_ip']); 
    30                         $this->setServerPort($nat_conf_values['mainframe_port']); 
    31                         $this->setKey($nat_conf_values['mainframe_key']); 
    32                         $this->setPassword($nat_conf_values['mainframe_password']); 
    33                         $this->setApplication($nat_conf_values['mainframe_environment']); 
     54                $this->logger = &Factory::getInstance('Logger', array('file')); 
     55        } 
     56 
     57        /** 
     58         * This method MUST be called before using execute method 
     59         * It specifies the natural sub-program to be accessed. 
     60         * 
     61         * @param Object $obj Object that specifies natural sub-program properties 
     62         * @return void 
     63         */ 
     64        public function configure($obj) 
     65        { 
     66                $this->obj = $obj; 
     67 
     68                $this->initialize($obj->name); 
     69 
     70                if ($obj->server != NULL){ 
     71                        $this->setIPAddress($obj->server); 
    3472                } 
    35  
    36                 /** 
    37                  * Method to configure the access to mainframe 
    38                  * This method MUST be called before using execute method, else 'false' will be returned 
    39                  * 
    40                  * Only the first and second param are mandatory. 
    41                  * 
    42                  * @param String $subProgram - Name of sub-program 
    43                  * @param String $inputParameter - Input parameters to sub-program 
    44                  * 
    45                  * @param String $ip - IP Address of Mainfram 
    46                  * @param int $port - ServerPort to access the mainframe 
    47                  * @param String $key - Access key (user) 
    48                  * @param String $password - Key (user) password 
    49                  * @param char $environment - Application environment access 'D' (development) or 'P' (production) 
    50  
    51                  */ 
    52  
    53                 public function configure($obj) 
    54                 { 
    55                         $this->obj = $obj; 
    56  
    57                         $this->initialize($obj->name); 
    58  
    59                         if ($obj->server != NULL){ 
    60                                 $this->setIPAddress($obj->server); 
    61                         } 
    62                         if ($obj->port != NULL){ 
    63                                 $this->setServerPort($obj->port); 
    64                         } 
    65                         if ($obj->key != NULL){ 
    66                                 $this->setKey($obj->key); 
    67                         } 
    68                         if ($obj->password != NULL){ 
    69                                 $this->setPassword($obj->password); 
    70                         } 
    71                         if ($obj->environment != NULL){ 
    72                                 $this->setApplication($obj->environment); 
    73                         } 
    74                         if ($obj->logon != NULL){ 
    75                                 $this->setLogon($obj->logon); 
    76                         } 
    77                         if ($obj->system != NULL){ 
    78                                 $this->setSystem($obj->system); 
    79                         } 
    80                         if ($obj->rc != NULL){ 
    81                                 $this->setRC($obj->rc); 
    82                         } 
     73                if ($obj->port != NULL){ 
     74                        $this->setServerPort($obj->port); 
    8375                } 
    84  
    85                 /* 
    86  
    87                 public function configure($subProgram, $inputParameter, $ip = NULL, $port = NULL, 
    88                                                                                 $key = NULL, $password = NULL, $environment = NULL, $logon = NULL, $system = NULL, $rc = NULL) 
    89                 { 
    90                         $this->initialize($subProgram, $inputParameter); 
    91  
    92                         if ($ip != NULL){ 
    93                                 $this->setIPAddress($ip); 
    94                         } 
    95                         if ($port != NULL){ 
    96                                 $this->setServerPort($port); 
    97                         } 
    98                         if ($key != NULL){ 
    99                                 $this->setKey($key); 
    100                         } 
    101                         if ($password != NULL){ 
    102                                 $this->setPassword($password); 
    103                         } 
    104                         if ($environment != NULL){ 
    105                                 $this->setApplication($environment); 
    106                         } 
    107                         if ($logon != NULL){ 
    108                                 $this->setLogon($logon); 
    109                         } 
    110                         if ($system != NULL){ 
    111                                 $this->setSystem($system); 
    112                         } 
    113                         if ($rc != NULL){ 
    114                                 $this->setRC($rc); 
    115                         } 
    116  
     76                if ($obj->key != NULL){ 
     77                        $this->setKey($obj->key); 
    11778                } 
    118  
    119                  */ 
    120  
    121                 /** 
    122                  * Access and retrieve data from mainframe 
    123                  * @return bool 
    124                  */ 
    125                 public function execute($inputParams = "") 
    126                 { 
    127                         return parent::execute($inputParams); 
     79                if ($obj->password != NULL){ 
     80                        $this->setPassword($obj->password); 
     81                } 
     82                if ($obj->environment != NULL){ 
     83                        $this->setApplication($obj->environment); 
     84                } 
     85                if ($obj->logon != NULL){ 
     86                        $this->setLogon($obj->logon); 
     87                } 
     88                if ($obj->system != NULL){ 
     89                        $this->setSystem($obj->system); 
     90                } 
     91                if ($obj->rc != NULL){ 
     92                        $this->setRC($obj->rc); 
    12893                } 
    12994        } 
     95 
     96        /** 
     97         * Method for accessing and retrieving data from mainframe 
     98         * @return bool 
     99         */ 
     100        public function execute($inputParams = "") 
     101        { 
     102                // execute action and log wasted time 
     103                $totalTime = microtime(true); 
     104                $result = parent::execute($inputParams); 
     105                $totalTime = microtime(time) - $totalTime; 
     106                $log = sprintf("WF_NATURAL [subprogram=%s] [time=%ss]", 
     107                                        $this->obj->name, 
     108                                        number_format($totalTime,3) 
     109                                        ); 
     110                $this->logger->debug($log); 
     111                return $result; 
     112        } 
     113} 
    130114?> 
Note: See TracChangeset for help on using the changeset viewer.