/// <summary> /// Add relation ship to attribute /// </summary> /// <param name="dim"></param> /// <param name="basedAttributeID"></param> /// <param name="relatedAttributeID"></param> /// <param name="attributeRelationShipType"></param> /// <param name="relationShipName"></param> internal static void ADD_ATTRIBUTE_RELATIONSHIP( DB_SQLHELPER_BASE sqlHelper, Dimension dim, String basedAttributeID, String relatedAttributeID, RelationshipType attributeRelationShipType = RelationshipType.Flexible, String relationShipName = null) { DimensionAttribute attr = dim.Attributes.Find(basedAttributeID); DimensionAttribute relatedAttr = dim.Attributes.Find(relatedAttributeID); if (relationShipName == null) { relationShipName = relatedAttr.Name; } AttributeRelationship relationship = new AttributeRelationship(); relationship.Attribute = attr; relationship.Name = relationShipName; relationship.AttributeID = relatedAttributeID; if (attributeRelationShipType != null) { relationship.RelationshipType = attributeRelationShipType; } else { sqlHelper.ADD_MESSAGE_LOG( String.Format("A None RelationShipType is passed between [{0} and [{1}]", basedAttributeID, relatedAttributeID), MESSAGE_TYPE.ATTRIBUTE_RELATIONSHIP, MESSAGE_RESULT_TYPE.Warning); } if (!attr.AttributeRelationships.Contains(relatedAttributeID)) { attr.AttributeRelationships.Add(relationship); } }
private static string GetQueryToValidateRelationship(AttributeRelationship r) { DataSourceView oDSV = r.ParentDimension.DataSourceView; DataItem[] cols1 = new DataItem[r.Parent.KeyColumns.Count]; DataItem[] cols2 = new DataItem[r.Attribute.KeyColumns.Count]; for (int i = 0; i < r.Parent.KeyColumns.Count; i++) { cols1[i] = r.Parent.KeyColumns[i]; } for (int i = 0; i < r.Attribute.KeyColumns.Count; i++) { cols2[i] = r.Attribute.KeyColumns[i]; } return(GetQueryToValidateUniqueness(oDSV, cols1, cols2)); }
/// <inheritdoc/> public void AddAttributeRelationship(AttributeRelationship combination, IAttributeSystem sourceAttributeHolder) { throw new NotImplementedException(); }
private static string GetQueryToValidateRelationship(AttributeRelationship r) { DataSourceView oDSV = r.ParentDimension.DataSourceView; DataItem[] cols1 = new DataItem[r.Parent.KeyColumns.Count]; DataItem[] cols2 = new DataItem[r.Attribute.KeyColumns.Count]; for (int i = 0; i < r.Parent.KeyColumns.Count; i++) { cols1[i] = r.Parent.KeyColumns[i]; } for (int i = 0; i < r.Attribute.KeyColumns.Count; i++) { cols2[i] = r.Attribute.KeyColumns[i]; } return GetQueryToValidateUniqueness(oDSV, cols1, cols2); }
/// <summary> /// Gets the input attribute and throws an exception if it's not initialized yet. /// </summary> /// <param name="element">The element.</param> /// <returns>The input attribute definition.</returns> /// <exception cref="InvalidOperationException">TargetAttribute not initialized.</exception> public static AttributeDefinition GetInputAttribute(this AttributeRelationship element) { return(element.InputAttribute ?? throw new InvalidOperationException("InputAttribute not initialized.")); }