/*******************************************************************************
 *  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 NSetImagePrintMangMeta. This class contains methods to encode and decode Query Model.
 */
public class NSetImagePrintMangMeta_QueryModel implements IQueryModel
{
	ISingleCollection<NSetImagePrintMangMeta_Attributes> objNSetImagePrintMangMeta_AttributesList = null;
	private EnumSOPClassUIDs enumSOPClassUIDs;
	
	/**
	 * This is default Constructor for NSetImagePrintMangMeta_QueryModel.
	 */
	public NSetImagePrintMangMeta_QueryModel() {
		super();
	}
	
	/**
	 * Retrieve the EnumSOPClassUIDs.
	 * @return EnumSOPClassUIDs
	 */
	public EnumSOPClassUIDs getEnumSOPClassUIDs()
	{
		return enumSOPClassUIDs;
	}
	/**
	 * Set the value of EnumSOPClassUIDs.
	 * @param enumSOPClassUIDs 
	 */
	public NSetImagePrintMangMeta_QueryModel(EnumSOPClassUIDs enumSOPClassUIDs)
	{
		this.objNSetImagePrintMangMeta_AttributesList = new SingleCollection<NSetImagePrintMangMeta_Attributes>();
		this.enumSOPClassUIDs = enumSOPClassUIDs;
	}
	/**
	 * Retrieve the object of NSetImagePrintMangMeta_Attributes.
	 * @return ISingleCollection of NSetImagePrintMangMeta_Attributes
	 */
	public ISingleCollection<NSetImagePrintMangMeta_Attributes> getNSetImagePrintMangMeta_AttributesList() 
	{
		return objNSetImagePrintMangMeta_AttributesList;
	}

	/**
	 * Set the value of NSetImagePrintMangMeta_Attributes.
	 * @param objNSetImagePrintMangMetaAttributes - ISingleCollection  of NSetImagePrintMangMeta_Attributes
	 */
	public void setNSetImagePrintMangMeta_AttributesList(ISingleCollection<NSetImagePrintMangMeta_Attributes> objNSetImagePrintMangMetaAttributes) 
	{
		objNSetImagePrintMangMeta_AttributesList = objNSetImagePrintMangMetaAttributes;
	}
	
	/**
	 * 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.objNSetImagePrintMangMeta_AttributesList == null)
			this.objNSetImagePrintMangMeta_AttributesList = new SingleCollection<NSetImagePrintMangMeta_Attributes>();
		
		NSetImagePrintMangMeta_Attributes objStudyAttributes = new NSetImagePrintMangMeta_Attributes(this.enumSOPClassUIDs);
		
		objStudyAttributes.populate(objIDataSet);
		
		objNSetImagePrintMangMeta_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(objNSetImagePrintMangMeta_AttributesList != null)
		{
			ICollectionIterator<NSetImagePrintMangMeta_Attributes> objNSetImagePrintMangMeta_AttributesIterator = objNSetImagePrintMangMeta_AttributesList.iterator();
			while(objNSetImagePrintMangMeta_AttributesIterator.hasNext())
			{
				NSetImagePrintMangMeta_Attributes objStudyAttributes = objNSetImagePrintMangMeta_AttributesIterator.next();
				if(objStudyAttributes != null)
				{
					IDataSet objIDataSet = new DataSet(objITransferSyntax);
					objStudyAttributes.fill(objIDataSet);
					objDataSetList.add(objIDataSet);
				}
			}
			return true;
		}
		else
			return false;
	}
}
