RequestOutputDataMiningNodeClass.php 4.47 KB
<?php

require_once "RequestOutputPostProcessingNodeClass.php";

define ("REQUESTOUTPUTDATAMINING_NAME", "dataMining");
define ("REQUESTOUTPUTDATAMINING_TIMEFORMAT", "timeFormat");
define ("REQUESTOUTPUTDATAMINING_FILEFORMAT", "fileFormat");
define ("REQUESTOUTPUTDATAMINING_STRUCTURE", "outputStructure");
define ("REQUESTOUTPUTDATAMINING_FILENAME", "fileName");

define ("REQUESTOUTPUTDATAMININGPARAM_NAME",  "param");
define ("REQUESTOUTPUTDATAMININGPARAM_ID", "id");

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

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

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

class RequestOutputDataMiningParamNodeClass extends NodeClass
{
	public function __construct()
	{
		parent::__construct(REQUESTOUTPUTDATAMININGPARAM_NAME);
	}

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

	public function getId()
	{
		return $this->getAttribute(REQUESTOUTPUTDATAMININGPARAM_ID);
	}
	
	public function loadFromNode($xmlNode)
	{
		$this->setId($this->getXmlNodeAttribute($xmlNode, REQUESTOUTPUTDATAMININGPARAM_ID));
	}
}

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

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

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

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

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

	public function setParam($id = "")
	{
		$node = $this->getFirstChildByName(REQUESTOUTPUTDATAMININGPARAM_NAME);
		if (!$node)
		{
			$node = new RequestOutputDataMiningParamNodeClass();
			$this->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);
		}

		if ($process != "")
			$node->addPostProcessing($process);
		return $node;
	}

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

		if ($node == NULL)
			return false;
			
		return $node->isPostProcessing($process);
	}
	
	public function loadFromNode($xmlNode)
	{
		$timeformatXmlNode = $this->getXmlNodeChildByTagName($xmlNode, REQUESTOUTPUTDATAMINING_TIMEFORMAT);
		if (isset($timeformatXmlNode))
			$this->setTimeFormat($this->getXmlNodeValue($timeformatXmlNode));
		
		$fileformatXmlNode = $this->getXmlNodeChildByTagName($xmlNode, REQUESTOUTPUTDATAMINING_FILEFORMAT);
		if (isset($fileformatXmlNode))
			$this->setFileFormat($this->getXmlNodeValue($fileformatXmlNode));
		
		$structureXmlNode = $this->getXmlNodeChildByTagName($xmlNode, REQUESTOUTPUTDATAMINING_STRUCTURE);
		if (isset($structureXmlNode))
			$this->setStructure($this->getXmlNodeValue($structureXmlNode));
		
		$filenameXmlNode = $this->getXmlNodeChildByTagName($xmlNode, REQUESTOUTPUTDATAMINING_FILENAME);
		if (isset($filenameXmlNode))
			$this->setFileName($this->getXmlNodeValue($filenameXmlNode));
		
		foreach ($this->getXmlNodeChildrenByTagName($xmlNode, REQUESTOUTPUTDATAMININGPARAM_NAME) as $paramXmlNode) {
			$this->setParam()->loadFromNode($paramXmlNode);
		}
		
		$postProcessingXmlNode = $this->getXmlNodeChildByTagName($xmlNode, REQUESTOUTPUTPOSTPROCESSING_NAME);
		if (isset($postProcessingXmlNode))
			$this->addPostProcessing()->loadFromNode($postProcessingXmlNode);
	}
}

?>