Esempio n. 1
0
        /// <summary>
        /// Get the latest allowed dataflow with version and agency (if are either defined)
        /// </summary>
        /// <param name="dataflowId">
        /// The dataflow id
        /// </param>
        /// <returns>
        /// The allowed dataflow with biggest version
        /// </returns>
        public IMaintainableRefObject GetAllowedDataflow(string dataflowId)
        {
            IMaintainableRefObject actualDataflow = null;

            Match conventionUsed = _dataflowRegex.Match(dataflowId);

            if (conventionUsed.Success)
            {
                actualDataflow = new MaintainableRefObjectImpl
                {
                    AgencyId       = conventionUsed.Groups["agency"].Value,
                    MaintainableId = conventionUsed.Groups["id"].Value,
                    Version        = conventionUsed.Groups["version"].Value
                };
                if (!this._authorizationProvider.AccessControl(this._user, actualDataflow))
                {
                    actualDataflow = null;
                }
            }
            else
            {
                IEnumerable <IMaintainableRefObject> dataflowRefBeans = this._authorizationProvider.GetDataflows(
                    this._user, dataflowId);
                foreach (IMaintainableRefObject dataflowRefBean in dataflowRefBeans)
                {
                    if (actualDataflow == null ||
                        string.CompareOrdinal(actualDataflow.Version, dataflowRefBean.Version) < 0)
                    {
                        actualDataflow = dataflowRefBean;
                    }
                }
            }

            return(actualDataflow);
        }
        /// <summary>
        /// Gets a maintainable defined by the StructureQueryObject parameter.
        ///     <p/>
        ///     Expects only ONE maintainable to be returned from this query
        /// </summary>
        /// <param name="sRref">
        /// The query.
        /// </param>
        /// <param name="returnStub">
        /// If true then a stub object will be returned
        /// </param>
        /// <returns>
        /// The <see cref="IMaintainableObject"/> .
        /// </returns>
        /// <exception cref="NotImplementedException">
        /// Not implemented.
        /// </exception>
        public IMaintainableObject GetMaintainable(IStructureReference sRref, bool returnStub)
        {
            IMaintainableRefObject xref = sRref.MaintainableReference;

            switch (sRref.MaintainableStructureEnumType.EnumType)
            {
            case SdmxStructureEnumType.ContentConstraint:
                return(this.GetContentConstraint(xref));

            case SdmxStructureEnumType.Categorisation:
                return(this.GetCategorisation(xref));

            case SdmxStructureEnumType.CategoryScheme:
                return(this.GetCategoryScheme(xref));

            case SdmxStructureEnumType.CodeList:
                return(this.GetCodelist(xref));

            case SdmxStructureEnumType.ConceptScheme:
                return(this.GetConceptScheme(xref));

            case SdmxStructureEnumType.Dataflow:
                return(this.GetDataflow(xref));

            case SdmxStructureEnumType.HierarchicalCodelist:
                return(this.GetHierarchicCodeList(xref));

            case SdmxStructureEnumType.Dsd:
                return(this.GetDataStructure(xref));

            default:
                throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.GetMaintainableFromSdmxObject, new Exception(sRref.MaintainableStructureEnumType.EnumType.ToString()));
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Returns the artefacts of <typeparamref name="T"/> that match <paramref name="xref"/>
        /// </summary>
        /// <param name="xref">
        /// The maintainable reference. ID, Agency and/or Version can have a value or null. Null is considered a wildcard.
        /// </param>
        /// <param name="returnLatest">
        /// The return Latest.
        /// </param>
        /// <param name="returnStub">
        /// The return Stub.
        /// </param>
        /// <param name="sdmxStructure">
        /// The SDMX structure type.
        /// </param>
        /// <param name="getter">
        /// The getter method to retrieve the artefacts if <see cref="_requestToArtefacts"/> doesn't not contain them.
        /// </param>
        /// <typeparam name="T">
        /// The type of the returned artefacts.
        /// </typeparam>
        /// <returns>
        /// The <see cref="ISet{T}"/>.
        /// </returns>
        private ISet <T> GetArtefacts <T>(IMaintainableRefObject xref, bool returnLatest, bool returnStub, SdmxStructureEnumType sdmxStructure, Func <IMaintainableRefObject, bool, bool, ISet <T> > getter)
            where T : class, IMaintainableMutableObject
        {
            ISet <IMaintainableMutableObject> mutableObjects;
            ISet <T>            retrievedObjects;
            IStructureReference structureReference = new StructureReferenceImpl(xref, sdmxStructure);

            if (!this._requestToArtefacts.TryGetValue(structureReference, out mutableObjects))
            {
                _log.DebugFormat(CultureInfo.InvariantCulture, "Cache miss: {0}", structureReference);
                retrievedObjects = getter(xref, returnLatest, returnStub);
                this._requestToArtefacts.Add(structureReference, new HashSet <IMaintainableMutableObject>(retrievedObjects));
                foreach (T retrievedObject in retrievedObjects)
                {
                    var reference = _fromMutable.Build(retrievedObject);
                    this._requestToArtefacts.AddToSet(reference, retrievedObject);
                }
            }
            else
            {
                retrievedObjects = new HashSet <T>(mutableObjects.Cast <T>());
            }

            return(retrievedObjects);
        }
Esempio n. 4
0
        /// <summary>
        /// Generate version parameters.
        /// </summary>
        /// <param name="maintainableRefObject">
        /// The maintainable ref object.
        /// </param>
        /// <param name="database">
        /// The database.
        /// </param>
        /// <param name="parameters">
        /// The parameters.
        /// </param>
        /// <param name="versionFieldPrefix">
        /// The version field prefix.
        /// </param>
        /// <param name="parameterNameBuilder">
        /// The parameter name builder.
        /// </param>
        /// <returns>
        /// The WHERE clause that contains the where statement.
        /// </returns>
        public static string GenerateVersionParameters(this IMaintainableRefObject maintainableRefObject, Database database, IList <DbParameter> parameters, string versionFieldPrefix, Func <string, string> parameterNameBuilder)
        {
            var sql = new StringBuilder();

            if (maintainableRefObject.HasVersion())
            {
                var version = maintainableRefObject.SplitVersion();

                // update this when Mapping Store stored function isEqualVersion changes.
                Debug.Assert(version.Count == 3, "Version particles not 3. Either update this assert or fix the code.");

                if (version.Count > 0)
                {
                    sql.Append("dbo.isEqualVersion(");
                    var parameterNames = new string[version.Count];
                    for (int i = 0; i < version.Count; i++)
                    {
                        var particle  = version[i];
                        var versionNo = (i + 1).ToString(CultureInfo.InvariantCulture);
                        sql.AppendFormat(CultureInfo.InvariantCulture, "{0}{1}, ", versionFieldPrefix, versionNo);
                        var parameterName = parameterNameBuilder(versionNo);
                        parameterNames[i] = database.BuildParameterName(parameterName);
                        parameters.Add(database.CreateInParameter(parameterName, DbType.Int64, particle.ToDbValue()));
                    }

                    sql.Append(string.Join(",", parameterNames));

                    sql.Append(")=1");
                }
            }

            return(sql.ToString());
        }
Esempio n. 5
0
        /// <summary>
        /// Get the latest allowed dataflow with version and agency (if are either defined)
        /// </summary>
        /// <param name="dataflowRef">
        /// The dataflow reference
        /// </param>
        /// <returns>
        /// The allowed dataflow with biggest version
        /// </returns>
        public IMaintainableRefObject GetAllowedDataflow(IMaintainableRefObject dataflowRef)
        {
            if (dataflowRef == null)
            {
                throw new ArgumentNullException("dataflowRef");
            }

            IMaintainableRefObject actualDataflow = null;

            if (dataflowRef.HasAgencyId() && dataflowRef.HasVersion())
            {
                if (this._authorizationProvider.AccessControl(this._user, dataflowRef))
                {
                    actualDataflow = dataflowRef;
                }
            }
            else
            {
                IEnumerable <IMaintainableRefObject> dataflowRefBeans = this._authorizationProvider.GetDataflows(
                    this._user, dataflowRef.MaintainableId);
                foreach (IMaintainableRefObject dataflowRefBean in dataflowRefBeans)
                {
                    // TODO fix version comparison
                    if (actualDataflow == null ||
                        string.CompareOrdinal(actualDataflow.Version, dataflowRefBean.Version) < 0)
                    {
                        actualDataflow = dataflowRefBean;
                    }
                }
            }

            return(actualDataflow);
        }
Esempio n. 6
0
        /// <summary>
        /// Retrieve the <see cref="IHierarchicalCodelistMutableObject"/> with the latest version group by ID and AGENCY from Mapping Store.
        /// </summary>
        /// <param name="maintainableRef">
        ///     The maintainable reference which may contain ID, AGENCY ID and/or VERSION.
        /// </param>
        /// <param name="detail">
        ///     The <see cref="StructureQueryDetail"/> which controls if the output will include details or not.
        /// </param>
        /// <returns>
        /// The <see cref="IHierarchicalCodelistMutableObject"/>.
        /// </returns>
        public override IHierarchicalCodelistMutableObject RetrieveLatest(IMaintainableRefObject maintainableRef, ComplexStructureQueryDetailEnumType detail)
        {
            SqlQueryInfo queryInfo = this.SqlQueryInfoForLatest;
            ISet <IHierarchicalCodelistMutableObject> mutableObjects = this.HierarchicalCodelistMutableObjects(maintainableRef, detail, queryInfo);

            return(mutableObjects.GetOneOrNothing());
        }
Esempio n. 7
0
        /// <summary>
        /// Split version of the specified <paramref name="maintainableRefObject"/>.
        /// </summary>
        /// <param name="maintainableRefObject">
        /// The maintainable reference object.
        /// </param>
        /// <param name="size">
        /// The number of tokens to return.
        /// </param>
        /// <returns>
        /// The list of version tokens
        /// </returns>
        public static IList <long?> SplitVersion(this IMaintainableRefObject maintainableRefObject, int size)
        {
            var version = new long? [size];

            if (maintainableRefObject.HasVersion())
            {
                for (int i = 0; i < version.Length; i++)
                {
                    version[i] = null;
                }

                var versionArray = maintainableRefObject.Version.Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries);
                int len          = Math.Min(versionArray.Length, version.Length);
                for (int i = 0; i < len; i++)
                {
                    int value;
                    if (int.TryParse(versionArray[i], out value))
                    {
                        version[i] = value;
                    }
                }
            }
            else
            {
                for (int i = 0; i < version.Length; i++)
                {
                    version[i] = null;
                }
            }

            return(version);
        }
