/// <summary> /// Write the element Code using the given code /// </summary> /// <param name="item"> /// The <see cref="ICodeMutableObject"/> object to write /// </param> private void WriteCode(ICodeMutableObject item) { this.WriteStartElement(this.DefaultPrefix, ElementNameTable.Code); this.WriteAttributeString(AttributeNameTable.value, item.Id); this.TryWriteAttribute(AttributeNameTable.urn, item.Urn); this.TryWriteAttribute(AttributeNameTable.parentCode, item.ParentCode); //// NOTE in SDMX 2.0 Code has only description. The Common API expects it to have Name. So we put Code description to Name. foreach (ITextTypeWrapperMutableObject textTypeBean in item.Names) { this.WriteTextType(this.DefaultNS, textTypeBean, ElementNameTable.Description); } this.WriteAnnotations(ElementNameTable.Annotations, item.Annotations); this.WriteEndElement(); }
/// <summary> /// Setup a CodelistBean object as a TimeDimension codelist containing two codes, startTime and endTime and using as codelist id the <see cref="CustomCodelistConstants.TimePeriodCodeList"/> . /// </summary> /// <param name="startCode"> /// The code that will contain the start Time period /// </param> /// <param name="endCode"> /// The code that will contain the end Time period /// </param> /// <param name="timeCodeList"> /// The codelist to setup /// </param> public static void SetupTimeCodelist(ICodeMutableObject startCode, ICodeMutableObject endCode, ICodelistMutableObject timeCodeList) { timeCodeList.Id = CustomCodelistConstants.TimePeriodCodeList; timeCodeList.AgencyId = CustomCodelistConstants.Agency; timeCodeList.Version = CustomCodelistConstants.Version; timeCodeList.Names.Add( new TextTypeWrapperMutableCore { Locale = CustomCodelistConstants.Lang, Value = CustomCodelistConstants.TimePeriodCodeListName }); startCode.Names.Add( new TextTypeWrapperMutableCore { Locale = CustomCodelistConstants.Lang, Value = CustomCodelistConstants.TimePeriodStartDescription }); timeCodeList.AddItem(startCode); if (endCode != null) { endCode.Names.Add( new TextTypeWrapperMutableCore { Locale = CustomCodelistConstants.Lang, Value = CustomCodelistConstants.TimePeriodEndDescription }); timeCodeList.AddItem(endCode); } }
/// <summary> /// Handle the common text elements for <paramref name="code"/> based objects /// </summary> /// <param name="code"> /// The parent <see cref="ICodeMutableObject"/> /// </param> /// <param name="localName"> /// The local name of the XML tag /// </param> private void HandleTextChildElement(ICodeMutableObject code, object localName) { if (NameTableCache.IsElement(localName, ElementNameTable.Description)) { //// NOTE in SDMX 2.0 Code has only description. The Common API expects it to have Name. So we put Code description to Name. code.Names.Add(new TextTypeWrapperMutableCore { Value = this.Text, Locale = this.Lang }); } }
/////////////////////////////////////////////////////////////////////////////////////////////////// ////////////BUILD FROM MUTABLE OBJECT ////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////// #region Constructors and Destructors /// <summary> /// Initializes a new instance of the <see cref="CodeCore"/> class. /// </summary> /// <param name="parent"> /// The parent. /// </param> /// <param name="itemMutableObject"> /// The sdmxObject. /// </param> public CodeCore(ICodelistObject parent, ICodeMutableObject itemMutableObject) : base(itemMutableObject, parent) { this.parentCode = string.IsNullOrWhiteSpace(itemMutableObject.ParentCode) ? null : itemMutableObject.ParentCode; }
private List <ICodeMutableObject> SpecialCodelist_CL_CONTRAINED(string _dataFlowCode, ISpecialConcept specialConcept) { string WhereStatement = "1=1"; string Time = "1=1"; List <string> _ConceptWhere = new List <string>(); if (specialConcept.ContrainConceptREF != null && specialConcept.ContrainConceptREF.Keys.Count > 0) { foreach (string otherconept in specialConcept.ContrainConceptREF.Keys.ToList()) { if (specialConcept.ContrainConceptREF[otherconept] == null) { continue; } if (new List <string>() { "TIME", "TIME_PERIOD" }.Contains(otherconept.Trim().ToUpper())) { if (specialConcept.ContrainConceptREF[otherconept].Count > 0 && specialConcept.TimeDimensionRef != null) { string timedim = string.Format(DataMessageManager.FormatWhereValue, ((IDimensionConcept)specialConcept.TimeDimensionRef).GetColumTimeName()); ISdmxDate StartDate = new SdmxDateCore(specialConcept.ContrainConceptREF[otherconept][0].Value); string STime = TimePeriodDBFormat.GetTimeWhereStatment(timedim, TimePeriodDBFormat.TypeDateOperation.Major, StartDate.TimeFormatOfDate.EnumType, StartDate); Time = String.Format("({0})", STime); if (specialConcept.ContrainConceptREF[otherconept].Count == 2) { ISdmxDate EndDate = new SdmxDateCore(specialConcept.ContrainConceptREF[otherconept][1].Value); string ETime = TimePeriodDBFormat.GetTimeWhereStatment(timedim, TimePeriodDBFormat.TypeDateOperation.Minor, EndDate.TimeFormatOfDate.EnumType, EndDate); Time = String.Format("({0} AND {1})", STime, ETime); } } continue; } if (otherconept.Trim().ToUpper() == "FREQ") { //Devo controllare se stò in modalità FakeFrequency se cosi continue; } List <string> ConceptInternalWhere = new List <string>(); foreach (var item in specialConcept.ContrainConceptREF[otherconept]) { ConceptInternalWhere.Add(string.Format("{0}='{1}'", string.Format(DataMessageManager.FormatWhereValue, otherconept), item.Value)); } _ConceptWhere.Add(string.Format("({0})", string.Join(" OR ", ConceptInternalWhere))); } } WhereStatement = string.Format("{0}", string.Join(" AND ", _ConceptWhere)); if (string.IsNullOrEmpty(WhereStatement)) { WhereStatement = "1=1"; } List <IParameterValue> parametri = new List <IParameterValue>() { new ParameterValue() { Item = "DataSetCode", Value = _dataFlowCode }, new ParameterValue() { Item = "WhereStatement", Value = WhereStatement }, new ParameterValue() { Item = "Time", Value = Time }, new ParameterValue() { Item = "UserName", Value = FlyConfiguration.UserName }, new ParameterValue() { Item = "Domain", Value = FlyConfiguration.Domain }, }; List <ICodeMutableObject> codes = null; if (specialConcept.Id.Trim().ToUpper() == "FREQ") { codes = GetFrequencyCodelist(); } else { DimensionCodelistsManager dimcm = new DimensionCodelistsManager(this.parsingObject, this.versionTypeResp); codes = dimcm.InternalGetDimensionCodelistConstrain(_dataFlowCode, specialConcept.Id); } List <string> existCode = ((DWHAccess)DbAccess).GetCL_CONTRAINED(parametri, specialConcept.Id); List <ICodeMutableObject> Contrainedcodes = new List <ICodeMutableObject>(); for (int i = codes.Count - 1; i >= 0; i--) { if (existCode.Contains(codes[i].Id)) { Contrainedcodes.Add(codes[i]); } } for (int i = 0; i < Contrainedcodes.Count; i++) { ICodeMutableObject observeCode = Contrainedcodes[i]; while (true) { if (!string.IsNullOrEmpty(observeCode.ParentCode) && !Contrainedcodes.Exists(c => c.Id == observeCode.ParentCode)) { ICodeMutableObject ParentCode = codes.Find(c => c.Id == observeCode.ParentCode); if (ParentCode != null) { Contrainedcodes.Add(ParentCode); observeCode = ParentCode; continue; } } break; } } return(Contrainedcodes); }