/*******************************************************************************
 *  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.xray;

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.CineModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.ContrastBolusModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.CurveModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.DXDetectorModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.DeviceModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.DisplayShutterModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.FramePointersModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.GeneralImageModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.ImageIOD;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.InterventionModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.MaskModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.ModalityLUTModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.MultiFrameModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.MultiFrameOverlayModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.OverlayPlaneModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.SOPCommonModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.SynchronizationModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.VOILUTModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.XAPositionerModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.XRFPositionerModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.XRayAcquisitionModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.XRayCollimatorModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.XRayImageModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.XRayTableModule;
import cdac.medinfo.sdk.dcm30_04.enums.EnumModuleNames;
import cdac.medinfo.sdk.dcm30_04.enums.EnumSOPClassUIDs;

import cdac.medinfo.sdk.dcm30_04.exceptions.ConditionFailedException;
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;
/**
 \* This module describes a single plane X-Ray Angiographic Imaging that includes those
 * data elements and information objects necessary for the interchange of digital XRay
 * Angiographic data. This includes images of the heart and all blood vessels.
 * 
 * 
 */
public class XRayAngiographicIOD extends ImageIOD 
{
	

	/**
	 * The Constant XRAY_ANGIOGRAPHIC_IOD.
	 */
	public static final String XRAY_ANGIOGRAPHIC_IOD = "XRay Angiographic IOD";

	/**
	 * The obj contrast bolus module.
	 */
	ContrastBolusModule objContrastBolusModule = null;

	/**
	 * The obj cine module.
	 */
	CineModule objCineModule= null;

	/**
	 * The obj curve module.
	 */
	CurveModule objCurveModule = null;

	/**
	 * The obj display shutter module.
	 */
	DisplayShutterModule objDisplayShutterModule = null;

	/**
	 * The obj device module.
	 */
	DeviceModule objDeviceModule = null;

	/**
	 * The obj dx detector module.
	 */
	DXDetectorModule objDXDetectorModule = null;

	/**
	 * The obj frame pointers module.
	 */
	FramePointersModule objFramePointersModule= null;

	/**
	 * The obj general image module.
	 */
	GeneralImageModule objGeneralImageModule = null;

	/**
	 * The obj intervention module.
	 */
	InterventionModule objInterventionModule = null;

	/**
	 * The obj mask module.
	 */
	MaskModule objMaskModule = null;

	/**
	 * The obj multi frame module.
	 */
	MultiFrameModule objMultiFrameModule = null;

	/**
	 * The obj multi frame overlay module.
	 */
	MultiFrameOverlayModule objMultiFrameOverlayModule = null;

	/**
	 * The obj modality lut module.
	 */
	ModalityLUTModule objModalityLUTModule = null;

	/**
	 * The obj overlay plane module.
	 */
	OverlayPlaneModule objOverlayPlaneModule = null;

	/**
	 * The obj synchronization module.
	 */
	SynchronizationModule objSynchronizationModule = null;

	/**
	 * The obj sop common module.
	 */
	SOPCommonModule objSOPCommonModule = null;

	/**
	 * The obj voilut module.
	 */
	VOILUTModule objVOILUTModule = null;

	/**
	 * The obj x ray image module.
	 */
	XRayImageModule objXRayImageModule = null;

	/**
	 * The obj x ray acquisition module.
	 */
	XRayAcquisitionModule objXRayAcquisitionModule = null;

	/**
	 * The obj x ray collimator module.
	 */
	XRayCollimatorModule objXRayCollimatorModule = null;

	/**
	 * The obj x ray table module.
	 */
	XRayTableModule objXRayTableModule = null;

	/**
	 * The obj xa positioner module.
	 */
	XAPositionerModule objXAPositionerModule = null;

	/**
	 * Instantiates a new x ray angiographic iod.
	 */
	public XRayAngiographicIOD()
	{
		super();
	}

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

