예제 #1
0
        private void CheckConstraintsOnProjectedConditionMembers(Dictionary <MemberValueBinding, CellTreeNode> memberValueTrees, LeftCellWrapper wrapper, CellTreeNode sQueryTree, BoolExpression inExtentCondition)
        {
            // for S-side condition members that are projected,
            // add condition <member=value> on both sides of the mapping constraint, and check key equivalence
            // applies to columns that are (1) projected and (2) conditional
            foreach (MemberPath column in _domainMap.ConditionMembers(_viewgenContext.Extent))
            {
                // Get the slot on the C side and see if it is projected
                int index = _viewgenContext.MemberMaps.ProjectedSlotMap.IndexOf(column);
                MemberProjectedSlot slot = wrapper.RightCellQuery.ProjectedSlotAt(index) as MemberProjectedSlot;
                if (slot != null)
                {
                    foreach (Constant domainValue in _domainMap.GetDomain(column))
                    {
                        CellTreeNode sQueryTreeForDomainValue;
                        if (memberValueTrees.TryGetValue(new MemberValueBinding(column, domainValue), out sQueryTreeForDomainValue))
                        {
                            BoolExpression cWhereClause = PropagateCellConstantsToWhereClause(wrapper, wrapper.RightCellQuery.WhereClause,
                                                                                              domainValue, column, _viewgenContext.MemberMaps);
                            FragmentQuery cCombinedQuery = FragmentQuery.Create(cWhereClause);
                            CellTreeNode  sCombinedTree  = (sQueryTree == _basicView) ?
                                                           sQueryTreeForDomainValue :
                                                           new OpCellTreeNode(_viewgenContext, CellTreeOpType.IJ, sQueryTreeForDomainValue, sQueryTree);

                            BoolExpression unsatisfiedConstraint;
                            if (!CheckEquivalence(cCombinedQuery, sCombinedTree.RightFragmentQuery, inExtentCondition,
                                                  out unsatisfiedConstraint))
                            {
                                string memberLossMessage = Strings.ViewGen_CQ_DomainConstraint(slot.ToUserString());
                                ReportConstraintViolation(memberLossMessage, unsatisfiedConstraint, ViewGenErrorCode.DomainConstraintViolation,
                                                          sCombinedTree.GetLeaves().Concat(new LeftCellWrapper[] { wrapper }));
                            }
                        }
                    }
                }
            }
        }
예제 #2
0
 private void CheckConstraintsOnProjectedConditionMembers(
     Dictionary <RewritingValidator.MemberValueBinding, CellTreeNode> memberValueTrees,
     LeftCellWrapper wrapper,
     CellTreeNode sQueryTree,
     BoolExpression inExtentCondition)
 {
     foreach (MemberPath conditionMember in this._domainMap.ConditionMembers(this._viewgenContext.Extent))
     {
         int slotNum = this._viewgenContext.MemberMaps.ProjectedSlotMap.IndexOf(conditionMember);
         MemberProjectedSlot memberProjectedSlot = wrapper.RightCellQuery.ProjectedSlotAt(slotNum) as MemberProjectedSlot;
         if (memberProjectedSlot != null)
         {
             foreach (Constant constant in this._domainMap.GetDomain(conditionMember))
             {
                 CellTreeNode cellTreeNode1;
                 if (memberValueTrees.TryGetValue(new RewritingValidator.MemberValueBinding(conditionMember, constant), out cellTreeNode1))
                 {
                     FragmentQuery cQuery = FragmentQuery.Create(RewritingValidator.PropagateCellConstantsToWhereClause(wrapper, wrapper.RightCellQuery.WhereClause, constant, conditionMember, this._viewgenContext.MemberMaps));
                     CellTreeNode  cellTreeNode2;
                     if (sQueryTree != this._basicView)
                     {
                         cellTreeNode2 = (CellTreeNode) new OpCellTreeNode(this._viewgenContext, CellTreeOpType.IJ, new CellTreeNode[2]
                         {
                             cellTreeNode1,
                             sQueryTree
                         });
                     }
                     else
                     {
                         cellTreeNode2 = cellTreeNode1;
                     }
                     CellTreeNode   cellTreeNode3 = cellTreeNode2;
                     BoolExpression unsatisfiedConstraint;
                     if (!this.CheckEquivalence(cQuery, cellTreeNode3.RightFragmentQuery, inExtentCondition, out unsatisfiedConstraint))
                     {
                         this.ReportConstraintViolation(Strings.ViewGen_CQ_DomainConstraint((object)memberProjectedSlot.ToUserString()), unsatisfiedConstraint, ViewGenErrorCode.DomainConstraintViolation, cellTreeNode3.GetLeaves().Concat <LeftCellWrapper>((IEnumerable <LeftCellWrapper>) new LeftCellWrapper[1]
                         {
                             wrapper
                         }));
                     }
                 }
             }
         }
     }
 }