コード例 #1
0
        /// <summary>
        /// Returns collection of M dependency objects that hold references to the object identified by the param values (directly or chained).
        /// </summary>
        /// <param name="objectType">Type of the object to look up dependencies.</param>
        /// <param name="objectName">Name of the object to look up dependencies.</param>
        /// <returns></returns>
        public CalcDependencyCollection DependenciesReferenceTo(CalcDependencyObjectType referencedObjectType, string referencedObjectName)
        {
            CalcDependencyCollection returnVal = new CalcDependencyCollection();

            LookUpDependenciesReferenceTo(referencedObjectType, referencedObjectName, returnVal);
            return(returnVal);
        }
コード例 #2
0
        /// <summary>
        /// Returns collection of calc dependencies that the object identified by the params references (directly or indirectly).
        /// </summary>
        /// <param name="objectType">Type of the object to look up dependencies.</param>
        /// <param name="objectName">Name of the object to look up dependencies.</param>
        /// <returns></returns>
        public CalcDependencyCollection DependenciesReferenceFrom(CalcDependencyObjectType objectType, string tableName, string objectName)
        {
            CalcDependencyCollection returnVal = new CalcDependencyCollection();

            LookUpDependenciesReferenceFrom(objectType, tableName, objectName, returnVal);
            return(returnVal);
        }
コード例 #3
0
        /// <summary>
        /// Returns collection of calc dependencies that the object identified by the params references (directly or indirectly).
        /// </summary>
        /// <param name="objectType">Type of the object to look up dependencies.</param>
        /// <param name="objectName">Name of the object to look up dependencies.</param>
        /// <returns></returns>
        public CalcDependencyCollection DependenciesReferenceFrom(CalcDependencyObjectType objectType, string tableName, string objectName)
        {
            CalcDependencyCollection returnVal = new CalcDependencyCollection();

            recursionCounter = 0;
            try
            {
                LookUpDependenciesReferenceFrom(objectType, tableName, objectName, returnVal);
            }
            catch (CalcDependenciesInfiniteRecursionException)
            {   //Some M is not parsable
            }
            return(returnVal);
        }
コード例 #4
0
        private void PopulateProperties()
        {
            base.RemovePropertyFromObjectDefinition("measures");

            _isCalculationGroup   = (_tomTable.CalculationGroup != null);
            _partitionsDefinition = "";
            _dataSourceName       = "";
            bool hasMQueryOrPolicyPartition = false;

            //Associate table with a DataSource if possible. It's not possible if calc table or if M expression refers to a shared expression, or multiple data sources
            foreach (Partition partition in _tomTable.Partitions)
            {
                _tableModeType = partition.Mode;
                if (partition.SourceType == PartitionSourceType.M)
                {
                    hasMQueryOrPolicyPartition = true;

                    //Check M dependency tree to see if all partitions refer only to a single DataSource
                    CalcDependencyCollection calcDependencies = _parentTabularModel.MDependencies.DependenciesReferenceFrom(CalcDependencyObjectType.Partition, _tomTable.Name, partition.Name);

                    if (calcDependencies.Count == 1 && calcDependencies[0].ReferencedObjectType == CalcDependencyObjectType.DataSource)
                    {
                        if (_dataSourceName == "")
                        {
                            _dataSourceName = calcDependencies[0].ReferencedObjectName;
                        }
                        else if (_dataSourceName != calcDependencies[0].ReferencedObjectName)
                        {
                            //Partition depends on a different DataSource to another partition in same table, so ensure no DataSource association for the table and stop iterating partitions.
                            _dataSourceName = "";
                            break;
                        }
                    }
                    else
                    {
                        //Partition has mutiple dependencies, or depends on an expression instead of DataSource, so ensure no DataSource association for the table and stop iterating partitions.
                        _dataSourceName = "";
                        break;
                    }
                }

                //If old partition, find the primary partition (first one) to determine DataSource. Technically it is possible for different partitions in the same table to point to different DataSources, but the Tabular Designer in VS doesn't support it. If set manually in .bim file, the UI still associates with the first partition (e.g. when processing table by itself, or deletinig the DataSource gives a warning message listing associated tables).
                if (partition.SourceType == PartitionSourceType.Query)
                {
                    hasMQueryOrPolicyPartition = true;
                    _dataSourceName            = ((QueryPartitionSource)partition.Source).DataSource.Name;
                    break;
                }

                //Might be a policy partition.
                if (partition.SourceType == PartitionSourceType.PolicyRange)
                {
                    hasMQueryOrPolicyPartition = true;
                    break;
                }
            }

            if (hasMQueryOrPolicyPartition || _isCalculationGroup)
            {
                _partitionsDefinition = base.RetrievePropertyFromObjectDefinition("partitions");

                //Option to hide partitions only applies to M, query and policy partitions (calculated tables hold dax defintitions in their partitions)
                if (!_parentTabularModel.ComparisonInfo.OptionsInfo.OptionPartitions)
                {
                    base.RemovePropertyFromObjectDefinition("partitions");
                }
            }

            //Find table relationships
            foreach (Tom.Relationship relationship in _tomTable.Model.Relationships)
            {
                if (relationship.FromTable.Name == _tomTable.Name && relationship.Type == RelationshipType.SingleColumn)  //currently only support single column
                {
                    _relationships.Add(new Relationship(this, (SingleColumnRelationship)relationship));
                }
            }

            //Find measures
            foreach (Tom.Measure measure in _tomTable.Measures)
            {
                _measures.Add(new Measure(this, measure, measure.KPI != null));
            }

            //Find calc items
            if (_isCalculationGroup)
            {
                foreach (Tom.CalculationItem calcItem in _tomTable.CalculationGroup.CalculationItems)
                {
                    _calculationItems.Add(new CalculationItem(this, calcItem));
                }
            }
        }