	/**
	 * This constructor initializes the  DictionaryReader
	 * in its superclass IOD.
	 * 
	 * @param objIDictionaryReader_ - specifies the DICOM Dictionary reader to be used .
	 */
	public XRayAngiographicIOD(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 XRayAngiographicIOD(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 XRayAngiographicIOD(ITransferSyntax objITransferSyntax_,IDictionaryReader objIDictionaryReader_)
	{
		super(objITransferSyntax_,objIDictionaryReader_);
	}

	/**
	 * Creates XRayAngiografic IOD from a DICOM file containing XRayAngiografic 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 XRayAngiographicIOD(String strFileName)throws IOException,InvalidIODException
	{
		super(strFileName);
		try
		{
			if(objIDataSet != null)
			{
				String strSOPClassUID = objIDataSet.getSOPClassUID();
				if(strSOPClassUID != null)
				{
					if(!strSOPClassUID.equals(EnumSOPClassUIDs.XRAYANGIOGRAPHICIOD.getValue()))
					{
						throw new InvalidIODException(ResourceBundleWrapper.getValue("exceptions", "InvalidIOD.FileNotMatched", new Locale(DicomConfig.createInstance().getLocale())) + XRAY_ANGIOGRAPHIC_IOD);
					}
				}
				strSOPClassUID = null;
			}
		}
		catch(InvalidIODException iie)
		{
			if(DicomConfig.createInstance().isLoggingOn())
			{
				DicomLogger.getLogger().log(iie.getMessage());
			}
			throw iie;
		}
	}

	/**
	 * Retrieves pre-initialized instance of Contrast Bolus 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 ContrastBolusModule - instance of {@link ContrastBolusModule}.
	 */
	public ContrastBolusModule getContrastBolusModule()
	{
		if(objContrastBolusModule == null)
		{
			objContrastBolusModule = new ContrastBolusModule(objIDataSet);
			return objContrastBolusModule;
		}
		return objContrastBolusModule;
	}

	/**
	 * Retrieves pre-initialized instance of Cine 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 CineModule - instance of {@link CineModule}.
	 */
	public CineModule getCineModule()
	{
		if(objCineModule == null)
		{
			objCineModule = new CineModule(objIDataSet);
			return objCineModule;
		}
		return objCineModule;
	}

	/**
	 * Retrieves pre-initialized instance of Device 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 DeviceModule - instance of {@link DeviceModule}.
	 */
	public DeviceModule getDeviceModule() 
	{
		if(objDeviceModule == null)
		{
			objDeviceModule = new DeviceModule(objIDataSet);
			return objDeviceModule;
		}
		return objDeviceModule;
	}

	/**
	 * 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 DX Detector 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 DXDetectorModule - instance of {@link DXDetectorModule}.
	 */
	public DXDetectorModule getDXDetectorModule() 
	{
		if(objDXDetectorModule == null)
		{
			objDXDetectorModule = new DXDetectorModule(objIDataSet);
			return objDXDetectorModule;
		}
		return objDXDetectorModule;
	}

	/**
	 * Retrieves pre-initialized instance of Frame Pointers 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 FramePointersModule - instance of {@link FramePointersModule}.
	 */
	public FramePointersModule getFramePointersModule() 
	{
		if(objFramePointersModule == null)
		{
			objFramePointersModule = new FramePointersModule(objIDataSet);
			return objFramePointersModule;
		}
		return objFramePointersModule;
	}

	/**
	 * Retrieves pre-initialized instance of General Image 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 GeneralImageModule - instance of {@link GeneralImageModule}.
	 */
	public GeneralImageModule getGeneralImageModule()
	{
		if(objGeneralImageModule == null)
		{
			objGeneralImageModule = new GeneralImageModule(objIDataSet);
			return objGeneralImageModule;
		}
		return objGeneralImageModule;
	}

	/**
	 * Retrieves pre-initialized instance of Intervention 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 InterventionModule - instance of {@link InterventionModule}.
	 */
	public InterventionModule getInterventionModule() 
	{
		if(objInterventionModule == null)
		{
			objInterventionModule = new InterventionModule(objIDataSet);
			return objInterventionModule;
		}
		return objInterventionModule;
	}

	/**
	 * Retrieves pre-initialized instance of Mask 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 MaskModule - instance of {@link MaskModule}.
	 */
	public MaskModule getMaskModule()
	{
		if(objMaskModule == null)
		{
			objMaskModule = new MaskModule(objIDataSet);
			return objMaskModule;
		}
		return objMaskModule;
	}

	/**
	 * Retrieves pre-initialized instance of Modality LUT 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 ModalityLUTModule - instance of {@link ModalityLUTModule}.
	 */
	public ModalityLUTModule getModalityLUTModule()
	{
		if(objModalityLUTModule == null)
		{
			objModalityLUTModule = new ModalityLUTModule(objIDataSet);
			return objModalityLUTModule;
		}
		return objModalityLUTModule;
	}

	/**
	 * Retrieves pre-initialized instance of Multi Frame 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 MultiFrameModule - instance of {@link MultiFrameModule}.
	 */
	public MultiFrameModule getMultiFrameModule() 
	{
		if(objMultiFrameModule == null)
		{
			objMultiFrameModule = new MultiFrameModule(objIDataSet);
			return objMultiFrameModule;
		}
		return objMultiFrameModule;
	}

	/**
	 * Retrieves pre-initialized instance of Multi Frame Overlay 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 MultiFrameOverlayModule - instance of {@link MultiFrameOverlayModule}.
	 */
	public MultiFrameOverlayModule getMultiFrameOverlayModule()
	{
		if(objMultiFrameOverlayModule == null)
		{
			objMultiFrameOverlayModule = new MultiFrameOverlayModule(objIDataSet);
			return objMultiFrameOverlayModule;
		}
		return objMultiFrameOverlayModule;
	}

	/**
	 * 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 XA Positioner 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 XAPositionerModule - instance of {@link XAPositionerModule}.
	 */
	public XAPositionerModule getXAPositionerModule() 
	{
		if(objXAPositionerModule == null)
		{
			objXAPositionerModule = new XAPositionerModule(objIDataSet);
			return objXAPositionerModule;
		}
		return objXAPositionerModule;
	}

	/**
	 * Retrieves pre-initialized instance of XRay Acquisition 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 XRayAcquisitionModule - instance of {@link XRayAcquisitionModule}.
	 */
	public XRayAcquisitionModule getXRayAcquisitionModule()
	{
		if(objXRayAcquisitionModule == null)
		{
			objXRayAcquisitionModule = new XRayAcquisitionModule(objIDataSet);
			return objXRayAcquisitionModule;
		}
		return objXRayAcquisitionModule;
	}

	/**
	 * Retrieves pre-initialized instance of XRay Collimator 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 XRayCollimatorModule - instance of {@link XRayCollimatorModule}.
	 */
	public XRayCollimatorModule getXRayCollimatorModule()
	{
		if(objXRayCollimatorModule == null)
		{
			objXRayCollimatorModule = new XRayCollimatorModule(objIDataSet);
			return objXRayCollimatorModule;
		}
		return objXRayCollimatorModule;
	}

	/**
	 * Retrieves pre-initialized instance of XRay Image 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 XRayImageModule - instance of {@link XRayImageModule}.
	 */
	public XRayImageModule getXRayImageModule()
	{
		if(objXRayImageModule == null)
		{
			objXRayImageModule = new XRayImageModule(objIDataSet);
			return objXRayImageModule;
		}
		return objXRayImageModule;
	}

	/**
	 * Retrieves pre-initialized instance of XRay Table 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 XRayTableModule - instance of {@link XRayTableModule}.
	 */
	public XRayTableModule getXRayTableModule() 
	{
		if(objXRayTableModule == null)
		{
			objXRayTableModule = new XRayTableModule(objIDataSet);
			return objXRayTableModule;
		}
		return objXRayTableModule;
	}

	/**
	 * 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 Synchronization 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 SynchronizationModule - instance of {@link SynchronizationModule}.
	 */
	public SynchronizationModule getSynchronizationModule()
	{
		if(objSynchronizationModule == null)
		{
			objSynchronizationModule = new SynchronizationModule(objIDataSet);
			return objSynchronizationModule;
		}
		return objSynchronizationModule;
	}

	/**
	 * Retrieves pre-initialized instance of VOILUT 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 VOILUTModule - instance of {@link VOILUTModule}.
	 */
	public VOILUTModule getVOILUTModule()
	{
		if(objVOILUTModule == null)
		{
			objVOILUTModule = new VOILUTModule(objIDataSet);
			return objVOILUTModule;
		}
		return objVOILUTModule;
	}

	/**
	 * Retrieves pre-initialized instance of Curve 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 CurveModule - instance of {@link CurveModule}.
	 */
	public CurveModule getCurveModule()
	{
		if(objCurveModule == null)
		{
			objCurveModule= new CurveModule(objIDataSet);
			return objCurveModule;
		}
		return objCurveModule;
	}

	/**
	 * This method validates XRay Angiographic 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- function status indicating success or failure
	 * 
	 * @throws InvalidIODException -  throws when the IOD is invalid.
	 */
	public boolean validate() throws InvalidIODException
	{
		try
		{
			/*
			 * This condition calls ImageIOD class's validation which checks for common modules validation
			 */
			super.validate();

			/*
			 * Mandatory modules if not present,validation fails
			 */
			getGeneralEquipmentModule().validateModule();
			getGeneralImageModule().validateModule();
			getXRayImageModule().validateModule();
			getXRayAcquisitionModule().validateModule();
			getXAPositionerModule().validateModule();
			getSOPCommonModule().validateModule();

			/*
			 * Validation for attribute PatientOrientation(0020,0020) of GeneralImageModule is implemented at IOD level.
			 * condition :- Required if image does not require Image Orientation (Patient)(0020,0037) and Image Position (Patient)
			 * 				(0020,0032). See C.7.6.1.1.1 for further explanation.
			 * Right now we are taking it as if IOD contains any module which has (0020,0037) and (0020,0032)
			 * and if that module and attribute are compulsory then (0020,0020) is not mandatory.
			 * If no module is there in IOD then (0020,0020) is mandatory.
			 * and if attribute or module is optional or conditional then 0020,0020 is also conditional.
			 * THIS IOD DOES NOT CONTAIN ANY MODULE containing THESE ATTRIBUTES.
			 */
			if( !getGeneralImageModule().isPresent(0x0020,0x0020))
			{
				ConditionFailedException cce = new ConditionFailedException("0020,0020");
				if(DicomConfig.createInstance().isLoggingOn())
					DicomLogger.getLogger().log(cce.getMessage());
				throw cce;

			}
			/*
			 * Conditions for Conditional Modules could not understand.
			 * PDF 3, Pg. No. 116
			 */
			/*
			 * Check for optional modules.
			 */
			if(isModulePresent(SynchronizationModule.objSingleCollection,objIDataSet))
				getSynchronizationModule().validateModule();
			if(isModulePresent(FramePointersModule.objSingleCollection,objIDataSet))
				getFramePointersModule().validateModule();
			if(isModulePresent(XRayCollimatorModule.objSingleCollection,objIDataSet))
				getXRayCollimatorModule().validateModule();
			if(isModulePresent(DisplayShutterModule.objSingleCollection,objIDataSet))
				getDisplayShutterModule().validateModule();
			if(isModulePresent(DeviceModule.objSingleCollection,objIDataSet))
				getDeviceModule().validateModule();
			if(isModulePresent(InterventionModule.objSingleCollection,objIDataSet))
				getInterventionModule().validateModule();
			if(isModulePresent(DXDetectorModule.objSingleCollection,objIDataSet))
				getDXDetectorModule().validateModule();
			if(isModulePresent(OverlayPlaneModule.objSingleCollection,objIDataSet))
				getOverlayPlaneModule().validateModule();
			if(isModulePresent(VOILUTModule.objSingleCollection,objIDataSet))
				getVOILUTModule().validateModule();
			if(isModulePresent(CurveModule.objSingleCollection,objIDataSet))
				getCurveModule().validateModule();
			// checking for presence of Image data
			if(!isPresent(0x7FE0,0x0010))
			{
				InvalidIODException iie= new InvalidIODException(ResourceBundleWrapper.getValue("exceptions", "ImageData", new Locale(DicomConfig.createInstance().getLocale())));
				if(DicomConfig.createInstance().isLoggingOn())
					DicomLogger.getLogger().log(iie.getMessage());
				throw iie;

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

	/**
	 *  dumps the Name of Module and corresponding Attributs of IOD.
	 *  @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(XRAY_ANGIOGRAPHIC_IOD + "\n");
		super.dumpDICOMInfo(objIDicomStream);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

		objIDicomStream.writeString("\t" + getXAPositionerModule().getClass().getSimpleName() + "\n");
		getXAPositionerModule().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.CINE_MODULE.getValue()) && isModulePresent(CineModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.CONTRAST_BOLUS_MODULE.getValue()) && isModulePresent(ContrastBolusModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.CURVE_MODULE.getValue()) && isModulePresent(CurveModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.DEVICE_MODULE.getValue()) && isModulePresent(DeviceModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.DISPLAY_SHUTTER_MODULE.getValue()) && isModulePresent(DisplayShutterModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.DX_DETECTOR_MODULE.getValue()) && isModulePresent(DXDetectorModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.GENERAL_IMAGE_MODULE.getValue()) && isModulePresent(GeneralImageModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.FRAME_POINTERS_MODULE.getValue()) && isModulePresent(FramePointersModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.INTERVENTION_MODULE.getValue()) && isModulePresent(InterventionModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.MASK_MODULE.getValue()) && isModulePresent(MaskModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.SOP_COMMON_MODULE.getValue()) && isModulePresent(SOPCommonModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.MODALITY_LUT_MODULE.getValue()) && isModulePresent(ModalityLUTModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.MULTI_FRAME_MODULE.getValue()) && isModulePresent(MultiFrameModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.MULTI_FRAME_OVERLAY_MODULE.getValue()) && isModulePresent(MultiFrameOverlayModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.OVERLAY_PLANE_MODULE.getValue()) && isModulePresent(OverlayPlaneModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.SYNCHRONIZATION_MODULE.getValue()) && isModulePresent(SynchronizationModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.VOI_LUT_MODULE.getValue()) && isModulePresent(VOILUTModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.X_RAY_ACQUISITION_MODULE.getValue()) && isModulePresent(XRayAcquisitionModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.X_RAY_COLLIMATOR_MODULE.getValue()) && isModulePresent(XRayCollimatorModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.X_RAY_IMAGE_MODULE.getValue()) && isModulePresent(XRayImageModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.X_RAY_TABLE_MODULE.getValue()) && isModulePresent(XRayTableModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.XRF_POSITIONER_MODULE.getValue()) && isModulePresent(XRFPositionerModule.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;
	}
}
