public bool ContainsOtherPerspectiveSelections()

in BismNormalizer/BismNormalizer/TabularCompare/MultidimensionalMetadata/Perspective.cs [236:398]


        public bool ContainsOtherPerspectiveSelections(Perspective otherPerspective)
        {
            bool everythingMatches = true;

            //Tables
            foreach (PerspectiveDimension otherDimension in otherPerspective.AmoPerspective.Dimensions)
            {
                bool foundDimensionMatch = false;
                foreach (PerspectiveDimension perspectiveDimension in _amoPerspective.Dimensions)
                {
                    if (perspectiveDimension.Dimension.Name == otherDimension.Dimension.Name)
                    {
                        foundDimensionMatch = true;

                        //Columns
                        foreach (PerspectiveAttribute otherAttribute in otherDimension.Attributes)
                        {
                            bool foundAttributeMatch = false;
                            foreach (PerspectiveAttribute perspectiveAttribute in perspectiveDimension.Attributes)
                            {
                                if (perspectiveAttribute.Attribute.Name == otherAttribute.Attribute.Name)
                                {
                                    foundAttributeMatch = true;
                                    break;
                                }
                            }
                            if (!foundAttributeMatch)
                            {
                                everythingMatches = false;
                                break;
                            }
                        }

                        //Hierarchies
                        foreach (PerspectiveHierarchy otherHierarchy in otherDimension.Hierarchies)
                        {
                            bool foundHierarchyMatch = false;
                            foreach (PerspectiveHierarchy perspectiveHierarchy in perspectiveDimension.Hierarchies)
                            {
                                if (perspectiveHierarchy.Hierarchy.Name == otherHierarchy.Hierarchy.Name)
                                {
                                    foundHierarchyMatch = true;
                                    break;
                                }
                            }
                            if (!foundHierarchyMatch)
                            {
                                everythingMatches = false;
                                break;
                            }
                        }

                    }
                    if (!everythingMatches) break;
                }

                if (!foundDimensionMatch)
                {
                    everythingMatches = false;
                    break;
                }
            }

            if (everythingMatches)
            {
                //Measures
                foreach (PerspectiveCalculation otherCalculation in otherPerspective.AmoPerspective.Calculations)
                {
                    string measureName = otherCalculation.Name.Replace("[Measures].[", "").Replace("]", "");
                    if (otherPerspective.ParentTabularModel.Measures.ContainsName(measureName)) // this if clause shouldn't be necessary, but it is
                    {
                        bool foundCalculationMatch = false;
                        foreach (PerspectiveCalculation perspectiveCalculation in _amoPerspective.Calculations)
                        {
                            if (perspectiveCalculation.Name == otherCalculation.Name)
                            {
                                foundCalculationMatch = true;
                                break;
                            }
                        }
                        if (!foundCalculationMatch)
                        {
                            everythingMatches = false;
                            break;
                        }
                    }
                }
            }

            if (everythingMatches)
            {
                //Kpis
                foreach (PerspectiveKpi otherKpi in otherPerspective.AmoPerspective.Kpis)
                {
                    string KpiName = otherKpi.ToString();
                    if (otherPerspective.ParentTabularModel.Kpis.ContainsName(KpiName))
                    {
                        bool foundKpiMatch = false;
                        foreach (PerspectiveKpi perspectiveKpi in _amoPerspective.Kpis)
                        {
                            if (perspectiveKpi.ToString() == otherKpi.ToString())
                            {
                                foundKpiMatch = true;
                                break;
                            }
                        }
                        if (!foundKpiMatch)
                        {
                            everythingMatches = false;
                            break;
                        }
                    }
                }
            }

            if (everythingMatches)
            {
                //Actions
                foreach (PerspectiveAction otherAction in otherPerspective.AmoPerspective.Actions)
                {
                    bool foundActionMatch = false;
                    foreach (PerspectiveAction perspectiveAction in _amoPerspective.Actions)
                    {
                        if (perspectiveAction.ParentCube.Actions.Contains(perspectiveAction.ActionID) && otherAction.ParentCube.Actions.Contains(otherAction.ActionID) &&  //need this check or .Action returns error
                            perspectiveAction.Action.Name == otherAction.Action.Name)
                        {
                            foundActionMatch = true;
                            break;
                        }
                    }
                    if (!foundActionMatch)
                    {
                        everythingMatches = false;
                        break;
                    }
                }
            }

            if (everythingMatches)
            {
                //Translations
                foreach (Translation otherTranslation in otherPerspective.AmoPerspective.Translations)
                {
                    bool foundActionMatch = false;
                    foreach (Translation perspectiveTranslation in _amoPerspective.Translations)
                    {
                        if (perspectiveTranslation.Language == otherTranslation.Language &&
                            perspectiveTranslation.Caption == otherTranslation.Caption)
                        {
                            foundActionMatch = true;
                            break;
                        }
                    }
                    if (!foundActionMatch)
                    {
                        everythingMatches = false;
                        break;
                    }
                }
            }

            return everythingMatches;
        }