/*******************************************************************************
 *  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.services.printmanagement.testcases.scu;
import cdac.medinfo.sdk.dcm30_04.utils.DicomConstants;

import java.io.IOException;


import cdac.medinfo.sdk.dcm30_04.baselibs.DataSet;
import cdac.medinfo.sdk.dcm30_04.baselibs.DicomV3Factory;
import cdac.medinfo.sdk.dcm30_04.baselibs.ImplicitDE;
import cdac.medinfo.sdk.dcm30_04.baselibs.ReferencedFilmSessionSequence;
import cdac.medinfo.sdk.dcm30_04.baselibs.ReferencedPresentationLUTSequence;
import cdac.medinfo.sdk.dcm30_04.baselibs.SOPInstanceReferenceMacroDependentItem;
import cdac.medinfo.sdk.dcm30_04.baselibs.SQ;
import cdac.medinfo.sdk.dcm30_04.commoninterface.IDataElement;
import cdac.medinfo.sdk.dcm30_04.commoninterface.IDataSet;
import cdac.medinfo.sdk.dcm30_04.commoninterface.IItem;
import cdac.medinfo.sdk.dcm30_04.enums.EnumLoggingLevel;
import cdac.medinfo.sdk.dcm30_04.enums.EnumPDUType;
import cdac.medinfo.sdk.dcm30_04.enums.EnumSOPClassUIDs;

import cdac.medinfo.sdk.dcm30_04.services.association.AAbort;
import cdac.medinfo.sdk.dcm30_04.services.association.AReleaseRQorRP;
import cdac.medinfo.sdk.dcm30_04.services.association.AssociateRQ;
import cdac.medinfo.sdk.dcm30_04.services.association.DefaultAssociation;
import cdac.medinfo.sdk.dcm30_04.services.dicomnetcommons.EnumActionTypeID;
import cdac.medinfo.sdk.dcm30_04.services.dicomnetcommons.EnumServiceType;
import cdac.medinfo.sdk.dcm30_04.services.dimsecommons.DicomMessage;
import cdac.medinfo.sdk.dcm30_04.services.naction.commons.NActionRQ;
import cdac.medinfo.sdk.dcm30_04.services.naction.commons.NActionRSP;
import cdac.medinfo.sdk.dcm30_04.services.ncreate.commons.NCreateRQ;
import cdac.medinfo.sdk.dcm30_04.services.ncreate.commons.NCreateRSP;
import cdac.medinfo.sdk.dcm30_04.services.ndelete.commons.NDeleteRQ;
import cdac.medinfo.sdk.dcm30_04.services.ndelete.commons.NDeleteRSP;
import cdac.medinfo.sdk.dcm30_04.services.nget.commons.NGetRQ;
import cdac.medinfo.sdk.dcm30_04.services.nget.commons.NGetRSP;
import cdac.medinfo.sdk.dcm30_04.services.nset.commons.NSetRQ;
import cdac.medinfo.sdk.dcm30_04.services.nset.commons.NSetRSP;
import cdac.medinfo.sdk.dcm30_04.services.print.scu.PrintSCU;
import cdac.medinfo.sdk.dcm30_04.services.scu.commons.SCUSession;
import cdac.medinfo.sdk.dcm30_04.utils.DicomConfig;
import cdac.medinfo.sdk.dcm30_04.utils.ICollectionIterator;
import cdac.medinfo.sdk.dcm30_04.utils.ISingleCollection;

/**
 * This sample code specifies the role of Print Management service class user for Basic GrayScale Meta SOP Class.
 * It uses Print SCU to send the request to SCP.
 * Basic GrayScale Print Management Meta SOP Class -
 *  	This Meta SOP class support following SOP classes
 *  	1) Basic Film Session SOP Class :- This class supports following Services N-Create,N-Set,N-Delete,N-Action services.
 *  	2) Basic Film Box SOP Class :- This class supports following Services N-Create,N-Set,N-Delete,N-Action services.
 *  	3) Basic GrayScale Image Box SOP Class :- This class supports following Services N-Set services.
 *  	4) Printer SOP Class :- This class supports following Services N-Get and N-Event Report services.
 *  
 * Print Queue Management SOP Class
 * 		This SOP class support following services
 * 		1)N-Action to cancel and prioritize jobs.
 * 		2)N-Get to get print job information.
 * 
 * Following are the option SOP Class supported by Print Management Service Class with Basic Print Management SOP 
 * 		1)Basic Annotation Box SOP Class :- This class supports following Services N-Set services.
 * 		2)Print Job SOP Class :- This class supports following Services N-Get and N-Event Report services.
 * 		3)Basic print Image Overlay Box SOP Class.
 * 		4)Presentation LUT Sop Class :- This class supports following Services N-Create and N-Delete services.
 * 		5)Printer Configuration Retrieval SOP Class.
 * 		
 * In order to run the following class , please refer to this link($Link) to create the environment.
 * To implement an SCU of a particular we need to do the following things:
 * Create the SCUSession object which maintains the current session of the SCU. Its "start" method accepts
 * the SCP's IP Address and Port and tries to establish a connection with the SCP.
 * 
 * Next step is to establish association .Some ways to create an Association Request: 
 * 1)Use Default Association class to Load the association for requested Services. User can load the association 
 * by specifying the Services Type in loadAssociation method of Default association.
 * 2) Manually create object of AssociationRQ class and set all presentation contexts collection on it. 
 * More details provided in the API DOCS of AssociationRQ class.
 * 
 * After successful association is established the SCUSession stores the status of the Association with it.  
 * Create respective SCU object to send the service Request to the SCP. Currently the "sendMessage" method 
 * of the respective SCU would wait after sending the service DIMSE-RQ until a suitable DIMSE-RSP is received. 
 * This operation is part of Synchronous mode request handling.  
 * Once the DIMSE response is received by the SCU it stores it into its collection
 * which then can be retrieved.
 * 
 * After this, create a A-Release-RQ in order to request for association release and send it using the
 * SCUSession object. This again is a blocking call and the SCUSession waits until a A-Release-RP is received.
 * 
 * At the end of an operation calling "close" on SCUSession would disconnect the connection made with the 
 * SCP and release all the acquired resources.
 * Instead of closing the session after a service operation is complete,we can create another association
 * and send more requests. 
 * Also it is possible to create multiple service requests and send them one by one on the same Association.
 */
public class BasicGrayScalePrint_SCU
{
	String strAffectedSOPINstanceUIDForBasicFilmSession;
	String strSOPInstanceForBasicFimBox;
	String strSOPInstanceForBasicGrayScaleImageBox;
	String strSOPInstanceForPresentationLUT;
	String strSOPInstanceForBasicPrintImageOverlay;
	String strSOPInstanceForAnotation;
	PopulateDataSets objPopulateDataSets = new PopulateDataSets();
	String PrintJOBID ;
	String strPrintJobSOPInstanceUID;