Esempio n. 8
0
        /// <summary>
        /// Retrieve the <see cref="IMaintainableMutableObject"/> from Mapping Store.
        /// </summary>
        /// <param name="maintainableRef">
        /// The maintainable reference which may contain ID, AGENCY ID and/or VERSION.
        /// </param>
        /// <param name="detail">
        /// The <see cref="StructureQueryDetail"/> which controls if the output will include details or not.
        /// </param>
        /// <param name="versionConstraints">
        /// The version types.
        /// </param>
        /// <returns>
        /// The <see cref="ISet{IMaintainableMutableObject}"/>.
        /// </returns>
        public override ISet <TMaintaible> Retrieve(IMaintainableRefObject maintainableRef, ComplexStructureQueryDetailEnumType detail, VersionQueryType versionConstraints)
        {
            var sqlInfo  = versionConstraints == VersionQueryType.Latest ? this.SqlQueryInfoForLatest : this.SqlQueryInfoForAll;
            var sqlQuery = new ArtefactSqlQuery(sqlInfo, maintainableRef);

            return(this.RetrieveItemScheme(detail, sqlQuery));
        }
Esempio n. 9
0
        /// <summary>
        /// Create the WHERE clause from the <paramref name="maintainableRef"/>  and write it to <paramref name="sqlCommand"/>
        /// </summary>
        /// <param name="maintainableRef">
        ///     The maintainable Ref.
        /// </param>
        /// <param name="sqlCommand">
        ///     The output string buffer
        /// </param>
        /// <param name="whereState">the current state of the WHERE clause in <paramref name="sqlCommand"/></param>
        /// <returns>
        /// The list of <see cref="DbParameter"/>
        /// </returns>
        protected virtual IList <DbParameter> CreateArtefactWhereClause(IMaintainableRefObject maintainableRef, StringBuilder sqlCommand, WhereState whereState)
        {
            var parameters = new List <DbParameter>();

            if (maintainableRef == null)
            {
                return(parameters);
            }

            if (maintainableRef.HasMaintainableId())
            {
                SqlHelper.AddWhereClause(sqlCommand, whereState, " A.ID = {0} ", this._mappingStoreDb.BuildParameterName(ParameterNameConstants.IdParameter));
                whereState = WhereState.And;
                parameters.Add(this._mappingStoreDb.CreateInParameter(ParameterNameConstants.IdParameter, DbType.AnsiString, maintainableRef.MaintainableId));
            }

            if (maintainableRef.HasVersion())
            {
                var versionParameters = maintainableRef.GenerateVersionParameters(this._mappingStoreDb, parameters, "A.VERSION", versionNumber => string.Format("{0}{1}", ParameterNameConstants.VersionParameter, versionNumber));
                SqlHelper.AddWhereClause(sqlCommand, whereState, versionParameters);
            }

            if (maintainableRef.HasAgencyId())
            {
                SqlHelper.AddWhereClause(sqlCommand, whereState, " A.AGENCY = {0} ", this._mappingStoreDb.BuildParameterName(ParameterNameConstants.AgencyParameter));
                parameters.Add(this._mappingStoreDb.CreateInParameter(ParameterNameConstants.AgencyParameter, DbType.AnsiString, maintainableRef.AgencyId));
            }

            return(parameters);
        }
Esempio n. 10
0
        /// <summary>
        /// Retrieve the <see cref="ICategorisationMutableObject"/> with the latest version group by ID and AGENCY from Mapping Store.
        /// </summary>
        /// <param name="maintainableRef">
        /// The maintainable reference which may contain ID, AGENCY ID and/or VERSION.
        /// </param>
        /// <param name="detail">
        /// The <see cref="StructureQueryDetail"/> which controls if the output will include details or not.
        /// </param>
        /// <param name="allowedDataflows">
        /// The allowed Dataflows.
        /// </param>
        /// <returns>
        /// The <see cref="ISet{ICategorisationMutableObject}"/>.
        /// </returns>
        public override ICategorisationMutableObject RetrieveLatest(IMaintainableRefObject maintainableRef, ComplexStructureQueryDetailEnumType detail, IList <IMaintainableRefObject> allowedDataflows)
        {
            ISet <ICategorisationMutableObject> mutableObjects = this.Retrieve(maintainableRef, detail, VersionQueryType.Latest, allowedDataflows);

            ////return mutableObjects.GetOneOrNothing();
            //// HACK This needs to be fixed after including proper categorisation support
            return(mutableObjects.FirstOrDefault());
        }
Esempio n. 11
0
        /// <summary>
        /// Split version of the specified <paramref name="maintainableRefObject"/>.
        /// </summary>
        /// <param name="maintainableRefObject">
        /// The maintainable reference object.
        /// </param>
        /// <returns>
        /// The list of version tokens
        /// </returns>
        public static IList <long?> SplitVersion(this IMaintainableRefObject maintainableRefObject)
        {
            var version = SplitVersion(maintainableRefObject, 3);

            version[0] = version[0] ?? 0;
            version[1] = version[1] ?? 0;
            return(version);
        }
Esempio n. 12
0
        /// <summary>
        /// Returns an error message with the specified <paramref name="format"/> for <paramref name="reference"/>
        /// </summary>
        /// <param name="format">
        /// The format.
        /// </param>
        /// <param name="reference">
        /// The component.
        /// </param>
        /// <returns>
        /// The error message.
        /// </returns>
        private static string GetError(string format, IStructureReference reference)
        {
            IMaintainableRefObject maintainableRefObject = reference.MaintainableReference;

            return(reference.HasChildReference()
                       ? string.Format(format, maintainableRefObject.MaintainableId, maintainableRefObject.AgencyId, maintainableRefObject.Version, reference.ChildReference.Id)
                       : string.Format(format, maintainableRefObject.MaintainableId, maintainableRefObject.AgencyId, maintainableRefObject.Version));
        }
