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

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 NEventReportImagePrintMangMeta. This class contains methods to encode and decode Query Model.
 */
public class NEventReportImagePrintMangMeta_QueryModel implements IQueryModel
{
	ISingleCollection<NEventReportImagePrintMangMeta_Attributes> objNEventReportImagePrintMangMeta_AttributesList = null;
	private EnumSOPClassUIDs enumSOPClassUIDs;
	/**
	 * This is default Constructor for NEventReportImagePrintMangMeta_QueryModel.
	 */
	public NEventReportImagePrintMangMeta_QueryModel() {
		super();
	}
	/**
	 * Retrieve EnumSOPClassUIDs .
	 * @return EnumSOPClassUIDs
	 */
	
	public EnumSOPClassUIDs getEnumSOPClassUIDs()
	{
		return enumSOPClassUIDs;
	}

	public NEventReportImagePrintMangMeta_QueryModel(EnumSOPClassUIDs enumSOPClassUIDs)
	{
		this.objNEventReportImagePrintMangMeta_AttributesList = new SingleCollection<NEventReportImagePrintMangMeta_Attributes>();
		this.enumSOPClassUIDs = enumSOPClassUIDs;
	}
	/**
	 * Retrieve the object of NEventReportImagePrintMangMeta_Attributes.
	 * @return ISingleCollection of NEventReportImagePrintMangMeta_Attributes
	 */
	public ISingleCollection<NEventReportImagePrintMangMeta_Attributes> getNEventReportImagePrintMangMeta_AttributesList() 
	{
		return objNEventReportImagePrintMangMeta_AttributesList;
	}
	/**
	 * Set the value of NEventReportImagePrintMangMeta_Attributes.
	 * @param objGPWLAttributesList - object of ISingleCollection
	 */
	public void setNEventReportImagePrintMangMeta_AttributesList(ISingleCollection<NEventReportImagePrintMangMeta_Attributes> objGPWLAttributesList) 
	{
		objNEventReportImagePrintMangMeta_AttributesList = objGPWLAttributesList;
	}
	
	/**
	 * 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.objNEventReportImagePrintMangMeta_AttributesList == null)
			this.objNEventReportImagePrintMangMeta_AttributesList = new SingleCollection<NEventReportImagePrintMangMeta_Attributes>();
		
		NEventReportImagePrintMangMeta_Attributes objStudyAttributes = new NEventReportImagePrintMangMeta_Attributes(this.enumSOPClassUIDs);
		
		objStudyAttributes.populate(objIDataSet);
		
		objNEventReportImagePrintMangMeta_AttributesList.add(objStudyAttributes);
		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(objNEventReportImagePrintMangMeta_AttributesList != null)
		{
			ICollectionIterator<NEventReportImagePrintMangMeta_Attributes> objNEventReportImagePrintMangMeta_AttributesIterator = objNEventReportImagePrintMangMeta_AttributesList.iterator();
			while(objNEventReportImagePrintMangMeta_AttributesIterator.hasNext())
			{
				NEventReportImagePrintMangMeta_Attributes objStudyAttributes = objNEventReportImagePrintMangMeta_AttributesIterator.next();
				if(objStudyAttributes != null)
				{
					IDataSet objIDataSet = new DataSet(objITransferSyntax);
					objStudyAttributes.fill(objIDataSet);
					objDataSetList.add(objIDataSet);
				}
			}
			return true;
		}
		else
			return false;
	}
}
