/*******************************************************************************
 *  Copyright 2017-2018 Centre for Development of Advanced Computing(C-DAC), Pune
 *  
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *  
 *   http://www.apache.org/licenses/LICENSE-2.0
 *  
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *******************************************************************************/
package cdac.medinfo.sdk.dcm30_04.dicommodel.presentationstate;

import java.io.IOException;
import java.util.Locale;

import cdac.medinfo.sdk.dcm30_04.commoninterface.IDataSet;
import cdac.medinfo.sdk.dcm30_04.commoninterface.IDicomStream;
import cdac.medinfo.sdk.dcm30_04.commoninterface.IDictionaryReader;
import cdac.medinfo.sdk.dcm30_04.commoninterface.ITransferSyntax;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.BitmapDisplayShutterModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.ClinicalTrialSeriesModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.DisplayShutterModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.DisplayedAreaModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.GeneralEquipmentModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.GeneralSeriesModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.GeneralStudyModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.GraphicAnnotationModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.GraphicGroupModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.GraphicLayerModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.ICCProfileModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.NonImageIOD;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.OverlayPlaneModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.PatientModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.PatientStudyModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.PresentationSeriesModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.PresentationStateIdentificationModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.PresentationStateRelationshipModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.PresentationStateShutterModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.SOPCommonModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.SpatialTransformationModule;
import cdac.medinfo.sdk.dcm30_04.enums.EnumModuleNames;
import cdac.medinfo.sdk.dcm30_04.enums.EnumSOPClassUIDs;

import cdac.medinfo.sdk.dcm30_04.exceptions.InvalidIODException;
import cdac.medinfo.sdk.dcm30_04.exceptions.InvalidModuleException;
import cdac.medinfo.sdk.dcm30_04.exceptions.ParseException;
import cdac.medinfo.sdk.dcm30_04.utils.DicomConfig;
import cdac.medinfo.sdk.dcm30_04.utils.DicomLogger;
import cdac.medinfo.sdk.dcm30_04.utils.ResourceBundleWrapper;
/**
 * The Color Softcopy Presentation State Information Object Definition (IOD) specifies information that may be used to present (display)color images that are referenced from within the IOD.
 * @author saloni
 *
 */
public class ColorSoftcopyPresentationStateIOD extends NonImageIOD 
{

	/**
	 * The Constant COLOR_SOFTCOPY_PRESENTATION_STATE_IOD.
	 */
	public static final String COLOR_SOFTCOPY_PRESENTATION_STATE_IOD = "Color Softcopy Presentation State IOD";

	/**
	 * The obj patient module.
	 */
	PatientModule objPatientModule  = null ;                   

	/**
	 * The obj general study module.
	 */
	GeneralStudyModule objGeneralStudyModule = null;

	/**
	 * The obj patient study module.
	 */
	PatientStudyModule	objPatientStudyModule = null;

	/**
	 * The obj general series module.
	 */
	GeneralSeriesModule objGeneralSeriesModule = null;
	
	/**
	 * The obj clinical trial series module.
	 */
	ClinicalTrialSeriesModule objClinicalTrialSeriesModule = null;
	
	/**
	 * The obj general equipment module.
	 */
	GeneralEquipmentModule	objGeneralEquipmentModule = null;
	
	/**
	 * The obj sop common module.
	 */
	SOPCommonModule	objSOPCommonModule = null;
	
	/**
	 * The obj Presentation Series module.
	 */
	PresentationSeriesModule objPresentationSeriesModule = null;
	
	/**
	 * The obj Presentation State Identification module.
	 */
	PresentationStateIdentificationModule	objPresentationStateIdentificationModule = null;
	
	/**
	 * The obj Presentation State Relationship module.
	 */
	PresentationStateRelationshipModule	objPresentationStateRelationshipModule = null;
	
	/**
	 * The obj Presentation State Shutter module.
	 */
	PresentationStateShutterModule	objPresentationStateShutterModule = null;
	
	/**
	 * The obj Display Shutter module.
	 */
	DisplayShutterModule	objDisplayShutterModule = null;
	
	/**
	 * The obj Bitmap Display Shutter module.
	 */
	BitmapDisplayShutterModule	objBitmapDisplayShutterModule = null;
	
	/**
	 * The obj Overlay Plane module.
	 */
	OverlayPlaneModule	objOverlayPlaneModule = null;
	