Esempio n. 13
0
        /// <summary>
        /// Retrieve the <see cref="IDataflowMutableObject"/> from Mapping Store.
        /// </summary>
        /// <param name="maintainableRef">
        ///     The maintainable reference which may contain ID, AGENCY ID and/or VERSION.
        /// </param>
        /// <param name="detail">
        ///     The <see cref="StructureQueryDetail"/> which controls if the output will include details or not.
        /// </param>
        /// <param name="versionConstraints">
        /// The version query type
        /// </param>
        /// <param name="allowedDataflows">
        ///     The allowed Dataflows.
        /// </param>
        /// <returns>
        /// The <see cref="ISet{IDataflowMutableObject}"/>.
        /// </returns>
        public override ISet <IDataflowMutableObject> Retrieve(IMaintainableRefObject maintainableRef, ComplexStructureQueryDetailEnumType detail, VersionQueryType versionConstraints, IList <IMaintainableRefObject> allowedDataflows)
        {
            var dataflowMutableObjects = new HashSet <IDataflowMutableObject>();
            var sqlQueryInfo           = versionConstraints == VersionQueryType.Latest ? this._sqlQueryInfoLatest : this._sqlQueryInfo;
            var artefactSqlQuery       = new ArtefactSqlQuery(sqlQueryInfo, maintainableRef);

            // do a security check.
            return(!SecurityHelper.Contains(allowedDataflows, maintainableRef) ? dataflowMutableObjects : this.RetrieveArtefacts(artefactSqlQuery, detail, query => this._artefactCommandBuilder.Build(query, allowedDataflows)));
        }
		public virtual IHierarchicalCodelistMutableObjectBase IGetHierarchicCodeListObjectBase(
				IMaintainableRefObject xref) {
			IHierarchicalCodelistObjectBase hclSuperBean = sdmxSuperBeanRetrievalManager
					.IGetHierarchicCodeListObjectBase(xref);
			if (hclSuperBean != null) {
				return new HierarchicalCodelistMutableObjectBaseCore(hclSuperBean);
			}
			return null;
		}
Esempio n. 15
0
 /// <summary>
 /// Gets CategorisationObjects that match the parameters in the ref @object.  If the ref @object is null or
 ///     has no attributes set, then this will be interpreted as a search for all CodelistObjects
 /// </summary>
 /// <param name="xref">
 /// The maintainable reference.
 /// </param>
 /// <param name="returnLatest">
 /// Set to <c>true</c> to return only the latest version.
 /// </param>
 /// <param name="returnStub">
 /// Set to <c>true</c> to return only stubs.
 /// </param>
 /// <param name="allowedDataflows">
 /// The allowed Dataflows. Optional. Set to null to disable checking against allowed dataflows.
 /// </param>
 /// <returns>
 /// list of sdmxObjects that match the search criteria
 /// </returns>
 public override ISet <ICategorisationMutableObject> GetMutableCategorisationObjects(
     IMaintainableRefObject xref,
     bool returnLatest,
     bool returnStub,
     IList <IMaintainableRefObject> allowedDataflows)
 {
     //// TODO Change this when mapping store is modified to host proper categorisation artefacts
     return(this._retrievalEngineContainer.CategorisationRetrievalEngine.Retrieve(xref, returnStub.GetComplexQueryDetail(), returnLatest.GetVersionConstraints(), allowedDataflows));
 }
Esempio n. 16
0
 /// <summary>
 /// Check if there is a dataflow in the list of allowed dataflows which matches the id, version and agencyId of the specified <see cref="IMaintainableRefObject"/>
 /// </summary>
 /// <param name="user">
 /// The <see cref="IUser"/> to check
 /// </param>
 /// <param name="dataflowRef">
 /// The <see cref="IMaintainableRefObject"/> to check
 /// </param>
 /// <returns>
 /// True if there is a dataflow in the list of allowed dataflows which matches the id, version and agencyId of the specified <see cref="IMaintainableRefObject"/>
 /// </returns>
 public bool AccessControl(IUser user, IMaintainableRefObject dataflowRef)
 {
     this.SetUser(user);
     return(this._dataflowSet.ContainsKey(dataflowRef) ||
            this._dataflowSet.Any(
                pair =>
                pair.Key.MaintainableId.Equals(dataflowRef.MaintainableId) && (!pair.Key.HasAgencyId() || pair.Key.AgencyId.Equals(dataflowRef.AgencyId)) &&
                (!pair.Key.HasVersion() || pair.Key.Version.Equals(dataflowRef.Version))));
 }
Esempio n. 17
0
        /// <summary>
        /// Gets a single Categorisation, this expects the ref object either to contain
        ///     a URN or all the attributes required to uniquely identify the object.  If version information
        ///     is missing then the latest version is assumed.
        /// </summary>
        /// <param name="xref">
        /// The maintainable reference.
        /// </param>
        /// <param name="returnLatest">
        /// if set to <c>true</c> [return latest].
        /// </param>
        /// <param name="returnStub">
        /// Set to <c>true</c> to return only stubs.
        /// </param>
        /// <param name="allowedDataflows">
        /// The allowed Dataflows. Optional. Set to null to disable checking against allowed
        ///     dataflows.
        /// </param>
        /// <returns>
        /// The <see cref="T:Org.Sdmxsource.Sdmx.Api.Model.Mutable.CategoryScheme.ICategorisationMutableObject"/> .
        /// </returns>
        public override ICategorisationMutableObject GetMutableCategorisation(IMaintainableRefObject xref, bool returnLatest, bool returnStub, IList <IMaintainableRefObject> allowedDataflows)
        {
            if (xref.HasVersion())
            {
                return(this._retrievalEngineContainer.CategorisationRetrievalEngine.Retrieve(xref, returnStub.GetComplexQueryDetail(), VersionQueryType.All, allowedDataflows).FirstOrDefault());
            }

            //// TODO Change this when mapping store is modified to host proper categorisation artefacts
            return(this._retrievalEngineContainer.CategorisationRetrievalEngine.RetrieveLatest(xref, returnStub.GetComplexQueryDetail(), allowedDataflows));
        }
Esempio n. 18
0
        /// <summary>
        /// Get a list of CodeList matching the given id, version and agencyID and dataflow/component information.
        /// </summary>
        /// <param name="codelistReference">
        /// The codelist reference
        /// </param>
        /// <param name="dataflowReference">
        /// The dataflow reference
        /// </param>
        /// <param name="componentConceptRef">
        /// The component in the dataflow that this codelist is used and for which partial codes are requests.
        /// </param>
        /// <param name="isTranscoded">
        /// if true will get the codes from the transcoding rules. Otherwise from locally stored codes.
        /// </param>
        /// <param name="allowedDataflows">
        /// The allowed dataflows.
        /// </param>
        /// <returns>
        /// The list of matched CodeListBean objects
        /// </returns>
        /// <remarks>
        /// I.e. codes used for the given dataflow.
        ///     It can look codes actually used from transcoding rule or from locally stored codes.
        ///     If any of the Codelist identification parameters is null or empty it will act as wildcard.
        /// </remarks>
        public ISet <ICodelistMutableObject> GetMutableCodelistObjects(
            IMaintainableRefObject codelistReference, IMaintainableRefObject dataflowReference, string componentConceptRef, bool isTranscoded, IList <IMaintainableRefObject> allowedDataflows)
        {
            if (SecurityHelper.Contains(allowedDataflows, dataflowReference))
            {
                return(this._codeListRetrievalEngine.Retrieve(codelistReference, ComplexStructureQueryDetailEnumType.Full, dataflowReference, componentConceptRef, isTranscoded, allowedDataflows));
            }

            return(new HashSet <ICodelistMutableObject>());
        }
