Exemple #1
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);
                }
                Concept.CodelistCode = this.parsingObject.MaintainableId;
            }
            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.CodelistCode = Concept.CodelistCode;
                    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);
        }
        /// <summary>
        /// retrieves the codelist of Frequency dimension from AllData in DB
        /// </summary>
        /// <param name="_dataFlowCode">Dataflow Code</param>
        /// <returns>list of Mutable Code Object</returns>
        public List <ICodeMutableObject> GetFrequencyCodelist(string _dataFlowCode)
        {
            ISpecialConcept specialConcept = new SpecialConcept("FREQ", SpecialTypeEnum.CL_CONTRAINED);

            return(SpecialCodelist_CL_CONTRAINED(_dataFlowCode, specialConcept));
        }