	/**
	 * The obj Displayed Area module.
	 */
	DisplayedAreaModule	objDisplayedAreaModule = null;
	
	/**
	 * The obj Graphic Annotation module.
	 */
	GraphicAnnotationModule	objGraphicAnnotationModule = null;
	
	/**
	 * The obj Spatial Transformation module.
	 */
	SpatialTransformationModule	objSpatialTransformationModule = null;
	
	/**
	 * The obj Graphic Layer module.
	 */
	GraphicLayerModule	objGraphicLayerModule = null;
	
	/**
	 * The obj Graphic Group module.
	 */
	GraphicGroupModule	objGraphicGroupModule = null;
	
	/**
	 * The obj ICC Profile module.
	 */
	ICCProfileModule objICCProfileModule = null;

	/**
	 * This constructor initializes the TransferSyntax, Dictionary Reader and data set in its superclass IOD.
	 */
	public ColorSoftcopyPresentationStateIOD()
	{
		super();
	}

	/**
	 * This constructor initializes the TransferSyntax  in its superclass IOD.
	 * 
	 * @param objITransferSyntax_ - specifies the DICOM Standard defined TransfeSyntax.
	 */
	public ColorSoftcopyPresentationStateIOD(ITransferSyntax objITransferSyntax_)
	{
		super(objITransferSyntax_);
	}

	/**
	 * This constructor initializes the  DictionaryReader
	 * in its superclass IOD.
	 * 
	 * @param objIDictionaryReader_ - specifies the DICOM Dictionary reader to be used .
	 */
	public ColorSoftcopyPresentationStateIOD(IDictionaryReader objIDictionaryReader_)
	{
		super(objIDictionaryReader_);
	}

	/**
	 * This constructor accepts the DataSet from the user   in its superclass IOD.
	 * 
	 * @param objIDataSet_ - specifies the data set to be set in the IOD.
	 */
	public ColorSoftcopyPresentationStateIOD(IDataSet objIDataSet_)
	{
		super(objIDataSet_);
	}

	/**
	 * This constructor initializes the TransferSyntax and DictionaryReader in its super class IOD.
	 * 
	 * @param objITransferSyntax_ specifies the DICOM Standard defined TransfeSyntax.
	 * @param objIDictionaryReader_ specifies the DICOM Dictionary reader to be used .
	 */
	public ColorSoftcopyPresentationStateIOD(ITransferSyntax objITransferSyntax_,IDictionaryReader objIDictionaryReader_)
	{
		super(objITransferSyntax_,objIDictionaryReader_);
	}

	/**
	 * Creates ColorSoftcopyPresentationStateIOD IOD from a DICOM file containing ColorSoftcopyPresentationStateIOD DICOM data.
	 * @param strFileName DICOM File with absolute path.
	 * @throws IOException Exception caused due to wrong I/O operations. 
	 * @throws ParseException signals if some parse exceptions are occurred.
	 * @throws InvalidIODException signals if some IOD exceptions are occurred.
	 */
	public ColorSoftcopyPresentationStateIOD(String strFileName)throws IOException,InvalidIODException
	{
		super(strFileName);
		try
		{
			if(objIDataSet != null)
			{
				String strSOPClassUID = objIDataSet.getSOPClassUID();
				if(strSOPClassUID != null)
				{
					if(!strSOPClassUID.equals(EnumSOPClassUIDs.COLORSOFTCOPYPRESENTATIONSTATEIOD.getValue()))
					{
						throw new InvalidIODException(ResourceBundleWrapper.getValue("exceptions", "InvalidIOD.FileNotMatched", new Locale(DicomConfig.createInstance().getLocale())) + COLOR_SOFTCOPY_PRESENTATION_STATE_IOD);
					}
				}
				strSOPClassUID = null;
			}
		}
		catch(InvalidIODException iie)
		{
			if(DicomConfig.createInstance().isLoggingOn())
			{
				DicomLogger.getLogger().log(iie.getMessage());
			}
			throw iie;
		}
	}


	/**
	 * Retrieves pre-initialized instance of Patient Module. Creates a new instance
	 * if no pre-existing module instance is available.If previously created instance is
	 * present then returns the same module instance.
	 * 
	 * @return PatientModule - instance of {@link PatientModule}.
	 */
	public PatientModule getPatientModule() 
	{
		if(objPatientModule == null)
			objPatientModule = new PatientModule(objIDataSet);

		return objPatientModule;
	}

