[795] | 1 | <?php |
---|
[3167] | 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 | \**************************************************************************/ |
---|
[795] | 11 | |
---|
[3167] | 12 | require_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 | */ |
---|
| 25 | class wf_natural extends Natural |
---|
| 26 | { |
---|
| 27 | |
---|
[795] | 28 | /** |
---|
[3167] | 29 | * @var object Log Object |
---|
| 30 | * @access private |
---|
| 31 | */ |
---|
| 32 | private $logger = null; |
---|
[795] | 33 | |
---|
[3167] | 34 | function __construct() |
---|
[795] | 35 | { |
---|
[3167] | 36 | parent::Natural(); |
---|
[795] | 37 | |
---|
[3167] | 38 | $natconf = array( |
---|
| 39 | 'mainframe_ip' => '', |
---|
| 40 | 'mainframe_port' => '', |
---|
| 41 | 'mainframe_key' => '', |
---|
| 42 | 'mainframe_password' => '', |
---|
| 43 | 'mainframe_environment' => '' |
---|
| 44 | ); |
---|
[795] | 45 | |
---|
[3167] | 46 | $nat_conf_values = &Factory::getInstance('workflow_wfruntime')->getConfigValues($natconf); |
---|
[795] | 47 | |
---|
[3167] | 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']); |
---|
[795] | 53 | |
---|
[3167] | 54 | $this->logger = &Factory::getInstance('Logger', array('file')); |
---|
| 55 | } |
---|
[795] | 56 | |
---|
[3167] | 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; |
---|
[795] | 67 | |
---|
[3167] | 68 | $this->initialize($obj->name); |
---|
[795] | 69 | |
---|
[3167] | 70 | if ($obj->server != NULL){ |
---|
| 71 | $this->setIPAddress($obj->server); |
---|
[795] | 72 | } |
---|
[3167] | 73 | if ($obj->port != NULL){ |
---|
| 74 | $this->setServerPort($obj->port); |
---|
[795] | 75 | } |
---|
[3167] | 76 | if ($obj->key != NULL){ |
---|
| 77 | $this->setKey($obj->key); |
---|
[795] | 78 | } |
---|
[3167] | 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); |
---|
| 93 | } |
---|
[795] | 94 | } |
---|
[3167] | 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 | } |
---|
[795] | 114 | ?> |
---|