Esempio n. 19
0
        /// <summary>
        /// Retrieve the <see cref="IDataflowMutableObject"/> with the latest version group by ID and AGENCY from Mapping Store.
        /// </summary>
        /// <param name="maintainableRef">
        ///     The maintainable reference which may contain ID, AGENCY ID and/or VERSION.
        /// </param>
        /// <param name="detail">
        ///     The <see cref="StructureQueryDetail"/> which controls if the output will include details or not.
        /// </param>
        /// <param name="allowedDataflows">
        ///     The allowed Dataflows.
        /// </param>
        /// <returns>
        /// The <see cref="ISet{IDataflowMutableObject}"/>.
        /// </returns>
        public override IDataflowMutableObject RetrieveLatest(IMaintainableRefObject maintainableRef, ComplexStructureQueryDetailEnumType detail, IList <IMaintainableRefObject> allowedDataflows)
        {
            var dataflowMutableObjects = new HashSet <IDataflowMutableObject>();

            var artefactSqlQuery = new ArtefactSqlQuery(this._sqlQueryInfoLatest, maintainableRef);

            // do a security check.
            var dataflows = !SecurityHelper.Contains(allowedDataflows, maintainableRef) ? dataflowMutableObjects : this.RetrieveArtefacts(artefactSqlQuery, detail, query => this._artefactCommandBuilder.Build(query, allowedDataflows));

            return(dataflows.GetOneOrNothing());
        }
		public virtual ICategorySchemeObjectBase IGetCategorySchemeObjectBase(
				IMaintainableRefObject xref) {
			ISet<ICategorySchemeObjectBase> beans = IGetCategorySchemeObjectsBase(xref);
			if (!Org.Sdmxsource.Util.ObjectUtil.ValidCollection(beans)) {
				throw new ReferenceException(
						Org.Sdmxsource.Sdmx.Api.Constants.ExceptionCode.ReferenceErrorUnresolvable,
						Org.Sdmxsource.Sdmx.Api.Constants.SdmxStructureType.GetFromEnum(SdmxStructureEnumType.CategoryScheme), xref);
			}
            return (ICategorySchemeObjectBase)Org.Sdmxsource.Sdmx.Util.Objects.SuperBeanRefUtil<ICategorySchemeObjectBase>.ResolveReference(
					beans, xref);
		}
		public virtual IRegistrationObject GetRegistration(IMaintainableRefObject xref) {
			ISet<IRegistrationObject> registrations0 = GetRegistrations(xref);
			if (!Org.Sdmxsource.Util.ObjectUtil.ValidCollection(registrations0)) {
				return null;
			}
			if (registrations0.Count > 1) {
				throw new ArgumentException(
						"More then one registration returned for reference (expected only one):"
								+ xref);
			}
			return (IRegistrationObject) ILOG.J2CsMapping.Collections.Generics.Collections.ToArray(registrations0)[0];
		}
Esempio n. 22
0
        /// <summary>
        /// Returns the categorisations.
        /// </summary>
        /// <param name="maintainableRef">
        /// The maintainable ref.
        /// </param>
        /// <param name="detail">
        /// The detail.
        /// </param>
        /// <param name="sqlInfo">
        /// The SQL info.
        /// </param>
        /// <param name="allowedDataflows">
        /// The allowed dataflows.
        /// </param>
        /// <returns>
        /// The <see cref="ISet{ICategorisationMutableObject}"/>.
        /// </returns>
        private ISet <ICategorisationMutableObject> GetCategorisations(
            IMaintainableRefObject maintainableRef, ComplexStructureQueryDetailEnumType detail, SqlQueryInfo sqlInfo, IList <IMaintainableRefObject> allowedDataflows)
        {
            var artefactSqlQuery = new ArtefactSqlQuery(sqlInfo, maintainableRef);

            var dataflowCache = new Dictionary <long, IStructureReference>();
            var categoryCache = new Dictionary <long, IStructureReference>();

            this.RetrieveArtefactReference(dataflowCache, allowedDataflows);
            this.RetrieveCategoryReference(categoryCache);

            return(this.RetrieveArtefacts(artefactSqlQuery, detail, null, (o, l) => RetrieveReferences(o, l, l1 => GetReference(l1, dataflowCache), l1 => GetReference(l1, categoryCache))));
        }
Esempio n. 23
0
        /// <summary>
        /// Try to authorize using the dataflow from <see cref="IDataflowObject"/>.
        ///     It uses and checks the <see cref="_principal"/> if there is an authorized user.
        /// </summary>
        /// <param name="dataflow">
        /// The dataflow.
        /// </param>
        /// <exception cref="SdmxUnauthorisedException">
        /// Not authorized
        /// </exception>
        protected void Authorize(IDataflowObject dataflow)
        {
            if (this._principal != null)
            {
                IMaintainableRefObject dataflowRefBean = this._principal.GetAllowedDataflow(dataflow);

                if (dataflowRefBean == null)
                {
                    string errorMessage = string.Format(CultureInfo.CurrentCulture, Resources.NoMappingForDataflowFormat1, dataflow.Id);
                    throw new SdmxUnauthorisedException(errorMessage);
                }
            }
        }
Esempio n. 24
0
        /// <summary>
        /// Retrieve the <see cref="IDataStructureMutableObject"/> from Mapping Store.
        /// </summary>
        /// <param name="maintainableRef">
        /// The maintainable reference which may contain ID, AGENCY ID and/or VERSION.
        /// </param>
        /// <param name="detail">
        /// The <see cref="StructureQueryDetail"/> which controls if the output will include details or not.
        /// </param>
        /// <param name="versionConstraints">
        /// The version query type.
        /// </param>
        /// <param name="allowedDataflows">
        /// The allowed Dataflows.
        /// </param>
        /// <returns>
        /// The <see cref="ISet{IDataStructureMutableObject}"/>.
        /// </returns>
        public override ISet <ICategorisationMutableObject> Retrieve(
            IMaintainableRefObject maintainableRef,
            ComplexStructureQueryDetailEnumType detail,
            VersionQueryType versionConstraints,
            IList <IMaintainableRefObject> allowedDataflows)
        {
            var sqlInfo         = versionConstraints == VersionQueryType.Latest ? this.SqlQueryInfoForLatest : this.SqlQueryInfoForAll;
            var categorisations = this.GetCategorisations(maintainableRef, ComplexStructureQueryDetailEnumType.Full, sqlInfo, allowedDataflows);

            NormalizeDetailLevel(detail, categorisations);

            return(categorisations);
        }
Esempio n. 25
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="maintainableRef"></param>
        /// <param name="detail"></param>
        /// <returns></returns>
        public override IContentConstraintMutableObject RetrieveLatest(IMaintainableRefObject maintainableRef, ComplexStructureQueryDetailEnumType detail)
        {
            ISet <IContentConstraintMutableObject> mutableObjects = this.GetConstraintMutableObjects(maintainableRef, detail, this.SqlQueryInfoForLatest);

            if (mutableObjects.Count > 0)
            {
                foreach (IContentConstraintMutableObject cons in mutableObjects)
                {
                    return(cons);
                }
            }

            return(null);
        }
        /// <summary>
        /// Create the WHERE clause from the <paramref name="maintainableRef"/>  and write it to <paramref name="sqlCommand"/>
        /// </summary>
        /// <param name="maintainableRef">
        /// The maintainable Ref.
        /// </param>
        /// <param name="sqlCommand">
        /// The output string buffer
        /// </param>
        /// <param name="whereState">
        /// the current state of the WHERE clause in <paramref name="sqlCommand"/>
        /// </param>
        /// <param name="allowedDataflows">
        /// The allowed Dataflows.
        /// </param>
        /// <returns>
        /// The list of <see cref="DbParameter"/>
        /// </returns>
        protected override IList<DbParameter> CreateArtefactWhereClause(IMaintainableRefObject maintainableRef, StringBuilder sqlCommand, WhereState whereState, IList<IMaintainableRefObject> allowedDataflows)
        {
            IList<DbParameter> parameters = this.CreateArtefactWhereClause(maintainableRef, sqlCommand, whereState);
            if (parameters.Count > 0)
            {
                whereState = WhereState.And;
            }

            if (this._filter == DataflowFilter.Production)
            {
                SqlHelper.AddWhereClause(sqlCommand, whereState, DataflowConstant.ProductionWhereClause);
                whereState = WhereState.And;
            }

            return SecurityHelper.AddWhereClauses(maintainableRef, this.MappingStoreDB, sqlCommand, parameters, allowedDataflows, whereState);
        }