	/**
	 * Retrieves pre-initialized instance of General Study Module. Creates a new instance
	 * if no pre-existing module instance is available.If previously created instance is
	 * present then returns the same module instance.
	 * 
	 * @return GeneralStudyModule - instance of {@link GeneralStudyModule}.
	 */
	public GeneralStudyModule getGeneralStudyModule() 
	{
		if(objGeneralStudyModule == null)
		{
			objGeneralStudyModule = new GeneralStudyModule(objIDataSet);
			return objGeneralStudyModule;
		}
		return objGeneralStudyModule;
	}

	/**
	 * Retrieves pre-initialized instance of Patient Study Module. Creates a new instance
	 * if no pre-existing module instance is available.If previously created instance is
	 * present then returns the same module instance.
	 * 
	 * @return PatientStudyModule - instance of {@link PatientStudyModule}.
	 */
	public PatientStudyModule getPatientStudyModule() 
	{
		if(objPatientStudyModule == null)
		{
			objPatientStudyModule = new PatientStudyModule(objIDataSet);
			return objPatientStudyModule;
		}
		return objPatientStudyModule;
	}

	/**
	 * Retrieves pre-initialized instance of General Series Module. Creates a new instance
	 * if no pre-existing module instance is available.If previously created instance is
	 * present then returns the same module instance.
	 * 
	 * @return GeneralSeriesModule - instance of {@link GeneralSeriesModule}.
	 */
	public GeneralSeriesModule getGeneralSeriesModule() 
	{
		if(objGeneralSeriesModule == null)
		{
			objGeneralSeriesModule = new GeneralSeriesModule(objIDataSet);
			return objGeneralSeriesModule;
		}
		return objGeneralSeriesModule;
	}
	
	/**
	 * Retrieves pre-initialized instance of Clinical Trial Series Module. Creates a new instance
	 * if no pre-existing module instance is available.If previously created instance is
	 * present then returns the same module instance.
	 * 
	 * @return ClinicalTrialSeriesModule - instance of {@link ClinicalTrialSeriesModule}.
	 */
	public ClinicalTrialSeriesModule getClinicalTrialSeriesModule() 
	{
		if(objClinicalTrialSeriesModule == null)
		{
			objClinicalTrialSeriesModule = new ClinicalTrialSeriesModule(objIDataSet);
			return objClinicalTrialSeriesModule;
		}
		return objClinicalTrialSeriesModule;
	}
	
	/**
	 * Retrieves pre-initialized instance of General Equipment Module. Creates a new instance
	 * if no pre-existing module instance is available.If previously created instance is
	 * present then returns the same module instance.
	 * 
	 * @return GeneralEquipmentModule - instance of {@link GeneralEquipmentModule}.
	 */
	public GeneralEquipmentModule getGeneralEquipmentModule() 
	{
		if(objGeneralEquipmentModule == null)
		{
			objGeneralEquipmentModule = new GeneralEquipmentModule(objIDataSet);
			return objGeneralEquipmentModule;
		}
		return objGeneralEquipmentModule;
	}
	
	/**
	 * Retrieves pre-initialized instance of SOP Common Module. Creates a new instance
	 * if no pre-existing module instance is available.If previously created instance is
	 * present then returns the same module instance.
	 * 
	 * @return SOPCommonModule - instance of {@link SOPCommonModule}.
	 */
	public SOPCommonModule getSOPCommonModule() 
	{
		if(objSOPCommonModule == null)
		{
			objSOPCommonModule = new SOPCommonModule(objIDataSet);
			return objSOPCommonModule;
		}
		return objSOPCommonModule;
	}
	
	/**
	 * Retrieves pre-initialized instance of  Presentation Series Module. Creates a new instance
	 * if no pre-existing module instance is available.If previously created instance is
	 * present then returns the same module instance.
	 * 
	 * @return PresentationSeriesModule - instance of {@link PresentationSeriesModule}.
	 */
	public PresentationSeriesModule getPresentationSeriesModule() 
	{
		if(objPresentationSeriesModule == null)
		{
			objPresentationSeriesModule = new PresentationSeriesModule(objIDataSet);
			return objPresentationSeriesModule;
		}
		return objPresentationSeriesModule;
	}
	
