示例#1
0
        private ArtefactInfo Generate_Codelist_Mapping_Artefact()
        {
            ArtefactInfo RetVal;
            SDMXObjectModel.Message.StructureType Structure;
            StructureSetType StructureSet;
            CodelistMapType CodelistMap;
            CodeMapType CodeMap;
            string CodelistMapId, CodelistMapName;
            string FileName, OutputFolder;

            RetVal = null;
            StructureSet = null;
            CodelistMap = null;
            CodeMap = null;
            CodelistMapId = string.Empty;
            CodelistMapName = string.Empty;
            FileName = string.Empty;

            try
            {
                if (!string.IsNullOrEmpty(this._fileNameWPath) || File.Exists(this._fileNameWPath))
                {
                    Structure = (SDMXObjectModel.Message.StructureType)Deserializer.LoadFromFile(typeof(SDMXObjectModel.Message.StructureType), this._fileNameWPath);

                    if (Structure != null && Structure.Structures != null && Structure.Structures.StructureSets != null &&
                        Structure.Structures.StructureSets.Count > 0)
                    {
                        StructureSet = Structure.Structures.StructureSets[0];
                    }

                    this.Remove_Extra_Annotations(Structure);

                    FileName = Path.GetFileName(this._fileNameWPath);
                    this.OutputFolder = Path.GetDirectoryName(this._fileNameWPath);
                }
                else
                {
                    StructureSet = new StructureSetType();
                    StructureSet.id = Constants.StructureSet.id;
                    StructureSet.agencyID = this.AgencyId;
                    StructureSet.version = Constants.StructureSet.version;

                    StructureSet.Name = new List<TextType>();
                    StructureSet.Name.Add(new TextType(this.Language, Constants.StructureSet.CodelistMap.name));

                    StructureSet.Annotations = null;

                    FileName = Constants.StructureSet.CodelistMap.FileName;
                }

                switch (this._codelistName)//_sourceId
                {
                    case Constants.CodeList.Indicator.Id:
                        CodelistMapId = Constants.StructureSet.CodelistMap.Indicator.id;
                        CodelistMapName = Constants.StructureSet.CodelistMap.Indicator.name;
                        break;
                    case Constants.CodeList.Unit.Id:
                        CodelistMapId = Constants.StructureSet.CodelistMap.Unit.id;
                        CodelistMapName = Constants.StructureSet.CodelistMap.Unit.name;
                        break;
                    case Constants.CodelistPrefix + "AGE":
                        CodelistMapId = Constants.StructureSet.CodelistMap.Age.id;
                        CodelistMapName = Constants.StructureSet.CodelistMap.Age.name;
                        break;
                    case Constants.CodelistPrefix + "SEX":
                        CodelistMapId = Constants.StructureSet.CodelistMap.Sex.id;
                        CodelistMapName = Constants.StructureSet.CodelistMap.Sex.name;
                        break;
                    case Constants.CodelistPrefix + "LOCATION":
                        CodelistMapId = Constants.StructureSet.CodelistMap.Location.id;
                        CodelistMapName = Constants.StructureSet.CodelistMap.Location.name;
                        break;
                    case Constants.CodelistPrefix + "AREA":
                        CodelistMapId = Constants.StructureSet.CodelistMap.Area.id;
                        CodelistMapName = Constants.StructureSet.CodelistMap.Area.name;
                        break;
                    default:
                        break;
                }

                CodelistMap = new SDMXObjectModel.Structure.CodelistMapType();
                CodelistMap.id = CodelistMapId;

                CodelistMap.Name = new List<TextType>();
                CodelistMap.Name.Add(new TextType(Language, CodelistMapName));

                CodelistMap.Source = new SDMXObjectModel.Common.CodelistReferenceType();
                CodelistMap.Source.Items = new List<object>();
                CodelistMap.Source.Items.Add(new SDMXObjectModel.Common.CodelistRefType());
                ((SDMXObjectModel.Common.CodelistRefType)CodelistMap.Source.Items[0]).id = this._sourceId;
                ((SDMXObjectModel.Common.CodelistRefType)CodelistMap.Source.Items[0]).agencyID = this._sourceAgencyId;
                ((SDMXObjectModel.Common.CodelistRefType)CodelistMap.Source.Items[0]).version = this._sourceVersion;

                CodelistMap.Target = new SDMXObjectModel.Common.CodelistReferenceType();
                CodelistMap.Target.Items = new List<object>();
                CodelistMap.Target.Items.Add(new SDMXObjectModel.Common.CodelistRefType());
                ((SDMXObjectModel.Common.CodelistRefType)CodelistMap.Target.Items[0]).id = this._targetId;
                ((SDMXObjectModel.Common.CodelistRefType)CodelistMap.Target.Items[0]).agencyID = this._targetAgencyId;
                ((SDMXObjectModel.Common.CodelistRefType)CodelistMap.Target.Items[0]).version = this._targetVersion;

                CodelistMap.Annotations = null;

                if (this._dictMapping != null && this._dictMapping.Keys.Count > 0)
                {
                    if (StructureSet.Items == null || StructureSet.Items.Count == 0)
                    {
                        StructureSet.Items = new List<NameableType>();
                    }

                    CodelistMap.Items = new List<SDMXObjectModel.Structure.ItemAssociationType>();

                    foreach (string SourceGId in this._dictMapping.Keys)
                    {
                        CodeMap = new SDMXObjectModel.Structure.CodeMapType();

                        CodeMap.Source = new SDMXObjectModel.Common.LocalCodeReferenceType();
                        CodeMap.Source.Items = new List<object>();
                        CodeMap.Source.Items.Add(new SDMXObjectModel.Common.LocalCodeRefType());
                        ((LocalCodeRefType)CodeMap.Source.Items[0]).id = SourceGId;

                        CodeMap.Target = new SDMXObjectModel.Common.LocalCodeReferenceType();
                        CodeMap.Target.Items = new List<object>();
                        CodeMap.Target.Items.Add(new SDMXObjectModel.Common.LocalCodeRefType());
                        ((LocalCodeRefType)CodeMap.Target.Items[0]).id = this._dictMapping[SourceGId];

                        CodeMap.Annotations = null;
                        CodelistMap.Items.Add(CodeMap);
                    }

                    StructureSet.Items.Add(CodelistMap);
                }

                RetVal = this.Prepare_ArtefactInfo_From_StructureSet(StructureSet, FileName);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
            }

            return RetVal;
        }