Esempio n. 27
0
        /// <summary>
        /// Create the WHERE clause from the <paramref name="maintainableRef"/>  and write it to <paramref name="sqlCommand"/>
        /// </summary>
        /// <param name="maintainableRef">
        /// The maintainable Ref.
        /// </param>
        /// <param name="sqlCommand">
        /// The output string buffer
        /// </param>
        /// <param name="whereState">
        /// the current state of the WHERE clause in <paramref name="sqlCommand"/>
        /// </param>
        /// <param name="allowedDataflows">
        /// The allowed Dataflows.
        /// </param>
        /// <returns>
        /// The list of <see cref="DbParameter"/>
        /// </returns>
        protected override IList <DbParameter> CreateArtefactWhereClause(IMaintainableRefObject maintainableRef, StringBuilder sqlCommand, WhereState whereState, IList <IMaintainableRefObject> allowedDataflows)
        {
            IList <DbParameter> parameters = this.CreateArtefactWhereClause(maintainableRef, sqlCommand, whereState);

            if (parameters.Count > 0)
            {
                whereState = WhereState.And;
            }

            if (this._filter == DataflowFilter.Production)
            {
                SqlHelper.AddWhereClause(sqlCommand, whereState, DataflowConstant.ProductionWhereClause);
                whereState = WhereState.And;
            }

            return(SecurityHelper.AddWhereClauses(maintainableRef, this.MappingStoreDB, sqlCommand, parameters, allowedDataflows, whereState));
        }
Esempio n. 28
0
        /// <summary>
        /// Retrieve the <see cref="IMaintainableMutableObject"/> with the latest version group by ID and AGENCY from Mapping Store.
        /// </summary>
        /// <param name="maintainableRef">
        /// The maintainable reference which may contain ID, AGENCY ID and/or VERSION.
        /// </param>
        /// <param name="detail">
        /// The <see cref="StructureQueryDetail"/> which controls if the output will include details or not.
        /// </param>
        /// <returns>
        /// The <see cref="ISet{IMaintainableMutableObject}"/>.
        /// </returns>
        public override TMaintaible RetrieveLatest(IMaintainableRefObject maintainableRef, ComplexStructureQueryDetailEnumType detail)
        {
            var sqlQuery       = new ArtefactSqlQuery(this.SqlQueryInfoForLatest, maintainableRef);
            var mutableObjects = this.RetrieveItemScheme(detail, sqlQuery);

            switch (mutableObjects.Count)
            {
            case 0:
                return(default(TMaintaible));

            case 1:
                return(mutableObjects.First());

            default:
                throw new ArgumentException(ErrorMessages.MoreThanOneArtefact, "maintainableRef");
            }
        }
Esempio n. 29
0
        /// <summary>
        /// Get the latest allowed dataflow with version and agency (if are either defined)
        /// </summary>
        /// <param name="dataflow">
        /// The dataflow object
        /// </param>
        /// <returns>
        /// The allowed dataflow with biggest version
        /// </returns>
        public IMaintainableRefObject GetAllowedDataflow(IDataflowObject dataflow)
        {
            if (dataflow == null)
            {
                throw new ArgumentNullException("dataflow");
            }

            IMaintainableRefObject actualDataflow = null;

            var dataflowRef = dataflow.AsReference.MaintainableReference;

            if (this._authorizationProvider.AccessControl(this._user, dataflowRef))
            {
                actualDataflow = dataflowRef;
            }

            return(actualDataflow);
        }
Esempio n. 30
0
        /// <summary>
        /// Retrieve the <see cref="ICodelistMutableObject"/> from Mapping Store.
        /// </summary>
        /// <param name="maintainableRef">
        /// The maintainable reference which may contain ID, AGENCY ID and/or VERSION.
        /// </param>
        /// <param name="detail">
        /// The <see cref="StructureQueryDetail"/> which controls if the output will include details or not.
        /// </param>
        /// <param name="subset">
        /// The subset.
        /// </param>
        /// <returns>
        /// The <see cref="ISet{ICodelistMutableObject}"/>.
        /// </returns>
        public ISet <ICodelistMutableObject> Retrieve(IMaintainableRefObject maintainableRef, ComplexStructureQueryDetailEnumType detail, IList <string> subset)
        {
            var sqlQuery = new ArtefactSqlQuery(this.SqlQueryInfoForAll, maintainableRef);
            Func <ICodelistMutableObject, long, ICodelistMutableObject> hashMethod    = (itemSchemeBean, parentSysId) => this.FillCodesHash(itemSchemeBean, parentSysId, subset);
            Func <ICodelistMutableObject, long, ICodelistMutableObject> whereInMethod = (itemSchemeBean, parentSysId) => this.FillCodes(itemSchemeBean, parentSysId, subset);
            Func <ICodelistMutableObject, long, ICodelistMutableObject> selected      = whereInMethod;

            switch (this.MappingStoreDb.ProviderName)
            {
            case MappingStoreDefaultConstants.SqlServerProvider:

                // SQL server performs very bad with 'IN'
                selected = hashMethod;

                break;

            case MappingStoreDefaultConstants.MySqlProvider:
                if (subset.Count > 2000)
                {
                    selected = hashMethod;
                }

                break;

            case MappingStoreDefaultConstants.OracleProvider:
            case MappingStoreDefaultConstants.OracleProviderOdp:
                if (subset.Count > 4000)
                {
                    selected = hashMethod;
                }

                break;

            default:
                if (subset.Count > 1000)
                {
                    selected = hashMethod;
                }

                break;
            }

            return(this.RetrieveArtefacts(sqlQuery, detail, retrieveDetails: selected));
        }
