package cdac.medinfo.sdk.hl7282.hl7net.auxiliaryprotocol.transactionhandler;

import cdac.medinfo.sdk.hl7282.baselibs.messages.Message;
import cdac.medinfo.sdk.hl7282.utils.EnumMessageCode;
import cdac.medinfo.sdk.hl7282.utils.StandardMethods;

/**
 * This class holds required information about Message.
 * It contains Message Structure,Message Event,Message Controller ID & Query Identifier of Message.  
 */
public class MessageData   
{

	private String strMessageStructure = null;
	private String strTriggerEvent = null;
	private String strBatchControlID = null;
	private EnumMessageCode enumMessageCode = null;
	private String strMessageControllerID = null;
	private String strQueryIdentifier = null;;
	private boolean booldeferred = false;
	private boolean bBatchExpected = false;

	/**
	 * Constructor of MessageData for initializing Members.
	 * @param objMessage - object of Message
	 */
	public MessageData(Message objMessage)
	{
		strMessageStructure = objMessage.getMessageStructure();
		strTriggerEvent = objMessage.getTriggerEvent();
		enumMessageCode = StandardMethods.getEnumMessageCode(objMessage.getMessageCode());
		strMessageControllerID = (String)objMessage.getHeader().getMessageControlID().getValue();
	}

	/**
	 * Set b Batch Expected
	 * @param bBatchExpected - object b batch Expected
	 */
	public void setBatchExpected(boolean bBatchExpected)
	{
		this.bBatchExpected = bBatchExpected;
	}


	/** 
	 * Checks whether incoiming entity is batch or not.  
	 * @return boolean - Returns true if incoming entity is batch or not.
	 */
	public boolean isBatchExpected()
	{
		return bBatchExpected;
	}

	/**
	 * Retrieves Message Structure
	 * @return String - message structure retrived. 
	 */
	public String getMessageStructure() 
	{
		return strMessageStructure;
	}
	/**
	 * Retrieves Trigger Event
	 * @return String - Trigger event retrived.
	 */
	public String getTriggerEvent()
	{
		return strTriggerEvent;
	}


	/**
	 * Retrieves Message Code.
	 * @return EnumMessageCode - Message Code.
	 */
	public EnumMessageCode getEnumMessageCode()
	{
		return enumMessageCode;
	}

	/**
	 * Retrieves Message Controller ID.
	 * @return String - Message Controller ID.
	 */
	public String getMessageControllerID()
	{
		return strMessageControllerID;
	}

	/**
	 * Retrieves Query Identifier.
	 * @return String - Query Identifier.
	 */
	public String getQueryIdentifier() 
	{
		return strQueryIdentifier;
	}

	/**
	 * Sets Query Identifier.
	 * @param strQueryIdentifier - Query Identifier.
	 */
	public void setQueryIdentifier(String strQueryIdentifier)
	{
		this.strQueryIdentifier = strQueryIdentifier;
	}

	/**
	 * @param deferred
	 */
	public void setDeferred(boolean deferred)
	{
		this.booldeferred = deferred;
	}

	/**
	 * @return  boolean
	 */
	public boolean  getDeferred()
	{
		return this.booldeferred;
	}

	/**
	 * This will set the Batch Control ID for the batch. 
	 */
	public void setBatchControlID(String strBatchControlID)
	{
		this.strBatchControlID = strBatchControlID; 
	}

	/**
	 * Retrieves Batch ControlID .
	 * @return String - Batch ControlID
	 */
	public String getBatchControlID() 
	{
		return strBatchControlID;
	}
}