示例#2
0
        private ArtefactInfo Generate_Metadata_Mapping()
        {
            ArtefactInfo RetVal;
            StructureSetType StructureSet;
            ConceptSchemeMapType ConceptSchemeMap;
            ConceptMapType ConceptMap;

            RetVal = null;
            StructureSet = null;
            ConceptSchemeMap = null;
            ConceptMap = null;

            try
            {
                StructureSet = new StructureSetType();
                StructureSet.id = Constants.StructureSet.id;
                StructureSet.agencyID = this.AgencyId;
                StructureSet.version = Constants.StructureSet.version;

                StructureSet.Name = new List<TextType>();
                StructureSet.Name.Add(new TextType(this.Language, Constants.StructureSet.ConceptSchemeMap.name));

                StructureSet.Annotations = null;

                ConceptSchemeMap = new SDMXObjectModel.Structure.ConceptSchemeMapType();
                ConceptSchemeMap.id = Constants.StructureSet.ConceptSchemeMap.MetadataMap.id;

                ConceptSchemeMap.Name = new List<TextType>();
                ConceptSchemeMap.Name.Add(new TextType(Language, Constants.StructureSet.ConceptSchemeMap.MetadataMap.name));

                ConceptSchemeMap.Source = new SDMXObjectModel.Common.ConceptSchemeReferenceType();
                ConceptSchemeMap.Source.Items = new List<object>();
                ConceptSchemeMap.Source.Items.Add(new SDMXObjectModel.Common.ConceptSchemeRefType());
                ((SDMXObjectModel.Common.ConceptSchemeRefType)ConceptSchemeMap.Source.Items[0]).id = this._sourceId;
                ((SDMXObjectModel.Common.ConceptSchemeRefType)ConceptSchemeMap.Source.Items[0]).agencyID = this._sourceAgencyId;
                ((SDMXObjectModel.Common.ConceptSchemeRefType)ConceptSchemeMap.Source.Items[0]).version = this._sourceVersion;

                ConceptSchemeMap.Target = new SDMXObjectModel.Common.ConceptSchemeReferenceType();
                ConceptSchemeMap.Target.Items = new List<object>();
                ConceptSchemeMap.Target.Items.Add(new SDMXObjectModel.Common.ConceptSchemeRefType());
                ((SDMXObjectModel.Common.ConceptSchemeRefType)ConceptSchemeMap.Target.Items[0]).id = this._targetId;
                ((SDMXObjectModel.Common.ConceptSchemeRefType)ConceptSchemeMap.Target.Items[0]).agencyID = this._targetAgencyId;
                ((SDMXObjectModel.Common.ConceptSchemeRefType)ConceptSchemeMap.Target.Items[0]).version = this._targetVersion;

                ConceptSchemeMap.Annotations = null;

                if (this._dictMapping != null && this._dictMapping.Keys.Count > 0)
                {
                    StructureSet.Items = new List<NameableType>();
                    ConceptSchemeMap.Items = new List<SDMXObjectModel.Structure.ItemAssociationType>();

                    foreach (string SourceGId in this._dictMapping.Keys)
                    {
                        ConceptMap = new SDMXObjectModel.Structure.ConceptMapType();

                        ConceptMap.Source = new SDMXObjectModel.Common.LocalConceptReferenceType();
                        ConceptMap.Source.Items = new List<object>();
                        ConceptMap.Source.Items.Add(new SDMXObjectModel.Common.LocalConceptRefType());
                        ((LocalConceptRefType)ConceptMap.Source.Items[0]).id = SourceGId;

                        ConceptMap.Target = new SDMXObjectModel.Common.LocalConceptReferenceType();
                        ConceptMap.Target.Items = new List<object>();
                        ConceptMap.Target.Items.Add(new SDMXObjectModel.Common.LocalConceptRefType());
                        ((LocalConceptRefType)ConceptMap.Target.Items[0]).id = this._dictMapping[SourceGId];

                        ConceptMap.Annotations = null;
                        ConceptSchemeMap.Items.Add(ConceptMap);
                    }

                    StructureSet.Items.Add(ConceptSchemeMap);
                }

                RetVal = this.Prepare_ArtefactInfo_From_StructureSet(StructureSet, Constants.StructureSet.ConceptSchemeMap.MetadataMap.FileName);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
            }

            return RetVal;
        }
        public StructuresType(ProvisionAgreementType provisionAgreement, ConstraintType constraint, ProcessType process, 
                              ReportingTaxonomyType reportingTaxonomoy, StructureSetType structureSet, DataStructureType dataStructure, 
                              MetadataStructureType metadataStructure, ConceptSchemeType conceptScheme, 
                              HierarchicalCodelistType hierarchicalCodelist, CodelistType codelist, CategorisationType categorisation, 
                              CategorySchemeType categoryScheme, MetadataflowType metadataFlow, DataflowType dataFlow, 
                              OrganisationSchemeType organisationScheme)
        {
            if (provisionAgreement != null)
            {
                this.provisionAgreementsField = new List<ProvisionAgreementType>();
                this.provisionAgreementsField.Add(provisionAgreement);
            }

            if (constraint != null)
            {
                this.constraintsField = new List<ConstraintType>();
                this.constraintsField.Add(constraint);
            }

            if (process != null)
            {
                this.processesField = new List<ProcessType>();
                this.processesField.Add(process);
            }

            if (reportingTaxonomoy != null)
            {
                this.reportingTaxonomiesField = new List<ReportingTaxonomyType>();
                this.reportingTaxonomiesField.Add(reportingTaxonomoy);
            }

            if (structureSet != null)
            {
                this.structureSetsField = new List<StructureSetType>();
                this.structureSetsField.Add(structureSet);
            }

            if (dataStructure != null)
            {
                this.dataStructuresField = new List<DataStructureType>();
                this.dataStructuresField.Add(dataStructure);
            }

            if (metadataStructure != null)
            {
                this.metadataStructuresField = new List<MetadataStructureType>();
                this.metadataStructuresField.Add(metadataStructure);
            }

            if (conceptScheme != null)
            {
                this.conceptsField = new List<ConceptSchemeType>();
                this.conceptsField.Add(conceptScheme);
            }

            if (hierarchicalCodelist != null)
            {
                this.hierarchicalCodelistsField = new List<HierarchicalCodelistType>();
                this.hierarchicalCodelistsField.Add(hierarchicalCodelist);
            }

            if (codelist != null)
            {
                this.codelistsField = new List<CodelistType>();
                this.codelistsField.Add(codelist);
            }

            if (categorisation != null)
            {
                this.categorisationsField = new List<CategorisationType>();
                this.categorisationsField.Add(categorisation);
            }

            if (categoryScheme != null)
            {
                this.categorySchemesField = new List<CategorySchemeType>();
                this.categorySchemesField.Add(categoryScheme);
            }

            if (metadataFlow != null)
            {
                this.metadataflowsField = new List<MetadataflowType>();
                this.metadataflowsField.Add(metadataFlow);
            }

            if (dataFlow != null)
            {
                this.dataflowsField = new List<DataflowType>();
                this.dataflowsField.Add(dataFlow);
            }

            if (organisationScheme != null)
            {
                this.organisationSchemesField = new List<OrganisationSchemeType>();
                this.organisationSchemesField.Add(organisationScheme);
            }
        }