package cdac.medinfo.sdk.dcm30_04.services.colorpalette.sourceimpl;

import cdac.medinfo.sdk.dcm30_04.baselibs.AlternateContentDescriptionSequence;
import cdac.medinfo.sdk.dcm30_04.baselibs.DicomV3Factory;
import cdac.medinfo.sdk.dcm30_04.utils.DicomConstants;
/**
 * This class represents the ColorPalette Attributes.
 *
 */
public class ColorPaletteDefinitionAttributes extends Attributes{
	/**
	 * Sets the Content Label of Color Palette.
	 * @param strContentLabel
	 */
	public void setContentLabel(String strContentLabel)
	{
		/* Accept the Hanging Protocol Level in String format of type CS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		addDataElement(0x0070, 0x0080, DicomConstants.DCM_DT_CS,strContentLabel);
	}
	/**
	 * Return the Color Palette Content Label.
	 * @return String - value of Color Palette Content Label.
	 */
	public String getHangingProtocolLevel()
	{
		Object objValue = getValue(0x0070, 0x0080);
		if(objValue != null)
			return objValue.toString();
		return null;
	}
	
	/**
	 * Sets the Explanation of the objective or intent of the  Color Palette
	 * @param strContentDescription
	 */
	public void setContentDescription(String strContentDescription)
	{
		/*Accept the Color Palette Name Content Descriptionin String format.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		addDataElement(0x0070, 0x0081, DicomConstants.DCM_DT_LO,strContentDescription);
	}
	/**
	 * Retrieves Explanation of the objective or intent of the  Color Palette
	 * @return String - value of Content Description Description
	 */
	public String getContentDescription()
	{
		Object objValue = getValue(0x0070, 0x0081);
		if(objValue != null)
			return objValue.toString();
		return null;
	}
	
	/**
	 * Retrieves pre-initialized object of Alternate Content DescriptionSequence
	 * @return AlternateContentDescriptionSequence - Alternate Content DescriptionSequence
	 */
	public AlternateContentDescriptionSequence getAlternateContentDescriptionSequence()
	{
		AlternateContentDescriptionSequence objAlternateContentDescriptionSequence = (AlternateContentDescriptionSequence)getDicomValue(0x0070, 0x0087);
		if(objAlternateContentDescriptionSequence == null)
		{
			/*
			 * If the sequence object is not present in the DataSet, a new sequence object is created and
			 * the TransferSyntax and DictionaryReader is set into it as it is set in the Module. This ensures that 
			 * the DataElements getting added in the DataSet follow the same TransferSyntax and use the same
			 * DictionaryReader object as that of the module.
			 */
			DicomV3Factory objDicomV3Factory = DicomV3Factory.createInstance();
			objAlternateContentDescriptionSequence = (AlternateContentDescriptionSequence)objDicomV3Factory.createSequence(0x0070, 0x0087,getDataSet().getTransferSyntax(), getDataSet().getDictionaryReader());
			
			// This will add Data Element of SQ to the DataSet.
			addDataElement(0x0070, 0x0087, DicomConstants.DCM_DT_SQ, objAlternateContentDescriptionSequence.getValue());
		}
		return objAlternateContentDescriptionSequence;	
	}
	
}
