/// <summary> /// /// </summary> /// <param name="artefact"></param> /// <param name="sysId"></param> private void PopulateCubeRegion(IContentConstraintMutableObject artefact, long sysId) { var inParameter = MappingStoreDb.CreateInParameter(ParameterNameConstants.IdParameter, DbType.Int64, sysId); using (DbCommand command = MappingStoreDb.GetSqlStringCommandParam(ContentConstraintConstant.SqlConsItem, inParameter)) { using (IDataReader dataReader = this.MappingStoreDb.ExecuteReader(command)) { string keyValueIDCurr = String.Empty; string componentTypeCurr = String.Empty; artefact.IncludedCubeRegion = new CubeRegionMutableCore(); IKeyValuesMutable key = null; while (dataReader.Read()) { if (dataReader["CUBE_REGION_KEY_VALUE_ID"].ToString() != keyValueIDCurr) { if (key != null) { if (componentTypeCurr == "Attribute") { artefact.IncludedCubeRegion.AddAttributeValue(key); } if (componentTypeCurr == "Dimension") { artefact.IncludedCubeRegion.AddKeyValue(key); } } keyValueIDCurr = dataReader["CUBE_REGION_KEY_VALUE_ID"].ToString(); componentTypeCurr = dataReader["COMPONENT_TYPE"].ToString(); key = new KeyValuesMutableImpl(); } if (String.IsNullOrEmpty(key.Id)) { key.Id = dataReader["MEMBER_ID"].ToString(); } key.AddValue(dataReader["MEMBER_VALUE"].ToString()); } if (componentTypeCurr == "Attribute") { artefact.IncludedCubeRegion.AddAttributeValue(key); } if (componentTypeCurr == "Dimension") { artefact.IncludedCubeRegion.AddKeyValue(key); } } } }
/////////////////////////////////////////////////////////////////////////////////////////////////// ////////////BUILD FROM MUTABLE OBJECT ////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////// #region Constructors and Destructors /// <summary> /// Initializes a new instance of the <see cref="KeyValuesCore"/> class. /// </summary> /// <param name="mutable"> /// The mutable. /// </param> /// <param name="parent"> /// The parent. /// </param> public KeyValuesCore(IKeyValuesMutable mutable, ISdmxStructure parent) : base(SdmxStructureType.GetFromEnum(SdmxStructureEnumType.KeyValues), parent) { this.values = new List<string>(); this.caseCadeList = new List<string>(); this.id = mutable.Id; this.values.AddRange(mutable.KeyValues); foreach (string value in this.values) { if (mutable.IsCascadeValue(value)) { this.caseCadeList.Add(value); } } if (mutable.TimeRange != null) { this.timeRange = new TimeRangeCore(mutable.TimeRange, this); } Validate(); }
/// <summary> /// The add key value. /// </summary> /// <param name="keyvalue"> /// The keyvalue. /// </param> public virtual void AddKeyValue(IKeyValuesMutable inputValue) { if (inputValue == null) { return; } IKeyValuesMutable foundKvm = null; foreach (IKeyValuesMutable kvm in _keyValues) { if (kvm.Id != null && kvm.Id.Equals(inputValue.Id)) { foundKvm = kvm; break; } } if (foundKvm == null) { // This id doesn't already exist so just add the KeyValuesMutable this._keyValues.Add(inputValue); } else { // A KeyValuesMutable with this id does already exist so merge the inputVlaue var q = (from x in inputValue.KeyValues select x).Distinct(); foreach (var itm in q) { foundKvm.AddValue(itm); } /*foreach (String val in inputValue.KeyValues) { foreach (String str in foundKvm.KeyValues) { if (str.Equals(val)) { break; } foundKvm.AddValue(val); } }*/ } }
/// <summary> /// The add attribute value. /// </summary> /// <param name="attvalue"> /// The attvalue. /// </param> public virtual void AddAttributeValue(IKeyValuesMutable attvalue) { this._attributeValues.Add(attvalue); }
/// <summary> /// Write Member /// </summary> /// <param name="member"> /// The MemberBean to write /// </param> /// <param name="isIncluded"> /// A value indication whether the <paramref name="member"/> is included /// </param> private void WriteMember(IKeyValuesMutable member, bool isIncluded) { if (member != null) { this.WriteStartElement(this._commonPrefix, ElementNameTable.Member); this.WriteAttribute(AttributeNameTable.isIncluded, isIncluded); this.TryToWriteElement(this._commonPrefix, ElementNameTable.ComponentRef, member.Id); foreach (string memberValue in member.KeyValues) { this.WriteMemberValue(memberValue); } this.WriteEndElement(); } }
public void AddAttribute(IKeyValuesMutable attribute) { this.attributes.Add(attribute); }
/// <summary> /// Handle Member Child Text elements /// </summary> /// <param name="parent"> /// The parent MemberValueBean object /// </param> /// <param name="localName"> /// The name of the current xml element /// </param> protected void HandleTextChildElement(IKeyValuesMutable parent, object localName) { if (NameTableCache.IsElement(localName, ElementNameTable.ComponentRef)) { parent.Id = this.Text; } }
/// <summary> /// Handle Member Child elements /// </summary> /// <param name="parent"> /// The parent MemberBean object /// </param> /// <param name="localName"> /// The name of the current xml element /// </param> /// <returns> /// The <see cref="StructureReaderBaseV20.ElementActions"/>. /// </returns> protected ElementActions HandleChildElements(IKeyValuesMutable parent, object localName) { if (NameTableCache.IsElement(localName, ElementNameTable.MemberValue)) { return this.BuildElementActions(parent.KeyValues, DoNothingComplex, this.HandleTextChildElement); } return null; }
private void PopolateKeyValue(ref IKeyValuesMutable kv) { kv = new KeyValuesMutableImpl(); kv.Id = lblComponentSelectedID.Text; foreach (ListItem li in lbTarget.Items) { kv.AddValue(li.Value); } }