コード例 #5
0
 private void LookUpDependenciesReferenceTo(CalcDependencyObjectType referencedObjectType, string referencedObjectName, CalcDependencyCollection returnVal)
 {
     foreach (CalcDependency calcDependency in this)
     {
         if (calcDependency.ReferencedObjectType == referencedObjectType && calcDependency.ReferencedObjectName == referencedObjectName)
         {
             LookUpDependenciesReferenceTo(calcDependency.ObjectType, calcDependency.ObjectName, returnVal);
             returnVal.Add(calcDependency);
         }
     }
 }
コード例 #6
0
 private void LookUpDependenciesReferenceFrom(CalcDependencyObjectType objectType, string tableName, string objectName, CalcDependencyCollection returnVal)
 {
     foreach (CalcDependency calcDependency in this)
     {
         if (calcDependency.ObjectType == objectType && calcDependency.TableName == tableName && calcDependency.ObjectName == objectName)
         {
             LookUpDependenciesReferenceFrom(calcDependency.ReferencedObjectType, calcDependency.ReferencedTableName, calcDependency.ReferencedObjectName, returnVal);
             returnVal.Add(calcDependency);
         }
     }
 }
コード例 #7
0
 private void LookUpDependenciesReferenceTo(CalcDependencyObjectType referencedObjectType, string referencedObjectName, string referencedTableName, CalcDependencyCollection returnVal)
 {
     foreach (CalcDependency calcDependency in this)
     {
         if (
             (calcDependency.ReferencedObjectType == referencedObjectType && referencedObjectType != CalcDependencyObjectType.Partition && calcDependency.ReferencedObjectName == referencedObjectName) ||
             (calcDependency.ReferencedObjectType == referencedObjectType && referencedObjectType == CalcDependencyObjectType.Partition && calcDependency.ReferencedTableName == referencedTableName)   //References to table-partition expressions are by table name, not partition name
             )
         {
             LookUpDependenciesReferenceTo(calcDependency.ObjectType, calcDependency.ObjectName, calcDependency.TableName, returnVal);
             returnVal.Add(calcDependency);
         }
     }
 }
コード例 #8
0
        private void LookUpDependenciesReferenceFrom(CalcDependencyObjectType objectType, string tableName, string objectName, CalcDependencyCollection returnVal)
        {
            recursionCounter++;
            if (recursionCounter >= RecursionCounterMax)
            {
                Exception infRecursion = new CalcDependenciesInfiniteRecursionException($"Calc dependencies infinite recursion detected for type \"{objectType}\", table \"{tableName}\", name \"{objectName}\".");
                Telemetry.TrackException(infRecursion);
                throw infRecursion;
            }

            foreach (CalcDependency calcDependency in this)
            {
                if (calcDependency.ObjectType == objectType && calcDependency.TableName == tableName && calcDependency.ObjectName == objectName)
                {
                    LookUpDependenciesReferenceFrom(calcDependency.ReferencedObjectType, calcDependency.ReferencedTableName, calcDependency.ReferencedObjectName, returnVal);
                    returnVal.Add(calcDependency);
                }
            }
        }