/*******************************************************************************
 *  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 NActionImagePrintMangMeta. This class contains methods to encode and decode Query Model.
 */
public class NActionImagePrintMangMeta_QueryModel implements IQueryModel
{
	/**
	 * This is default Constructor for NActionImagePrintMangMeta_QueryModel.
	 */
	public NActionImagePrintMangMeta_QueryModel() {
		super();
	}
	
	ISingleCollection<NActionImagePrintMangMeta_Attributes> objNActionImagePrintMangMeta_AttributesList = null;
	private EnumSOPClassUIDs enumSOPClassUIDs;
	
	public NActionImagePrintMangMeta_QueryModel(EnumSOPClassUIDs enumSOPClassUIDs)
	{
		this.objNActionImagePrintMangMeta_AttributesList = new SingleCollection<NActionImagePrintMangMeta_Attributes>();
		this.enumSOPClassUIDs = enumSOPClassUIDs;
	}
	/**
	 * Retrieve EnumSOPClassUIDs .
	 * @return EnumSOPClassUIDs
	 */
	public EnumSOPClassUIDs getEnumSOPClassUIDs() 
	{
		return enumSOPClassUIDs;
	}
	/**
	 * Retrieve the object of NActionImagePrintMangMeta_AttributesList.
	 * @return ISingleCollection of NActionImagePrintMangMeta_AttributesList
	 */
	public ISingleCollection<NActionImagePrintMangMeta_Attributes> getNActionImagePrintMangMeta_AttributesList() 
	{
		return objNActionImagePrintMangMeta_AttributesList;
	}
	/**
	 * Set the value of NActionImagePrintMangMeta_Attributes.
	 * @param objGPWLAttributesList - object of ISingleCollection
	 */
	public void setNActionImagePrintMangMeta_AttributesList(ISingleCollection<NActionImagePrintMangMeta_Attributes> objGPWLAttributesList) 
	{
		objNActionImagePrintMangMeta_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.objNActionImagePrintMangMeta_AttributesList == null)
			this.objNActionImagePrintMangMeta_AttributesList = new SingleCollection<NActionImagePrintMangMeta_Attributes>();
		
		NActionImagePrintMangMeta_Attributes objStudyAttributes = new NActionImagePrintMangMeta_Attributes(this.enumSOPClassUIDs);
		
		objStudyAttributes.populate(objIDataSet);
		
		objNActionImagePrintMangMeta_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(objNActionImagePrintMangMeta_AttributesList != null)
		{
			ICollectionIterator<NActionImagePrintMangMeta_Attributes> objNActionImagePrintMangMeta_AttributesIterator = objNActionImagePrintMangMeta_AttributesList.iterator();
			while(objNActionImagePrintMangMeta_AttributesIterator.hasNext())
			{
				NActionImagePrintMangMeta_Attributes objStudyAttributes = objNActionImagePrintMangMeta_AttributesIterator.next();
				if(objStudyAttributes != null)
				{
					IDataSet objIDataSet = new DataSet(objITransferSyntax);
					objStudyAttributes.fill(objIDataSet);
					objDataSetList.add(objIDataSet);
				}
			}
			return true;
		}
		else
			return false;
	}
}
