Beispiel #1
0
 public override SnQueryPredicate VisitSimplePredicate(SimplePredicate simplePredicate)
 {
     if (!SharingRelatedFieldNames.Contains(simplePredicate.FieldName))
     {
         _isSharingStack.Push(false);
         return(simplePredicate);
     }
     _isSharingStack.Push(true);
     return(SharingComposerVisitor.CreateSharingSimplePredicate(simplePredicate.Value));
 }
Beispiel #2
0
        private LogicalPredicate VisitTopLevelSharingPredicate(LogicalPredicate logic, bool[] isSharingFlags)
        {
            var generalClauses = new List <LogicalClause>();
            var sharingClauses = new List <LogicalClause>();

            for (int i = 0; i < logic.Clauses.Count; i++)
            {
                if (isSharingFlags[i])
                {
                    sharingClauses.Add(logic.Clauses[i]);
                }
                else
                {
                    generalClauses.Add(logic.Clauses[i]);
                }
            }

            // ---------------------------------------------------


            // Handle logical predicates
            var sharingPredicate           = new LogicalPredicate(sharingClauses);
            var normalizer                 = new SharingNormalizerVisitor();
            var normalizedSharingPredicate = normalizer.Visit(sharingPredicate);

            // Make combinations
            var composer    = new SharingComposerVisitor();
            var composition = (LogicalPredicate)composer.Visit(normalizedSharingPredicate);

            // Last normalization
            var normalizedComposition = new SharingNormalizerVisitor().Visit(composition);

            // Convert sharing combined values from string array to one comma separated string
            var finalizer = new SharingFinalizerVisitor();
            var finalTree = (LogicalPredicate)finalizer.Visit(normalizedComposition);

            // Return the final product
            var allClauses = generalClauses.Union(finalTree.Clauses);

            return(new LogicalPredicate(allClauses));
        }