	/**
	 * Retrieves pre-initialized instance of Presentation State Identification Module. Creates a new instance
	 * if no pre-existing module instance is available.If previously created instance is
	 * present then returns the same module instance.
	 * 
	 * @return PresentationStateIdentificationModule - instance of {@link PresentationStateIdentificationModule}.
	 */
	public PresentationStateIdentificationModule getPresentationStateIdentificationModule() 
	{
		if(objPresentationStateIdentificationModule == null)
		{
			objPresentationStateIdentificationModule = new PresentationStateIdentificationModule(objIDataSet);
			return objPresentationStateIdentificationModule;
		}
		return objPresentationStateIdentificationModule;
	}
	
	/**
	 * Retrieves pre-initialized instance of Presentation State Relationship Module. Creates a new instance
	 * if no pre-existing module instance is available.If previously created instance is
	 * present then returns the same module instance.
	 * 
	 * @return PresentationStateRelationshipModule - instance of {@link PresentationStateRelationshipModule}.
	 */
	public PresentationStateRelationshipModule getPresentationStateRelationshipModule() 
	{
		if(objPresentationStateRelationshipModule == null)
		{
			objPresentationStateRelationshipModule = new PresentationStateRelationshipModule(objIDataSet);
			return objPresentationStateRelationshipModule;
		}
		return objPresentationStateRelationshipModule;
	}
	
	/**
	 * Retrieves pre-initialized instance of Presentation State Shutter Module. Creates a new instance
	 * if no pre-existing module instance is available.If previously created instance is
	 * present then returns the same module instance.
	 * 
	 * @return PresentationStateShutterModule - instance of {@link PresentationStateShutterModule}.
	 */
	public PresentationStateShutterModule getPresentationStateShutterModule() 
	{
		if(objPresentationStateShutterModule == null)
		{
			objPresentationStateShutterModule = new PresentationStateShutterModule(objIDataSet);
			return objPresentationStateShutterModule;
		}
		return objPresentationStateShutterModule;
	}
	
	/**
	 * Retrieves pre-initialized instance of Display Shutter Module. Creates a new instance
	 * if no pre-existing module instance is available.If previously created instance is
	 * present then returns the same module instance.
	 * 
	 * @return DisplayShutterModule - instance of {@link DisplayShutterModule}.
	 */
	public DisplayShutterModule getDisplayShutterModule() 
	{
		if(objDisplayShutterModule == null)
		{
			objDisplayShutterModule = new DisplayShutterModule(objIDataSet);
			return objDisplayShutterModule;
		}
		return objDisplayShutterModule;
	}
	
	/**
	 * Retrieves pre-initialized instance of Bitmap Display Shutter Module. Creates a new instance
	 * if no pre-existing module instance is available.If previously created instance is
	 * present then returns the same module instance.
	 * 
	 * @return BitmapDisplayShutterModule - instance of {@link BitmapDisplayShutterModule}.
	 */
	public BitmapDisplayShutterModule getBitmapDisplayShutterModule() 
	{
		if(objBitmapDisplayShutterModule == null)
		{
			objBitmapDisplayShutterModule = new BitmapDisplayShutterModule(objIDataSet);
			return objBitmapDisplayShutterModule;
		}
		return objBitmapDisplayShutterModule;
	}
	
	/**
	 * Retrieves pre-initialized instance of Overlay Plane Module. Creates a new instance
	 * if no pre-existing module instance is available.If previously created instance is
	 * present then returns the same module instance.
	 * 
	 * @return OverlayPlaneModule - instance of {@link OverlayPlaneModule}.
	 */
	public OverlayPlaneModule getOverlayPlaneModule() 
	{
		if(objOverlayPlaneModule == null)
		{
			objOverlayPlaneModule = new OverlayPlaneModule(objIDataSet);
			return objOverlayPlaneModule;
		}
		return objOverlayPlaneModule;
	}
	
	/**
	 * Retrieves pre-initialized instance of Displayed Area Module. Creates a new instance
	 * if no pre-existing module instance is available.If previously created instance is
	 * present then returns the same module instance.
	 * 
	 * @return DisplayedAreaModule - instance of {@link DisplayedAreaModule}.
	 */
	public DisplayedAreaModule getDisplayedAreaModule() 
	{
		if(objDisplayedAreaModule == null)
		{
			objDisplayedAreaModule = new DisplayedAreaModule(objIDataSet);
			return objDisplayedAreaModule;
		}
		return objDisplayedAreaModule;
	}
	
