Ejemplo n.º 1
0
        // effects: Align the fields of each cell in mapping using projectedSlotMap that has a mapping
        // for each member of this extent to the slot number of that member in the projected slots
        // example:
        //    input:  Proj[A,B,"5"] = Proj[F,"7",G]
        //            Proj[C,B]     = Proj[H,I]
        //   output:  m_projectedSlotMap: A -> 0, B -> 1, C -> 2
        //            Proj[A,B,null] = Proj[F,"7",null]
        //            Proj[null,B,C] = Proj[null,I,H]
        private static List <Cell> AlignFields(
            IEnumerable <Cell> cells, MemberProjectionIndex projectedSlotMap,
            ViewTarget viewTarget)
        {
            var outputCells = new List <Cell>();

            // Determine the aligned field for each cell
            // The new cells have ProjectedSlotMap.Count number of fields
            foreach (var cell in cells)
            {
                // If isQueryView is true, we need to consider the C side of
                // the cells; otherwise, we look at the S side. Note that we
                // CANNOT use cell.LeftQuery since that is determined by
                // cell's isQueryView

                // The query for which we are constructing the extent
                var mainQuery  = cell.GetLeftQuery(viewTarget);
                var otherQuery = cell.GetRightQuery(viewTarget);

                CellQuery newMainQuery;
                CellQuery newOtherQuery;
                // Create both queries where the projected slot map is used
                // to determine the order of the fields of the mainquery (of
                // course, the otherQuery's fields are aligned automatically)
                mainQuery.CreateFieldAlignedCellQueries(
                    otherQuery, projectedSlotMap,
                    out newMainQuery, out newOtherQuery);

                var outputCell = viewTarget == ViewTarget.QueryView
                                     ? Cell.CreateCS(newMainQuery, newOtherQuery, cell.CellLabel, cell.CellNumber)
                                     : Cell.CreateCS(newOtherQuery, newMainQuery, cell.CellLabel, cell.CellNumber);
                outputCells.Add(outputCell);
            }
            return(outputCells);
        }
 private static bool IsMemberPartOfNotNullCondition(
     IEnumerable <LeftCellWrapper> wrappers,
     MemberPath leftMember,
     ViewTarget viewTarget)
 {
     foreach (LeftCellWrapper wrapper in wrappers)
     {
         CellQuery leftQuery = wrapper.OnlyInputCell.GetLeftQuery(viewTarget);
         if (ErrorPatternMatcher.HasNotNullCondition(leftQuery, leftMember))
         {
             return(true);
         }
         CellQuery rightQuery = wrapper.OnlyInputCell.GetRightQuery(viewTarget);
         int       slotNum    = leftQuery.GetProjectedMembers().TakeWhile <MemberPath>((Func <MemberPath, bool>)(path => !path.Equals(leftMember))).Count <MemberPath>();
         if (slotNum < leftQuery.GetProjectedMembers().Count <MemberPath>())
         {
             MemberPath memberPath = ((MemberProjectedSlot)rightQuery.ProjectedSlotAt(slotNum)).MemberPath;
             if (ErrorPatternMatcher.HasNotNullCondition(rightQuery, memberPath))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
        protected override void OnResume()
        {
            base.OnResume();
            if (prefs.GetBoolean("FirstRun", true))
            {
                var vt_btnTutor = new ViewTarget(Resource.Id.btnTutor, this);
                ShowcaseView.ConfigOptions config = new ShowcaseView.ConfigOptions();
                config.IsOneShot  = false;
                config.ShowcaseId = 0;
                ShowcaseView showcaseView_btnTutor = ShowcaseView.InsertShowcaseView(vt_btnTutor, this,
                                                                                     "Tutorial", "Use this section to train by playing a series of notes.", config);

                var vt_btnTuner = new ViewTarget(Resource.Id.btnTuner, this);
                config.ShowcaseId = 1;
                ShowcaseView showcaseView_btnTuner = ShowcaseView.InsertShowcaseView(vt_btnTuner, this,
                                                                                     "Tuner", "Use this to tune your guitar.", config);

                /*NoneOnShowcaseEventListener nosel = new NoneOnShowcaseEventListener();
                 * nosel.OnShowcaseViewDidHide(showcaseView_btnTuner);
                 * showcaseView_btnTutor.SetOnShowcaseEventListener(nosel);*/


                showcaseView_btnTutor.Show();

                prefs.Edit().PutBoolean("FirstRun", false).Commit();
            }
        }
Ejemplo n.º 4
0
 internal LeftCellWrapper(
     ViewTarget viewTarget, Set <MemberPath> attrs,
     FragmentQuery fragmentQuery,
     CellQuery leftCellQuery, CellQuery rightCellQuery, MemberMaps memberMaps, Cell inputCell)
     : this(viewTarget, attrs, fragmentQuery, leftCellQuery, rightCellQuery, memberMaps, Enumerable.Repeat(inputCell, 1))
 {
 }
Ejemplo n.º 5
0
        // effects: Shrinks the domain of members whose types can be enumerated - currently it applies
        // only to boolean type as for enums we don't restrict enum values to specified members only.
        // For example NOT(False, True, Null) for a boolean domain should be removed
        internal void ReduceEnumerableDomainToEnumeratedValues(ViewTarget target, ConfigViewGenerator config)
        {
            // Go through the two maps

            ReduceEnumerableDomainToEnumeratedValues(target, m_conditionDomainMap, config, m_edmItemCollection);
            ReduceEnumerableDomainToEnumeratedValues(target, m_nonConditionDomainMap, config, m_edmItemCollection);
        }
Ejemplo n.º 6
0
        private static bool IsMemberPartOfNotNullCondition(
            IEnumerable <LeftCellWrapper> wrappers, MemberPath leftMember, ViewTarget viewTarget)
        {
            foreach (var leftCellWrapper in wrappers)
            {
                var leftCellQuery = leftCellWrapper.OnlyInputCell.GetLeftQuery(viewTarget);

                if (HasNotNullCondition(leftCellQuery, leftMember))
                {
                    return(true);
                }

                //Now figure out corresponding right side MemberPath
                var rightCellQuery            = leftCellWrapper.OnlyInputCell.GetRightQuery(viewTarget);
                var indexOfMemberInProjection = leftCellQuery.GetProjectedMembers().TakeWhile(path => !path.Equals(leftMember)).Count();

                //Member with condition is projected, so check opposite CellQuery's condition
                if (indexOfMemberInProjection < leftCellQuery.GetProjectedMembers().Count())
                {
                    var rightmember = ((MemberProjectedSlot)rightCellQuery.ProjectedSlotAt(indexOfMemberInProjection)).MemberPath;

                    if (HasNotNullCondition(rightCellQuery, rightmember))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Ejemplo n.º 7
0
        // effects: Given the cells for the extent (extentCells) along with
        // the signatures (multiconstants + needed attributes) for this extent, generates
        // the left cell wrappers for it extent (viewTarget indicates whether
        // the view is for querying or update purposes
        // Modifies m_cellWrappers to contain this list
        private bool CreateLeftCellWrappers(IList <Cell> extentCells, ViewTarget viewTarget)
        {
            var alignedCells = AlignFields(extentCells, m_memberMaps.ProjectedSlotMap, viewTarget);

            Debug.Assert(alignedCells.Count == extentCells.Count, "Cell counts disagree");

            // Go through all the cells and create cell wrappers that can be used for generating the view
            m_cellWrappers = new List <LeftCellWrapper>();

            for (var i = 0; i < alignedCells.Count; i++)
            {
                var alignedCell = alignedCells[i];
                var left        = alignedCell.GetLeftQuery(viewTarget);
                var right       = alignedCell.GetRightQuery(viewTarget);

                // Obtain the non-null projected slots into attributes
                var attributes = left.GetNonNullSlots();

                var fromVariable = BoolExpression.CreateLiteral(
                    new CellIdBoolean(m_identifiers, extentCells[i].CellNumber), m_memberMaps.LeftDomainMap);
                var leftFragmentQuery = FragmentQuery.Create(fromVariable, left);

                if (viewTarget == ViewTarget.UpdateView)
                {
                    leftFragmentQuery = m_leftFragmentQP.CreateDerivedViewBySelectingConstantAttributes(leftFragmentQuery)
                                        ?? leftFragmentQuery;
                }

                var leftWrapper = new LeftCellWrapper(
                    m_viewTarget, attributes, leftFragmentQuery, left, right, m_memberMaps,
                    extentCells[i]);
                m_cellWrappers.Add(leftWrapper);
            }
            return(true);
        }
Ejemplo n.º 8
0
        private QueryRewriter GenerateDirectionalViewsForExtent(
            ViewTarget viewTarget,
            EntitySetBase extent,
            CqlIdentifiers identifiers,
            KeyToListMap <EntitySetBase, GeneratedView> views)
        {
            ViewgenContext viewgenContext = this.CreateViewgenContext(extent, viewTarget, identifiers);
            QueryRewriter  queryRewriter  = (QueryRewriter)null;

            if (this.m_config.GenerateViewsForEachType)
            {
                foreach (EdmType generatedType in MetadataHelper.GetTypeAndSubtypesOf((EdmType)extent.ElementType, (ItemCollection)this.m_entityContainerMapping.StorageMappingItemCollection.EdmItemCollection, false))
                {
                    if (this.m_config.IsViewTracing && !generatedType.Equals((object)extent.ElementType))
                    {
                        Helpers.FormatTraceLine("CQL View for {0} and type {1}", (object)extent.Name, (object)generatedType.Name);
                    }
                    queryRewriter = this.GenerateViewsForExtentAndType(generatedType, viewgenContext, identifiers, views, ViewGenMode.OfTypeViews);
                }
            }
            else
            {
                queryRewriter = this.GenerateViewsForExtentAndType((EdmType)extent.ElementType, viewgenContext, identifiers, views, ViewGenMode.OfTypeViews);
            }
            if (viewTarget == ViewTarget.QueryView)
            {
                this.m_config.SetTimeForFinishedActivity(PerfType.QueryViews);
            }
            else
            {
                this.m_config.SetTimeForFinishedActivity(PerfType.UpdateViews);
            }
            this.m_queryRewriterCache[extent] = queryRewriter;
            return(queryRewriter);
        }
Ejemplo n.º 9
0
        // requires: schema refers to C-side or S-side schema for the cells
        // inside this. if schema.IsQueryView is true, the left side of cells refers
        // to the C side (and vice-versa for the right side)
        // effects: Generates the relevant views for the schema side and
        // returns them. If allowMissingAttributes is true and attributes
        // are missing on the schema side, substitutes them with NULL
        // Modifies views to contain the generated views for different
        // extents specified by cells and the schemaContext
        private ErrorLog GenerateDirectionalViews(ViewTarget viewTarget, CqlIdentifiers identifiers, ViewSet views)
        {
            var isQueryView = viewTarget == ViewTarget.QueryView;

            // Partition cells by extent.
            var extentCellMap = GroupCellsByExtent(m_cellGroup, viewTarget);

            // Keep track of the mapping exceptions that we have generated
            var errorLog = new ErrorLog();

            // Generate views for each extent
            foreach (var extent in extentCellMap.Keys)
            {
                if (m_config.IsViewTracing)
                {
                    Helpers.StringTraceLine(String.Empty);
                    Helpers.StringTraceLine(String.Empty);
                    Helpers.FormatTraceLine(
                        "================= Generating {0} View for: {1} ===========================",
                        isQueryView ? "Query" : "Update", extent.Name);
                    Helpers.StringTraceLine(String.Empty);
                    Helpers.StringTraceLine(String.Empty);
                }
                try
                {
                    // (1) view generation (checks that extents are fully mapped)
                    var queryRewriter = GenerateDirectionalViewsForExtent(viewTarget, extent, identifiers, views);

                    // (2) validation for update views
                    if (viewTarget == ViewTarget.UpdateView
                        &&
                        m_config.IsValidationEnabled)
                    {
                        if (m_config.IsViewTracing)
                        {
                            Helpers.StringTraceLine(String.Empty);
                            Helpers.StringTraceLine(String.Empty);
                            Helpers.FormatTraceLine(
                                "----------------- Validation for generated update view for: {0} -----------------",
                                extent.Name);
                            Helpers.StringTraceLine(String.Empty);
                            Helpers.StringTraceLine(String.Empty);
                        }

                        var validator = new RewritingValidator(queryRewriter.ViewgenContext, queryRewriter.BasicView);
                        validator.Validate();
                    }
                }
                catch (InternalMappingException exception)
                {
                    // All exceptions have mapping errors in them
                    Debug.Assert(
                        exception.ErrorLog.Count > 0,
                        "Incorrectly created mapping exception");
                    errorLog.Merge(exception.ErrorLog);
                }
            }
            return(errorLog);
        }
Ejemplo n.º 10
0
 internal CellQuery GetRightQuery(ViewTarget side)
 {
     if (side != ViewTarget.QueryView)
     {
         return(this.m_cQuery);
     }
     return(this.m_sQuery);
 }
        private Frame GetTargetFrame(ViewTarget target)
        {
            _lastTarget = target;
            if (target == ViewTarget.MainFrame)
            {
                return((Frame)Window.Current.Content);
            }

            return(_subFrame);
        }
        internal MemberDomainMap(
            ViewTarget viewTarget,
            bool isValidationEnabled,
            IEnumerable <Cell> extentCells,
            EdmItemCollection edmItemCollection,
            ConfigViewGenerator config,
            Dictionary <EntityType, Set <EntityType> > inheritanceGraph)
        {
            this.m_conditionDomainMap = new Dictionary <MemberPath, Set <Constant> >(MemberPath.EqualityComparer);
            this.m_edmItemCollection  = edmItemCollection;
            Dictionary <MemberPath, Set <Constant> > dictionary = viewTarget != ViewTarget.UpdateView ? Domain.ComputeConstantDomainSetsForSlotsInQueryViews(extentCells, this.m_edmItemCollection, isValidationEnabled) : Domain.ComputeConstantDomainSetsForSlotsInUpdateViews(extentCells, this.m_edmItemCollection);

            foreach (Cell extentCell in extentCells)
            {
                foreach (MemberRestriction memberRestriction in extentCell.GetLeftQuery(viewTarget).GetConjunctsFromWhereClause())
                {
                    MemberPath     memberPath = memberRestriction.RestrictedMemberSlot.MemberPath;
                    Set <Constant> set;
                    if (!dictionary.TryGetValue(memberPath, out set))
                    {
                        set = Domain.DeriveDomainFromMemberPath(memberPath, edmItemCollection, isValidationEnabled);
                    }
                    if (set.Contains(Constant.Null) || !memberRestriction.Domain.Values.All <Constant>((Func <Constant, bool>)(conditionConstant => conditionConstant.Equals((object)Constant.NotNull))))
                    {
                        if (set.Count <= 0 || !set.Contains(Constant.Null) && memberRestriction.Domain.Values.Contains <Constant>(Constant.Null))
                        {
                            ExceptionHelpers.ThrowMappingException(new ErrorLog.Record(ViewGenErrorCode.InvalidCondition, Strings.ViewGen_InvalidCondition((object)memberPath.PathToString(new bool?(false))), extentCell, string.Empty), config);
                        }
                        if (!memberPath.IsAlwaysDefined(inheritanceGraph))
                        {
                            set.Add(Constant.Undefined);
                        }
                        this.AddToDomainMap(memberPath, (IEnumerable <Constant>)set);
                    }
                }
            }
            this.m_nonConditionDomainMap = new Dictionary <MemberPath, Set <Constant> >(MemberPath.EqualityComparer);
            foreach (Cell extentCell in extentCells)
            {
                foreach (MemberProjectedSlot allQuerySlot in extentCell.GetLeftQuery(viewTarget).GetAllQuerySlots())
                {
                    MemberPath memberPath = allQuerySlot.MemberPath;
                    if (!this.m_conditionDomainMap.ContainsKey(memberPath) && !this.m_nonConditionDomainMap.ContainsKey(memberPath))
                    {
                        Set <Constant> set = Domain.DeriveDomainFromMemberPath(memberPath, this.m_edmItemCollection, true);
                        if (!memberPath.IsAlwaysDefined(inheritanceGraph))
                        {
                            set.Add(Constant.Undefined);
                        }
                        Set <Constant> iconstants = Domain.ExpandNegationsInDomain((IEnumerable <Constant>)set, (IEnumerable <Constant>)set);
                        this.m_nonConditionDomainMap.Add(memberPath, (Set <Constant>) new MemberDomainMap.CellConstantSetInfo(iconstants));
                    }
                }
            }
        }
Ejemplo n.º 13
0
        // requires: The Where clause satisfies the same requirements a GetConjunctsFromWhereClause
        // effects: For each slot that has a NotNull condition in the where
        // clause, checks if it is projected. If all such slots are
        // projected, returns null. Else returns an error record
        internal ErrorLog.Record CheckForProjectedNotNullSlots(Cell sourceCell, IEnumerable <Cell> associationSets)
        {
            StringBuilder builder    = new StringBuilder();
            bool          foundError = false;

            foreach (MemberRestriction restriction in Conditions)
            {
                if (restriction.Domain.ContainsNotNull())
                {
                    MemberProjectedSlot slot = MemberProjectedSlot.GetSlotForMember(m_projectedSlots, restriction.RestrictedMemberSlot.MemberPath);
                    if (slot == null) //member with not null condition is not mapped in this extent
                    {
                        bool missingMapping = true;
                        if (Extent is EntitySet)
                        {
                            bool       isCQuery       = sourceCell.CQuery == this;
                            ViewTarget target         = isCQuery ? ViewTarget.QueryView : ViewTarget.UpdateView;
                            CellQuery  rightCellQuery = isCQuery? sourceCell.SQuery : sourceCell.CQuery;

                            //Find out if there is an association mapping but only if the current Not Null condition is on an EntitySet
                            EntitySet rightExtent = rightCellQuery.Extent as EntitySet;
                            if (rightExtent != null)
                            {
                                List <AssociationSet> associations = MetadataHelper.GetAssociationsForEntitySet(rightCellQuery.Extent as EntitySet);
                                foreach (var association in associations.Where(association => association.AssociationSetEnds.Any(end => (end.CorrespondingAssociationEndMember.RelationshipMultiplicity == RelationshipMultiplicity.One &&
                                                                                                                                         (MetadataHelper.GetOppositeEnd(end).EntitySet.EdmEquals(rightExtent))))))
                                {
                                    foreach (var associationCell in associationSets.Where(c => c.GetRightQuery(target).Extent.EdmEquals(association)))
                                    {
                                        if (MemberProjectedSlot.GetSlotForMember(associationCell.GetLeftQuery(target).ProjectedSlots, restriction.RestrictedMemberSlot.MemberPath) != null)
                                        {
                                            missingMapping = false;
                                        }
                                    }
                                }
                            }
                        }

                        if (missingMapping)
                        {
                            // condition of NotNull and slot not being projected
                            builder.AppendLine(System.Data.Entity.Strings.ViewGen_NotNull_No_Projected_Slot(
                                                   restriction.RestrictedMemberSlot.MemberPath.PathToString(false)));
                            foundError = true;
                        }
                    }
                }
            }
            if (false == foundError)
            {
                return(null);
            }
            ErrorLog.Record record = new ErrorLog.Record(true, ViewGenErrorCode.NotNullNoProjectedSlot, builder.ToString(), sourceCell, String.Empty);
            return(record);
        }
Ejemplo n.º 14
0
 internal MemberMaps(
     ViewTarget viewTarget,
     MemberProjectionIndex projectedSlotMap,
     MemberDomainMap queryDomainMap,
     MemberDomainMap updateDomainMap)
 {
     this.m_projectedSlotMap = projectedSlotMap;
     this.m_queryDomainMap   = queryDomainMap;
     this.m_updateDomainMap  = updateDomainMap;
     this.m_viewTarget       = viewTarget;
 }
Ejemplo n.º 15
0
        internal MemberMaps(ViewTarget viewTarget, MemberProjectionIndex projectedSlotMap,
                            MemberDomainMap queryDomainMap, MemberDomainMap updateDomainMap)
        {
            m_projectedSlotMap = projectedSlotMap;
            m_queryDomainMap   = queryDomainMap;
            m_updateDomainMap  = updateDomainMap;

            Debug.Assert(m_queryDomainMap != null);
            Debug.Assert(m_updateDomainMap != null);
            Debug.Assert(m_projectedSlotMap != null);
            m_viewTarget = viewTarget;
        }
        internal ViewgenContext(
            ViewTarget viewTarget,
            EntitySetBase extent,
            IList <Cell> extentCells,
            CqlIdentifiers identifiers,
            ConfigViewGenerator config,
            MemberDomainMap queryDomainMap,
            MemberDomainMap updateDomainMap,
            EntityContainerMapping entityContainerMapping)
        {
            foreach (Cell extentCell in (IEnumerable <Cell>)extentCells)
            {
                ;
            }
            this.m_extent                 = extent;
            this.m_viewTarget             = viewTarget;
            this.m_config                 = config;
            this.m_edmItemCollection      = entityContainerMapping.StorageMappingItemCollection.EdmItemCollection;
            this.m_entityContainerMapping = entityContainerMapping;
            this.m_identifiers            = identifiers;
            updateDomainMap               = updateDomainMap.MakeCopy();
            MemberDomainMap domainMap = viewTarget == ViewTarget.QueryView ? queryDomainMap : updateDomainMap;

            this.m_memberMaps = new MemberMaps(viewTarget, MemberProjectionIndex.Create(extent, this.m_edmItemCollection), queryDomainMap, updateDomainMap);
            FragmentQueryKBChaseSupport kb1 = new FragmentQueryKBChaseSupport();

            kb1.CreateVariableConstraints(extent, domainMap, this.m_edmItemCollection);
            this.m_leftFragmentQP = new FragmentQueryProcessor(kb1);
            this.m_rewritingCache = new Dictionary <FragmentQuery, Tile <FragmentQuery> >(FragmentQuery.GetEqualityComparer(this.m_leftFragmentQP));
            if (!this.CreateLeftCellWrappers(extentCells, viewTarget))
            {
                return;
            }
            FragmentQueryKBChaseSupport kb2             = new FragmentQueryKBChaseSupport();
            MemberDomainMap             memberDomainMap = viewTarget == ViewTarget.QueryView ? updateDomainMap : queryDomainMap;

            foreach (LeftCellWrapper cellWrapper in this.m_cellWrappers)
            {
                EntitySetBase rightExtent = cellWrapper.RightExtent;
                kb2.CreateVariableConstraints(rightExtent, memberDomainMap, this.m_edmItemCollection);
                kb2.CreateAssociationConstraints(rightExtent, memberDomainMap, this.m_edmItemCollection);
            }
            if (this.m_viewTarget == ViewTarget.UpdateView)
            {
                this.CreateConstraintsForForeignKeyAssociationsAffectingThisWrapper((FragmentQueryKB)kb2, memberDomainMap);
            }
            this.m_rightFragmentQP = new FragmentQueryProcessor(kb2);
            if (this.m_viewTarget == ViewTarget.QueryView)
            {
                this.CheckConcurrencyControlTokens();
            }
            this.m_cellWrappers.Sort(LeftCellWrapper.Comparer);
        }
        internal ErrorLog.Record CheckForProjectedNotNullSlots(
            Cell sourceCell,
            IEnumerable <Cell> associationSets)
        {
            StringBuilder stringBuilder = new StringBuilder();
            bool          flag1         = false;

            foreach (MemberRestriction condition in this.Conditions)
            {
                if (condition.Domain.ContainsNotNull() && MemberProjectedSlot.GetSlotForMember((IEnumerable <ProjectedSlot>) this.m_projectedSlots, condition.RestrictedMemberSlot.MemberPath) == null)
                {
                    bool flag2 = true;
                    if (this.Extent is EntitySet)
                    {
                        bool       flag3       = sourceCell.CQuery == this;
                        ViewTarget target      = flag3 ? ViewTarget.QueryView : ViewTarget.UpdateView;
                        CellQuery  cellQuery   = flag3 ? sourceCell.SQuery : sourceCell.CQuery;
                        EntitySet  rightExtent = cellQuery.Extent as EntitySet;
                        if (rightExtent != null)
                        {
                            foreach (AssociationSet associationSet in MetadataHelper.GetAssociationsForEntitySet((EntitySetBase)(cellQuery.Extent as EntitySet)).Where <AssociationSet>((Func <AssociationSet, bool>)(association => association.AssociationSetEnds.Any <AssociationSetEnd>((Func <AssociationSetEnd, bool>)(end =>
                            {
                                if (end.CorrespondingAssociationEndMember.RelationshipMultiplicity == RelationshipMultiplicity.One)
                                {
                                    return(MetadataHelper.GetOppositeEnd(end).EntitySet.EdmEquals((MetadataItem)rightExtent));
                                }
                                return(false);
                            })))))
                            {
                                AssociationSet association = associationSet;
                                foreach (Cell cell in associationSets.Where <Cell>((Func <Cell, bool>)(c => c.GetRightQuery(target).Extent.EdmEquals((MetadataItem)association))))
                                {
                                    if (MemberProjectedSlot.GetSlotForMember((IEnumerable <ProjectedSlot>)cell.GetLeftQuery(target).ProjectedSlots, condition.RestrictedMemberSlot.MemberPath) != null)
                                    {
                                        flag2 = false;
                                    }
                                }
                            }
                        }
                    }
                    if (flag2)
                    {
                        stringBuilder.AppendLine(Strings.ViewGen_NotNull_No_Projected_Slot((object)condition.RestrictedMemberSlot.MemberPath.PathToString(new bool?(false))));
                        flag1 = true;
                    }
                }
            }
            if (!flag1)
            {
                return((ErrorLog.Record)null);
            }
            return(new ErrorLog.Record(ViewGenErrorCode.NotNullNoProjectedSlot, stringBuilder.ToString(), sourceCell, string.Empty));
        }
Ejemplo n.º 18
0
 // effects: Creates a LeftCellWrapper of the form:
 // Project[attrs] (Select[var IN {domain}] (Extent)) = cellquery
 // memberMaps is the set of maps used for producing the query or update views
 internal LeftCellWrapper(ViewTarget viewTarget, Set <MemberPath> attrs,
                          FragmentQuery fragmentQuery,
                          CellQuery leftCellQuery, CellQuery rightCellQuery, MemberMaps memberMaps, IEnumerable <Cell> inputCells)
 {
     m_leftFragmentQuery = fragmentQuery;
     m_rightCellQuery    = rightCellQuery;
     m_leftCellQuery     = leftCellQuery;
     m_attributes        = attrs;
     m_viewTarget        = viewTarget;
     m_memberMaps        = memberMaps;
     m_mergedCells       = new HashSet <Cell>(inputCells);
 }
Ejemplo n.º 19
0
        private static KeyToListMap <EntitySetBase, Cell> GroupCellsByExtent(
            IEnumerable <Cell> cells,
            ViewTarget viewTarget)
        {
            KeyToListMap <EntitySetBase, Cell> keyToListMap = new KeyToListMap <EntitySetBase, Cell>((IEqualityComparer <EntitySetBase>)EqualityComparer <EntitySetBase> .Default);

            foreach (Cell cell in cells)
            {
                CellQuery leftQuery = cell.GetLeftQuery(viewTarget);
                keyToListMap.Add(leftQuery.Extent, cell);
            }
            return(keyToListMap);
        }
Ejemplo n.º 20
0
        internal MemberMaps(ViewTarget viewTarget, MemberProjectionIndex projectedSlotMap,
                            MemberDomainMap queryDomainMap, MemberDomainMap updateDomainMap)
        {

            m_projectedSlotMap = projectedSlotMap;
            m_queryDomainMap = queryDomainMap;
            m_updateDomainMap = updateDomainMap;

            Debug.Assert(m_queryDomainMap != null);
            Debug.Assert(m_updateDomainMap != null);
            Debug.Assert(m_projectedSlotMap != null);
            m_viewTarget = viewTarget;
        }
Ejemplo n.º 21
0
        private ViewgenContext CreateViewgenContext(
            EntitySetBase extent,
            ViewTarget viewTarget,
            CqlIdentifiers identifiers)
        {
            QueryRewriter queryRewriter;

            if (this.m_queryRewriterCache.TryGetValue(extent, out queryRewriter))
            {
                return(queryRewriter.ViewgenContext);
            }
            List <Cell> list = this.m_cellGroup.Where <Cell>((Func <Cell, bool>)(c => c.GetLeftQuery(viewTarget).Extent == extent)).ToList <Cell>();

            return(new ViewgenContext(viewTarget, extent, (IList <Cell>)list, identifiers, this.m_config, this.m_queryDomainMap, this.m_updateDomainMap, this.m_entityContainerMapping));
        }
        // effects: Returns a context corresponding to extent (if one does not exist, creates one)
        private ViewgenContext CreateViewgenContext(EntitySetBase extent, ViewTarget viewTarget, CqlIdentifiers identifiers)
        {
            QueryRewriter queryRewriter;

            if (!m_queryRewriterCache.TryGetValue(extent, out queryRewriter))
            {
                // collect the cells that belong to this extent (just a few of them since we segment the mapping first)
                var cellsForExtent = m_cellGroup.Where(c => c.GetLeftQuery(viewTarget).Extent == extent);

                return(new ViewgenContext(viewTarget, extent, cellsForExtent, identifiers, m_config, m_queryDomainMap, m_updateDomainMap, m_entityContainerMapping));
            }
            else
            {
                return(queryRewriter.ViewgenContext);
            }
        }
Ejemplo n.º 23
0
        private void SearchShipData(ViewTarget target)
        {
            Cursor = Cursors.Wait;
            try
            {
                _shipDataGridItemsSource.Clear();

                using (var entities = new FleetManagerDataEntities())
                {
                    var newList = new ObservableCollection <ShipDataModel>();

                    switch (target)
                    {
                    case ViewTarget.Possession:
                        foreach (var ship in entities.ViewPossessionShips.OrderBy(s => s.ShipBaseCode + s.Grade.ToString()))
                        {
                            var model = Mapper.Map <ViewPossessionShips, ShipDataModel>(ship);
                            newList.Add(model);
                        }
                        break;

                    case ViewTarget.NotPossession:
                        foreach (var ship in entities.ViewNotPossessionShips.OrderBy(s => s.ShipBaseCode + s.Grade.ToString()))
                        {
                            var model = Mapper.Map <ViewNotPossessionShips, ShipDataModel>(ship);
                            newList.Add(model);
                        }
                        break;

                    case ViewTarget.All:
                        foreach (var ship in entities.ViewAllShips.OrderBy(s => s.ShipBaseCode + s.Grade.ToString()))
                        {
                            var model = Mapper.Map <ViewAllShips, ShipDataModel>(ship);
                            newList.Add(model);
                        }
                        break;
                    }

                    ShipDataGridItemsSource = newList;
                }
            }
            finally
            {
                Cursor = null;
            }
        }
        private static List <Cell> AlignFields(
            IEnumerable <Cell> cells,
            MemberProjectionIndex projectedSlotMap,
            ViewTarget viewTarget)
        {
            List <Cell> cellList = new List <Cell>();

            foreach (Cell cell1 in cells)
            {
                CellQuery newMainQuery;
                CellQuery newOtherQuery;
                cell1.GetLeftQuery(viewTarget).CreateFieldAlignedCellQueries(cell1.GetRightQuery(viewTarget), projectedSlotMap, out newMainQuery, out newOtherQuery);
                Cell cell2 = viewTarget == ViewTarget.QueryView ? Cell.CreateCS(newMainQuery, newOtherQuery, cell1.CellLabel, cell1.CellNumber) : Cell.CreateCS(newOtherQuery, newMainQuery, cell1.CellLabel, cell1.CellNumber);
                cellList.Add(cell2);
            }
            return(cellList);
        }
Ejemplo n.º 25
0
        private ErrorLog GenerateDirectionalViews(
            ViewTarget viewTarget,
            CqlIdentifiers identifiers,
            KeyToListMap <EntitySetBase, GeneratedView> views)
        {
            bool flag = viewTarget == ViewTarget.QueryView;
            KeyToListMap <EntitySetBase, Cell> keyToListMap = ViewGenerator.GroupCellsByExtent((IEnumerable <Cell>) this.m_cellGroup, viewTarget);
            ErrorLog errorLog = new ErrorLog();

            foreach (EntitySetBase key in keyToListMap.Keys)
            {
                if (this.m_config.IsViewTracing)
                {
                    Helpers.StringTraceLine(string.Empty);
                    Helpers.StringTraceLine(string.Empty);
                    Helpers.FormatTraceLine("================= Generating {0} View for: {1} ===========================", flag ? (object)"Query" : (object)"Update", (object)key.Name);
                    Helpers.StringTraceLine(string.Empty);
                    Helpers.StringTraceLine(string.Empty);
                }
                try
                {
                    QueryRewriter directionalViewsForExtent = this.GenerateDirectionalViewsForExtent(viewTarget, key, identifiers, views);
                    if (viewTarget == ViewTarget.UpdateView)
                    {
                        if (this.m_config.IsValidationEnabled)
                        {
                            if (this.m_config.IsViewTracing)
                            {
                                Helpers.StringTraceLine(string.Empty);
                                Helpers.StringTraceLine(string.Empty);
                                Helpers.FormatTraceLine("----------------- Validation for generated update view for: {0} -----------------", (object)key.Name);
                                Helpers.StringTraceLine(string.Empty);
                                Helpers.StringTraceLine(string.Empty);
                            }
                            new RewritingValidator(directionalViewsForExtent.ViewgenContext, directionalViewsForExtent.BasicView).Validate();
                        }
                    }
                }
                catch (InternalMappingException ex)
                {
                    errorLog.Merge(ex.ErrorLog);
                }
            }
            return(errorLog);
        }
Ejemplo n.º 26
0
        // effects: Generates a view for an extent "extent" that belongs to
        // schema "schema". extentCells are the cells for this extent.
        // Adds the view corresponding to the extent to "views"
        private QueryRewriter GenerateDirectionalViewsForExtent(
            ViewTarget viewTarget, EntitySetBase extent, CqlIdentifiers identifiers, ViewSet views)
        {
            // First normalize the cells in terms of multiconstants, etc
            // and then generate the view for the extent
            var           context       = CreateViewgenContext(extent, viewTarget, identifiers);
            QueryRewriter queryRewriter = null;

            if (m_config.GenerateViewsForEachType)
            {
                // generate views for each OFTYPE(Extent, Type) combination
                foreach (
                    var type in
                    MetadataHelper.GetTypeAndSubtypesOf(
                        extent.ElementType, m_entityContainerMapping.StorageMappingItemCollection.EdmItemCollection, false
                        /*includeAbstractTypes*/))
                {
                    if (m_config.IsViewTracing &&
                        false == type.Equals(extent.ElementType))
                    {
                        Helpers.FormatTraceLine("CQL View for {0} and type {1}", extent.Name, type.Name);
                    }
                    queryRewriter = GenerateViewsForExtentAndType(type, context, identifiers, views, ViewGenMode.OfTypeViews);
                }
            }
            else
            {
                // generate the view for Extent only
                queryRewriter = GenerateViewsForExtentAndType(extent.ElementType, context, identifiers, views, ViewGenMode.OfTypeViews);
            }
            if (viewTarget == ViewTarget.QueryView)
            {
                m_config.SetTimeForFinishedActivity(PerfType.QueryViews);
            }
            else
            {
                m_config.SetTimeForFinishedActivity(PerfType.UpdateViews);
            }

            // cache this rewriter (and context inside it) for future use in FK checking
            m_queryRewriterCache[extent] = queryRewriter;
            return(queryRewriter);
        }
        private bool CreateLeftCellWrappers(IList <Cell> extentCells, ViewTarget viewTarget)
        {
            List <Cell> cellList = ViewgenContext.AlignFields((IEnumerable <Cell>)extentCells, this.m_memberMaps.ProjectedSlotMap, viewTarget);

            this.m_cellWrappers = new List <LeftCellWrapper>();
            for (int index = 0; index < cellList.Count; ++index)
            {
                Cell             cell          = cellList[index];
                CellQuery        leftQuery     = cell.GetLeftQuery(viewTarget);
                CellQuery        rightQuery    = cell.GetRightQuery(viewTarget);
                Set <MemberPath> nonNullSlots  = leftQuery.GetNonNullSlots();
                FragmentQuery    fragmentQuery = FragmentQuery.Create(BoolExpression.CreateLiteral((BoolLiteral) new CellIdBoolean(this.m_identifiers, extentCells[index].CellNumber), this.m_memberMaps.LeftDomainMap), leftQuery);
                if (viewTarget == ViewTarget.UpdateView)
                {
                    fragmentQuery = this.m_leftFragmentQP.CreateDerivedViewBySelectingConstantAttributes(fragmentQuery) ?? fragmentQuery;
                }
                this.m_cellWrappers.Add(new LeftCellWrapper(this.m_viewTarget, nonNullSlots, fragmentQuery, leftQuery, rightQuery, this.m_memberMaps, extentCells[index]));
            }
            return(true);
        }
Ejemplo n.º 28
0
        private bool TryCreateAdditionalCellWithCondition(
            Cell originalCell,
            MemberPath memberToExpand,
            bool conditionValue,
            ViewTarget viewTarget,
            out Cell result)
        {
            result = (Cell)null;
            MemberPath           extentMemberPath1 = originalCell.GetLeftQuery(viewTarget).SourceExtentMemberPath;
            MemberPath           extentMemberPath2 = originalCell.GetRightQuery(viewTarget).SourceExtentMemberPath;
            int                  slotNum1          = originalCell.GetLeftQuery(viewTarget).GetProjectedMembers().TakeWhile <MemberPath>((Func <MemberPath, bool>)(path => !path.Equals(memberToExpand))).Count <MemberPath>();
            MemberPath           rightSidePath     = ((MemberProjectedSlot)originalCell.GetRightQuery(viewTarget).ProjectedSlotAt(slotNum1)).MemberPath;
            List <ProjectedSlot> slots1            = new List <ProjectedSlot>();
            List <ProjectedSlot> slots2            = new List <ProjectedSlot>();
            ScalarConstant       negatedCondition  = new ScalarConstant((object)!conditionValue);

            if (originalCell.GetLeftQuery(viewTarget).Conditions.Where <MemberRestriction>((Func <MemberRestriction, bool>)(restriction => restriction.RestrictedMemberSlot.MemberPath.Equals(memberToExpand))).Where <MemberRestriction>((Func <MemberRestriction, bool>)(restriction => restriction.Domain.Values.Contains <Constant>((Constant)negatedCondition))).Any <MemberRestriction>() || originalCell.GetRightQuery(viewTarget).Conditions.Where <MemberRestriction>((Func <MemberRestriction, bool>)(restriction => restriction.RestrictedMemberSlot.MemberPath.Equals(rightSidePath))).Where <MemberRestriction>((Func <MemberRestriction, bool>)(restriction => restriction.Domain.Values.Contains <Constant>((Constant)negatedCondition))).Any <MemberRestriction>())
            {
                return(false);
            }
            for (int slotNum2 = 0; slotNum2 < originalCell.GetLeftQuery(viewTarget).NumProjectedSlots; ++slotNum2)
            {
                slots1.Add(originalCell.GetLeftQuery(viewTarget).ProjectedSlotAt(slotNum2));
            }
            for (int slotNum2 = 0; slotNum2 < originalCell.GetRightQuery(viewTarget).NumProjectedSlots; ++slotNum2)
            {
                slots2.Add(originalCell.GetRightQuery(viewTarget).ProjectedSlotAt(slotNum2));
            }
            BoolExpression literal1   = BoolExpression.CreateLiteral((BoolLiteral) new ScalarRestriction(memberToExpand, (Constant) new ScalarConstant((object)conditionValue)), (MemberDomainMap)null);
            BoolExpression and1       = BoolExpression.CreateAnd(originalCell.GetLeftQuery(viewTarget).WhereClause, literal1);
            BoolExpression literal2   = BoolExpression.CreateLiteral((BoolLiteral) new ScalarRestriction(rightSidePath, (Constant) new ScalarConstant((object)conditionValue)), (MemberDomainMap)null);
            BoolExpression and2       = BoolExpression.CreateAnd(originalCell.GetRightQuery(viewTarget).WhereClause, literal2);
            CellQuery      cellQuery1 = new CellQuery(slots2, and2, extentMemberPath2, originalCell.GetRightQuery(viewTarget).SelectDistinctFlag);
            CellQuery      cellQuery2 = new CellQuery(slots1, and1, extentMemberPath1, originalCell.GetLeftQuery(viewTarget).SelectDistinctFlag);
            Cell           cell       = viewTarget != ViewTarget.UpdateView ? Cell.CreateCS(cellQuery2, cellQuery1, originalCell.CellLabel, this.m_currentCellNumber) : Cell.CreateCS(cellQuery1, cellQuery2, originalCell.CellLabel, this.m_currentCellNumber);

            ++this.m_currentCellNumber;
            result = cell;
            return(true);
        }
Ejemplo n.º 29
0
 // effects: Fixes the domains of variables in this as specified in FixEnumerableDomains
 private static void ReduceEnumerableDomainToEnumeratedValues(ViewTarget target, Dictionary <MemberPath, CellConstantSet> domainMap, ConfigViewGenerator config,
                                                              EdmItemCollection edmItemCollection)
 {
     foreach (MemberPath member in domainMap.Keys)
     {
         if (MetadataHelper.HasDiscreteDomain(member.EdmType) == false)
         {
             continue;
         }
         CellConstantSet domain = Domain.DeriveDomainFromMemberPath(member, edmItemCollection, true /* leaveDomainUnbounded */);
         CellConstantSet extra  = domainMap[member].Difference(domain);
         extra.Remove(Constant.Undefined);
         if (extra.Count > 0)
         { // domainMap has extra members -- we should get rid of them
             if (config.IsNormalTracing)
             {
                 Helpers.FormatTraceLine("Changed domain of {0} from {1} - subtract {2}", member, domainMap[member], extra);
             }
             domainMap[member].Subtract(extra);
         }
     }
 }
Ejemplo n.º 30
0
 // effects: Given all the cells for a container, groups the cells by
 // the left query's extent and returns a dictionary for it
 private static KeyToListMap<EntitySetBase, Cell> GroupCellsByExtent(IEnumerable<Cell> cells, ViewTarget viewTarget)
 {
     // Partition cells by extent -- extent is the top node in
     // the tree. Even for compositions for now? CHANGE_ADYA_FEATURE_COMPOSITION
     var extentCellMap =
         new KeyToListMap<EntitySetBase, Cell>(EqualityComparer<EntitySetBase>.Default);
     foreach (var cell in cells)
     {
         // Get the cell query and determine its extent
         var cellQuery = cell.GetLeftQuery(viewTarget);
         extentCellMap.Add(cellQuery.Extent, cell);
     }
     return extentCellMap;
 }
Ejemplo n.º 31
0
        // effects: Returns a context corresponding to extent (if one does not exist, creates one)
        private ViewgenContext CreateViewgenContext(EntitySetBase extent, ViewTarget viewTarget, CqlIdentifiers identifiers)
        {
            QueryRewriter queryRewriter;
            if (!m_queryRewriterCache.TryGetValue(extent, out queryRewriter))
            {
                // collect the cells that belong to this extent (just a few of them since we segment the mapping first)
                var cellsForExtent = m_cellGroup.Where(c => c.GetLeftQuery(viewTarget).Extent == extent);

                return new ViewgenContext(
                    viewTarget, extent, cellsForExtent, identifiers, m_config, m_queryDomainMap, m_updateDomainMap, m_entityContainerMapping);
            }
            else
            {
                return queryRewriter.ViewgenContext;
            }
        }
Ejemplo n.º 32
0
        // effects: Generates a view for an extent "extent" that belongs to
        // schema "schema". extentCells are the cells for this extent.
        // Adds the view corrsponding to the extent to "views"
        private QueryRewriter GenerateDirectionalViewsForExtent(
            ViewTarget viewTarget, EntitySetBase extent, CqlIdentifiers identifiers, ViewSet views)
        {
            // First normalize the cells in terms of multiconstants, etc
            // and then generate the view for the extent
            var context = CreateViewgenContext(extent, viewTarget, identifiers);
            QueryRewriter queryRewriter = null;

            if (m_config.GenerateViewsForEachType)
            {
                // generate views for each OFTYPE(Extent, Type) combination
                foreach (
                    var type in
                        MetadataHelper.GetTypeAndSubtypesOf(
                            extent.ElementType, m_entityContainerMapping.StorageMappingItemCollection.EdmItemCollection, false
                            /*includeAbstractTypes*/))
                {
                    if (m_config.IsViewTracing
                        && false == type.Equals(extent.ElementType))
                    {
                        Helpers.FormatTraceLine("CQL View for {0} and type {1}", extent.Name, type.Name);
                    }
                    queryRewriter = GenerateViewsForExtentAndType(type, context, identifiers, views, ViewGenMode.OfTypeViews);
                }
            }
            else
            {
                // generate the view for Extent only
                queryRewriter = GenerateViewsForExtentAndType(extent.ElementType, context, identifiers, views, ViewGenMode.OfTypeViews);
            }
            if (viewTarget == ViewTarget.QueryView)
            {
                m_config.SetTimeForFinishedActivity(PerfType.QueryViews);
            }
            else
            {
                m_config.SetTimeForFinishedActivity(PerfType.UpdateViews);
            }

            // cache this rewriter (and context inside it) for future use in FK checking
            m_queryRewriterCache[extent] = queryRewriter;
            return queryRewriter;
        }
Ejemplo n.º 33
0
        // requires: schema refers to C-side or S-side schema for the cells
        // inside this. if schema.IsQueryView is true, the left side of cells refers
        // to the C side (and vice-versa for the right side)
        // effects: Generates the relevant views for the schema side and
        // returns them. If allowMissingAttributes is true and attributes
        // are missing on the schema side, substitutes them with NULL
        // Modifies views to contain the generated views for different
        // extents specified by cells and the the schemaContext
        private ErrorLog GenerateDirectionalViews(ViewTarget viewTarget, CqlIdentifiers identifiers, ViewSet views)
        {
            var isQueryView = viewTarget == ViewTarget.QueryView;

            // Partition cells by extent.
            var extentCellMap = GroupCellsByExtent(m_cellGroup, viewTarget);

            // Keep track of the mapping exceptions that we have generated
            var errorLog = new ErrorLog();

            // Generate views for each extent
            foreach (var extent in extentCellMap.Keys)
            {
                if (m_config.IsViewTracing)
                {
                    Helpers.StringTraceLine(String.Empty);
                    Helpers.StringTraceLine(String.Empty);
                    Helpers.FormatTraceLine(
                        "================= Generating {0} View for: {1} ===========================",
                        isQueryView ? "Query" : "Update", extent.Name);
                    Helpers.StringTraceLine(String.Empty);
                    Helpers.StringTraceLine(String.Empty);
                }
                try
                {
                    // (1) view generation (checks that extents are fully mapped)
                    var queryRewriter = GenerateDirectionalViewsForExtent(viewTarget, extent, identifiers, views);

                    // (2) validation for update views
                    if (viewTarget == ViewTarget.UpdateView
                        &&
                        m_config.IsValidationEnabled)
                    {
                        if (m_config.IsViewTracing)
                        {
                            Helpers.StringTraceLine(String.Empty);
                            Helpers.StringTraceLine(String.Empty);
                            Helpers.FormatTraceLine(
                                "----------------- Validation for generated update view for: {0} -----------------",
                                extent.Name);
                            Helpers.StringTraceLine(String.Empty);
                            Helpers.StringTraceLine(String.Empty);
                        }

                        var validator = new RewritingValidator(queryRewriter.ViewgenContext, queryRewriter.BasicView);
                        validator.Validate();
                    }
                }
                catch (InternalMappingException exception)
                {
                    // All exceptions have mapping errors in them
                    Debug.Assert(
                        exception.ErrorLog.Count > 0,
                        "Incorrectly created mapping exception");
                    errorLog.Merge(exception.ErrorLog);
                }
            }
            return errorLog;
        }
Ejemplo n.º 34
0
        // effects: Creates a map with all the condition member constants
        // from extentCells. viewtarget determines whether the view is an
        // update or query view
        internal MemberDomainMap(ViewTarget viewTarget, bool isValidationEnabled, IEnumerable<Cell> extentCells, EdmItemCollection edmItemCollection, ConfigViewGenerator config, Dictionary<EntityType, Set<EntityType>> inheritanceGraph)
        {
            m_conditionDomainMap = new Dictionary<MemberPath, CellConstantSet>(MemberPath.EqualityComparer);
            m_edmItemCollection = edmItemCollection;

            Dictionary<MemberPath, CellConstantSet> domainMap = null;
            if (viewTarget == ViewTarget.UpdateView)
            {
                domainMap = Domain.ComputeConstantDomainSetsForSlotsInUpdateViews(extentCells, m_edmItemCollection);
            }
            else
            {
                domainMap = Domain.ComputeConstantDomainSetsForSlotsInQueryViews(extentCells, m_edmItemCollection, isValidationEnabled);
            }

            foreach (Cell cell in extentCells)
            {
                CellQuery cellQuery = cell.GetLeftQuery(viewTarget);
                // Get the atoms from cellQuery and only keep the ones that
                // are condition members
                foreach (MemberRestriction condition in cellQuery.GetConjunctsFromWhereClause())
                {
                    // Note: TypeConditions are created using OneOfTypeConst and
                    // scalars are created using OneOfScalarConst
                    MemberPath memberPath = condition.RestrictedMemberSlot.MemberPath;

                    Debug.Assert(condition is ScalarRestriction || condition is TypeRestriction,
                                 "Unexpected restriction");

                    // Take the narrowed domain from domainMap, if any
                    CellConstantSet domainValues;
                    if (!domainMap.TryGetValue(memberPath, out domainValues))
                    {
                        domainValues = Domain.DeriveDomainFromMemberPath(memberPath, edmItemCollection, isValidationEnabled);
                    }

                    //Don't count conditions that are satisfied through IsNull=false 
                    if (!domainValues.Contains(Constant.Null))
                    {
                        //multiple values of condition represent disjunction in conditions (not currently supported)
                        // if there is any condition constant that is NotNull
                        if (condition.Domain.Values.All(conditionConstant => (conditionConstant.Equals(Constant.NotNull))))
                        {
                            continue;
                        }
                        //else there is atleast one condition value that is allowed, continue view generation
                    }

                    //------------------------------------------
                    //|  Nullable  |   IsNull  |   Test case   |
                    //|     T      |     T     |       T       |
                    //|     T      |     F     |       T       |
                    //|     F      |     T     |       F       |
                    //|     F      |     F     |       T       |
                    //------------------------------------------
                    //IsNull condition on a member that is non nullable is an invalid condition
                    if (domainValues.Count <= 0 || (!domainValues.Contains(Constant.Null) && condition.Domain.Values.Contains(Constant.Null)))
                    {
                        string message = System.Data.Entity.Strings.ViewGen_InvalidCondition(memberPath.PathToString(false));
                        ErrorLog.Record record = new ErrorLog.Record(true, ViewGenErrorCode.InvalidCondition, message, cell, String.Empty);
                        ExceptionHelpers.ThrowMappingException(record, config);
                    }
                    if (memberPath.IsAlwaysDefined(inheritanceGraph) == false)
                    {
                        domainValues.Add(Constant.Undefined);
                    }

                    AddToDomainMap(memberPath, domainValues);
                }
            }

            // Fill up the domains for the remaining slots as well
            m_nonConditionDomainMap = new Dictionary<MemberPath, CellConstantSet>(MemberPath.EqualityComparer);
            foreach (Cell cell in extentCells)
            {
                CellQuery cellQuery = cell.GetLeftQuery(viewTarget);
                // Get the atoms from cellQuery and only keep the ones that
                // are condition members
                foreach (MemberProjectedSlot slot in cellQuery.GetAllQuerySlots())
                {
                    MemberPath member = slot.MemberPath;
                    if (m_conditionDomainMap.ContainsKey(member) == false && m_nonConditionDomainMap.ContainsKey(member) == false)
                    {
                        CellConstantSet memberSet = Domain.DeriveDomainFromMemberPath(member, m_edmItemCollection, true /* Regardless of validation, leave the domain unbounded because this is not a condition member */);
                        if (member.IsAlwaysDefined(inheritanceGraph) == false)
                        { // nonConditionMember may belong to subclass
                            memberSet.Add(Constant.Undefined);
                        }
                        memberSet = Domain.ExpandNegationsInDomain(memberSet, memberSet);
                        m_nonConditionDomainMap.Add(member, new CellConstantSetInfo(memberSet, slot));
                    }
                }
            }
        }
Ejemplo n.º 35
0
 // effects: Fixes the domains of variables in this as specified in FixEnumerableDomains
 private static void ReduceEnumerableDomainToEnumeratedValues(ViewTarget target, Dictionary<MemberPath, CellConstantSet> domainMap, ConfigViewGenerator config,
                                               EdmItemCollection edmItemCollection)
 {
     foreach (MemberPath member in domainMap.Keys)
     {
         if (MetadataHelper.HasDiscreteDomain(member.EdmType) == false)
         {
             continue;
         }
         CellConstantSet domain = Domain.DeriveDomainFromMemberPath(member, edmItemCollection, true /* leaveDomainUnbounded */);
         CellConstantSet extra = domainMap[member].Difference(domain);
         extra.Remove(Constant.Undefined);
         if (extra.Count > 0)
         { // domainMap has extra members -- we should get rid of them
             if (config.IsNormalTracing)
             {
                 Helpers.FormatTraceLine("Changed domain of {0} from {1} - subtract {2}", member, domainMap[member], extra);
             }
             domainMap[member].Subtract(extra);
         }
     }
 }
Ejemplo n.º 36
0
        // effects: Align the fields of each cell in mapping using projectedSlotMap that has a mapping 
        // for each member of this extent to the slot number of that member in the projected slots
        // example:
        //    input:  Proj[A,B,"5"] = Proj[F,"7",G]
        //            Proj[C,B]     = Proj[H,I]
        //   output:  m_projectedSlotMap: A -> 0, B -> 1, C -> 2
        //            Proj[A,B,null] = Proj[F,"7",null]
        //            Proj[null,B,C] = Proj[null,I,H]
        private static List<Cell> AlignFields(
            IEnumerable<Cell> cells, MemberProjectionIndex projectedSlotMap,
            ViewTarget viewTarget)
        {
            var outputCells = new List<Cell>();

            // Determine the aligned field for each cell
            // The new cells have ProjectedSlotMap.Count number of fields
            foreach (var cell in cells)
            {
                // If isQueryView is true, we need to consider the C side of
                // the cells; otherwise, we look at the S side. Note that we
                // CANNOT use cell.LeftQuery since that is determined by
                // cell's isQueryView

                // The query for which we are constructing the extent
                var mainQuery = cell.GetLeftQuery(viewTarget);
                var otherQuery = cell.GetRightQuery(viewTarget);

                CellQuery newMainQuery;
                CellQuery newOtherQuery;
                // Create both queries where the projected slot map is used
                // to determine the order of the fields of the mainquery (of
                // course, the otherQuery's fields are aligned automatically)
                mainQuery.CreateFieldAlignedCellQueries(
                    otherQuery, projectedSlotMap,
                    out newMainQuery, out newOtherQuery);

                var outputCell = viewTarget == ViewTarget.QueryView
                                     ? Cell.CreateCS(newMainQuery, newOtherQuery, cell.CellLabel, cell.CellNumber)
                                     : Cell.CreateCS(newOtherQuery, newMainQuery, cell.CellLabel, cell.CellNumber);
                outputCells.Add(outputCell);
            }
            return outputCells;
        }
Ejemplo n.º 37
0
        internal ViewgenContext(
            ViewTarget viewTarget, EntitySetBase extent, IList <Cell> extentCells,
            CqlIdentifiers identifiers, ConfigViewGenerator config, MemberDomainMap queryDomainMap,
            MemberDomainMap updateDomainMap, StorageEntityContainerMapping entityContainerMapping)
        {
            foreach (var cell in extentCells)
            {
                Debug.Assert(extent.Equals(cell.GetLeftQuery(viewTarget).Extent));
                Debug.Assert(cell.CQuery.NumProjectedSlots == cell.SQuery.NumProjectedSlots);
            }

            m_extent                 = extent;
            m_viewTarget             = viewTarget;
            m_config                 = config;
            m_edmItemCollection      = entityContainerMapping.StorageMappingItemCollection.EdmItemCollection;
            m_entityContainerMapping = entityContainerMapping;
            m_identifiers            = identifiers;

            // create a copy of updateDomainMap so generation of query views later on is not affected
            // it is modified in QueryRewriter.AdjustMemberDomainsForUpdateViews
            updateDomainMap = updateDomainMap.MakeCopy();

            // Create a signature generator that handles all the
            // multiconstant work and generating the signatures
            var domainMap = viewTarget == ViewTarget.QueryView ? queryDomainMap : updateDomainMap;

            m_memberMaps = new MemberMaps(
                viewTarget, MemberProjectionIndex.Create(extent, m_edmItemCollection), queryDomainMap, updateDomainMap);

            // Create left fragment KB: includes constraints for the extent to be constructed
            var leftKB = new FragmentQueryKBChaseSupport();

            leftKB.CreateVariableConstraints(extent, domainMap, m_edmItemCollection);
            m_leftFragmentQP = new FragmentQueryProcessor(leftKB);
            m_rewritingCache = new Dictionary <FragmentQuery, Tile <FragmentQuery> >(
                FragmentQuery.GetEqualityComparer(m_leftFragmentQP));

            // Now using the signatures, create new cells such that
            // "extent's" query (C or S) is described in terms of multiconstants
            if (!CreateLeftCellWrappers(extentCells, viewTarget))
            {
                return;
            }

            // Create right fragment KB: includes constraints for all extents and association roles of right queries
            var rightKB        = new FragmentQueryKBChaseSupport();
            var rightDomainMap = viewTarget == ViewTarget.QueryView ? updateDomainMap : queryDomainMap;

            foreach (var leftCellWrapper in m_cellWrappers)
            {
                var rightExtent = leftCellWrapper.RightExtent;
                rightKB.CreateVariableConstraints(rightExtent, rightDomainMap, m_edmItemCollection);
                rightKB.CreateAssociationConstraints(rightExtent, rightDomainMap, m_edmItemCollection);
            }

            if (m_viewTarget == ViewTarget.UpdateView)
            {
                CreateConstraintsForForeignKeyAssociationsAffectingThisWrapper(rightKB, rightDomainMap);
            }

            m_rightFragmentQP = new FragmentQueryProcessor(rightKB);

            // Check for concurrency control tokens
            if (m_viewTarget == ViewTarget.QueryView)
            {
                CheckConcurrencyControlTokens();
            }
            // For backward compatibility -
            // order wrappers by increasing domain size, decreasing number of attributes
            m_cellWrappers.Sort(LeftCellWrapper.Comparer);
        }
Ejemplo n.º 38
0
        private void SearchShipData(ViewTarget target)
        {
            Cursor = Cursors.Wait;
            try
            {
                _shipDataGridItemsSource.Clear();

                using (var entities = new FleetManagerDataEntities())
                {
                    var newList = new ObservableCollection<ShipDataModel>();

                    switch (target)
                    {
                        case ViewTarget.Possession:
                            foreach (var ship in entities.ViewPossessionShips.OrderBy(s => s.ShipBaseCode + s.Grade.ToString()))
                            {
                                var model = Mapper.Map<ViewPossessionShips, ShipDataModel>(ship);
                                newList.Add(model);
                            }
                            break;

                        case ViewTarget.NotPossession:
                            foreach (var ship in entities.ViewNotPossessionShips.OrderBy(s => s.ShipBaseCode + s.Grade.ToString()))
                            {
                                var model = Mapper.Map<ViewNotPossessionShips, ShipDataModel>(ship);
                                newList.Add(model);
                            }
                            break;

                        case ViewTarget.All:
                            foreach (var ship in entities.ViewAllShips.OrderBy(s => s.ShipBaseCode + s.Grade.ToString()))
                            {
                                var model = Mapper.Map<ViewAllShips, ShipDataModel>(ship);
                                newList.Add(model);
                            }
                            break;
                    }

                    ShipDataGridItemsSource = newList;
                }
            }
            finally
            {
                Cursor = null;
            }
        }
Ejemplo n.º 39
0
 // effects: Returns the S query for ViewTarget.QueryView and C query for ViewTarget.UpdateView
 internal CellQuery GetRightQuery(ViewTarget side)
 {
     return side == ViewTarget.QueryView ? m_sQuery : m_cQuery;
 }
Ejemplo n.º 40
0
        internal ViewgenContext(
            ViewTarget viewTarget, EntitySetBase extent, IList<Cell> extentCells,
            CqlIdentifiers identifiers, ConfigViewGenerator config, MemberDomainMap queryDomainMap,
            MemberDomainMap updateDomainMap, EntityContainerMapping entityContainerMapping)
        {
            foreach (var cell in extentCells)
            {
                Debug.Assert(extent.Equals(cell.GetLeftQuery(viewTarget).Extent));
                Debug.Assert(cell.CQuery.NumProjectedSlots == cell.SQuery.NumProjectedSlots);
            }

            m_extent = extent;
            m_viewTarget = viewTarget;
            m_config = config;
            m_edmItemCollection = entityContainerMapping.StorageMappingItemCollection.EdmItemCollection;
            m_entityContainerMapping = entityContainerMapping;
            m_identifiers = identifiers;

            // create a copy of updateDomainMap so generation of query views later on is not affected
            // it is modified in QueryRewriter.AdjustMemberDomainsForUpdateViews
            updateDomainMap = updateDomainMap.MakeCopy();

            // Create a signature generator that handles all the
            // multiconstant work and generating the signatures
            var domainMap = viewTarget == ViewTarget.QueryView ? queryDomainMap : updateDomainMap;

            m_memberMaps = new MemberMaps(
                viewTarget, MemberProjectionIndex.Create(extent, m_edmItemCollection), queryDomainMap, updateDomainMap);

            // Create left fragment KB: includes constraints for the extent to be constructed
            var leftKB = new FragmentQueryKBChaseSupport();
            leftKB.CreateVariableConstraints(extent, domainMap, m_edmItemCollection);
            m_leftFragmentQP = new FragmentQueryProcessor(leftKB);
            m_rewritingCache = new Dictionary<FragmentQuery, Tile<FragmentQuery>>(
                FragmentQuery.GetEqualityComparer(m_leftFragmentQP));

            // Now using the signatures, create new cells such that
            // "extent's" query (C or S) is described in terms of multiconstants
            if (!CreateLeftCellWrappers(extentCells, viewTarget))
            {
                return;
            }

            // Create right fragment KB: includes constraints for all extents and association roles of right queries
            var rightKB = new FragmentQueryKBChaseSupport();
            var rightDomainMap = viewTarget == ViewTarget.QueryView ? updateDomainMap : queryDomainMap;
            foreach (var leftCellWrapper in m_cellWrappers)
            {
                var rightExtent = leftCellWrapper.RightExtent;
                rightKB.CreateVariableConstraints(rightExtent, rightDomainMap, m_edmItemCollection);
                rightKB.CreateAssociationConstraints(rightExtent, rightDomainMap, m_edmItemCollection);
            }

            if (m_viewTarget == ViewTarget.UpdateView)
            {
                CreateConstraintsForForeignKeyAssociationsAffectingThisWrapper(rightKB, rightDomainMap);
            }

            m_rightFragmentQP = new FragmentQueryProcessor(rightKB);

            // Check for concurrency control tokens
            if (m_viewTarget == ViewTarget.QueryView)
            {
                CheckConcurrencyControlTokens();
            }
            // For backward compatibility -
            // order wrappers by increasing domain size, decreasing number of attributes
            m_cellWrappers.Sort(LeftCellWrapper.Comparer);
        }
Ejemplo n.º 41
0
        // effects: Shrinks the domain of members whose types can be enumerated - currently it applies 
        // only to boolean type as for enums we don't restrict enum values to specified members only. 
        // For example NOT(False, True, Null) for a boolean domain should be removed
        internal void ReduceEnumerableDomainToEnumeratedValues(ViewTarget target, ConfigViewGenerator config)
        {
            // Go through the two maps

            ReduceEnumerableDomainToEnumeratedValues(target, m_conditionDomainMap, config, m_edmItemCollection);
            ReduceEnumerableDomainToEnumeratedValues(target, m_nonConditionDomainMap, config, m_edmItemCollection);
        }
Ejemplo n.º 42
0
        // effects: Given the cells for the extent (extentCells) along with
        // the signatures (multiconstants + needed attributes) for this extent, generates
        // the left cell wrappers for it extent (viewTarget indicates whether
        // the view is for querying or update purposes
        // Modifies m_cellWrappers to contain this list
        private bool CreateLeftCellWrappers(IList<Cell> extentCells, ViewTarget viewTarget)
        {
            var alignedCells = AlignFields(extentCells, m_memberMaps.ProjectedSlotMap, viewTarget);
            Debug.Assert(alignedCells.Count == extentCells.Count, "Cell counts disagree");

            // Go through all the cells and create cell wrappers that can be used for generating the view
            m_cellWrappers = new List<LeftCellWrapper>();

            for (var i = 0; i < alignedCells.Count; i++)
            {
                var alignedCell = alignedCells[i];
                var left = alignedCell.GetLeftQuery(viewTarget);
                var right = alignedCell.GetRightQuery(viewTarget);

                // Obtain the non-null projected slots into attributes
                var attributes = left.GetNonNullSlots();

                var fromVariable = BoolExpression.CreateLiteral(
                    new CellIdBoolean(m_identifiers, extentCells[i].CellNumber), m_memberMaps.LeftDomainMap);
                var leftFragmentQuery = FragmentQuery.Create(fromVariable, left);

                if (viewTarget == ViewTarget.UpdateView)
                {
                    leftFragmentQuery = m_leftFragmentQP.CreateDerivedViewBySelectingConstantAttributes(leftFragmentQuery)
                                        ?? leftFragmentQuery;
                }

                var leftWrapper = new LeftCellWrapper(
                    m_viewTarget, attributes, leftFragmentQuery, left, right, m_memberMaps,
                    extentCells[i]);
                m_cellWrappers.Add(leftWrapper);
            }
            return true;
        }
Ejemplo n.º 43
0
        // <summary>
        // Given a cell, a member and a boolean condition on that member, creates additional cell
        // which with the specified restriction on the member in addition to original condition.
        // e.i conjunction of original condition AND member in newCondition
        // Creation fails when the original condition contradicts new boolean condition
        // ViewTarget tells whether MemberPath is in Cquery or SQuery
        // </summary>
        private bool TryCreateAdditionalCellWithCondition(
            Cell originalCell, MemberPath memberToExpand, bool conditionValue, ViewTarget viewTarget, out Cell result)
        {
            DebugCheck.NotNull(originalCell);
            DebugCheck.NotNull(memberToExpand);
            result = null;

            //Create required structures
            var leftExtent  = originalCell.GetLeftQuery(viewTarget).SourceExtentMemberPath;
            var rightExtent = originalCell.GetRightQuery(viewTarget).SourceExtentMemberPath;

            //Now for the given left-side projected member, find corresponding right-side member that it is mapped to
            var indexOfBooLMemberInProjection =
                originalCell.GetLeftQuery(viewTarget).GetProjectedMembers().TakeWhile(path => !path.Equals(memberToExpand)).Count();
            var rightConditionMemberSlot =
                ((MemberProjectedSlot)originalCell.GetRightQuery(viewTarget).ProjectedSlotAt(indexOfBooLMemberInProjection));
            var rightSidePath = rightConditionMemberSlot.MemberPath;

            var leftSlots  = new List <ProjectedSlot>();
            var rightSlots = new List <ProjectedSlot>();

            //Check for impossible conditions (otherwise we get inaccurate pre-validation errors)
            var negatedCondition = new ScalarConstant(!conditionValue);

            if (originalCell.GetLeftQuery(viewTarget).Conditions
                .Where(restriction => restriction.RestrictedMemberSlot.MemberPath.Equals(memberToExpand))
                .Where(restriction => restriction.Domain.Values.Contains(negatedCondition)).Any() ||
                originalCell.GetRightQuery(viewTarget).Conditions
                .Where(restriction => restriction.RestrictedMemberSlot.MemberPath.Equals(rightSidePath))
                .Where(restriction => restriction.Domain.Values.Contains(negatedCondition)).Any())
            {
                return(false);
            }
            //End check

            //Create Projected Slots
            // Map all slots in original cell (not just keys) because some may be required (non nullable and no default)
            // and others may have not_null condition so MUST be projected. Rely on the user doing the right thing, otherwise
            // they will get the error message anyway
            for (var i = 0; i < originalCell.GetLeftQuery(viewTarget).NumProjectedSlots; i++)
            {
                leftSlots.Add(originalCell.GetLeftQuery(viewTarget).ProjectedSlotAt(i));
            }

            for (var i = 0; i < originalCell.GetRightQuery(viewTarget).NumProjectedSlots; i++)
            {
                rightSlots.Add(originalCell.GetRightQuery(viewTarget).ProjectedSlotAt(i));
            }

            //Create condition boolena expressions
            var leftQueryWhereClause =
                BoolExpression.CreateLiteral(new ScalarRestriction(memberToExpand, new ScalarConstant(conditionValue)), null);

            leftQueryWhereClause = BoolExpression.CreateAnd(originalCell.GetLeftQuery(viewTarget).WhereClause, leftQueryWhereClause);

            var rightQueryWhereClause =
                BoolExpression.CreateLiteral(new ScalarRestriction(rightSidePath, new ScalarConstant(conditionValue)), null);

            rightQueryWhereClause = BoolExpression.CreateAnd(originalCell.GetRightQuery(viewTarget).WhereClause, rightQueryWhereClause);

            //Create additional Cells
            var rightQuery = new CellQuery(
                rightSlots, rightQueryWhereClause, rightExtent, originalCell.GetRightQuery(viewTarget).SelectDistinctFlag);
            var leftQuery = new CellQuery(
                leftSlots, leftQueryWhereClause, leftExtent, originalCell.GetLeftQuery(viewTarget).SelectDistinctFlag);

            Cell newCell;

            if (viewTarget == ViewTarget.UpdateView)
            {
                newCell = Cell.CreateCS(rightQuery, leftQuery, originalCell.CellLabel, m_currentCellNumber);
            }
            else
            {
                newCell = Cell.CreateCS(leftQuery, rightQuery, originalCell.CellLabel, m_currentCellNumber);
            }

            m_currentCellNumber++;
            result = newCell;
            return(true);
        }
Ejemplo n.º 44
0
        /// <summary>
        ///     Given a cell, a member and a boolean condition on that member, creates additional cell
        ///     which with the specified restriction on the member in addition to original condition.
        ///     e.i conjunction of original condition AND member in newCondition
        ///     Creation fails when the original condition contradicts new boolean condition
        ///     ViewTarget tells whether MemberPath is in Cquery or SQuery
        /// </summary>
        private bool TryCreateAdditionalCellWithCondition(
            Cell originalCell, MemberPath memberToExpand, bool conditionValue, ViewTarget viewTarget, out Cell result)
        {
            DebugCheck.NotNull(originalCell);
            DebugCheck.NotNull(memberToExpand);
            result = null;

            //Create required structures
            var leftExtent = originalCell.GetLeftQuery(viewTarget).SourceExtentMemberPath;
            var rightExtent = originalCell.GetRightQuery(viewTarget).SourceExtentMemberPath;

            //Now for the given left-side projected member, find corresponding right-side member that it is mapped to 
            var indexOfBooLMemberInProjection =
                originalCell.GetLeftQuery(viewTarget).GetProjectedMembers().TakeWhile(path => !path.Equals(memberToExpand)).Count();
            var rightConditionMemberSlot =
                ((MemberProjectedSlot)originalCell.GetRightQuery(viewTarget).ProjectedSlotAt(indexOfBooLMemberInProjection));
            var rightSidePath = rightConditionMemberSlot.MemberPath;

            var leftSlots = new List<ProjectedSlot>();
            var rightSlots = new List<ProjectedSlot>();

            //Check for impossible conditions (otehrwise we get inaccurate pre-validation errors)
            var negatedCondition = new ScalarConstant(!conditionValue);

            if (originalCell.GetLeftQuery(viewTarget).Conditions
                            .Where(restriction => restriction.RestrictedMemberSlot.MemberPath.Equals(memberToExpand))
                            .Where(restriction => restriction.Domain.Values.Contains(negatedCondition)).Any()
                || originalCell.GetRightQuery(viewTarget).Conditions
                               .Where(restriction => restriction.RestrictedMemberSlot.MemberPath.Equals(rightSidePath))
                               .Where(restriction => restriction.Domain.Values.Contains(negatedCondition)).Any())
            {
                return false;
            }
            //End check

            //Create Projected Slots
            // Map all slots in original cell (not just keys) because some may be required (non nullable and no default)
            // and others may have not_null condition so MUST be projected. Rely on the user doing the right thing, otherwise
            // they will get the error message anyway
            for (var i = 0; i < originalCell.GetLeftQuery(viewTarget).NumProjectedSlots; i++)
            {
                leftSlots.Add(originalCell.GetLeftQuery(viewTarget).ProjectedSlotAt(i));
            }

            for (var i = 0; i < originalCell.GetRightQuery(viewTarget).NumProjectedSlots; i++)
            {
                rightSlots.Add(originalCell.GetRightQuery(viewTarget).ProjectedSlotAt(i));
            }

            //Create condition boolena expressions
            var leftQueryWhereClause =
                BoolExpression.CreateLiteral(new ScalarRestriction(memberToExpand, new ScalarConstant(conditionValue)), null);
            leftQueryWhereClause = BoolExpression.CreateAnd(originalCell.GetLeftQuery(viewTarget).WhereClause, leftQueryWhereClause);

            var rightQueryWhereClause =
                BoolExpression.CreateLiteral(new ScalarRestriction(rightSidePath, new ScalarConstant(conditionValue)), null);
            rightQueryWhereClause = BoolExpression.CreateAnd(originalCell.GetRightQuery(viewTarget).WhereClause, rightQueryWhereClause);

            //Create additional Cells
            var rightQuery = new CellQuery(
                rightSlots, rightQueryWhereClause, rightExtent, originalCell.GetRightQuery(viewTarget).SelectDistinctFlag);
            var leftQuery = new CellQuery(
                leftSlots, leftQueryWhereClause, leftExtent, originalCell.GetLeftQuery(viewTarget).SelectDistinctFlag);

            Cell newCell;
            if (viewTarget == ViewTarget.UpdateView)
            {
                newCell = Cell.CreateCS(rightQuery, leftQuery, originalCell.CellLabel, m_currentCellNumber);
            }
            else
            {
                newCell = Cell.CreateCS(leftQuery, rightQuery, originalCell.CellLabel, m_currentCellNumber);
            }

            m_currentCellNumber++;
            result = newCell;
            return true;
        }