private bool HasRelationshipOrDefaultForDataSet(ScopeTree scopeTree, ErrorContext errorContext, IRIFReportDataScope currentScope, DataSet ourDataSet, DataSet parentDataSet, bool hasValidRelationship) { if (DataSet.AreEqualById(parentDataSet, ourDataSet)) { return(true); } if (hasValidRelationship || ourDataSet.HasDefaultRelationship(parentDataSet)) { Relationship activeRelationship = GetActiveRelationship(ourDataSet, parentDataSet); if (activeRelationship == null) { RegisterInvalidCellDataSetNameError(scopeTree, errorContext, currentScope, ourDataSet, parentDataSet); return(false); } if (activeRelationship.IsCrossJoin) { DataRegion parentDataRegion = scopeTree.GetParentDataRegion(currentScope); errorContext.Register(ProcessingErrorCode.rsInvalidIntersectionNaturalCrossJoin, Severity.Error, currentScope.DataScopeObjectType, parentDataRegion.Name, "JoinConditions", parentDataRegion.ObjectType.ToString()); return(false); } return(true); } RegisterInvalidCellDataSetNameError(scopeTree, errorContext, currentScope, ourDataSet, parentDataSet); return(false); }
internal override bool ValidateRelationships(ScopeTree scopeTree, ErrorContext errorContext, DataSet ourDataSet, ParentDataSetContainer parentDataSets, IRIFReportDataScope currentScope) { Global.Tracer.Assert(parentDataSets != null && parentDataSets.Count == 1, "LinearJoinInfo can only be used with exactly one parent data set"); m_parentDataSet = parentDataSets.ParentDataSet; if (DataSet.AreEqualById(ourDataSet, m_parentDataSet)) { return(false); } bool flag = false; if (m_relationships != null) { foreach (IdcRelationship relationship in m_relationships) { flag |= relationship.ValidateLinearRelationship(errorContext, m_parentDataSet); } } if (flag || ourDataSet.HasDefaultRelationship(m_parentDataSet)) { Relationship activeRelationship = GetActiveRelationship(ourDataSet); if (activeRelationship == null) { RegisterInvalidInnerDataSetNameError(errorContext, ourDataSet, currentScope); return(false); } if (activeRelationship.IsCrossJoin && (!activeRelationship.NaturalJoin || ScopeHasParentGroups(currentScope, scopeTree))) { errorContext.Register(ProcessingErrorCode.rsInvalidNaturalCrossJoin, Severity.Error, currentScope.DataScopeObjectType, currentScope.Name, "JoinConditions"); return(false); } return(true); } RegisterInvalidInnerDataSetNameError(errorContext, ourDataSet, currentScope); return(false); }
internal override bool ValidateRelationships(ScopeTree scopeTree, ErrorContext errorContext, DataSet ourDataSet, ParentDataSetContainer parentDataSets, IRIFReportDataScope currentScope) { Global.Tracer.Assert(parentDataSets != null, "IntersectJoinInfo can only be used with one or two parent data sets"); if (parentDataSets.Count == 1) { DataRegion parentDataRegion = scopeTree.GetParentDataRegion(currentScope); errorContext.Register(ProcessingErrorCode.rsUnexpectedCellDataSetName, Severity.Error, currentScope.DataScopeObjectType, parentDataRegion.Name, "DataSetName", parentDataRegion.ObjectType.ToString()); return(false); } if (parentDataSets.AreAllSameDataSet() && DataSet.AreEqualById(parentDataSets.RowParentDataSet, ourDataSet)) { return(false); } m_rowParentDataSet = parentDataSets.RowParentDataSet; m_columnParentDataSet = parentDataSets.ColumnParentDataSet; if (m_rowParentDataSet == null || m_columnParentDataSet == null) { return(false); } bool dataSetAlreadyHasRelationship = false; bool dataSetAlreadyHasRelationship2 = false; if (m_relationships != null) { foreach (IdcRelationship relationship in m_relationships) { if (relationship.ValidateIntersectRelationship(errorContext, currentScope, scopeTree)) { CheckRelationshipDataSetBinding(scopeTree, errorContext, currentScope, relationship, m_rowParentDataSet, ref dataSetAlreadyHasRelationship); CheckRelationshipDataSetBinding(scopeTree, errorContext, currentScope, relationship, m_columnParentDataSet, ref dataSetAlreadyHasRelationship2); continue; } return(false); } } dataSetAlreadyHasRelationship = HasRelationshipOrDefaultForDataSet(scopeTree, errorContext, currentScope, ourDataSet, m_rowParentDataSet, dataSetAlreadyHasRelationship); dataSetAlreadyHasRelationship2 = HasRelationshipOrDefaultForDataSet(scopeTree, errorContext, currentScope, ourDataSet, m_columnParentDataSet, dataSetAlreadyHasRelationship2); if (!dataSetAlreadyHasRelationship || !dataSetAlreadyHasRelationship2) { return(false); } DataRegion parentDataRegion2 = scopeTree.GetParentDataRegion(currentScope); if (ValidateCellBoundTotheSameDataSetAsParentScpoe(m_columnParentDataSet, m_rowParentDataSet, ourDataSet, parentDataRegion2.IsColumnGroupingSwitched)) { IRIFDataScope parentDataRegion3 = scopeTree.GetParentDataRegion(currentScope); IRIFDataScope parentRowScopeForIntersection = scopeTree.GetParentRowScopeForIntersection(currentScope); IRIFDataScope parentColumnScopeForIntersection = scopeTree.GetParentColumnScopeForIntersection(currentScope); if (parentDataRegion2.IsColumnGroupingSwitched) { errorContext.Register(ProcessingErrorCode.rsInvalidIntersectionNaturalJoin, Severity.Error, currentScope.DataScopeObjectType, parentDataRegion3.Name, "ParentScope", parentDataRegion3.DataScopeObjectType.ToString(), parentColumnScopeForIntersection.Name, parentRowScopeForIntersection.Name); return(false); } errorContext.Register(ProcessingErrorCode.rsInvalidIntersectionNaturalJoin, Severity.Error, currentScope.DataScopeObjectType, parentDataRegion3.Name, "ParentScope", parentDataRegion3.DataScopeObjectType.ToString(), parentRowScopeForIntersection.Name, parentColumnScopeForIntersection.Name); return(false); } return(true); }
private void CheckRelationshipDataSetBinding(ScopeTree scopeTree, ErrorContext errorContext, IRIFReportDataScope currentScope, IdcRelationship relationship, DataSet parentDataSetCandidate, ref bool dataSetAlreadyHasRelationship) { if (DataSet.AreEqualById(relationship.RelatedDataSet, parentDataSetCandidate)) { if (dataSetAlreadyHasRelationship) { IRIFDataScope parentDataRegion = scopeTree.GetParentDataRegion(currentScope); IRIFDataScope parentRowScopeForIntersection = scopeTree.GetParentRowScopeForIntersection(currentScope); IRIFDataScope parentColumnScopeForIntersection = scopeTree.GetParentColumnScopeForIntersection(currentScope); errorContext.Register(ProcessingErrorCode.rsInvalidRelationshipDuplicateParentScope, Severity.Error, currentScope.DataScopeObjectType, parentDataRegion.Name, "ParentScope", parentDataRegion.DataScopeObjectType.ToString(), parentRowScopeForIntersection.Name, parentColumnScopeForIntersection.Name); } dataSetAlreadyHasRelationship = true; } }
internal static T FindActiveRelationship <T>(List <T> relationships, DataSet parentDataSet) where T : Relationship { if (relationships != null) { foreach (T relationship in relationships) { if (DataSet.AreEqualById(relationship.RelatedDataSet, parentDataSet)) { return(relationship); } } } return(null); }
private bool ValidateCellBoundTotheSameDataSetAsParentScpoe(DataSet columnParentDataSet, DataSet rowParentDataSet, DataSet ourDataSet, bool isColumnGroupingSwitched) { if (isColumnGroupingSwitched) { if (DataSet.AreEqualById(m_rowParentDataSet, ourDataSet)) { return(GetActiveColumnRelationship(ourDataSet).NaturalJoin); } return(false); } if (DataSet.AreEqualById(m_columnParentDataSet, ourDataSet)) { return(GetActiveRowRelationship(ourDataSet).NaturalJoin); } return(false); }
private void AddGroupingFieldIndicesFromParentScope(InitializationContext context, IRIFDataScope parentScope) { Global.Tracer.Assert(parentScope.DataScopeInfo.GroupingFieldIndicesForServerAggregates != null, "Grouping fields for parent should have been captured first."); if (DataSet.AreEqualById(parentScope.DataScopeInfo.DataSet, m_dataSet)) { m_groupingFieldIndicesForServerAggregates.AddRange(parentScope.DataScopeInfo.GroupingFieldIndicesForServerAggregates); } else if (m_joinInfo == null) { Global.Tracer.Assert(context.ErrorContext.HasError, "Missing expected error."); } else { m_joinInfo.AddMappedFieldIndices(parentScope.DataScopeInfo.GroupingFieldIndicesForServerAggregates, parentScope.DataScopeInfo.DataSet, m_dataSet, m_groupingFieldIndicesForServerAggregates); } }
internal override void AddMappedFieldIndices(List <int> parentFieldIndices, DataSet parentDataSet, DataSet ourDataSet, List <int> ourFieldIndices) { Relationship relationship; if (DataSet.AreEqualById(m_rowParentDataSet, parentDataSet)) { relationship = GetActiveRowRelationship(ourDataSet); } else if (DataSet.AreEqualById(m_columnParentDataSet, parentDataSet)) { relationship = GetActiveColumnRelationship(ourDataSet); } else { Global.Tracer.Assert(condition: false, "Invalid parent data set"); relationship = null; } JoinInfo.AddMappedFieldIndices(relationship, parentFieldIndices, ourFieldIndices); }
private void DetermineDataPipelineID(IRIFReportDataScope scope) { if (scope.DataScopeInfo.DataSet == null) { return; } DataSet dataSet = scope.DataScopeInfo.DataSet; int dataPipelineID; if (!scope.DataScopeInfo.NeedsIDC) { dataPipelineID = (((!m_tree.IsIntersectionScope(scope)) ? m_tree.GetParentScope(scope) : m_tree.GetParentRowScopeForIntersection(scope))?.DataScopeInfo.DataPipelineID ?? dataSet.IndexInCollection); } else if (m_tree.IsIntersectionScope(scope)) { if (DataSet.AreEqualById(dataSet, m_tree.GetParentRowScopeForIntersection(scope).DataScopeInfo.DataSet) || DataSet.AreEqualById(dataSet, m_tree.GetParentColumnScopeForIntersection(scope).DataScopeInfo.DataSet)) { IRIFDataScope canonicalCellScope = m_tree.GetCanonicalCellScope(scope); if (ScopeTree.SameScope(scope, canonicalCellScope)) { dataPipelineID = m_nextDataPipelineId; m_nextDataPipelineId++; } else { dataPipelineID = canonicalCellScope.DataScopeInfo.DataPipelineID; } } else { dataPipelineID = dataSet.IndexInCollection; } } else { dataPipelineID = dataSet.IndexInCollection; } scope.DataScopeInfo.DataPipelineID = dataPipelineID; }
internal void ValidateDataSetBindingAndRelationships(ScopeTree scopeTree, IRIFReportDataScope scope, ErrorContext errorContext) { if (m_dataSet != null) { return; } ParentDataSetContainer parentDataSetContainer = DetermineParentDataSets(scopeTree, scope); if (m_dataSetName == null) { BindToParentDataSet(scopeTree, scope, errorContext, parentDataSetContainer); } else { BindToNamedDataSet(scopeTree, scope, errorContext, parentDataSetContainer); } if (m_dataSet == null) { return; } if (scopeTree.GetParentDataRegion(scope) == null && m_joinInfo != null) { errorContext.Register(ProcessingErrorCode.rsInvalidRelationshipTopLevelDataRegion, Severity.Error, scope.DataScopeObjectType, scope.Name, "Relationship"); m_joinInfo = null; } if (parentDataSetContainer != null && m_joinInfo == null) { if (parentDataSetContainer.Count == 1) { m_joinInfo = new LinearJoinInfo(); } else { m_joinInfo = new IntersectJoinInfo(); } } if (m_joinInfo != null) { if (!m_joinInfo.ValidateRelationships(scopeTree, errorContext, m_dataSet, parentDataSetContainer, scope)) { m_joinInfo = null; } if (m_joinInfo == null && m_dataSetName != null && m_dataSet != null && !DataSet.AreEqualById(parentDataSetContainer.ParentDataSet, m_dataSet)) { UpdateDataSet(parentDataSetContainer.ParentDataSet, scope); } } }
internal override void AddMappedFieldIndices(List <int> parentFieldIndices, DataSet parentDataSet, DataSet ourDataSet, List <int> ourFieldIndices) { Global.Tracer.Assert(DataSet.AreEqualById(m_parentDataSet, parentDataSet), "Invalid parent data set"); JoinInfo.AddMappedFieldIndices(GetActiveRelationship(ourDataSet), parentFieldIndices, ourFieldIndices); }