	/**
	 * Retrieves pre-initialized instance of Graphic Annotation Module. Creates a new instance
	 * if no pre-existing module instance is available.If previously created instance is
	 * present then returns the same module instance.
	 * 
	 * @return GraphicAnnotationModule - instance of {@link GraphicAnnotationModule}.
	 */
	public GraphicAnnotationModule getGraphicAnnotationModule() 
	{
		if(objGraphicAnnotationModule == null)
		{
			objGraphicAnnotationModule = new GraphicAnnotationModule(objIDataSet);
			return objGraphicAnnotationModule;
		}
		return objGraphicAnnotationModule;
	}
	
	/**
	 * Retrieves pre-initialized instance of Spatial Transformation Module. Creates a new instance
	 * if no pre-existing module instance is available.If previously created instance is
	 * present then returns the same module instance.
	 * 
	 * @return SpatialTransformationModule - instance of {@link SpatialTransformationModule}.
	 */
	public SpatialTransformationModule getSpatialTransformationModule() 
	{
		if(objSpatialTransformationModule == null)
		{
			objSpatialTransformationModule = new SpatialTransformationModule(objIDataSet);
			return objSpatialTransformationModule;
		}
		return objSpatialTransformationModule;
	}
	
	/**
	 * Retrieves pre-initialized instance of Graphic Layer Module. Creates a new instance
	 * if no pre-existing module instance is available.If previously created instance is
	 * present then returns the same module instance.
	 * 
	 * @return GraphicLayerModule - instance of {@link GraphicLayerModule}.
	 */
	public GraphicLayerModule getGraphicLayerModule() 
	{
		if(objGraphicLayerModule == null)
		{
			objGraphicLayerModule = new GraphicLayerModule(objIDataSet);
			return objGraphicLayerModule;
		}
		return objGraphicLayerModule;
	}
	
	/**
	 * Retrieves pre-initialized instance of Graphic Group Module. Creates a new instance
	 * if no pre-existing module instance is available.If previously created instance is
	 * present then returns the same module instance.
	 * 
	 * @return GraphicGroupModule - instance of {@link GraphicGroupModule}.
	 */
	public GraphicGroupModule getGraphicGroupModule() 
	{
		if(objGraphicGroupModule == null)
		{
			objGraphicGroupModule = new GraphicGroupModule(objIDataSet);
			return objGraphicGroupModule;
		}
		return objGraphicGroupModule;
	}
	
	/**
	 * Retrieves pre-initialized instance of ICC Profile Module. Creates a new instance
	 * if no pre-existing module instance is available.If previously created instance is
	 * present then returns the same module instance.
	 * 
	 * @return ICCProfileModule - instance of {@link ICCProfileModule}.
	 */
	public ICCProfileModule getICCProfileModule() 
	{
		if(objICCProfileModule == null)
		{
			objICCProfileModule = new ICCProfileModule(objIDataSet);
			return objICCProfileModule;
		}
		return objICCProfileModule;
	}
	
	/**
	 * This method validates Non-Image IOD according to the Module Table given in The DICOM Standard.
	 * The validate method fails if one of the mandatory modules are absent or any of the
	 * modules are invalid. The validate method also checks for conditional modules.
	 * 
	 * @return boolean - status of validation as success or failure
	 * 
	 * @throws InvalidIODException -  throws when the IOD is invalid.
	 */
	public boolean validate() throws InvalidIODException
	{
		try{

			super.validate();	


			/*Validate the mandatory elements*/
			getPatientModule().validateModule();
			getGeneralStudyModule().validateModule();
			getGeneralSeriesModule().validateModule();
			getGeneralEquipmentModule().validateModule();
			getSOPCommonModule().validateModule();
			getPresentationSeriesModule().validateModule();
			getPresentationStateIdentificationModule().validateModule();
			getPresentationStateRelationshipModule().validateModule();
			getPresentationStateShutterModule().validateModule();
			getDisplayedAreaModule().validateModule();
			getICCProfileModule().validateModule();

			/* Validating AUTOREFRACTION MEASUREMENTS IOD Content Constraints */

			/*Validate optional modules*/

			if(isModulePresent(PatientStudyModule.objSingleCollection,objIDataSet))
				getPatientStudyModule().validateModule();
			if(isModulePresent(ClinicalTrialSeriesModule.objSingleCollection,objIDataSet))
				getClinicalTrialSeriesModule().validateModule();
			if(isModulePresent(DisplayShutterModule.objSingleCollection,objIDataSet))
				getDisplayShutterModule().validateModule();
			if(isModulePresent(BitmapDisplayShutterModule.objSingleCollection,objIDataSet))
				getBitmapDisplayShutterModule().validateModule();
			if(isModulePresent(OverlayPlaneModule.objSingleCollection,objIDataSet))
				getOverlayPlaneModule().validateModule();
			if(isModulePresent(GraphicAnnotationModule.objSingleCollection,objIDataSet))
				getGraphicAnnotationModule().validateModule();
			if(isModulePresent(SpatialTransformationModule.objSingleCollection,objIDataSet))
				getSpatialTransformationModule().validateModule();
			if(isModulePresent(GraphicLayerModule.objSingleCollection,objIDataSet))
				getGraphicLayerModule().validateModule();
			if(isModulePresent(GraphicGroupModule.objSingleCollection,objIDataSet))
				getGraphicGroupModule().validateModule();

		}catch(InvalidModuleException ime)
		{
			if(DicomConfig.createInstance().isLoggingOn())
				DicomLogger.getLogger().log(ime.getMessage());
			
				throw new InvalidIODException(COLOR_SOFTCOPY_PRESENTATION_STATE_IOD,ime);
		}
		return true;
	}

