コード例 #1
0
        /// <summary>
        /// retrieves the codelist Contrain from database
        /// </summary>
        /// <returns>list of Mutable Code Object</returns>
        public List <ICodelistMutableObject> GetCodelistNoConstrain()
        {
            if (ReferencesObject == null)
            {
                ReferencesObject = new IReferencesObject();
            }


            if (ReferencesObject.FoundedDataflows == null || ReferencesObject.FoundedDataflows.Count == 0)
            {
                IDataflowsManager gdf = new MetadataFactory().InstanceDataflowsManager((ISdmxParsingObject)this.parsingObject.Clone(), this.versionTypeResp);
                gdf.parsingObject.MaintainableId  = null;
                ReferencesObject.FoundedDataflows = gdf.GetDataFlows();
            }

            if (ReferencesObject.FoundedDataflows == null || ReferencesObject.FoundedDataflows.Count == 0)
            {
                throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.DataflowNotFound, new Exception(this.parsingObject.ConstrainDataFlow));
            }

            if (ReferencesObject.Concepts == null)
            {
                ReferencesObject.Concepts = new Dictionary <string, List <IConceptObjectImpl> >();
            }
            foreach (var df in ReferencesObject.FoundedDataflows)
            {
                List <IConceptObjectImpl> concepts = new ConceptSchemeManager(this.parsingObject, this.versionTypeResp).GetConceptList(df.Id);
                ReferencesObject.Concepts.Add(string.Format(FlyConfiguration.ConceptSchemeFormat, df.Id), concepts);
                if (!string.IsNullOrEmpty(this.parsingObject.MaintainableId))
                {
                    FlyNameArtefactSettings fnas   = new FlyNameArtefactSettings(this.parsingObject);
                    string             ConceptCode = fnas.GetConceptCodeFromCodelist();
                    IConceptObjectImpl Concept     = concepts.Find(c => c.ConceptObjectCode.Trim().ToLower() == ConceptCode.Trim().ToLower());
                    if (Concept == null)
                    {
                        continue;
                    }

                    BuildCodelist(null, Concept);
                    break;
                }
                else
                {
                    foreach (var Concept in concepts)
                    {
                        BuildCodelist(null, Concept);
                    }
                }
            }
            return(ReferencesObject.Codelists);
        }
コード例 #2
0
        /// <summary>
        /// retrieves the codelist Contrain  from database
        /// </summary>
        /// <returns>list of Mutable Code Object</returns>
        public List <ICodelistMutableObject> GetCodelistConstrain()
        {
            if (ReferencesObject == null)
            {
                ReferencesObject = new IReferencesObject();
            }

            if (ReferencesObject.FoundedDataflows == null || ReferencesObject.FoundedDataflows.Count == 0)
            {
                IDataflowsManager gdf = new MetadataFactory().InstanceDataflowsManager((ISdmxParsingObject)this.parsingObject.Clone(), this.versionTypeResp);
                gdf.parsingObject.MaintainableId  = null;
                ReferencesObject.FoundedDataflows = gdf.GetDataFlows();
            }

            if (ReferencesObject.FoundedDataflows == null || ReferencesObject.FoundedDataflows.Count == 0)
            {
                throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.DataflowNotFound, new Exception(this.parsingObject.ConstrainDataFlow));
            }

            if (ReferencesObject.Concepts == null)
            {
                ReferencesObject.Concepts = new Dictionary <string, List <IConceptObjectImpl> >();
            }

            IConceptObjectImpl Concept = null;
            SpecialTypeEnum    specType;

            if (!string.IsNullOrEmpty(this.parsingObject.MaintainableId) &&
                Enum.TryParse <SpecialTypeEnum>(this.parsingObject.MaintainableId.Trim().ToUpper(), out specType) &&
                this.parsingObject.AgencyId == "MA")
            {
                if (!string.IsNullOrEmpty(this.parsingObject.ConstrainConcept))
                {
                    Concept = new SpecialConcept(this.parsingObject.ConstrainConcept, specType);
                }
                else
                {
                    Concept = new SpecialConcept(specType.ToString(), specType);
                }
            }
            else
            {
                List <IConceptObjectImpl> concepts = new ConceptSchemeManager(this.parsingObject, this.versionTypeResp).GetConceptList(this.parsingObject.ConstrainDataFlow);
                ReferencesObject.Concepts.Add(string.Format(FlyConfiguration.ConceptSchemeFormat, this.parsingObject.ConstrainDataFlow), concepts);
                Concept = concepts.Find(c => c.ConceptObjectCode.Trim().ToLower() == this.parsingObject.ConstrainConcept.Trim().ToLower());
                if (Concept == null)
                {
                    throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.CodelistInvalid, new Exception(string.Format("Concept {0} Not Found in Dataflow {1}", this.parsingObject.ConstrainConcept, this.parsingObject.ConstrainDataFlow)));
                }

                if (this.parsingObject.ContrainConceptREF != null && this.parsingObject.ContrainConceptREF.Keys.Count > 0)
                {
                    ISpecialConcept sc = new SpecialConcept(Concept.Id, SpecialTypeEnum.CL_CONTRAINED);
                    sc.SetNames(Concept.ConceptObjectNames);
                    sc.TimeDimensionRef   = concepts.Find(c => c.ConceptType == ConceptTypeEnum.Dimension && ((IDimensionConcept)c).DimensionType == DimensionTypeEnum.Time);
                    sc.ContrainConceptREF = this.parsingObject.ContrainConceptREF;
                    Concept = sc;
                }
            }

            BuildCodelist(this.parsingObject.ConstrainDataFlow, Concept);
            return(ReferencesObject.Codelists);
        }