RequestOutputStatisticNodeClass.php 3.65 KB
<?php

define ("REQUESTOUTPUTSTATISTIC_NAME", "statistic");
define ("REQUESTOUTPUTSTATISTIC_TIMEFORMAT", "timeFormat");
define ("REQUESTOUTPUTSTATISTIC_FILEFORMAT", "fileFormat");
define ("REQUESTOUTPUTSTATISTIC_STRUCTURE", "outputStructure");
define ("REQUESTOUTPUTSTATISTIC_FILENAME", "fileName");

define ("REQUESTOUTPUTSTATISTICPARAM_NAME",  "param");
define ("REQUESTOUTPUTSTATISTICFUNCTION_NAME",  "function");
define ("REQUESTOUTPUTSTATISTICPARAM_ID", "id");
define ("REQUESTOUTPUTSTATISTICFUNCTION_ID",  "name");

abstract class RequestOutputStatisticTimeFormatEnum
{
	const UNKNOWN = "";
	const ISO   = "ISO";
}

abstract class RequestOutputStatisticFileFormatEnum
{
	const UNKNOWN = "";
	const ASCII   = "ASCII";
	const XML     = "XML";
	const VOT     = "VOT";
}

abstract class RequestOutputStatisticStructureEnum
{
	const UNKNOWN                             = "";
	const ONE_FILE                            = "one-file";
	const ONE_FILE_PER_INTERVAL               = "one-file-per-interval";
}

class RequestOutputStatisticFunctionNodeClass extends NodeClass
{
	public function __construct()
	{
		parent::__construct(REQUESTOUTPUTSTATISTICFUNCTION_NAME);		
	}

	public function setFunctionName($name)
	{
		$this->setAttribute(REQUESTOUTPUTSTATISTICFUNCTION_ID, $name);
	}
}

class RequestOutputStatisticParamNodeClass extends NodeClass
{
	public function __construct()
	{
		parent::__construct(REQUESTOUTPUTSTATISTICPARAM_NAME);
	}

	public function setId($id)
	{
		$this->setAttribute(REQUESTOUTPUTSTATISTICPARAM_ID, $id);
	}

	public function getId()
	{
		return $this->getAttribute(REQUESTOUTPUTSTATISTICPARAM_ID);
	}
		
	public function addFunction($name)
	{		
		$node = new RequestOutputStatisticFunctionNodeClass();	 
		$this->addChild($node);		 
	 	$node->setFunctionName($name);		 
	}
}

/**
 * @class RequestOutputStatisticNodeClass
 * @brief Definition of a request data mining output node for AMDA_Kernel
 * @details
 */
class RequestOutputStatisticNodeClass extends NodeClass
  {
	public function __construct()
	{
		parent::__construct(REQUESTOUTPUTSTATISTIC_NAME);				
	}

	public function setTimeFormat($timeFormat)
	{
		$node = $this->getChildInstanceByName(REQUESTOUTPUTSTATISTIC_TIMEFORMAT, true);
		$node->setValue($timeFormat);
	}

	public function setFileFormat($fileFormat)
	{
		$node = $this->getChildInstanceByName(REQUESTOUTPUTSTATISTIC_FILEFORMAT, true);
		$node->setValue($fileFormat);
	}

	public function setStructure($structure)
	{
		$node = $this->getChildInstanceByName(REQUESTOUTPUTSTATISTIC_STRUCTURE, true);
		$node->setValue($structure);						
	}

	public function setFileName($fileName)
	{
		$node = $this->getChildInstanceByName(REQUESTOUTPUTSTATISTIC_FILENAME, true);
		$node->setValue($fileName);
	}

	public function addParam($id)
	{
		$paramsNode = $this->getFirstChildByName(REQUESTPARAMS_NAME);
		
		if (!$paramsNode)
		{
			$paramsNode = new RequestParamsNodeClass();
			$this->addChild($paramsNode);
		}

		$node = new RequestOutputStatisticParamNodeClass();
		$paramsNode->addChild($node);

		$node->setId($id);
		
		return $node;
	}
	
	public function addPostProcessing($process)
	{
		$node = $this->getChildInstanceByName(REQUESTOUTPUTPOSTPROCESSING_NAME);
		if ($node == NULL)
		{
			$node = new RequestOutputPostProcessingNodeClass();
			$this->addChild($node);
		}

		$node->addPostProcessing($process);
	}

	public function isPostProcessing($process)
	{
		$node = $this->getChildInstanceByName(REQUESTOUTPUTPOSTPROCESSING_NAME);

		if ($node == NULL)
			return false;
			
		return $node->isPostProcessing($process);
	}
}

?>