	/**
	 *  Dumps the Name of IOD,Module and corresponding Attributes of Module.
	 *  @param objIDicomStream - the Stream on which the Data is to be written.
	 *  @throws IOException - Exception is thrown indicating runtime failure of writing operation.
	 */
	public void dumpDICOMInfo(IDicomStream objIDicomStream) throws IOException
	{
		objIDicomStream.writeString(COLOR_SOFTCOPY_PRESENTATION_STATE_IOD + "\n");
		super.dumpDICOMInfo(objIDicomStream);

		objIDicomStream.writeString("\t" + getPatientModule().getClass().getSimpleName() + "\n");
		getPatientModule().dumpDICOMInfo(objIDicomStream);

		objIDicomStream.writeString("\t" + getGeneralStudyModule().getClass().getSimpleName() + "\n");
		getGeneralStudyModule().dumpDICOMInfo(objIDicomStream);

		objIDicomStream.writeString("\t" + getPatientStudyModule().getClass().getSimpleName() + "\n");
		getPatientStudyModule().dumpDICOMInfo(objIDicomStream);

		objIDicomStream.writeString("\t" + getGeneralSeriesModule().getClass().getSimpleName() + "\n");
		getGeneralSeriesModule().dumpDICOMInfo(objIDicomStream);
		
		objIDicomStream.writeString("\t" + getClinicalTrialSeriesModule().getClass().getSimpleName() + "\n");
		getClinicalTrialSeriesModule().dumpDICOMInfo(objIDicomStream);
		
		objIDicomStream.writeString("\t" + getGeneralEquipmentModule().getClass().getSimpleName() + "\n");
		getGeneralEquipmentModule().dumpDICOMInfo(objIDicomStream);
		
		objIDicomStream.writeString("\t" + getSOPCommonModule().getClass().getSimpleName() + "\n");
		getSOPCommonModule().dumpDICOMInfo(objIDicomStream);
		
		objIDicomStream.writeString("\t" + getPresentationSeriesModule().getClass().getSimpleName() + "\n");
		getPresentationSeriesModule().dumpDICOMInfo(objIDicomStream);
		
		objIDicomStream.writeString("\t" + getPresentationStateIdentificationModule().getClass().getSimpleName() + "\n");
		getPresentationStateIdentificationModule().dumpDICOMInfo(objIDicomStream);
		
		objIDicomStream.writeString("\t" + getPresentationStateRelationshipModule().getClass().getSimpleName() + "\n");
		getPresentationStateRelationshipModule().dumpDICOMInfo(objIDicomStream);
		
		objIDicomStream.writeString("\t" + getPresentationStateShutterModule().getClass().getSimpleName() + "\n");
		getPresentationStateShutterModule().dumpDICOMInfo(objIDicomStream);
		
		objIDicomStream.writeString("\t" + getDisplayShutterModule().getClass().getSimpleName() + "\n");
		getDisplayShutterModule().dumpDICOMInfo(objIDicomStream);
		
		objIDicomStream.writeString("\t" + getBitmapDisplayShutterModule().getClass().getSimpleName() + "\n");
		getBitmapDisplayShutterModule().dumpDICOMInfo(objIDicomStream);
		
		objIDicomStream.writeString("\t" + getOverlayPlaneModule().getClass().getSimpleName() + "\n");
		getOverlayPlaneModule().dumpDICOMInfo(objIDicomStream);
		
		objIDicomStream.writeString("\t" + getDisplayedAreaModule().getClass().getSimpleName() + "\n");
		getDisplayedAreaModule().dumpDICOMInfo(objIDicomStream);
		
		objIDicomStream.writeString("\t" + getGraphicAnnotationModule().getClass().getSimpleName() + "\n");
		getGraphicAnnotationModule().dumpDICOMInfo(objIDicomStream);
		
		objIDicomStream.writeString("\t" + getSpatialTransformationModule().getClass().getSimpleName() + "\n");
		getSpatialTransformationModule().dumpDICOMInfo(objIDicomStream);
		
		objIDicomStream.writeString("\t" + getGraphicLayerModule().getClass().getSimpleName() + "\n");
		getGraphicLayerModule().dumpDICOMInfo(objIDicomStream);
		
		objIDicomStream.writeString("\t" + getGraphicGroupModule().getClass().getSimpleName() + "\n");
		getGraphicGroupModule().dumpDICOMInfo(objIDicomStream);
		
		objIDicomStream.writeString("\t" + getICCProfileModule().getClass().getSimpleName() + "\n");
		getICCProfileModule().dumpDICOMInfo(objIDicomStream);
		
	}

