/// <summary>
        /// Creates dataflow and categorisations based on the input dataflow
        /// </summary>
        /// <param name="dataflowsType">
        /// - if null will not add anything to the sdmxObjects container
        /// </param>
        /// <param name="beans">
        /// - to add dataflow and categorisations to
        /// </param>
        protected internal void ProcessDataflows(DataflowsType dataflowsType, ISdmxObjects beans)
        {
            var urns = new HashSet<Uri>();
            if (dataflowsType != null && ObjectUtil.ValidCollection(dataflowsType.Dataflow))
            {
                /* foreach */
                foreach (DataflowType currentType in dataflowsType.Dataflow)
                {
                    try
                    {
                        IDataflowObject currentDataflow = new DataflowObjectCore(currentType);
                        this.AddIfNotDuplicateURN(beans, urns, currentDataflow);

                        // CATEGORISATIONS FROM DATAFLOWS
                        if (currentType.CategoryRef != null)
                        {
                            /* foreach */
                            foreach (CategoryRefType cateogryRefType in currentType.CategoryRef)
                            {
                                // use mutable for now until the following issue is fixed. 
                                // http://www.metadatatechnology.com/mantis/view.php?id=1341
                                ICategorisationMutableObject mutable = new CategorisationMutableCore();
                                mutable.AgencyId = currentDataflow.AgencyId;
                                mutable.CategoryReference = RefUtil.CreateCategoryRef(cateogryRefType);

                                // TODO create specialized collections for TextTypeWrapperMutable and TextTypeWrapper 
                                foreach (ITextTypeWrapper name in currentDataflow.Names)
                                {
                                    mutable.Names.Add(new TextTypeWrapperMutableCore(name));
                                }

                                mutable.StructureReference = currentDataflow.AsReference;
                                mutable.Id = string.Format(
                                    CultureInfo.InvariantCulture,
                                    "{0}_{1}",
                                    mutable.CategoryReference.GetHashCode(),
                                    mutable.StructureReference.GetHashCode());

                                // TODO use MT fix in java when is done. Mantis ticket:
                                // http://www.metadatatechnology.com/mantis/view.php?id=1341
                                beans.AddCategorisation(new CategorisationObjectCore(mutable));

                                ////sdmxObjects.AddCategorisation(new CategorisationObjectCore(currentDataflow, cateogryRefType));
                            }
                        }
                    }
                    catch (Exception th)
                    {
                        throw new MaintainableObjectException(
                            th,
                            SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Dataflow),
                            currentType.agencyID,
                            currentType.id,
                            currentType.version);
                    }
                }
            }
        }
        /// <summary>
        /// Creates meta-dataflow and categorisations based on the input meta-dataflow
        /// </summary>
        /// <param name="metadataflowsType">
        /// - if null will not add anything to the sdmxObjects container
        /// </param>
        /// <param name="beans">
        /// - to add meta-dataflow and categorisations to
        /// </param>
        protected internal void ProcessMetadataFlows(MetadataflowsType metadataflowsType, ISdmxObjects beans)
        {
            var urns = new HashSet<Uri>();
            if (metadataflowsType != null && ObjectUtil.ValidCollection(metadataflowsType.Metadataflow))
            {
                /* foreach */
                foreach (MetadataflowType currentType in metadataflowsType.Metadataflow)
                {
                    try
                    {
                        IMetadataFlow currentMetadataflow = new MetadataflowObjectCore(currentType);

                        this.AddIfNotDuplicateURN(beans, urns, currentMetadataflow);

                        // CATEGORISATIONS FROM METADATAFLOWS
                        if (currentType.CategoryRef != null)
                        {
                            /* foreach */
                            foreach (CategoryRefType cateogryRefType in currentType.CategoryRef)
                            {
                                beans.AddCategorisation(
                                    new CategorisationObjectCore(currentMetadataflow, cateogryRefType));
                            }
                        }
                    }
                    catch (Exception th)
                    {
                        throw new MaintainableObjectException(
                            th,
                            SdmxStructureType.GetFromEnum(SdmxStructureEnumType.MetadataFlow),
                            currentType.agencyID,
                            currentType.id,
                            currentType.version);
                    }
                }
            }
        }
        /// <summary>
        /// Create Categorisations from Version 2.0 category, adds the categorisation to the sdmxObjects container
        /// </summary>
        /// <param name="beans">
        /// container to add to
        /// </param>
        /// <param name="categoryType">
        /// The category Type.
        /// </param>
        /// <param name="categoryBean">
        /// The category Bean.
        /// </param>
        protected internal void ProcessCategory(
            ISdmxObjects beans, CategoryType categoryType, ICategoryObject categoryBean)
        {
            if (categoryType.DataflowRef != null)
            {
                foreach (DataflowRefType dataflowRefType in categoryType.DataflowRef)
                {
                    // use mutable for now until the following issue is fixed. 
                    // http://www.metadatatechnology.com/mantis/view.php?id=1341
                    ICategorisationMutableObject mutable = new CategorisationMutableCore();
                    mutable.AgencyId = categoryBean.MaintainableParent.AgencyId;

                    mutable.CategoryReference = categoryBean.AsReference;

                    // TODO create specialized collections for TextTypeWrapperMutable and TextTypeWrapper 
                    foreach (ITextTypeWrapper name in categoryBean.Names)
                    {
                        mutable.Names.Add(new TextTypeWrapperMutableCore(name));
                    }

                    mutable.StructureReference = dataflowRefType.URN != null
                                                     ? new StructureReferenceImpl(dataflowRefType.URN)
                                                     : new StructureReferenceImpl(
                                                           dataflowRefType.AgencyID,
                                                           dataflowRefType.DataflowID,
                                                           dataflowRefType.Version,
                                                           SdmxStructureEnumType.Dataflow);
                    mutable.Id = string.Format(
                        CultureInfo.InvariantCulture,
                        "{0}_{1}",
                        mutable.CategoryReference.GetHashCode(),
                        mutable.StructureReference.GetHashCode());

                    // TODO use MT fix in java when is done. Mantis ticket:
                    // http://www.metadatatechnology.com/mantis/view.php?id=1341
                    // sdmxObjects.AddCategorisation(new CategorisationObjectCore(categoryBean, dataflowRefType));
                    beans.AddCategorisation(new CategorisationObjectCore(mutable));
                }
            }

            if (categoryType.MetadataflowRef != null)
            {
                foreach (var mdfRef in categoryType.MetadataflowRef)
                {
                    beans.AddCategorisation(new CategorisationObjectCore(categoryBean, mdfRef));
                }
            }
        }