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

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.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 Implant Template. This class contains methods to encode and decode Query Model.
 */
public class ImplantTemplate_QueryModel implements IQueryModel
{
	ISingleCollection<ImplantTemplate_Attributes> objImplantTemplate_Attributes = null;
	
	/**
	 * Default Constructor for ImplantTemplate_QueryModel class.
	 */
	public ImplantTemplate_QueryModel()
	{
		this.objImplantTemplate_Attributes = new SingleCollection<ImplantTemplate_Attributes>();
	}
	/**
	 * Retrieves the Attributes List of Implant Template
	 * @return Implant Template Attributes List
	 */
	public ISingleCollection<ImplantTemplate_Attributes> getImplantTemplate_AttributesList() 
	{
		return objImplantTemplate_Attributes;
	}
	/**
	 * Sets the Attributes List of Implant Template
	 * @param objImplantTemplate_Attributes
	 */
	public void setImplantTemplate_AttributesList(ISingleCollection<ImplantTemplate_Attributes> objImplantTemplate_Attributes) 
	{
		this.objImplantTemplate_Attributes = objImplantTemplate_Attributes;
	}
	
	/**
	 * Populates the query Model using filled data set.
	 * @param objIDataSet Object of IDataSet.
	 * @return True - if Query Model populated successfully else False.
	 */
	public boolean decode(IDataSet objIDataSet)
	{
		if(this.objImplantTemplate_Attributes == null)
			this.objImplantTemplate_Attributes = new SingleCollection<ImplantTemplate_Attributes>();
		
		ImplantTemplate_Attributes objImplantTemplateAttributes = new ImplantTemplate_Attributes();
		
		objImplantTemplateAttributes.populate(objIDataSet);
		
		objImplantTemplate_Attributes.add(objImplantTemplateAttributes);
		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(objImplantTemplate_Attributes != null)
		{
			ICollectionIterator<ImplantTemplate_Attributes> objImplantTemplate_AttributesIterator = objImplantTemplate_Attributes.iterator();
			while(objImplantTemplate_AttributesIterator.hasNext())
			{
				ImplantTemplate_Attributes objImplantTemplateAttributes = objImplantTemplate_AttributesIterator.next();
				if(objImplantTemplateAttributes != null)
				{
					IDataSet objIDataSet = new DataSet(objITransferSyntax);
					objImplantTemplateAttributes.fill(objIDataSet);
					objDataSetList.add(objIDataSet);
				}
			}
			return true;
		}
		else
			return false;
	}
}
