IHMInputOutputDeleteProcessClass.php 1.59 KB
<?php

/**
 * @class IHMInputOutputDeleteProcessClass
 * @brief Class that's implement an InputOutputInterface used to treat a delete process request
 * @details
 */
class IHMInputOutputDeleteProcessClass implements InputOutputInterface
{
	protected $jobsManager       = null;
	private $paramsData        = null;

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

	/*
	 * @brief translate input data from IHM client to AMDA_Integration module for a delete process request
	*/
	public function getInputData($input,$function,$requestId="")
	{
		if (isset($this->paramsData))
			unset($this->paramsData);

		$this->paramsData = new ProcessRequestDataClass();

		$this->paramsData->setManagerFilePath(IHMConfigClass::getProcessManagerFilePath());
		$this->paramsData->setType(ProcessTypeEnumClass::DELETE);

		$this->paramsData->setId($input->id);
		$this->paramsData->setUser(IHMConfigClass::getUserName());

		return $this->paramsData;
	}

	/*
	 * @brief translate output data from AMDA_Integration module to IHM client for a delete process request
	*/
	public function getOutput($data)
	{
		if (!$data->getSuccess())
		{
			return array(
					'success' => false,
					'message' => $data->getLastErrorMessage());
		}

		$res = $this->jobsManager->deleteJob($this->paramsData->getId());

		/*if (!$res['success'])
		{
			return array(
					'success' => false,
					'message' => $res['message']);
		}*/

		return array(
				'success' => true,
				'id'      => $this->paramsData->getId());
	}
}

?>