Ejemplo n.º 1
0
        /// <summary>
        ///  Create a ImmutableInstance of Categorisation
        /// </summary>
        /// <param name="DataflowCode">Dataflow Code</param>
        /// <param name="DataflowAgency">Dataflow Agency Id</param>
        /// <param name="DataflowVersion">Dataflow Version</param>
        /// <param name="CategoryParent">list of category parent, from hightLevel parent to low level child category</param>
        /// <returns>ICategorisationObject</returns>
        public ICategorisationObject BuildCategorisation(string DataflowCode, string DataflowAgency, string DataflowVersion, List <string> CategoryParent)
        {
            try
            {
                ICategorisationMutableObject ca = new CategorisationMutableCore();
                ca.AgencyId = this.CategorySchemeAgencyId;
                ca.Version  = this.CategorySchemeVersion;
                string IDName = string.Format("{0}@{1}@{2}@{3}@{4}@{5}",
                                              DataflowCode, DataflowAgency, DataflowVersion.Replace(".", ""),
                                              this.Code, this.CategorySchemeVersion.Replace(".", ""), CategoryParent[CategoryParent.Count - 1]);
                ca.Id = IDName;
                ca.AddName("en", IDName);

                //IAnnotationMutableObject ann = new AnnotationMutableCore();
                //ann.Type="CategoryScheme_node_order";
                //ann.Text.Add(new TextTypeWrapperMutableCore("en", (CategoryParent.Count).ToString()));
                //ca.AddAnnotation(ann);

                //ca.Id = string.Format(FlyConfiguration.CategorisationFormat, DataflowCode);
                //foreach (SdmxObjectNameDescription item in this.Names)
                //    ca.AddName(item.Lingua, item.Name);

                if (!this.ParsingObject.ReturnStub)
                {
                    if (this.VersionTypeResp == SdmxSchemaEnumType.VersionTwo)
                    {
                        ca.CategoryReference = ReferenceBuilder.CreateCategoryReference(this.Code, this.CategorySchemeAgencyId, this.CategorySchemeVersion, CategoryParent.ToArray());
                    }
                    else
                    {
                        ca.CategoryReference = ReferenceBuilder.CreateCategoryReference(this.Code, this.CategorySchemeAgencyId, this.CategorySchemeVersion, CategoryParent != null && CategoryParent.Count > 0 ? new string[1] {
                            CategoryParent[CategoryParent.Count - 1]
                        } : CategoryParent.ToArray());
                    }

                    ca.StructureReference = ReferenceBuilder.CreateDataflowReference(DataflowCode, DataflowAgency, DataflowVersion);
                }

                ca.FinalStructure = TertiaryBool.ParseBoolean(true);

                //if (this.ParsingObject.isReferenceOf || this.ParsingObject.ReturnStub)
                //{
                //    ca.ExternalReference = TertiaryBool.ParseBoolean(true);
                //    ca.StructureURL = RetreivalStructureUrl.Get(this, ca.Id, ca.AgencyId, ca.Version);
                //}

                return(ca.ImmutableInstance);
            }
            catch (SdmxException) { throw; }
            catch (Exception ex)
            {
                throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.CreateImmutable, ex);
            }
        }
        /// <summary>
        /// Create a ImmutableInstance of Dataflow
        /// </summary>
        /// <param name="AgencyId">Agency Id</param>
        /// <param name="Version">Artefact Version</param>
        /// <returns>IDataflowObject</returns>
        public IDataflowObject BuildDataflow(string AgencyId, string Version)
        {
            try
            {
                IDataflowMutableObject df = new DataflowMutableCore();
                df.AgencyId = AgencyId;
                df.Version  = Version;
                df.Id       = this.Code;
                if (this.Names != null)
                {
                    foreach (SdmxObjectNameDescription nome in this.Names)
                    {
                        df.AddName(nome.Lingua, nome.Name);
                    }
                }

                if (!this.ParsingObject.ReturnStub)
                {
                    if (this.DataStrunctureRef != null)
                    {
                        df.DataStructureRef = this.DataStrunctureRef;
                    }
                    else
                    {
                        df.DataStructureRef = ReferenceBuilder.CreateDSDStructureReference(this.Code);//Creo una struttura di riferimento
                    }
                }

                df.FinalStructure = TertiaryBool.ParseBoolean(true);

                if (this.ParsingObject.isReferenceOf || this.ParsingObject.ReturnStub)
                {
                    df.ExternalReference = TertiaryBool.ParseBoolean(true);
                    df.StructureURL      = RetreivalStructureUrl.Get(this, df.Id, df.AgencyId, df.Version);
                }
                return(df.ImmutableInstance);
            }
            catch (SdmxException) { throw; }
            catch (Exception ex)
            {
                throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.CreateImmutable, ex);
            }
        }