WSInputOutputGetInfoProcessClass.php 1.97 KB
<?php

/**
 * @class WSInputOutputGetInfoProcessClass
 * @brief Class that's implement an InputOutputInterface used to treat a get info process request
 * @details
 */
class WSInputOutputGetInfoProcessClass extends IHMInputOutputGetInfoProcessClass
{
	protected $jobsManager       = null;
//	protected $paramsData        = null;

	/*
	 * @brief Constructor
	*/
	function __construct()
	{
		$this->jobsManager      = new WSJobsManagerClass();
	}

 
	/*
	 * @brief translate output data from AMDA_Integration module to IHM client for a get info process request
	*/
// ProcessRequestDataClass Object
// (
//     [managerfilePath:ProcessRequestDataClass:private] => /home/budnik/AMDA/AMDA_IHM/data/processManager.xml
//     [workingPath:ProcessRequestDataClass:private] => 
//     [cmd:ProcessRequestDataClass:private] => 
//     [envVars:ProcessRequestDataClass:private] => Array
//         (
//         )
// 
//     [postCmd:ProcessRequestDataClass:private] => 
//     [id:ProcessRequestDataClass:private] => process_t7ovpn_1520344095_13119
//     [type:ProcessRequestDataClass:private] => info
//     [batchEnable:ProcessRequestDataClass:private] => 1
//     [status:ProcessRequestDataClass:private] => done
//     [exitCode:ProcessRequestDataClass:private] => 0
//     [start:ProcessRequestDataClass:private] => 1520344095
//     [success:RequestDataClass:private] => 1
//     [lastErrorMessage:RequestDataClass:private] => Cannot run process request
// )
// 	
	
	public function getOutput($data)
	{
		if (!$data->getSuccess())
		{
			return array(
					'success' => false,
					'message' => $data->getLastErrorMessage());
		}

		$jobInfo = $this->jobsManager->updateJobStatus(
					$data->getId(),
					$data->getStatus() == ProcessStatusEnumClass::RUNNING,
					$data->getErrorCode());

		if (!$jobInfo['success'])
		{
			return array(
					'success' => false,
					'message' => $data->getLastErrorMessage());
		}	 
		return $jobInfo;
	}
}

?>