	/**
	 * Checks whether the Module is present in the IOD or not.
	 * @param strModuleName String value of module name 
	 * @return boolean - true if the module is present in the IOD, else false is returned.
	 */
	public boolean isModulePresent(String strModuleName)
	{
		if(!super.isModulePresent(strModuleName))
		{
			if(strModuleName == null || strModuleName.equals(""))
				return false;
			if(strModuleName.equalsIgnoreCase(EnumModuleNames.PATIENT_MODULE.getValue()) && isModulePresent(PatientModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.GENERAL_STUDY_MODULE.getValue()) && isModulePresent(GeneralStudyModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.PATIENT_STUDY_MODULE.getValue()) && isModulePresent(PatientStudyModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.GENERAL_SERIES_MODULE.getValue()) && isModulePresent(GeneralSeriesModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.CLINICAL_TRIAL_SERIES_MODULE.getValue()) && isModulePresent(ClinicalTrialSeriesModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.GENERAL_EQUIPMENT_MODULE.getValue()) && isModulePresent(GeneralEquipmentModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.SOP_COMMON_MODULE.getValue()) && isModulePresent(SOPCommonModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.PRESENTATION_SERIES_MODULE.getValue()) && isModulePresent(PresentationSeriesModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.PRESENTATIONSTATEIDENTIFICATIONMODULE.getValue()) && isModulePresent(PresentationStateIdentificationModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.PRESENTATION_STATE_RELATIONSHIP_MODULE.getValue()) && isModulePresent(PresentationStateRelationshipModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.PRESENTATION_STATE_SHUTTER_MODULE.getValue()) && isModulePresent(PresentationStateShutterModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.DISPLAY_SHUTTER_MODULE.getValue()) && isModulePresent(DisplayShutterModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.BITMAP_DISPLAY_SHUTTER_MODULE.getValue()) && isModulePresent(BitmapDisplayShutterModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.OVERLAY_PLANE_MODULE.getValue()) && isModulePresent(OverlayPlaneModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.DISPLAYED_AREA_MODULE.getValue()) && isModulePresent(DisplayedAreaModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.GRAPHIC_ANNOTATION_MODULE.getValue()) && isModulePresent(GraphicAnnotationModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.SPATIAL_TRANSFORMATION_MODULE.getValue()) && isModulePresent(SpatialTransformationModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.GRAPHIC_LAYER_MODULE.getValue()) && isModulePresent(GraphicLayerModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.GRAPHIC_GROUP_MODULE.getValue()) && isModulePresent(GraphicGroupModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.ICC_PROFILE_MODULE.getValue()) && isModulePresent(ICCProfileModule.objSingleCollection))
				return true;
			else
			{
				if(DicomConfig.createInstance().isLoggingOn())
				{
					DicomLogger objDicomLogger = DicomLogger.getLogger();
					objDicomLogger.log(this.getClass().getName() + " : " +ResourceBundleWrapper.getValue("status","ModuleNotPresent",new Locale(DicomConfig.createInstance().getLocale())) + strModuleName);
				}
				return false;
			}
		}
		return true;
	}
}