Esempio n. 31
0
        /// <summary>
        /// Return the latest artefact of type <typeparamref name="T" /> that matches the <paramref name="xref" />.
        /// </summary>
        /// <typeparam name="T">The type of the requested artefact</typeparam>
        /// <param name="xref">The maintainable reference. The version must be null.</param>
        /// <param name="returnLatest">if set to <c>true</c> [return latest].</param>
        /// <param name="returnStub">The return Stub.</param>
        /// <param name="sdmxStructure">The SDMX structure type.</param>
        /// <param name="getter">The getter method to retrieve the artefact if <see cref="_requestToLatestArtefacts" /> doesn't not contain it.</param>
        /// <returns>
        /// The <see cref="IMaintainableMutableObject" /> of type <typeparamref name="T" />; otherwise null
        /// </returns>
        private T GetLatest <T>(IMaintainableRefObject xref, bool returnLatest, bool returnStub, SdmxStructureEnumType sdmxStructure, Func <IMaintainableRefObject, bool, bool, T> getter)
            where T : class, IMaintainableMutableObject
        {
            IMaintainableMutableObject mutableObject;
            IStructureReference        structureReference = new StructureReferenceImpl(xref, sdmxStructure);

            if (!this._requestToLatestArtefacts.TryGetValue(structureReference, out mutableObject))
            {
                _log.DebugFormat(CultureInfo.InvariantCulture, "Cache miss: {0}", structureReference);
                T retrievedObject = getter(xref, returnLatest, returnStub);
                if (retrievedObject != null)
                {
                    this._requestToLatestArtefacts.Add(structureReference, retrievedObject);
                    this._requestToArtefacts.AddToSet(_fromMutable.Build(retrievedObject), retrievedObject);
                    return(retrievedObject);
                }

                return(null);
            }

            return(mutableObject as T);
        }
		public virtual IHierarchicalCodelistMutableObject GetMutableHierarchicCodeList(
				IMaintainableRefObject xref) {
			IHierarchicalCodelistObject bean = this.SdmxObjectRetrievalManager
					.GetHierarchicCodeList(xref);
			return (bean == null) ? null : new HierarchicalCodelistMutableCore(
					bean);
		}
		public virtual ISet<IConceptSchemeMutableObject> GetMutableConceptSchemeBeans(
				IMaintainableRefObject xref) {
			ISet<IConceptSchemeObject> beans = this.SdmxObjectRetrievalManager
					.GetConceptSchemeBeans(xref);
			ISet<IConceptSchemeMutableObject> returnSet = new HashSet<IConceptSchemeMutableObject>();
			/* foreach */
			foreach (IConceptSchemeObject bean  in  beans) {
				returnSet.Add(new ConceptSchemeMutableCore(bean));
			}
			return returnSet;
		}
		public virtual ISet<IMetadataStructureDefinitionMutbale> GetMutableMetadataStructureBeans(
				IMaintainableRefObject xref) {
			ISet<IMetadataStructureDefinitionObject> beans = this.SdmxObjectRetrievalManager
					.GetMetadataStructureBeans(xref);
			ISet<IMetadataStructureDefinitionMutbale> returnSet = new HashSet<IMetadataStructureDefinitionMutbale>();
			/* foreach */
			foreach (IMetadataStructureDefinitionObject bean  in  beans) {
				returnSet.Add(new MetadataStructureDefinitionMutableCore(bean));
			}
			return returnSet;
		}
		public ISet<IContentConstraintMutableObject> GetMutableContentConstraintBeans(
				IMaintainableRefObject xref) {
			ISet<IContentConstraintObject> beans = this.SdmxObjectRetrievalManager
					.GetContentConstraints(xref);
			ISet<IContentConstraintMutableObject> returnSet = new HashSet<IContentConstraintMutableObject>();
			/* foreach */
			foreach (IContentConstraintObject bean  in  beans) {
				returnSet.Add(new ContentConstraintMutableCore(bean));
			}
			return returnSet;
		}
		public IProvisionAgreementMutableObject GetMutableProvisionAgreement(
				IMaintainableRefObject xref) {
			IProvisionAgreementObject bean = this.SdmxObjectRetrievalManager
					.GetProvisionAgreementBean(xref);
			return (bean == null) ? null
					: new ProvisionAgreementMutableCore(bean);
		}
 /// <summary>
 /// An empty Set will be returned if there are no matches to the query
 /// </summary>
 /// <param name="maintainableReference">
 /// Contains the identifiers of the structures to returns, can include widcarded values (null indicates a wildcard).
 /// </param>
 /// <returns>
 /// The set of <see cref="IMaintainableObject"/> .
 /// </returns>
 public ISet <T> GetMaintainableObjects <T>(IMaintainableRefObject maintainableReference) where T : IMaintainableObject
 {
     return(GetMaintainableObjects <T>(maintainableReference, false, false));
 }
        /// <summary>
        ///     An empty Set will be returned if there are no matches to the query
        /// </summary>
        /// <param name="maintainableReference">
        /// Contains the identifiers of the structures to returns, can include widcarded values (null indicates a wildcard).
        /// </param>
        /// <param name="returnStub">
        /// If true then a stub object will be returned
        /// </param>
        /// /// <param name="returnLatest">
        /// If true then the latest version is returned, regardless of whether version information is supplied
        /// </param>
        /// <returns>
        /// The set of <see cref="IMaintainableObject"/> .
        /// </returns>
        public ISet <T> GetMaintainableObjects <T>(IMaintainableRefObject maintainableReference, bool returnStub, bool returnLatest) where T : IMaintainableObject
        {
            ISet <T> returnSet;

            if (returnLatest)
            {
                maintainableReference = new MaintainableRefObjectImpl(maintainableReference.AgencyId, maintainableReference.MaintainableId, null);
            }

            SdmxStructureType   type = SdmxStructureType.ParseClass(typeof(T));
            IStructureReference sRef = new StructureReferenceImpl(maintainableReference, type);

            switch (sRef.TargetReference.EnumType)
            {
            //case SdmxStructureEnumType.AgencyScheme:
            //    returnSet = new HashSet<T>(base.GetAgencySchemeObjects(maintainableReference, returnStub).Cast<T>());
            //    break;
            //case SdmxStructureEnumType.DataConsumerScheme:
            //    returnSet = new HashSet<T>(this.GetDataConsumerSchemeObjects(maintainableReference, returnStub).Cast<T>());
            //    break;
            //case SdmxStructureEnumType.AttachmentConstraint:
            //    returnSet = new HashSet<T>(this.GetAttachmentConstraints(maintainableReference, returnLatest, returnStub).Cast<T>());
            //    break;
            case SdmxStructureEnumType.ContentConstraint:
                returnSet = new HashSet <T>(this.GetContentConstraints(maintainableReference, returnLatest, returnStub).Cast <T>());
                break;

            //case SdmxStructureEnumType.DataProviderScheme:
            //    returnSet = new HashSet<T>(this.GetDataProviderSchemeObjects(maintainableReference, returnStub).Cast<T>());
            //    break;
            case SdmxStructureEnumType.Categorisation:
                returnSet = new HashSet <T>(this.GetCategorisationObjects(maintainableReference, returnStub).Cast <T>());
                break;

            case SdmxStructureEnumType.CategoryScheme:
                returnSet = new HashSet <T>(this.GetCategorySchemeObjects(maintainableReference, returnLatest, returnStub).Cast <T>());
                break;

            case SdmxStructureEnumType.CodeList:
                returnSet = new HashSet <T>(this.GetCodelistObjects(maintainableReference, returnLatest, returnStub).Cast <T>());
                break;

            case SdmxStructureEnumType.ConceptScheme:
                returnSet = new HashSet <T>(this.GetConceptSchemeObjects(maintainableReference, returnLatest, returnStub).Cast <T>());
                break;

            case SdmxStructureEnumType.Dataflow:
                returnSet = new HashSet <T>(this.GetDataflowObjects(maintainableReference, returnLatest, returnStub).Cast <T>());
                break;

            case SdmxStructureEnumType.HierarchicalCodelist:
                returnSet = new HashSet <T>(this.GetHierarchicCodeListObjects(maintainableReference, returnLatest, returnStub).Cast <T>());
                break;

            case SdmxStructureEnumType.Dsd:
                returnSet = new HashSet <T>(this.GetDataStructureObjects(maintainableReference, returnLatest, returnStub).Cast <T>());
                break;

            //case SdmxStructureEnumType.MetadataFlow:
            //    returnSet = new HashSet<T>(this.GetMetadataflowObjects(maintainableReference, returnLatest, returnStub).Cast<T>());
            //    break;
            //case SdmxStructureEnumType.Msd:
            //    returnSet = new HashSet<T>(this.GetMetadataStructureObjects(maintainableReference, returnLatest, returnStub).Cast<T>());
            //    break;
            //case SdmxStructureEnumType.OrganisationUnitScheme:
            //    returnSet = new HashSet<T>(this.GetOrganisationUnitSchemeObjects(maintainableReference, returnLatest, returnStub).Cast<T>());
            //    break;
            //case SdmxStructureEnumType.Process:
            //    returnSet = new HashSet<T>(this.GetProcessObjects(maintainableReference, returnLatest, returnStub).Cast<T>());
            //    break;
            //case SdmxStructureEnumType.ReportingTaxonomy:
            //    returnSet = new HashSet<T>(this.GetReportingTaxonomyObjects(maintainableReference, returnLatest, returnStub).Cast<T>());
            //    break;
            //case SdmxStructureEnumType.StructureSet:
            //    returnSet = new HashSet<T>(this.GetStructureSetObjects(maintainableReference, returnLatest, returnStub).Cast<T>());
            //    break;
            //case SdmxStructureEnumType.ProvisionAgreement:
            //    returnSet = new HashSet<T>(this.GetProvisionAgreementObjects(maintainableReference, returnLatest, returnStub).Cast<T>());
            //    break;
            default:
                throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.RetrivalParsingError, new Exception(sRef.TargetReference.EnumType.ToString()));
            }

            //if (returnStub && _serviceRetrievalManager != null)
            //{
            //    ISet<T> stubSet = new HashSet<T>();
            //    foreach (T returnItm in returnSet)
            //    {
            //        if (returnItm.IsExternalReference.IsTrue)
            //            stubSet.Add(returnItm);
            //        else
            //            stubSet.Add((T)_serviceRetrievalManager.CreateStub(returnItm));
            //    }
            //    returnSet = stubSet;
            //}
            return(returnSet);
        }
        /// <summary>
        /// Get the Codes
        /// </summary>
        /// <param name="itemScheme">
        ///     The parent <see cref="ICodelistMutableObject"/>
        /// </param>
        /// <param name="parentSysId">
        ///     The parent ItemScheme primary key in Mapping Store
        /// </param>
        /// <param name="dataflowRef">
        ///     The dataflow Ref.
        /// </param>
        /// <param name="conceptId">
        ///     The concept Id.
        /// </param>
        /// <param name="isTranscoded">
        ///     Set to true if component is transcoded; otherwise false
        /// </param>
        /// <param name="allowedDataflows">The allowed dataflows.</param>
        /// <returns>
        /// The <see cref="ICodelistMutableObject"/>.
        /// </returns>
        private ICodelistMutableObject FillCodes(ICodelistMutableObject itemScheme, long parentSysId, IMaintainableRefObject dataflowRef, string conceptId, bool isTranscoded, IList<IMaintainableRefObject> allowedDataflows)
        {
            var allItems = new Dictionary<long, ICodeMutableObject>();
            var orderedItems = new List<KeyValuePair<long, ICodeMutableObject>>();
            var childItems = new Dictionary<long, long>();
            var sqlQuery = new PartialCodesSqlQuery(isTranscoded ? CodeListConstant.TranscodedSqlQueryInfo : CodeListConstant.LocalCodeSqlQueryInfo, parentSysId)
                               {
                                   ConceptId = conceptId, 
                                   DataflowReference = dataflowRef
                               };

            using (DbCommand command = this._partialCodesCommandBuilder.Build(sqlQuery, allowedDataflows))
            {
                this.ReadItems(allItems, orderedItems, command, childItems);
            }

            this.FillParentItems(itemScheme, childItems, allItems, orderedItems);

            return itemScheme;
        }
		public virtual ISet<IStructureSetMutableObject> GetMutableStructureSetBeans(
				IMaintainableRefObject xref) {
			ISet<IStructureSetObject> beans = this.SdmxObjectRetrievalManager
					.GetStructureSetBeans(xref);
			ISet<IStructureSetMutableObject> returnSet = new HashSet<IStructureSetMutableObject>();
			/* foreach */
			foreach (IStructureSetObject bean  in  beans) {
				returnSet.Add(new StructureSetMutableCore(bean));
			}
			return returnSet;
		}
		public virtual ISet<IHierarchicalCodelistMutableObject> GetMutableHierarchicCodeListBeans(
				IMaintainableRefObject xref) {
			ISet<IHierarchicalCodelistObject> beans = this.SdmxObjectRetrievalManager
					.GetHierarchicCodeListBeans(xref);
			ISet<IHierarchicalCodelistMutableObject> returnSet = new HashSet<IHierarchicalCodelistMutableObject>();
			/* foreach */
			foreach (IHierarchicalCodelistObject bean  in  beans) {
				returnSet.Add(new HierarchicalCodelistMutableCore(bean));
			}
			return returnSet;
		}
		public virtual ISet<IMetadataFlowMutableObject> GetMutableMetadataflowBeans(
				IMaintainableRefObject xref) {
			ISet<IMetadataFlow> beans = this.SdmxObjectRetrievalManager
					.GetMetadataflowBeans(xref);
			ISet<IMetadataFlowMutableObject> returnSet = new HashSet<IMetadataFlowMutableObject>();
			/* foreach */
			foreach (IMetadataFlow bean  in  beans) {
				returnSet.Add(new MetadataflowMutableCore(bean));
			}
			return returnSet;
		}
		public virtual IDataStructureMutableObject GetMutableDataStructure(
				IMaintainableRefObject xref) {
			IDataStructureObject bean = this.SdmxObjectRetrievalManager.GetDataStructure(xref);
			return (bean == null) ? null : new DataStructureMutableCore(bean);
		}
		public virtual ISet<IOrganisationUnitSchemeMutableObject> GetMutableOrganisationUnitSchemeBeans(
				IMaintainableRefObject xref) {
			ISet<IOrganisationUnitSchemeObject> beans = this.SdmxObjectRetrievalManager
					.GetOrganisationUnitSchemeBeans(xref);
			ISet<IOrganisationUnitSchemeMutableObject> returnSet = new HashSet<IOrganisationUnitSchemeMutableObject>();
			/* foreach */
			foreach (IOrganisationUnitSchemeObject bean  in  beans) {
				returnSet.Add(bean.MutableInstance);
			}
			return returnSet;
		}
		public IContentConstraintMutableObject GetMutableContentConstraintBean(
				IMaintainableRefObject xref) {
			IContentConstraintObject bean = this.SdmxObjectRetrievalManager
					.GetContentConstraint(xref);
			return (bean == null) ? null : new ContentConstraintMutableCore(bean);
		}
		public virtual ISet<IProcessMutableObject> GetMutableProcessBeanBeans(
				IMaintainableRefObject xref) {
			ISet<IProcessObject> beans = this.SdmxObjectRetrievalManager.GetProcessBeans(xref);
			ISet<IProcessMutableObject> returnSet = new HashSet<IProcessMutableObject>();
			/* foreach */
			foreach (IProcessObject bean  in  beans) {
				returnSet.Add(new ProcessMutableCore(bean));
			}
			return returnSet;
		}
		public virtual IMetadataStructureDefinitionMutbale GetMutableMetadataStructure(
				IMaintainableRefObject xref) {
			IMetadataStructureDefinitionObject bean = this.SdmxObjectRetrievalManager
					.GetMetadataStructure(xref);
			return (bean == null) ? null
					: new MetadataStructureDefinitionMutableCore(bean);
		}
		public virtual ISet<IReportingTaxonomyMutableObject> GetMutableReportingTaxonomyBeans(
				IMaintainableRefObject xref) {
			ISet<IReportingTaxonomyObject> beans = this.SdmxObjectRetrievalManager
					.GetReportingTaxonomyBeans(xref);
			ISet<IReportingTaxonomyMutableObject> returnSet = new HashSet<IReportingTaxonomyMutableObject>();
			/* foreach */
			foreach (IReportingTaxonomyObject bean  in  beans) {
				returnSet.Add(new ReportingTaxonomyMutableCore(bean));
			}
			return returnSet;
		}
		public virtual IMetadataFlowMutableObject GetMutableMetadataflow(
				IMaintainableRefObject xref) {
			IMetadataFlow bean = this.SdmxObjectRetrievalManager.GetMetadataflow(xref);
			return (bean == null) ? null : new MetadataflowMutableCore(bean);
		}
 /// <summary>
 /// Retrieve the <see cref="ICodelistMutableObject"/> from Mapping Store.
 /// </summary>
 /// <param name="maintainableRef">
 ///     The maintainable reference which may contain ID, AGENCY ID and/or VERSION.
 /// </param>
 /// <param name="detail">
 ///     The <see cref="StructureQueryDetail"/> which controls if the output will include details or not.
 /// </param>
 /// <param name="dataflowRef">
 ///     The dataflow Ref.
 /// </param>
 /// <param name="conceptId">
 ///     The concept Id.
 /// </param>
 /// <param name="isTranscoded">
 ///     The is Transcoded.
 /// </param>
 /// <param name="allowedDataflows">The allowed dataflows.</param>
 /// <returns>
 /// The <see cref="ISet{ICodelistMutableObject}"/>.
 /// </returns>
 public ISet<ICodelistMutableObject> Retrieve(IMaintainableRefObject maintainableRef, ComplexStructureQueryDetailEnumType detail, IMaintainableRefObject dataflowRef, string conceptId, bool isTranscoded, IList<IMaintainableRefObject> allowedDataflows)
 {
     var sqlQuery = new ArtefactSqlQuery(this.SqlQueryInfoForAll, maintainableRef);
     return this.RetrieveArtefacts(sqlQuery, detail, retrieveDetails: (o, l) => this.FillCodes(o, l, dataflowRef, conceptId, isTranscoded, allowedDataflows));
 }
		public virtual IOrganisationUnitSchemeMutableObject GetMutableOrganisationUnitScheme(
				IMaintainableRefObject xref) {
			IOrganisationUnitSchemeObject bean = this.SdmxObjectRetrievalManager
					.GetOrganisationUnitScheme(xref);
			return (bean == null) ? null : bean.MutableInstance;
		}
		public virtual ISet<IDataProviderSchemeMutableObject> GetMutableDataProviderSchemeBeans(
				IMaintainableRefObject xref) {
			ISet<IDataProviderSchemeMutableObject> returnSet = new HashSet<IDataProviderSchemeMutableObject>();
			/* foreach */
			foreach (IDataProviderScheme currentBean  in  this.SdmxObjectRetrievalManager
					.GetDataProviderSchemeBeans(xref)) {
				returnSet.Add(currentBean.MutableInstance);
			}
			return returnSet;
		}
		public virtual IProcessMutableObject GetMutableProcessBean(IMaintainableRefObject xref) {
			IProcessObject bean = this.SdmxObjectRetrievalManager.GetProcessBean(xref);
			return (bean == null) ? null : new ProcessMutableCore(bean);
		}
		public virtual ICategorisationMutableObject GetMutableCategorisation(
				IMaintainableRefObject xref) {
			ICategorisationObject bean = this.SdmxObjectRetrievalManager
					.GetCategorisation(xref);
			return (bean == null) ? null : new CategorisationMutableCore(bean);
		}
		public virtual IReportingTaxonomyMutableObject GetMutableReportingTaxonomy(
				IMaintainableRefObject xref) {
			IReportingTaxonomyObject bean = this.SdmxObjectRetrievalManager
					.GetReportingTaxonomy(xref);
			return (bean == null) ? null : new ReportingTaxonomyMutableCore(bean);
		}
		public virtual ISet<ICategorisationMutableObject> GetMutableCategorisationBeans(
				IMaintainableRefObject xref) {
			ISet<ICategorisationObject> beans = this.SdmxObjectRetrievalManager
					.GetCategorisationBeans(xref);
			ISet<ICategorisationMutableObject> returnSet = new HashSet<ICategorisationMutableObject>();
			/* foreach */
			foreach (ICategorisationObject csBean  in  beans) {
				returnSet.Add(new CategorisationMutableCore(csBean));
			}
			return returnSet;
		}
		public virtual IStructureSetMutableObject GetMutableStructureSet(
				IMaintainableRefObject xref) {
			IStructureSetObject bean = this.SdmxObjectRetrievalManager.GetStructureSet(xref);
			return (bean == null) ? null : new StructureSetMutableCore(bean);
		}
		public virtual IConceptSchemeMutableObject GetMutableConceptScheme(
				IMaintainableRefObject xref) {
			IConceptSchemeObject bean = this.SdmxObjectRetrievalManager.GetConceptScheme(xref);
			return (bean == null) ? null : new ConceptSchemeMutableCore(bean);
		}
		public virtual IDataProviderSchemeMutableObject GetMutableDataProviderScheme(
				IMaintainableRefObject xref) {
			IDataProviderScheme bean = this.SdmxObjectRetrievalManager
					.GetDataProviderSchemeBean(xref);
			return (bean == null) ? null : bean.MutableInstance;
		}
        /// <summary>
        ///     An empty Set will be returned if there are no matches to the query
        /// </summary>
        /// <param name="xType">
        /// Contains sdmx structure enum type
        /// </param>
        /// <param name="maintainableReference">
        /// Contains the identifiers of the structures to returns, can include widcarded values (null indicates a wildcard).
        /// </param>
        /// <param name="returnStub">
        /// If true then a stub object will be returned
        /// </param>
        /// /// <param name="returnLatest">
        /// If true then the latest version is returned, regardless of whether version information is supplied
        /// </param>
        /// <returns>
        /// The set of <see cref="IMaintainableObject"/> .
        /// </returns>
        private ISet <T> GetMaintainablesOfType <T>(SdmxStructureEnumType xType, IMaintainableRefObject maintainableReference, bool returnStub, bool returnLatest) where T : IMaintainableObject
        {
            ISet <T> returnSet;

            if (returnLatest)
            {
                maintainableReference = new MaintainableRefObjectImpl(maintainableReference.AgencyId, maintainableReference.MaintainableId, null);
            }

            switch (xType)
            {
            case SdmxStructureEnumType.AgencyScheme:
                returnSet = new HashSet <T>(GetMaintainableObjects <IAgencyScheme>(maintainableReference, returnStub, returnLatest).Cast <T>());
                break;

            case SdmxStructureEnumType.DataConsumerScheme:
                returnSet = new HashSet <T>(GetMaintainableObjects <IDataConsumerScheme>(maintainableReference, returnStub, returnLatest).Cast <T>());
                break;

            case SdmxStructureEnumType.AttachmentConstraint:
                returnSet = new HashSet <T>(GetMaintainableObjects <IAttachmentConstraintObject>(maintainableReference, returnStub, returnLatest).Cast <T>());
                break;

            case SdmxStructureEnumType.ContentConstraint:
                returnSet = new HashSet <T>(GetMaintainableObjects <IContentConstraintObject>(maintainableReference, returnStub, returnLatest).Cast <T>());
                break;

            case SdmxStructureEnumType.DataProviderScheme:
                returnSet = new HashSet <T>(GetMaintainableObjects <IDataProviderScheme>(maintainableReference, returnStub, returnLatest).Cast <T>());
                break;

            case SdmxStructureEnumType.Categorisation:
                returnSet = new HashSet <T>(GetMaintainableObjects <ICategorisationObject>(maintainableReference, returnStub, returnLatest).Cast <T>());
                break;

            case SdmxStructureEnumType.CategoryScheme:
                returnSet = new HashSet <T>(GetMaintainableObjects <ICategorySchemeObject>(maintainableReference, returnStub, returnLatest).Cast <T>());
                break;

            case SdmxStructureEnumType.CodeList:
                returnSet = new HashSet <T>(GetMaintainableObjects <ICodelistObject>(maintainableReference, returnStub, returnLatest).Cast <T>());
                break;

            case SdmxStructureEnumType.ConceptScheme:
                returnSet = new HashSet <T>(GetMaintainableObjects <IConceptSchemeObject>(maintainableReference, returnStub, returnLatest).Cast <T>());
                break;

            case SdmxStructureEnumType.Dataflow:
                returnSet = new HashSet <T>(GetMaintainableObjects <IDataflowObject>(maintainableReference, returnStub, returnLatest).Cast <T>());
                break;

            case SdmxStructureEnumType.HierarchicalCodelist:
                returnSet = new HashSet <T>(GetMaintainableObjects <IHierarchicalCodelistObject>(maintainableReference, returnStub, returnLatest).Cast <T>());
                break;

            case SdmxStructureEnumType.Dsd:
                returnSet = new HashSet <T>(GetMaintainableObjects <IDataStructureObject>(maintainableReference, returnStub, returnLatest).Cast <T>());
                break;

            case SdmxStructureEnumType.MetadataFlow:
                returnSet = new HashSet <T>(GetMaintainableObjects <IMetadataFlow>(maintainableReference, returnStub, returnLatest).Cast <T>());
                break;

            case SdmxStructureEnumType.Msd:
                returnSet = new HashSet <T>(GetMaintainableObjects <IMetadataStructureDefinitionObject>(maintainableReference, returnStub, returnLatest).Cast <T>());
                break;

            case SdmxStructureEnumType.OrganisationUnitScheme:
                returnSet = new HashSet <T>(GetMaintainableObjects <IOrganisationUnitSchemeObject>(maintainableReference, returnStub, returnLatest).Cast <T>());
                break;

            case SdmxStructureEnumType.Process:
                returnSet = new HashSet <T>(GetMaintainableObjects <IProcessObject>(maintainableReference, returnStub, returnLatest).Cast <T>());
                break;

            case SdmxStructureEnumType.ReportingTaxonomy:
                returnSet = new HashSet <T>(GetMaintainableObjects <IReportingTaxonomyObject>(maintainableReference, returnStub, returnLatest).Cast <T>());
                break;

            case SdmxStructureEnumType.StructureSet:
                returnSet = new HashSet <T>(GetMaintainableObjects <IStructureSetObject>(maintainableReference, returnStub, returnLatest).Cast <T>());
                break;

            case SdmxStructureEnumType.ProvisionAgreement:
                returnSet = new HashSet <T>(GetMaintainableObjects <IProvisionAgreementObject>(maintainableReference, returnStub, returnLatest).Cast <T>());
                break;

            default:
                throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.GetMaintainableFromSdmxObject, new Exception(xType.ToString()));
            }

            //if (returnStub && _serviceRetrievalManager != null)
            //{
            //    ISet<T> stubSet = new HashSet<T>();
            //    foreach (T returnItm in returnSet)
            //    {
            //        if (returnItm.IsExternalReference.IsTrue)
            //            stubSet.Add(returnItm);
            //        else
            //            stubSet.Add((T)_serviceRetrievalManager.CreateStub(returnItm));
            //    }
            //    returnSet = stubSet;
            //}
            return(returnSet);
        }