/// <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); }
internal List <IDataflowObject> InternalGetDataFlow() { List <IDataflowObject> dfls = null; if (this.ReferencesObject == null || this.ReferencesObject.FoundedDataflows == null || this.ReferencesObject.FoundedDataflows.Count == 0) { IDataflowsManager DataflowManager = new MetadataFactory().InstanceDataflowsManager(this.parsingObject, this.versionTypeResp); dfls = DataflowManager.GetDataFlows(); } else { dfls = this.ReferencesObject.FoundedDataflows; } return(dfls); }
/// <summary> /// Build a ConceptSchemes /// </summary> /// <returns>list of IConceptSchemeObject for SdmxObject</returns> public List <IConceptSchemeObject> GetConceptSchemes() { try { if (ReferencesObject == null) { ReferencesObject = new IReferencesObject(); } this.ReferencesObject.ConceptSchemes = new List <IConceptSchemeObject>(); this.ReferencesObject.Concepts = new Dictionary <string, List <IConceptObjectImpl> >(); //Cerco tutti i DataFlow Per Capire se esiste IDataflowsManager gdf = new MetadataFactory().InstanceDataflowsManager((ISdmxParsingObject)this.parsingObject.Clone(), this.versionTypeResp); gdf.parsingObject.MaintainableId = null; ReferencesObject.FoundedDataflows = gdf.GetDataFlows(); if (!string.IsNullOrEmpty(this.parsingObject.MaintainableId)) { FlyNameArtefactSettings fnas = new FlyNameArtefactSettings(this.parsingObject); string DataflowCode = fnas.GetDataFlowCodeFromConceptSchema(); if (ReferencesObject.FoundedDataflows.Exists(d => d.Id.Trim().ToUpper() == DataflowCode.Trim().ToUpper())) { ReferencesObject.FoundedDataflows = new List <IDataflowObject>() { ReferencesObject.FoundedDataflows.Find(d => d.Id.Trim().ToUpper() == DataflowCode.Trim().ToUpper()) } } ; } foreach (var referenceDF in ReferencesObject.FoundedDataflows) { BuildConcepts(referenceDF.Id); } return(ReferencesObject.ConceptSchemes); } catch (SdmxException) { throw; } catch (Exception ex) { throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.GetConceptsScheme, ex); } }
/// <summary> /// retrieves the codelist Contrain of Dimension from database /// </summary> /// <param name="dimension">Instance of Dimension "DimensionConcept"</param> /// <returns>list of Mutable Code Object</returns> public List <ICodeMutableObject> GetDimensionCodelistNoContrain(IDimensionConcept dimension) { try { if (FlyConfiguration.CodelistWhitoutConstrain) { if (dimension.IsFakeFrequency) { SpecialCodelistsManager sp = new SpecialCodelistsManager(this.parsingObject, this.versionTypeResp); return(sp.GetFrequencyCodelist()); } IDataflowsManager dfMan = new MetadataFactory().InstanceDataflowsManager(this.parsingObject.CloneForReferences(), this.versionTypeResp); List <ICodeMutableObject> listCode = new List <ICodeMutableObject>(); var _foundedDataflow = dfMan.GetDataFlows(); List <SdmxObjectNameDescription> nomiDf = new List <SdmxObjectNameDescription>(); foreach (var df in _foundedDataflow) { string dfCode = df.Id; DimensionManager dim = new DimensionManager(this.parsingObject, this.versionTypeResp); List <IDimensionConcept> conc = dim.GetDimensionConceptObjects(dfCode, out nomiDf); if (conc.Exists(c => c.Id == dimension.Id)) { foreach (ICodeMutableObject item in GetDimensionCodelistContrain(dfCode, conc.Find(c => c.Id == dimension.Id))) { if (!listCode.Exists(cl => cl.Id == item.Id)) { listCode.Add(item); } } } } return(listCode); } else { throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.CodelistContrainRequired); } } catch (SdmxException) { throw; } catch (Exception ex) { throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.CreateICodeMutableObject, ex); } }
/// <summary> /// retrieves the codelist of an attribute from SP Attribute codelist NoConstrain or from the file "AttributeConcept.xml" /// </summary> /// <param name="attribute">Instance of Attribute "AttributeConcept"</param> /// <returns>list of Mutable Code Object</returns> public List <ICodeMutableObject> GetAttributeCodelistNoConstrain(IAttributeConcept attribute) { if (!this.DbAccess.CheckExistStoreProcedure(DBOperationEnum.GetAttributeCodelistConstrain)) { return(AttributeCodelistFromFile(attribute)); } else if (!FlyConfiguration.CodelistWhitoutConstrain) { throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.CodelistContrainRequired); } else { IDataflowsManager dfMan = new MetadataFactory().InstanceDataflowsManager(this.parsingObject.CloneForReferences(), this.versionTypeResp); List <ICodeMutableObject> listCode = new List <ICodeMutableObject>(); var _foundedDataflow = dfMan.GetDataFlows(); foreach (var df in _foundedDataflow) { string dfCode = df.Id; IAttributeManager _AttributeManager = new AttributeManagerSP(this.parsingObject, this.versionTypeResp); if (!this.DbAccess.CheckExistStoreProcedure(DBOperationEnum.GetAttributes)) { _AttributeManager = new AttributeManager_FromFile(this.parsingObject, this.versionTypeResp); } List <IAttributeConcept> conc = _AttributeManager.GetAttribute(dfCode); if (conc.Exists(c => c.Id == attribute.Id)) { foreach (ICodeMutableObject item in GetAttributeCodelistConstrain(dfCode, conc.Find(c => c.Id == attribute.Id))) { if (!listCode.Exists(cl => cl.Id == item.Id)) { listCode.Add(item); } } } } return(listCode); } }
/// <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 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)) { string PossibleDimTable = this.parsingObject.MaintainableId.Trim().ToUpper(); string PossibleAttTable = this.parsingObject.MaintainableId.Trim().ToUpper(); if (PossibleDimTable.StartsWith(FlyConfiguration.CodelistFormat.ToUpper().Replace("{0}", ""))) { PossibleDimTable = string.Format("DIM{0}", PossibleDimTable.Substring(FlyConfiguration.CodelistFormat.ToUpper().Replace("{0}", "").Length)); PossibleAttTable = string.Format("ATT{0}", PossibleDimTable.Substring(FlyConfiguration.CodelistFormat.ToUpper().Replace("{0}", "").Length)); } else if (PossibleDimTable.EndsWith(FlyConfiguration.CodelistFormat.ToUpper().Replace("{0}", ""))) { PossibleDimTable = string.Format("DIM{0}", PossibleDimTable.Substring(0, PossibleDimTable.Length - FlyConfiguration.CodelistFormat.ToUpper().Replace("{0}", "").Length)); PossibleAttTable = string.Format("ATT{0}", PossibleDimTable.Substring(0, PossibleDimTable.Length - FlyConfiguration.CodelistFormat.ToUpper().Replace("{0}", "").Length)); } IConceptObjectImpl Concept = concepts.Find(c => !string.IsNullOrEmpty(c.CodelistCode) && (c.CodelistCode.Trim().ToUpper() == PossibleDimTable || c.CodelistCode.Trim().ToUpper() == PossibleAttTable)); if (Concept == null) { continue; } BuildCodelist(null, Concept); break; } else { foreach (var Concept in concepts) { BuildCodelist(null, Concept); } } } return(ReferencesObject.Codelists); }
/// <summary> /// retrieves the DSD from database /// </summary> /// <returns>list of DataStructure for SDMXObject</returns> public List <DataStructureObjectImpl> GetDSDs() { try { if (ReferencesObject == null) { ReferencesObject = new IReferencesObject(); } if (ReferencesObject.DSDs != null) { return(ReferencesObject.DSDs); } 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 (!string.IsNullOrEmpty(this.parsingObject.MaintainableId)) { FlyNameArtefactSettings fnas = new FlyNameArtefactSettings(this.parsingObject); string DataFlowCode = fnas.GetDataFlowCodeFromKeyFamily(); //Controllo se esiste il Dataflow ReferencesObject.FoundedDataflows = new List <IDataflowObject>() { ReferencesObject.FoundedDataflows.Find(df => df.Id.Trim().ToUpper() == DataFlowCode.Trim().ToUpper()) }; } if (ReferencesObject.FoundedDataflows == null) { throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.DataflowNotFound); } ReferencesObject.DSDs = new List <DataStructureObjectImpl>(); if (ReferencesObject.Codelists == null) { ReferencesObject.Codelists = new List <ICodelistMutableObject>(); } if (ReferencesObject.Concepts == null) { ReferencesObject.Concepts = new Dictionary <string, List <IConceptObjectImpl> >(); } foreach (var df in ReferencesObject.FoundedDataflows) { ReferencesObject.DSDs.Add(BuildDSD(df)); } return(ReferencesObject.DSDs); } catch (SdmxException) { throw; } catch (Exception ex) { throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.BuildDSD, ex); } }