	public static void main(String[] args) throws IOException
	{
		DicomConfig objDicomConfig = DicomConfig.createInstance();

		//enable logging,specify the path of the directory where log files are created.
		//User can specify any directory in place of 'c:\DCM_Logs'.
		//If no directory is defined by user to create logs then it is created in User Temp DIR.
		objDicomConfig.enableLogging(EnumLoggingLevel.INFO, "C:/logs");

		/*
		 * creates object of BasicGrayScalePrint_SCU and Start BasicGrayScalePrint SCU.
		 */
		BasicGrayScalePrint_SCU objBasicGrayScalePrintSCU = new BasicGrayScalePrint_SCU();

		/*
		 * Performs operation of BasicGrayScalePrint Services 
		 */
		objBasicGrayScalePrintSCU.doBasicGrayScalePrint();
	}

	/**
	 * This function performs the operation for all supported services of Basic GrayScale Print SCU
	 * with the optional services classes of print management Service.
	 * Basic GrayScale print SCU operation involves following steps :-
	 * 1. Establish the connection with SCP
	 * 2. Establish the association with SCP
	 * 3. Initializes the SCU for corresponding N-Service and performs the operation using service request
	 * 4. Releases the association after successful processing of service request
	 * 5. Closes the connection with SCP. 
	 */
	public void doBasicGrayScalePrint()
	{
		//Current SCU Session
		SCUSession objSession = null;

		try
		{
			//create SCU session.
			objSession = new SCUSession();
			
			/*
			 * Setting time out as 5000 milli second. It will wait 5000 milli seconds for read and write operation.
			 * If in the time specified (5000 ms) read or write operation is not performed then 
			 * session is time out.
			 */ 
		//	objSession.setTimeOut(5000);

			/*
			 * Initializes the service types and populates the default association
			 */
			EnumServiceType[] arrenumServiceType = new EnumServiceType[13];
			arrenumServiceType[0] = EnumServiceType.NCREATE_BASIC_GRAYSCALEPRINT_MANAGEMENT;
			arrenumServiceType[1] = EnumServiceType.NSET_BASIC_GRAYSCALE_PRINT_MANAGEMENT;
			arrenumServiceType[2] = EnumServiceType.NDELETE_BASIC_GRAYSCALE_PRINT_MANAGEMENT;
			arrenumServiceType[3] = EnumServiceType.NACTION_BASIC_GRAYSCALE_PRINT_MANAGEMENT;
			arrenumServiceType[4] = EnumServiceType.NSET_BASIC_ANNOTATION;
			arrenumServiceType[5] = EnumServiceType.NCREATE_PRESENTATION_LUT;
			arrenumServiceType[6] = EnumServiceType.NDELETE_PRESENTATION_LUT;
			arrenumServiceType[7] = EnumServiceType.NCREATE_BASIC_PRINT_IMAGE_OVERLAY;
			arrenumServiceType[8] = EnumServiceType.NSET_BASIC_PRINT_IMAGE_OVERLAY;
			arrenumServiceType[9] = EnumServiceType.NDELETE_BASIC_PRINT_IMAGE_OVERLAY;
			arrenumServiceType[10] = EnumServiceType.NACTION_PRINT_QUEUE_MANAGEMENT;
			arrenumServiceType[11] = EnumServiceType.NGET_PRINTER_CONFIGURATION_RETRIEVAL;
			arrenumServiceType[12] = EnumServiceType.NGET_PRINT_JOB;
			DefaultAssociation objDefaultAssociation = new DefaultAssociation("SDK");
			objDefaultAssociation.loadAssociation(arrenumServiceType);

			//Start SCU Session by providing the IP address and Port of SCP.
			objSession.start("localhost", 9000);

			//Create Association RQ
			AssociateRQ objAssociateRQ = objDefaultAssociation.getAssociationRQ("SDK");

			//Send the Association Request
			if(objSession.sendAssociationMessage(objAssociateRQ))
			{
				//When associaton is successfully established the "objSession.sendAssociationMessage()"
				//method returns true.
				System.out.println("Association established");
				
				//Create PrintSCU object using the current SCU Session.
				PrintSCU objPrintSCU = new PrintSCU(objSession);

				/*
				 * *************************************************************************
				 * This block of code creates the PrintSCU to  perform the retrieval process of 
				 * Printer Configuration IOD.
				 * It initializes the NGet RQ and sends it to SCP using PrintSCU.
				 * *************************************************************************
				 */
				doNGetForPrinterConfiguration(objPrintSCU);

				/*
				 * *************************************************************************
				 * This block of code creates the PrintSCU to  perform the retrieval process of 
				 * Printer IOD.
				 * It initializes the NGet RQ and sends it to SCP using PrintSCU.
				 * *************************************************************************
				 */
				doNGetForPrinter(objPrintSCU);

				/*
				 * *************************************************************************
				 * This block of code creates the PrintSCU to perform the process of 
				 * SOP Instance creation operation for Basic Film Session.
				 * It initializes the NCreate RQ and sends it to SCP using PrintSCU.
				 * *************************************************************************
				 */
				doNCreateForBasicFilmSession(objPrintSCU);

				/*
				 * *************************************************************************
				 * This block of code creates the PrintSCU to perform the process of 
				 * SOP Instance creation operation for Basic Film Box.
				 * It initializes the NCreate RQ and sends it to SCP using PrintSCU.
				 * *************************************************************************
				 */
				doNCreateForBasicFilmBox(objPrintSCU);
				
				/*
				 * *************************************************************************
				 * This block of code creates the PrintSCU to perform the process of 
				 * SOP Instance creation operation for Presentation LUT.
				 * It initializes the NCreate RQ and sends it to SCP using PrintSCU.
				 * *************************************************************************
				 */
				doNCreateForPresentationLUT(objPrintSCU);

				/*
				 * *************************************************************************
				 * This block of code creates the PrintSCU to perform the process of 
				 * SOP Instance updation operation for Basic Film Session.
				 * It initializes the NSET RQ and sends it to SCP using PrintSCU.
				 * *************************************************************************
				 */
				doNSetForBasicFilmSession(objPrintSCU);

				/*
				 * *************************************************************************
				 * This block of code creates the PrintSCU to perform the process of 
				 * SOP Instance updation operation for Basic Film Box.
				 * It initializes the NSET RQ and sends it to SCP using PrintSCU.
				 * *************************************************************************
				 */
				doNSetForBasicFilmBox(objPrintSCU);

				/*
				 * *************************************************************************
				 * This block of code creates the PrintSCU to perform the process of 
				 * SOP Instance updation operation for Basic GrayScale Image Box.
				 * It initializes the NSET RQ and sends it to SCP using PrintSCU.
				 * *************************************************************************
				 */
				doNSetForBasicGrayScaleImageBox(objPrintSCU);

				/*
				 * *************************************************************************
				 * This block of code creates the PrintSCU to perform the process of 
				 * SOP Instance updation operation for Basic Annotation Box.
				 * It initializes the NSET RQ and sends it to SCP using PrintSCU.
				 * *************************************************************************
				 */
				doNSetForBasicAnnotationBox(objPrintSCU);


				/*
				 * *************************************************************************
				 * This block of code creates the PrintSCU to perform the process of 
				 * SOP Instance updation operation for Basic Film Session.
				 * It initializes the NACTION RQ and sends it to SCP using PrintSCU.
				 * *************************************************************************
				 */
				doNActionForBasicFilmSession(objPrintSCU);

				/*
				 * *************************************************************************
				 * This block of code creates the PrintSCU to  perform the retrieval process of 
				 * Print JOB IOD.
				 * It initializes the NGet RQ and sends it to SCP using PrintSCU.
				 * *************************************************************************
				 */
				doNGetForPrintJob(objPrintSCU);

				/*
				 * *************************************************************************
				 * This block of code creates the PrintSCU to perform the process of 
				 * retrieve operation for PrintQueueMangement.
				 * It initializes the NGET RQ and sends it to SCP using PrintSCU.
				 * *************************************************************************
				 */
				doGetForPrintQueueManagement(objPrintSCU);

				/*
				 * *************************************************************************
				 * This block of code creates the PrintSCU to perform the process of 
				 * SOP Instance updation operation for Print Queue Management Prioritize.
				 * It initializes the Naction RQ and sends it to SCP using PrintSCU.
				 * *************************************************************************
				 */
				doNActionForPrintQueueManagementPrioritize(objPrintSCU);

				/*
				 * *************************************************************************
				 * This block of code creates the PrintSCU to perform the process of 
				 * retrieve operation for PrintQueueMangement Delete.
				 * It initializes the Naction RQ and sends it to SCP using PrintSCU.
				 * *************************************************************************
				 */
				doNActionForPrintQueueManagementDelete(objPrintSCU);

							
				//Create A-Release-RQ to release the association
				AReleaseRQorRP objAReleaseRQorRP = new AReleaseRQorRP(EnumPDUType.RELEASE_RQ);

				//Send the A-Release-RQ
				if(objSession.sendAssociationMessage(objAReleaseRQorRP))
				{
					System.out.println("Association is released");
					//When successful A-Release-RP is received, close the Session.
					//Please note that instead of closing the session we can create 
					//another association and send more requests. Also it is possible
					//to create multiple C-Find-RQs and send them one by one.
					objSession.close();
				}

				//In case an ABORT is received from SCP during the C-Store operation
				if(objSession.getDIMSEAssociation() instanceof AAbort)
				{
					System.out.println("Abort arrives. Closing session.");
					objSession.close();
				}
			}
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
	}

	/*
	 * *************************************************************************
	 * This block of code creates the PrintSCU to perform the  retrieval process of 
	 * Printer SOP Class.
	 * It initializes the NGet Request and sends it to SCP using PrintSCU.
	 * *************************************************************************
	 */
	private void doNGetForPrinter(PrintSCU objPrintSCU) throws IOException
	{

		System.out.println("N-Get Request For Printer is Initialized................");

		//Initializing NCreate RQ 
		NGetRQ objNGetRQ = NGetRQ.getDefaultRQ(EnumSOPClassUIDs.PRINTERIOD.getValue(), "1.2.840.10008.5.1.1.17", null);
		NGetRSP objNGetRSP = null;

		//sending RQ to SCP
		if(objPrintSCU.sendMessage(objNGetRQ))
		{
			System.out.println("Response of N-Get For Printer IOD  is received");

			/*
			 * Get the Response collection from the Print SCU.
			 */
			ISingleCollection<DicomMessage> objSingleCollection = objPrintSCU.getDIMSEResponse();
			System.out.println("Response Size collection :: " + objSingleCollection.size());

			//Get the Dicom Message from the Collection
			DicomMessage objDicomMessage = objSingleCollection.get(objSingleCollection.size()-1);

			//Printing Status of N-Create for Basic Film Session
			objNGetRSP = new NGetRSP(objDicomMessage);
			System.out.println("Status For N-Get For Printer" + objNGetRSP.getStatus());

			//If the DataSet is present in the response print the DataSet.
			IDataSet objIDataSet2 = objDicomMessage.getDataSet();
			if(objIDataSet2 != null)
			{
				System.out.println("*********************************************");
				display(objIDataSet2);
				System.out.println("*********************************************");
			}

		}
		else
			System.out.println("N-Get For Printer operation failed.");
	}

	/*
	 * *************************************************************************
	 * This block of code creates the PrintSCU to perform the  retrieval process of 
	 * Printer Configuration SOP Class.
	 * It initializes the NGet Request and sends it to SCP using PrintSCU.
	 * *************************************************************************
	 */
	private void doNGetForPrinterConfiguration(PrintSCU objPrintSCU) throws IOException
	{

		System.out.println("N-Get Request For Printer Configuration is Initialized................");

		//Initializing NCreate RQ 
		NGetRQ objNGetRQ = NGetRQ.getDefaultRQ(EnumSOPClassUIDs.PRINTERCONFIGURATIONRETRIEVAL.getValue(), "1.2.840.10008.5.1.1.17.376", null);
		NGetRSP objNGetRSP = null;

		//sending RQ to SCP
		if(objPrintSCU.sendMessage(objNGetRQ))
		{
			System.out.println("Response of N-Get For Printer Configuration Retrieval  is received");

			/*
			 * Get the Response collection from the Print SCU.
			 */
			ISingleCollection<DicomMessage> objSingleCollection = objPrintSCU.getDIMSEResponse();
			System.out.println("Response Size collection :: " + objSingleCollection.size());

			//Get the Dicom Message from the Collection
			DicomMessage objDicomMessage = objSingleCollection.get(objSingleCollection.size()-1);

			//Printing Status of N-Create for Basic Film Session
			objNGetRSP = new NGetRSP(objDicomMessage);
			System.out.println("Status For N-Get For Printer Configuration Retrieval " + objNGetRSP.getStatus());

			//If the DataSet is present in the response print the DataSet.
			IDataSet objIDataSet2 = objDicomMessage.getDataSet();
			if(objIDataSet2 != null)
			{
				System.out.println("*********************************************");
				display(objIDataSet2);
				System.out.println("*********************************************");
			}

		}
		else
			System.out.println("N-Get For Printer Configuration Retrieval  operation failed.");
	}

	/*
	 * *************************************************************************
	 * This block of code creates the PrintSCU to perform the  retrieval process of 
	 * Print Job SOP Class.
	 * It initializes the NGet Request and sends it to SCP using PrintSCU.
	 * *************************************************************************
	 */
	private void doNGetForPrintJob(PrintSCU objPrintSCU) throws IOException
	{

		System.out.println("N-Get Request For Print Job is Initialized................");

		//Initializing NCreate RQ 
		NGetRQ objNGetRQ = NGetRQ.getDefaultRQ(EnumSOPClassUIDs.PRINTJOBIOD.getValue(), "1.2.840.10008.5.1.1.14", null);
		NGetRSP objNGetRSP = null;

		//sending RQ to SCP
		if(objPrintSCU.sendMessage(objNGetRQ))
		{
			System.out.println("Response of N-Get For Print Job  is received");

			/*
			 * Get the Response collection from the Print SCU.
			 */
			ISingleCollection<DicomMessage> objSingleCollection = objPrintSCU.getDIMSEResponse();
			System.out.println("Response Size collection :: " + objSingleCollection.size());

			//Get the Dicom Message from the Collection
			DicomMessage objDicomMessage = objSingleCollection.get(objSingleCollection.size()-1);

			//Printing Status of N-Create for Basic Film Session
			objNGetRSP = new NGetRSP(objDicomMessage);
			System.out.println("Status For N-Get For Print Job " + objNGetRSP.getStatus());

			//If the DataSet is present in the response print the DataSet.
			IDataSet objIDataSet2 = objDicomMessage.getDataSet();
			if(objIDataSet2 != null)
			{
				System.out.println("*********************************************");
				display(objIDataSet2);
				System.out.println("*********************************************");
			}

		}
		else
			System.out.println("N-Get For Print Job  operation failed.");
	}

	/*
	 * *************************************************************************
	 * This block of code creates the PrintSCU to perform the process of 
	 * SOP Instance creation operation for Basic Film Session.
	 * It initializes the NCreate RQ and sends it to SCP using PrintSCU.
	 * *************************************************************************
	 */
	public void doNCreateForBasicFilmSession(PrintSCU objPrintSCU) throws IOException
	{

		//Generating Dataset for Basic Film Session N-Create.
		IDataSet objIDataSet = 	objPopulateDataSets.getBasicFilmSessionDataSetForCreate();

		System.out.println("N-Create Request For basic Film Session is Initialized................");

		//Initializing NCreate RQ 
		NCreateRQ objNCreateRQ = NCreateRQ.getDefaultRQ(EnumSOPClassUIDs.BASICFILMSESSIONIOD.getValue(), "1.2.840.10008.5.1.1.1", objIDataSet);
		NCreateRSP objNCreateRSP = null;

		//sending RQ to SCP
		if(objPrintSCU.sendMessage(objNCreateRQ))
		{
			System.out.println("Response of N-Create For Basic Print Session  is received");

			/*
			 * Get the Response collection from the Print SCU.
			 */
			ISingleCollection<DicomMessage> objSingleCollection = objPrintSCU.getDIMSEResponse();
			System.out.println("Response Size collection :: " + objSingleCollection.size());

			//Get the Dicom Message from the Collection
			DicomMessage objDicomMessage = objSingleCollection.get(objSingleCollection.size()-1);

			//Printing Status of N-Create for Basic Film Session
			objNCreateRSP = new NCreateRSP(objDicomMessage);
			strAffectedSOPINstanceUIDForBasicFilmSession = objNCreateRSP.getAffectedSOPInstanceUID();
			System.out.println("Status For N-Create For Basic Print Session " + objNCreateRSP.getStatus());

			//If the DataSet is present in the response print the DataSet.
			IDataSet objIDataSet2 = objDicomMessage.getDataSet();
			if(objIDataSet2 != null)
			{
				System.out.println("*********************************************");
				display(objIDataSet2);
				System.out.println("*********************************************");
			}

		}
		else
			System.out.println("N-Create For Basic Print Session  operation failed.");
	}

	/*
	 * *************************************************************************
	 * This block of code creates the PrintSCU to perform the process of 
	 * SOP Instance creation operation for Basic Film Box.
	 * It initializes the NCreate RQ and sends it to SCP using PrintSCU.
	 * *************************************************************************
	 */
	@SuppressWarnings("unchecked")
	public void doNCreateForBasicFilmBox(PrintSCU objPrintSCU) throws IOException
	{
		//Creation of N-Create of Basic Film Box	
		IDataSet objIDataSet = objPopulateDataSets.getBasicFilmBoxDataSetForCreate();

		System.out.println("N-Create Request for Basic Film Box initialized");

		//Create Reference Film Session sequence from the SOP instance UID created at the SCP.
		ReferencedFilmSessionSequence objReferencedFilmSessionSequence = (ReferencedFilmSessionSequence)DicomV3Factory.createInstance().createSequence(0x2010, 0x0500,objIDataSet.getTransferSyntax());
		SOPInstanceReferenceMacroDependentItem objReferencedSequenceDependentItem = objReferencedFilmSessionSequence.getNewItem();
		objReferencedSequenceDependentItem.getSOPInstanceReferenceMacro().setReferencedSOPClassUID(EnumSOPClassUIDs.BASICFILMBOXIOD.getValue());
		objReferencedSequenceDependentItem.getSOPInstanceReferenceMacro().setReferencedSOPInstanceUID("1.2.840.10008.5.1.1.1");
		objReferencedFilmSessionSequence.addItem(objReferencedSequenceDependentItem);
		IDataElement objIDataElement = new ImplicitDE(0x2010,0x0500,objReferencedFilmSessionSequence,objIDataSet.getTransferSyntax(), objIDataSet.getDictionaryReader());
		objIDataSet.addDataElement(objIDataElement);

		//Initializing NCreate RQ 
		NCreateRQ objNCreateRQ = NCreateRQ.getDefaultRQ(EnumSOPClassUIDs.BASICFILMBOXIOD.getValue(), "1.2.840.10008.5.1.1.2", objIDataSet);

		//sending RQ to SCP
		if(objPrintSCU.sendMessage(objNCreateRQ))
		{
			/*
			 * Get the Response collection from the Print SCU.
			 */
			System.out.println("Response of N-Create For Basic Fim Box  Received");
			ISingleCollection<DicomMessage> objSingleCollection = objPrintSCU.getDIMSEResponse();
			System.out.println("Response Size collection :: " + objSingleCollection.size());

			//Get the Dicom Message from the Collection 
			DicomMessage objDicomMessage = objSingleCollection.get(objSingleCollection.size()-1);

			//Printing Status of N-Create for Basic Film Box
			NCreateRSP objNCreateRSP = new NCreateRSP(objDicomMessage);
			System.out.println("Status For N-Create For Basic Fim Box  " + objNCreateRSP.getStatus());

			//If the DataSet is present in the response print the DataSet.
			IDataSet objIDataSet2 = objDicomMessage.getDataSet();
			if(objIDataSet2 != null)
			{
				System.out.println("*********************************************");
				display(objIDataSet2);
				System.out.println("*********************************************");
			}

			//retrieve SOP Instance of Basic Film box created at SCP
			strSOPInstanceForBasicFimBox = objNCreateRSP.getAffectedSOPInstanceUID();
			objIDataElement = objIDataSet2.getDataForTag(0x2010, 0x0510);
			ISingleCollection<SOPInstanceReferenceMacroDependentItem> objITemCollection= (ISingleCollection<SOPInstanceReferenceMacroDependentItem>)objIDataElement.getValue();
			SOPInstanceReferenceMacroDependentItem objItem = objITemCollection.get(0);

			//Retrieve SOP instance of Basic GrayScale Create at SCP.
			strSOPInstanceForBasicGrayScaleImageBox = objItem.getSOPInstanceReferenceMacro().getReferencedSOPInstanceUID();
			objIDataElement = objIDataSet2.getDataForTag(0x2010, 0x0520);
			objITemCollection= (ISingleCollection<SOPInstanceReferenceMacroDependentItem>)objIDataElement.getValue();
			objItem = objITemCollection.get(0);

			//Retrieve SOP Instance of Basic Annotation SOP Instance created at SCP.
			strSOPInstanceForAnotation = objItem.getSOPInstanceReferenceMacro().getReferencedSOPInstanceUID();

		}
		else
			System.out.println("N-Create For Basic Fim Box operation failed.");
	}

	/*
	 * *************************************************************************
	 * This block of code creates the PrintSCU to perform the process of 
	 * SOP Instance creation operation for PresentationLUT.
	 * It initializes the NCreate RQ and sends it to SCP using PrintSCU.
	 * *************************************************************************
	 */
	public void doNCreateForPresentationLUT(PrintSCU objPrintSCU) throws IOException
	{
		//Creation of N-Create of Presentation LUT
		IDataSet objIDataSet = objPopulateDataSets.getPresentationLUTDataSetForCreate(); 

		System.out.println("N-Create Request for Presentation LUT initialized");

		//Initializing NCreate RQ 
		NCreateRQ objNCreateRQ = NCreateRQ.getDefaultRQ(EnumSOPClassUIDs.PRESENTATIONLUTIOD.getValue(), "1.2.840.10008.5.1.1.23", objIDataSet);

		//sending RQ to SCP
		if(objPrintSCU.sendMessage(objNCreateRQ))
		{
			/*
			 * Get the Response collection from the Print SCU.
			 */
			System.out.println("Response of N-Create For Presentation LUT  Received");
			ISingleCollection<DicomMessage> objSingleCollection = objPrintSCU.getDIMSEResponse();
			System.out.println("Response Size collection :: " + objSingleCollection.size());

			//Get the Dicom Message from the Collection 
			DicomMessage objDicomMessage = objSingleCollection.get(objSingleCollection.size()-1);

			//Printing Status of N-Create 
			NCreateRSP objNCreateRSP = new NCreateRSP(objDicomMessage);

			//Retrieve SOP Instance of Presentation LUT SOP Instance created at SCP.
			strSOPInstanceForPresentationLUT = objNCreateRSP.getAffectedSOPInstanceUID();
			System.out.println("Status For N-Create For Presentation LUT " + objNCreateRSP.getStatus());

			//If the DataSet is present in the response print the DataSet.
			IDataSet objIDataSet2 = objDicomMessage.getDataSet();
			if(objIDataSet2 != null)
			{
				System.out.println("*********************************************");
				display(objIDataSet2);
				System.out.println("*********************************************");
			}
		}
		else
			System.out.println("N-Create For Presentation LUT operation failed.");
	}

	/*
	 * *************************************************************************
	 * This block of code creates the PrintSCU to perform the process of 
	 * SOP Instance updation operation for Basic Film Session.
	 * It initializes the NSet RQ and sends it to SCP using PrintSCU.
	 * *************************************************************************
	 */
	public void doNSetForBasicFilmSession(PrintSCU objPrintSCU) throws IOException
	{
		System.out.println("N-Action Request for Basic Film Session initialized");

		//Creation of N-Set DataSet of Basic Film Session 
		IDataSet objIDataSet = objPopulateDataSets.getBasicFilmSessionDataSetForSet();

		//Initializing NSet RQ
		NSetRQ objNSetRQ = NSetRQ.getDefaultRQ(EnumSOPClassUIDs.BASICFILMSESSIONIOD.getValue(), "1.2.840.10008.5.1.1.1", objIDataSet);

		//sending RQ to SCP
		if(objPrintSCU.sendMessage(objNSetRQ))
		{
			/*
			 * Get the Response collection from the Print SCU.
			 */
			System.out.println("Response of N-Set For Basic Print Session  Received");
			ISingleCollection<DicomMessage> objSingleCollection = objPrintSCU.getDIMSEResponse();
			System.out.println("Response Size collection :: " + objSingleCollection.size());

			//Get the Dicom Message from the Collection 
			DicomMessage objDicomMessage = objSingleCollection.get(objSingleCollection.size()-1);

			//Printing Status of N-Set 
			NSetRSP objNSetRSP = new NSetRSP(objDicomMessage);
			System.out.println("Status For N-Set For Basic Print Session " + objNSetRSP.getStatus());

			//If the DataSet is present in the response print the DataSet.
			IDataSet objIDataSet2 = objDicomMessage.getDataSet();
			if(objIDataSet2 != null)
			{
				System.out.println("*********************************************");
				display(objIDataSet2);
				System.out.println("*********************************************");
			}
		}
		else
			System.out.println("N-Set For Basic Print Session  operation failed.");
	}

	/*
	 * *************************************************************************
	 * This block of code creates the PrintSCU to perform the process of 
	 * SOP Instance updation operation for Basic Film Box.
	 * It initializes the NSet RQ and sends it to SCP using PrintSCU.
	 * *************************************************************************
	 */
	public void doNSetForBasicFilmBox(PrintSCU objPrintSCU) throws IOException
	{
		System.out.println("N-Set Request for Basic Film Box initialized");

		//Creation of N-Set DataSet of Basic Film Box 
		IDataSet objIDataSet = objPopulateDataSets.getBasicFilmBoxDataSetForSet();

		//Set the created Presentation LUT in ReferencedPresentationLUTSequence
		ReferencedPresentationLUTSequence objReferencedPresentationLUTSequence = (ReferencedPresentationLUTSequence)DicomV3Factory.createInstance().createSequence(0x2050, 0x0500, objIDataSet.getTransferSyntax(),objIDataSet.getDictionaryReader());
		SOPInstanceReferenceMacroDependentItem objReferencedSequenceDependentItem =objReferencedPresentationLUTSequence.getNewItem();
		objReferencedSequenceDependentItem.getSOPInstanceReferenceMacro().setReferencedSOPClassUID(EnumSOPClassUIDs.PRESENTATIONLUTIOD.getValue());
		objReferencedSequenceDependentItem.getSOPInstanceReferenceMacro().setReferencedSOPInstanceUID(strSOPInstanceForPresentationLUT);
		objReferencedPresentationLUTSequence.addItem(objReferencedSequenceDependentItem);
		IDataElement objIDataElement = new ImplicitDE(0x2050,0x0500,objReferencedPresentationLUTSequence, objIDataSet.getTransferSyntax(),objIDataSet.getDictionaryReader());
		objIDataSet.addDataElement(objIDataElement);

		//Initializing NSet RQ
		NSetRQ objNSetRQ = NSetRQ.getDefaultRQ(EnumSOPClassUIDs.BASICFILMBOXIOD.getValue(), "1.2.840.10008.5.1.1.2", objIDataSet);

		//sending RQ to SCP
		if(objPrintSCU.sendMessage(objNSetRQ))
		{
			/*
			 * Get the Response collection from the Print SCU.
			 */
			System.out.println("N-Set For Basic Film Box  Operation performed");
			ISingleCollection<DicomMessage> objSingleCollection = objPrintSCU.getDIMSEResponse();
			System.out.println("Response Size collection :: " + objSingleCollection.size());

			//Get the Dicom Message from the Collection 
			DicomMessage objDicomMessage = objSingleCollection.get(objSingleCollection.size()-1);

			//Printing Status of N-Set 
			NSetRSP objNSetRSP = new NSetRSP(objDicomMessage);
			System.out.println("Status For N-Set For Basic Film Box " + objNSetRSP.getStatus());

			//If the DataSet is present in the response print the DataSet.
			IDataSet objIDataSet2 = objDicomMessage.getDataSet();
			if(objIDataSet2 != null)
			{
				System.out.println("*********************************************");
				display(objIDataSet2);
				System.out.println("*********************************************");
			}

		}
		else
			System.out.println("N-Set For Basic Fim Box  operation failed.");
	}

	/*
	 * *************************************************************************
	 * This block of code creates the PrintSCU to perform the process of 
	 * SOP Instance updation operation for Basic GrayScale Image Box.
	 * It initializes the NCreate RQ and sends it to SCP using PrintSCU.
	 * *************************************************************************
	 */
	public void doNSetForBasicGrayScaleImageBox(PrintSCU objPrintSCU) throws IOException
	{
		System.out.println("N-Set Request for Basic GrayScale Image Box initialized");

		//Creation of N-Set DataSet
		IDataSet objIDataSet = objPopulateDataSets.getBasicGrayScaleImageBoxDataSetForSet();

		//creation of ReferencedPresentationLUTSequence and adding it to Dataset.
		ReferencedPresentationLUTSequence objReferencedPresentationLUTSequence = (ReferencedPresentationLUTSequence)DicomV3Factory.createInstance().createSequence(0x2050, 0x0500, objIDataSet.getTransferSyntax(),objIDataSet.getDictionaryReader());
		SOPInstanceReferenceMacroDependentItem objReferencedSequenceDependentItem =objReferencedPresentationLUTSequence.getNewItem();
		objReferencedSequenceDependentItem.getSOPInstanceReferenceMacro().setReferencedSOPClassUID(EnumSOPClassUIDs.PRESENTATIONLUTIOD.getValue());
		objReferencedSequenceDependentItem.getSOPInstanceReferenceMacro().setReferencedSOPInstanceUID("1.2.840.10008.5.1.1.23");
		objReferencedPresentationLUTSequence.addItem(objReferencedSequenceDependentItem);
		IDataElement objIDataElement = new ImplicitDE(0x2050,0x0500,objReferencedPresentationLUTSequence, objIDataSet.getTransferSyntax(),objIDataSet.getDictionaryReader());
		objIDataSet.addDataElement(objIDataElement);

	/*	//creation of ReferencedImageOverlayBoxSequence and adding it to Dataset.
		ReferencedImageOverlayBoxSequence objReferencedImageOverlayBoxSequence = (ReferencedImageOverlayBoxSequence)DicomV3Factory.createInstance().createSequence(0x2020, 0x0130,objIDataSet.getTransferSyntax(),objIDataSet.getDictionaryReader());
		objReferencedSequenceDependentItem = objReferencedImageOverlayBoxSequence.getNewItem();
		objReferencedSequenceDependentItem.getSOPInstanceReferenceMacro().setReferencedSOPClassUID(EnumSOPClassUIDs.BASICPRINTIMAGEOVERLAYBOXIOD.getValue());
		objReferencedSequenceDependentItem.getSOPInstanceReferenceMacro().setReferencedSOPInstanceUID(strSOPInstanceForBasicPrintImageOverlay);
		objReferencedImageOverlayBoxSequence.addItem(objReferencedSequenceDependentItem);
		objIDataElement = new ImplicitDE(0x2020,0x0130,objReferencedImageOverlayBoxSequence, objIDataSet.getTransferSyntax(),objIDataSet.getDictionaryReader());
		objIDataSet.addDataElement(objIDataElement);*/
		NSetRQ objNSetRQ = NSetRQ.getDefaultRQ(EnumSOPClassUIDs.BASICGRAYSCALEIMAGEBOX.getValue(), "1.2.840.10008.5.1.1.4", objIDataSet);

		//sending RQ to SCP
		if(objPrintSCU.sendMessage(objNSetRQ))
		{
			/*
			 * Get the Response collection from the Print SCU.
			 */
			System.out.println("N-Set For Basic Gray Scale Image Box  Operation performed");
			ISingleCollection<DicomMessage> objSingleCollection = objPrintSCU.getDIMSEResponse();
			System.out.println("Response Size collection :: " + objSingleCollection.size());

			//Get the Dicom Message from the Collection 
			DicomMessage objDicomMessage = objSingleCollection.get(objSingleCollection.size()-1);

			//Printing Status of N-Set 
			NSetRSP objNSetRSP = new NSetRSP(objDicomMessage);
			System.out.println("Status For N-Set For Basic Gray Scale Image Box " + objNSetRSP.getStatus());

			//If the DataSet is present in the response print the DataSet.
			IDataSet objIDataSet2 = objDicomMessage.getDataSet();
			if(objIDataSet2 != null)
			{
				System.out.println("*********************************************");
				display(objIDataSet2);
				System.out.println("*********************************************");
			}
		}
		else
			System.out.println("N-Set For Basic Gray Scale Image Box operation failed.");
	}
	/*
	 * *************************************************************************
	 * This block of code creates the PrintSCU to perform the process of 
	 * SOP Instance updation operation for Basic GrayScale Image Box.
	 * It initializes the NCreate RQ and sends it to SCP using PrintSCU.
	 * *************************************************************************
	 */
	public void doNSetForBasicAnnotationBox(PrintSCU objPrintSCU) throws IOException
	{
		//Creation of N-Set DataSet
		IDataSet objIDataSet = objPopulateDataSets.getBasicAnnotationBoxDataSetForSet();

		System.out.println("N-Set Request for Basic Annotation Box initialized");

		//Initializes N-Set Request
		NSetRQ objNSetRQ = NSetRQ.getDefaultRQ(EnumSOPClassUIDs.BASICANNOTATIONBOX.getValue(), "1.2.840.10008.5.1.1.15", objIDataSet);

		//sending RQ to SCP
		if(objPrintSCU.sendMessage(objNSetRQ))
		{
			/*
			 * Get the Response collection from the Print SCU.
			 */
			System.out.println("N-Set For Basic Annotation Box  Operation performed");

			//Get the Dicom Message from the Collection 
			ISingleCollection<DicomMessage> objSingleCollection = objPrintSCU.getDIMSEResponse();
			System.out.println("Response Size collection :: " + objSingleCollection.size());

			//Printing Status of N-Set 
			DicomMessage objDicomMessage = objSingleCollection.get(objSingleCollection.size()-1);
			NSetRSP objNSetRSP = new NSetRSP(objDicomMessage);
			System.out.println("Status For N-Set Basic Annotation Box " + objNSetRSP.getStatus());

			//If the DataSet is present in the response print the DataSet.
			IDataSet objIDataSet2 = objDicomMessage.getDataSet();
			if(objIDataSet2 != null)
			{
				System.out.println("*********************************************");
				display(objIDataSet2);
				System.out.println("*********************************************");
			}

		}
		else
			System.out.println("N-Set For Basic Annotation Box failed.");
	}

	/*
	 * *************************************************************************
	 * This block of code creates the PrintSCU to perform the process of 
	 * SOP Instance updation operation for Basic Film Session.
	 * It initializes the Naction RQ and sends it to SCP using PrintSCU.
	 * *************************************************************************
	 */
	@SuppressWarnings("unchecked")
	public void doNActionForBasicFilmSession(PrintSCU objPrintSCU) throws IOException
	{
		System.out.println("N-Action Request for Basic Film Session initialized");

		////Initializes N-Action Request
		NActionRQ objNActionRQ = NActionRQ.getDefaultRQ(EnumSOPClassUIDs.BASICFILMSESSIONIOD.getValue(), "1.2.840.10008.5.1.1.1", EnumActionTypeID.PRINT_ACTION, null);

		////sending RQ to SCP
		if(objPrintSCU.sendMessage(objNActionRQ))
		{
			/*
			 * Get the Response collection from the Print SCU.
			 */
			System.out.println("N-Action For Basic Film Session  Operation performed");

			//Get the Dicom Message from the Collection 
			ISingleCollection<DicomMessage> objSingleCollection = objPrintSCU.getDIMSEResponse();
			System.out.println("Response Size collection :: " + objSingleCollection.size());
			DicomMessage objDicomMessage = objSingleCollection.get(objSingleCollection.size()-1);

			//Printing Status of N-Set 
			NActionRSP objNActionRSP = new NActionRSP(objDicomMessage);
			System.out.println("Status For N-Action Basic Film Session " + objNActionRSP.getStatus());

			//If the DataSet is present in the response print the DataSet.
			IDataSet objIDataSet2 = objDicomMessage.getDataSet();
			if(objIDataSet2 != null)
			{
				System.out.println("*********************************************");
				display(objIDataSet2);
				System.out.println("*********************************************");
				if(objIDataSet2.getValue(0x2100,0x0500) != null)
				{
					ISingleCollection<IItem> objItemCollection = (ISingleCollection<IItem>)objIDataSet2.getValue(0x2100,0x0500);
					if(objItemCollection.size() >0)
					{
						IItem objItem = objItemCollection.get(0);
						if(objItem.getValue(0x2100, 0x0010) != null)
						{
							PrintJOBID = objItem.getValue(0x2100, 0x0010).toString();

						}
						if(objItem.getValue(0x0008, 0x1155) != null)
						{
							strPrintJobSOPInstanceUID = objItem.getValue(0x0008, 0x1155).toString();
						}
					}

				}
			}

		}
		else
			System.out.println("N-Action For Basic Film Session failed.");

	}

	/*
	 * *************************************************************************
	 * This block of code creates the PrintSCU to perform the process of 
	 * SOP Instance deletion operation for Basic Film Session.
	 * It initializes the NCreate RQ and sends it to SCP using PrintSCU.
	 * *************************************************************************
	 */
	public void doNDeleteForBasicFilmSession(PrintSCU objPrintSCU) throws IOException
	{
		System.out.println("N-Delete Request for Basic Film Session initialized");

		NDeleteRQ objNDeleteRQ = NDeleteRQ.getDefaultRQ(EnumSOPClassUIDs.BASICFILMSESSIONIOD.getValue(), "1.2.840.10008.5.1.1.1");
		if(objPrintSCU.sendMessage(objNDeleteRQ))
		{
			System.out.println("N-Delete Response For Basic Film Box received");
			ISingleCollection<DicomMessage> objSingleCollection = objPrintSCU.getDIMSEResponse();
			System.out.println("Response Size collection :: " + objSingleCollection.size());
			DicomMessage objDicomMessage = objSingleCollection.get(objSingleCollection.size()-1);
			NDeleteRSP objNDeleteRSP = new NDeleteRSP(objDicomMessage);
			System.out.println("Status For N-Delete Basic Film Box " + objNDeleteRSP.getStatus());
		}
		else
			System.out.println("N-Delete  For Basic Film Box failed.");
	}

	/*
	 * *************************************************************************
	 * This block of code creates the PrintSCU to perform the process of 
	 * retrieve operation for PrintQueueMangement.
	 * It initializes the NGET RQ and sends it to SCP using PrintSCU.
	 * *************************************************************************
	 */
	public void doGetForPrintQueueManagement(PrintSCU objPrintSCU) throws IOException
	{

		////Initializes N-Action Request
		NGetRQ objNGetRQ = NGetRQ.getDefaultRQ(EnumSOPClassUIDs.PRINTQUEUEMANAGEMENTIOD.getValue(), DicomConstants.DCM_PRINT_QUEUE_MANAGEMENT_SOP_INSTANCE,null);

		System.out.println("N-Get Request for Print Queue Management initialized");

		////sending RQ to SCP
		if(objPrintSCU.sendMessage(objNGetRQ))
		{
			/*
			 * Get the Response collection from the Print SCU.
			 */
			System.out.println("N-Get For Print Queue Management  Operation performed");

			//Get the Dicom Message from the Collection 
			ISingleCollection<DicomMessage> objSingleCollection = objPrintSCU.getDIMSEResponse();
			System.out.println("Response Size collection :: " + objSingleCollection.size());
			DicomMessage objDicomMessage = objSingleCollection.get(objSingleCollection.size()-1);

			//Printing Status of N-Set 
			NGetRSP objNGetRSP = new NGetRSP(objDicomMessage);
			System.out.println("Status For N-Get Print Queue Management " + objNGetRSP.getStatus());

			//If the DataSet is present in the response print the DataSet.
			IDataSet objIDataSet2 = objDicomMessage.getDataSet();
			if(objIDataSet2 != null)
			{
				System.out.println("*********************************************");
				display(objIDataSet2);
				System.out.println("*********************************************");
			}

		}
		else
			System.out.println("N-Get For Print Queue Management failed.");
	}

	/*
	 * *************************************************************************
	 * This block of code creates the PrintSCU to perform the process of 
	 * SOP Instance updation operation for Print Queue Management Delete.
	 * It initializes the Naction RQ and sends it to SCP using PrintSCU.
	 * *************************************************************************
	 */
	public void doNActionForPrintQueueManagementDelete(PrintSCU objPrintSCU) throws IOException
	{
		//Creation of N-Action DataSet
		IDataSet objIDataSet = getNActionDeleteDatSetForPrintQueueMang();

		System.out.println("N-Action Request for Print Queue Management initialized");

		////Initializes N-Action Request
		NActionRQ objNActionRQ = NActionRQ.getDefaultRQ(EnumSOPClassUIDs.PRINTQUEUEMANAGEMENTIOD.getValue(), DicomConstants.DCM_PRINT_QUEUE_MANAGEMENT_SOP_INSTANCE, EnumActionTypeID.PRINT_QUEUE_ACTION_DELETE, objIDataSet);

		////sending RQ to SCP
		if(objPrintSCU.sendMessage(objNActionRQ))
		{
			/*
			 * Get the Response collection from the Print SCU.
			 */
			System.out.println("N-Action For Print Queue Management Delete");

			//Get the Dicom Message from the Collection 
			ISingleCollection<DicomMessage> objSingleCollection = objPrintSCU.getDIMSEResponse();
			System.out.println("Response Size collection :: " + objSingleCollection.size());
			DicomMessage objDicomMessage = objSingleCollection.get(objSingleCollection.size()-1);

			//Printing Status of N-Set 
			NActionRSP objNActionRSP = new NActionRSP(objDicomMessage);
			System.out.println("Status For N-Action Print Queue Management Delete " + objNActionRSP.getStatus());
		}
		else
			System.out.println(" N-Action Print Queue Management Delete failed.");

	}

	/*
	 * *************************************************************************
	 * This block of code creates the PrintSCU to perform the process of 
	 * SOP Instance updation operation for Print Queue Management Prioritize.
	 * It initializes the Naction RQ and sends it to SCP using PrintSCU.
	 * *************************************************************************
	 */
	public void doNActionForPrintQueueManagementPrioritize(PrintSCU objPrintSCU) throws IOException
	{
		//Creation of N-Action DataSet
		IDataSet objIDataSet = getNActionPrioritizeDatSetForPrintQueueMang();

		System.out.println("N-Action Request for Print Queue Management initialized");

		////Initializes N-Action Request
		NActionRQ objNActionRQ = NActionRQ.getDefaultRQ(EnumSOPClassUIDs.PRINTQUEUEMANAGEMENTIOD.getValue(), DicomConstants.DCM_PRINT_QUEUE_MANAGEMENT_SOP_INSTANCE, EnumActionTypeID.PRINT_QUEUE_ACTION_PRIORITIZE, objIDataSet);

		////sending RQ to SCP
		if(objPrintSCU.sendMessage(objNActionRQ))
		{
			/*
			 * Get the Response collection from the Print SCU.
			 */
			System.out.println("N-Action For Print Queue Management Prioritize");

			//Get the Dicom Message from the Collection 
			ISingleCollection<DicomMessage> objSingleCollection = objPrintSCU.getDIMSEResponse();
			System.out.println("Response Size collection :: " + objSingleCollection.size());
			DicomMessage objDicomMessage = objSingleCollection.get(objSingleCollection.size()-1);

			//Printing Status of N-Set 
			NActionRSP objNActionRSP = new NActionRSP(objDicomMessage);
			System.out.println("Status For N-Action Print Queue Management Prioritize " + objNActionRSP.getStatus());
		}
		else
			System.out.println(" N-Action Print Queue Management Prioritize failed.");

	}

	/*
	 * Displays the DataElements of Dataset
	 */
	private void display(IDataSet objIDataSet)
	{
		ICollectionIterator<IDataElement> objIDataSetIterator = objIDataSet.iterator();

		System.out.println("Tag     Value");
		while(objIDataSetIterator.hasNext())
		{
			IDataElement objDataElement = objIDataSetIterator.next();				

			if(!(objDataElement.getDicomValue() instanceof SQ))
			{

				System.out.println(objDataElement.getTag().getGroupNumber()+"    "+
						objDataElement.getTag().getElementNumber()+"    "+
						objDataElement.getDicomValue().toString());
			}
			else  
			{
				displaySequence((SQ)objDataElement.getDicomValue(),"> ");					
			}
		}
	}

	/*
	 * This method Display the SQ data type.
	 */
	private void displaySequence(SQ objSQDataElement,String ss)
	{
		ICollectionIterator<IItem> objSQItemIterator = objSQDataElement.iterator();
		int i = 1;
		while(objSQItemIterator.hasNext())
		{
			System.out.println("ITEM :"+ i++ );
			IItem objItem = objSQItemIterator.next();
			ICollectionIterator<IDataElement> objDataElementIterator = objItem.iterator();
			while(objDataElementIterator.hasNext())
			{
				IDataElement objDataElement = objDataElementIterator.next();

				if(!(objDataElement.getDicomValue() instanceof SQ))
				{
					System.out.println(ss +objDataElement.getTag().getGroupNumber()+"    "+
							objDataElement.getTag().getElementNumber()+"    "+
							objDataElement.getDicomValue().toString());						 

				}
				else
				{
					displaySequence((SQ)objDataElement.getDicomValue(),ss+ss);
				}	 
			}
		}
	}

	/*
	 * This function gets the dataset for N-Action operation of Print Queue Management Service.
	 * This data set should contain Print Job ID and Owner ID.
	 */
	private IDataSet getNActionDeleteDatSetForPrintQueueMang()
	{
		IDataSet objIDataSet = new DataSet();
		IDataElement objIDataElement = new ImplicitDE(0x2100,0x0010,PrintJOBID, objIDataSet.getTransferSyntax(), objIDataSet.getDictionaryReader());
		objIDataSet.addDataElement(objIDataElement);
		objIDataElement = new ImplicitDE(0x2100,0x0160,"1", objIDataSet.getTransferSyntax(), objIDataSet.getDictionaryReader());
		objIDataSet.addDataElement(objIDataElement);
		return objIDataSet;
	}

	/*
	 * This function gets the dataset for N-Action operation of Print Queue Management Service.
	 * This data set should contain Print Job ID and Owner ID and priority.
	 */
	private IDataSet getNActionPrioritizeDatSetForPrintQueueMang()
	{
		IDataSet objIDataSet = new DataSet();
		IDataElement objIDataElement = new ImplicitDE(0x2100,0x0010,PrintJOBID, objIDataSet.getTransferSyntax(), objIDataSet.getDictionaryReader());
		objIDataSet.addDataElement(objIDataElement);
		objIDataElement = new ImplicitDE(0x2100,0x0160,"1", objIDataSet.getTransferSyntax(), objIDataSet.getDictionaryReader());
		objIDataSet.addDataElement(objIDataElement);
		objIDataElement = new ImplicitDE(0x2000,0x0020,"LOW", objIDataSet.getTransferSyntax(), objIDataSet.getDictionaryReader());
		objIDataSet.addDataElement(objIDataElement);
		return objIDataSet;
	}
}
