/// <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); } } } }
/// <summary> /// Create a new Constrain from the <see cref="SessionQuery._queryComponentIndex"/> and optionally for the specified component /// </summary> /// <param name="currentComponent"> /// The current component. Normally this component should be belong to the AvailableComponents set. Set to null if there isn't any current component /// </param> /// <returns> /// A constrain bean /// </returns> public IContentConstraintMutableObject CreateConstraintBean(string currentComponent) { if (!this._sessionQuery.IsDataflowSet) { throw new InvalidOperationException("Dataflow is not set"); } IContentConstraintMutableObject criteria = new ContentConstraintMutableCore(); criteria.Id = currentComponent ?? "SPECIAL"; criteria.AddName("en", "english"); criteria.AgencyId = "agency"; ICubeRegionMutableObject region = new CubeRegionMutableCore(); if (currentComponent != null) { IKeyValuesMutable keyValue = new KeyValuesMutableImpl(); keyValue.Id = currentComponent; keyValue.AddValue(SpecialValues.DummyMemberValue); region.AddKeyValue(keyValue); } foreach (var queryComponent in this._sessionQuery.GetQueryComponents()) { if (queryComponent != null && !queryComponent.GetKeyFamilyComponent().ConceptRef.ChildReference.Id.Equals(currentComponent)) { var setComponents = new KeyValuesMutableImpl(); region.AddKeyValue(setComponents); setComponents.Id = queryComponent.GetKeyFamilyComponent().ConceptRef.ChildReference.Id; var dimension = queryComponent.GetKeyFamilyComponent() as IDimension; if (dimension != null && dimension.TimeDimension) { // there is another way to handle this with ReferencePeriod but // ReferencePeriod accepts {xs:Date,xs:DateTime}. Using this way, MemberValue, we can use anything we want. // must be first setComponents.KeyValues.Add(queryComponent.StartDate); if (!string.IsNullOrEmpty(queryComponent.EndDate)) { setComponents.KeyValues.Add(queryComponent.EndDate); } } else if (queryComponent.GetKeyFamilyComponent().Representation.Representation.MaintainableReference.MaintainableId != null) { // java has different API for MemberValue foreach (ICode code in queryComponent.RetrieveCodes()) { setComponents.KeyValues.Add(code.Id); } if (setComponents.KeyValues.Count == 0) { setComponents.AddValue(SpecialValues.DummyMemberValue); } } else { setComponents.KeyValues.Add(queryComponent.TextValue); } } } if (region.KeyValues.Count > 0) { criteria.IncludedCubeRegion = region; } return(criteria); }