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

import cdac.medinfo.sdk.dcm30_04.baselibs.DataSet;
import cdac.medinfo.sdk.dcm30_04.commoninterface.IDataSet;
import cdac.medinfo.sdk.dcm30_04.commoninterface.ITransferSyntax;
import cdac.medinfo.sdk.dcm30_04.enums.EnumSOPClassUIDs;
import cdac.medinfo.sdk.dcm30_04.services.dimsecommons.IQueryModel;
import cdac.medinfo.sdk.dcm30_04.utils.ICollectionIterator;
import cdac.medinfo.sdk.dcm30_04.utils.ISingleCollection;
import cdac.medinfo.sdk.dcm30_04.utils.SingleCollection;

/**
 *  This class represents Query Model for NCreateImagePrintMangMeta. This class contains methods to encode and decode Query Model.
 */
public class NCreateImagePrintMangMeta_QueryModel implements IQueryModel
{
	ISingleCollection<NCreateImagePrintMangMeta_Attributes> objNCreateGrayscalePrintMangMeta_AttributesList = null;
	private EnumSOPClassUIDs enumSOPClassUIDs;
	
	/**
	 * This is default Constructor for NCreateImagePrintMangMeta_QueryModel.
	 */
	public NCreateImagePrintMangMeta_QueryModel() {
		super();
	}

	/**
	 * Retrieve EnumSOPClassUIDs .
	 * @return EnumSOPClassUIDs
	 */
	public EnumSOPClassUIDs getEnumSOPClassUIDs()
	{
		return enumSOPClassUIDs;
	}
	
	public NCreateImagePrintMangMeta_QueryModel(EnumSOPClassUIDs enumSOPClassUIDs)
	{
		this.objNCreateGrayscalePrintMangMeta_AttributesList = new SingleCollection<NCreateImagePrintMangMeta_Attributes>();
		this.enumSOPClassUIDs = enumSOPClassUIDs;
	}
	
	/**
	 * Retrieve the object of NCreateImagePrintMangMeta_Attributes.
	 * @return ISingleCollection of NCreateImagePrintMangMeta_Attributes
	 */
	public ISingleCollection<NCreateImagePrintMangMeta_Attributes> getNCreateGrayscalePrintMangMeta_AttributesList() 
	{
		return objNCreateGrayscalePrintMangMeta_AttributesList;
	}

	/**
	 * Set the value of NCreateImagePrintMangMeta_Attributes.
	 * @param objGrayscalePrintMangMetaAttributesList - object of ISingleCollection
	 */
	public void setNCreateGrayscalePrintMangMeta_AttributesList(ISingleCollection<NCreateImagePrintMangMeta_Attributes> objGrayscalePrintMangMetaAttributesList) 
	{
		objNCreateGrayscalePrintMangMeta_AttributesList = objGrayscalePrintMangMetaAttributesList;
	}
	
	/**
	 * Populates the Query Model using filled DataSet.
	 * @param objIDataSet Object of IDataSet.
	 * @return True - if Query Model populated successfully else False.
	 */
	public boolean decode(IDataSet objIDataSet)
	{
		if(this.objNCreateGrayscalePrintMangMeta_AttributesList == null)
			this.objNCreateGrayscalePrintMangMeta_AttributesList = new SingleCollection<NCreateImagePrintMangMeta_Attributes>();
		
		NCreateImagePrintMangMeta_Attributes objStudySAttributes = new NCreateImagePrintMangMeta_Attributes(this.enumSOPClassUIDs);
		
		objStudySAttributes.populate(objIDataSet);
		
		objNCreateGrayscalePrintMangMeta_AttributesList.add(objStudySAttributes);
		return true;
	}
	
	
	/**
	 * Gets the filled DataSet list from already populated Query Model. 
	 * @param objITransferSyntax Object of ITransferSyntax. 
	 * @param objDataSetList Single collect of DataSet.
	 * @return True - Dataset List filled successfully else False.
	 */
	public boolean encode(ITransferSyntax objITransferSyntax, ISingleCollection<IDataSet> objDataSetList)
	{
		if(objNCreateGrayscalePrintMangMeta_AttributesList != null)
		{
			ICollectionIterator<NCreateImagePrintMangMeta_Attributes> objNCreateGrayscalePrintMangMeta_AttributesIterator = objNCreateGrayscalePrintMangMeta_AttributesList.iterator();
			while(objNCreateGrayscalePrintMangMeta_AttributesIterator.hasNext())
			{
				NCreateImagePrintMangMeta_Attributes objStudySAttributes = objNCreateGrayscalePrintMangMeta_AttributesIterator.next();
				if(objStudySAttributes != null)
				{
					IDataSet objIDataSet = new DataSet(objITransferSyntax);
					objStudySAttributes.fill(objIDataSet);
					objDataSetList.add(objIDataSet);
				}
			}
			return true;
		}
		else
			return false;
	}
}
