/// <summary>
        /// Get partial codelist from a coded non-measure dimension
        /// </summary>
        /// <param name="codelistRef">
        /// The codelist reference containing the id, agency and version of the requested dimension.
        /// </param>
        /// <returns>
        /// The partial codelist
        /// </returns>
        private CodeListBean GetPartialCodelist(CodelistRefBean codelistRef)
        {
            ComponentInfo component;
            if (!this._componentMapping.TryGetValue(this._requestedComponent, out component))
            {
                return null;
            }

            ICollection<DataSetColumnEntity> dataSetColumns = component.Mapping.Columns;
            var codesSet = new Dictionary<string, object>();
            CodeListBean codelist = null;

            if (dataSetColumns != null && dataSetColumns.Count > 0)
            {
                // mapped against dataset column
                this._logger.LogInformation("|-- Generating SQL WHERE for dissemination database...");
                string sqlWhere = this.GenerateWhere(this._criteria);
                this._logger.LogInformation("|-- WHERE :..." + sqlWhere);
                this._logger.LogInformation("|-- Generating SQL for dissemination database...");
                string sql = this.GenerateSql(component.Mapping, sqlWhere);
                this._logger.LogInformation("|-- SQL for dissemination database generated:\n" + sql);
                this.ExecuteSql(component, codesSet, sql);
                this._logger.LogInformation("|-- Query executed successfully, found : " + codesSet.Count + " codes");
            }
            else
            {
                // constant time mapping
                codesSet.Add(component.Mapping.Constant, null);
            }

            if (codesSet.Count > 0)
            {
                var subset = new List<string>(codesSet.Keys);
                codelist = this.GetCodeList(codelistRef.Id, codelistRef.Version, codelistRef.AgencyID, subset);
            }

            if (codelist != null && codelist.Items.Count == 0)
            {
                string error = string.Format(
                    CultureInfo.CurrentCulture, 
                    ErrorMessages.ZeroCodesFoundFormat3, 
                    this._mappingSet.Id, 
                    this._requestedComponent, 
                    this._mappingSet.Dataflow.Id);
                this._logger.LogWarning(error);
                throw new StructureRetrieverException(StructureRetrieverErrorTypes.MissingStructure, error);
            }

            return codelist;
        }
        /// <summary>
        /// Check if the requested Component is set and if the requested codelist ref is for that component
        /// </summary>
        /// <param name="codelistRef">
        /// The requested codelistRef
        /// </param>
        /// <returns>
        /// The is requested component codelist.
        /// </returns>
        private bool IsRequestedComponentCodelist(CodelistRefBean codelistRef)
        {
            if (this._requestedComponent == null)
            {
                return false;
            }

            if (this._requestedComponent.Equals(this._timeDimension)
                && (string.IsNullOrEmpty(codelistRef.Id) || CustomCodelistConstants.IsTimeDimensionRequest(codelistRef)))
            {
                return true;
            }

            if (this._measureComponent != null && this._measureComponent.Equals(this._requestedComponent))
            {
                return true;
            }

            ComponentInfo info;
            if (this._componentMapping.TryGetValue(this._requestedComponent, out info))
            {
                CodelistRefBean c = info.CodelistRef;
                return string.Equals(c.Id, codelistRef.Id) && string.Equals(c.AgencyID, codelistRef.AgencyID);
            }

            return false;
        }
        /// <summary>
        /// Retrieve the codelist that is referenced by the given codelistRef. The codelist
        /// </summary>
        /// <param name="codelistRef">
        /// The codelist reference containing the id, agency and version of the requested dimension. Can be empty for time dimension
        /// </param>
        /// <returns>
        /// The partial codelist
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// codelist is null
        /// </exception>
        public CodeListBean RetrieveAvailableData(CodelistRefBean codelistRef)
        {
            if (codelistRef == null)
            {
                throw new ArgumentNullException("codelistRef");
            }

            if (this._mappingSet == null)
            {
                return null;
            }

            if (!this.IsRequestedComponentCodelist(codelistRef))
            {
                if (CustomCodelistConstants.IsCountRequest(codelistRef))
                {
                    // COUNT data request
                    return this.GetCountCodelist(); // get the count special codelist
                }

                return null;
            }

            if (this._requestedComponent.Equals(this._measureComponent))
            {
                // measure dimension codelist request if measure dimension is not mapped
                return this.GetCodeList(codelistRef.Id, codelistRef.Version, codelistRef.AgencyID);

                // get the entire codelist for measure dimension
            }

            if (this._requestedComponent.Equals(this._timeDimension))
            {
                // time dimension codelist request
                return this.GetTimeDimensionStartEnd();

                // get the time dimension special codelist with start and possibly end codes.
            }

            return this.GetPartialCodelist(codelistRef); // partial code list request for mapped coded components
        }