IHMInputOutputClass.php 4.27 KB
<?php

/**
 * @class IHMInputOutputClass
 * @brief Class that's implement an InputOutputInterface for AMDA IHM client.
 * @details
 */
class IHMInputOutputClass implements InputOutputInterface
{
	protected $inputOutput = null;
	protected $userWSMgr   = null;

	/*
	 * @brief Constructor
	*/
	function __construct($userName, $userHost)
	{
		IHMConfigClass::setUserName($userName);
		IHMConfigClass::setUserHost($userHost);
		$this->userWSMgr = new IHMUserWSManagerClass();
	}

	/*
	 * @brief translate input data from AMDA IHM to AMDA_Integration module
	*/
	public function getInputData($input,$function,$requestId = "")
	{
		switch ($function)
		{
			case FunctionTypeEnumClass::PARAMS :
				switch ($input->nodeType)
				{
					case 'download' :
						//download data
						if ($input->downloadSrc != "0")
							throw new Exception('Download source '.$input->downloadSrc.' not implemented for this client.');
						$this->inputOutput = new IHMInputOutputParamsDownloadClass();
						break;
					case 'condition' :
						//data mining
						$this->inputOutput = new IHMInputOutputParamsDataMiningClass();
						break;
					case 'request' :
						//plot
						if (($input->{"file-format"} == "PNG") && ($input->{"file-output"} == "INTERACTIVE"))
						{
							//set working dir for interactive plot
							$requestId = "Plot";
						}
						$this->inputOutput = new IHMInputOutputParamsPlotClass();
						break;
					case 'multiplot' :
						//multiplot
						$this->inputOutput = new IHMInputOutputParamsMultiPlotClass();
						//set working dir for interactive plot
						$requestId = "Plot";
						break;
					case 'statistic' :
						//catalog generation
						$this->inputOutput = new IHMInputOutputParamsStatisticsClass();
						break;
					case 'killplot' :
						$requestId = "Plot";
						$this->inputOutput = new IHMInputOutputParamsKillPlotClass();
						break;
					default :
						throw new Exception('Params request type '.$input_request->nodeType.' not implemented for this client.');
				}
				break;
			case FunctionTypeEnumClass::PARAMSGEN :
				$this->inputOutput = new IHMInputOutputParamsGeneratorClass();
				$requestId = "ParamGen";
				break;
                        case FunctionTypeEnumClass::PARAMSINFOGEN :
                                $this->inputOutput = new IHMInputOutputParamsInfoGeneratorClass();
                                $requestId = "ParamInfoGen";
                                break;
			case FunctionTypeEnumClass::ACTION :
				if (!$input->action->multiplot) {
					$this->inputOutput = new IHMInputOutputParamsPlotClass();
				}
				else {
					$this->inputOutput = new IHMInputOutputParamsMultiPlotClass();
				}
				$requestId = "Plot";
				break;
			case FunctionTypeEnumClass::PROCESSDELETE :
				$this->inputOutput = new IHMInputOutputDeleteProcessClass();
				break;
			case FunctionTypeEnumClass::PROCESSRUNNINGINFO :
				$this->inputOutput = new IHMInputOutputRunningInfoProcessClass();
				break;
			case FunctionTypeEnumClass::PROCESSGETINFO :
				$this->inputOutput = new IHMInputOutputGetInfoProcessClass();
				break;
			case FunctionTypeEnumClass::PROCESSCLEAN :
				$this->inputOutput = new IHMInputOutputCleanProcessClass();
				break;
			case FunctionTypeEnumClass::PROCESSGETREQUEST :
				$this->inputOutput = new IHMInputOutputGetProcessRequestClass();
				break;
				/*case FunctionTypeEnumClass::TTMERGE :
				 $this->inputOutput = new IHMInputOutputMergeTTClass();
				break;
				case FunctionTypeEnumClass::TTUNION :
				$this->inputOutput = new IHMInputOutputUnionTTClass();
				break;*/
			case FunctionTypeEnumClass::TTCONVERT :
				$this->inputOutput = new IHMInputOutputTTClass();
				break;
			case FunctionTypeEnumClass::PARAMINFO :
				$this->inputOutput = new IHMInputOutputParamInfoClass();
				break;
			case FunctionTypeEnumClass::USERWSINIT :
				return $this->userWSMgr->init();
			default :
				throw new Exception('Request type '.$function.' not implemented for this client.');
		}

		return $this->inputOutput->getInputData($input,$function,$requestId);
	}

	/*
	 * @brief translate output data from AMDA_Integration module to AMDA IHM
	*/
	public function getOutput($data)
	{
		if (!isset($this->inputOutput))
			return array("success" => false, "message" => "Input Output Interface not initialized for this request");

		return $this->inputOutput->getOutput($data);
	}
}

?>