/// <summary> /// Updates the specified <paramref name="mutable"/>. /// </summary> /// <param name="mutable"> /// The nameable mutable object. /// </param> /// <param name="primaryKeyValue"> /// The primary key value. /// </param> /// <exception cref="System.ArgumentNullException"> /// <paramref name="mutable"/> is null /// </exception> /// <exception cref="System.ArgumentException"> /// <paramref name="primaryKeyValue"/> is not valid /// </exception> public void Update(INameableMutableObject mutable, long primaryKeyValue) { bool isArtefact = IsArtefact(mutable); this.Update(primaryKeyValue, LocalisedStringType.Name, isArtefact, mutable.Names); this.Update(primaryKeyValue, LocalisedStringType.Desc, isArtefact, mutable.Descriptions); }
private void SetNames(DataRow[] dataRow, INameableMutableObject mutableObj) { foreach (DataRow name in dataRow) { mutableObj.AddName(name[1].ToString(), name[2].ToString()); } }
/// <summary> /// Read the localized string from <paramref name="dataReader"/> /// </summary> /// <param name="item"> /// The <see cref="INameableMutableObject"/> . /// </param> /// <param name="typeIdx"> /// The <c>LOCALISED_STRING.TYPE</c> ordinal /// </param> /// <param name="txtIdx"> /// The <c>LOCALISED_STRING.TEXT</c> ordinal /// </param> /// <param name="langIdx"> /// The <c>LOCALISED_STRING.LANGUAGE</c> ordinal /// </param> /// <param name="dataReader"> /// The MASTORE DB <see cref="IDataReader"/> /// </param> /// <param name="detail">The Structure Query Detail</param> protected static void ReadLocalisedString(INameableMutableObject item, int typeIdx, int txtIdx, int langIdx, IDataRecord dataReader, ComplexStructureQueryDetailEnumType detail = ComplexStructureQueryDetailEnumType.Full) { //// TODO support SDMX-ML Query detail CompleteStub versus Stub when Common API supports it. //// When it is stub then only name should be returned. //// When it is complete stub both name and description. //// Now we use StructureQueryDetail which is for REST queries only. //// According to the http://sdmx.org/wp-content/uploads/2012/05/SDMX_2_1-SECTION_07_WebServicesGuidelines_May2012.pdf //// page 10, footnotes 10-12 REST AllStubs == SDMX-ML Query Stub so in that case we skip description var value = DataReaderHelper.GetString(dataReader, txtIdx); var locale = DataReaderHelper.GetString(dataReader, langIdx); string type = DataReaderHelper.GetString(dataReader, typeIdx); var textType = new TextTypeWrapperMutableCore { Locale = locale, Value = value }; switch (type) { case LocalisedStringType.Name: item.Names.Add(textType); break; case LocalisedStringType.Desc: if (detail != ComplexStructureQueryDetailEnumType.Stub) { item.Descriptions.Add(textType); } break; default: _log.WarnFormat(CultureInfo.InvariantCulture, "Unknown type at LOCALISATION.TYPE : '{0}', Locale: '{1}', Text:'{2}'", type, locale, value); if (item.Names.Count == 0) { item.AddName(null, !string.IsNullOrWhiteSpace(value) ? value : item.Id); } break; } }
/// <summary> /// Write the Name(s) and Description(s) of the given IIdentifiableMutableObject type object /// </summary> /// <param name="artefact"> /// The IIdentifiableMutableObject type object to write /// </param> protected void WriteIdentifiableArtefactContent(INameableMutableObject artefact) { foreach (ITextTypeWrapperMutableObject textTypeBean in artefact.Names) { this.WriteTextType(this._defaultNs, textTypeBean, ElementNameTable.Name); } foreach (ITextTypeWrapperMutableObject textTypeBean in artefact.Descriptions) { this.WriteTextType(this._defaultNs, textTypeBean, ElementNameTable.Description); } }
/////////////////////////////////////////////////////////////////////////////////////////////////// ////////////BUILD FROM MUTABLE OBJECT ////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Initializes a new instance of the <see cref="NameableCore"/> class. /// </summary> /// <param name="itemMutableObject"> /// The itemMutableObject. /// </param> /// <param name="parent"> /// The parent. /// </param> protected internal NameableCore(INameableMutableObject itemMutableObject, IIdentifiableObject parent) : base(itemMutableObject, parent) { this.name = new List<ITextTypeWrapper>(); this.description = new List<ITextTypeWrapper>(); if (itemMutableObject.Names != null) { foreach (ITextTypeWrapperMutableObject mutable in itemMutableObject.Names) { if (!string.IsNullOrWhiteSpace(mutable.Value)) { this.name.Add(new TextTypeWrapperImpl(mutable, this)); } } } if (itemMutableObject.Descriptions != null) { foreach (ITextTypeWrapperMutableObject mutable0 in itemMutableObject.Descriptions) { if (!string.IsNullOrWhiteSpace(mutable0.Value)) { this.description.Add(new TextTypeWrapperImpl(mutable0, this)); } } } this.ValidateNameableAttributes(); }