public TranslatedQuery Translate(Query.IContentQuery <TextContent> contentQuery)
        {
            if (contentQuery is CategoriesQuery)
            {
                var categoriesQuery = (CategoriesQuery)contentQuery;
                var translated      = new TranslatedCategoriesQuery(categoriesQuery.Repository, categoriesQuery.CategoryFolder);
                translated.SubQuery = this.Translate(categoriesQuery.InnerQuery);

                StringVisitor visitor = new StringVisitor(translated);
                visitor.Visite(contentQuery.Expression);

                return(translated);
            }
            //else if (contentQuery is CategorizablesQuery)
            //{
            //    var categorizablesQuery = (CategorizablesQuery)contentQuery;
            //    var translated = new TranslatedCategorizablesQuery(categorizablesQuery.Repository, categorizablesQuery.CategorizableFolder);
            //    translated.CategoryQuery = this.Translate(categorizablesQuery.CategoryQuery);

            //    StringVisitor visitor = new StringVisitor(translated);
            //    visitor.Visite(contentQuery.Expression);

            //    return translated;
            //}
            else if (contentQuery is ChildrenQuery)
            {
                var childrenQuery = (ChildrenQuery)contentQuery;
                var translated    = new TranslatedChildrenQuery(childrenQuery.Repository, childrenQuery.ChildSchema);
                translated.ParentQuery = this.Translate(childrenQuery.ParentQuery);

                StringVisitor visitor = new StringVisitor(translated);
                visitor.Visite(contentQuery.Expression);

                return(translated);
            }
            else if (contentQuery is ParentQuery)
            {
                var parentQuery = (ParentQuery)contentQuery;
                var translated  = new TranslatedParentQuery(parentQuery.Repository, parentQuery.ParentSchema);
                translated.ChildrenQuery = this.Translate(parentQuery.ChildrenQuery);


                StringVisitor visitor = new StringVisitor(translated);
                visitor.Visite(contentQuery.Expression);

                return(translated);
            }
            else if (contentQuery is TextContentQuery)
            {
                var textContentQuery = (TextContentQuery)contentQuery;
                var translated       = new TranslatedTextContentQuery(textContentQuery.Repository, textContentQuery.Schema, textContentQuery.Folder);

                StringVisitor visitor = new StringVisitor(translated);
                visitor.Visite(contentQuery.Expression);

                return(translated);
            }
            return(null);
        }
Example #2
0
        public TranslatedQuery Translate(IContentQuery <MediaContent> contentQuery)
        {
            var mediaQuery = (MediaContentQuery)contentQuery;
            TranslatedMediaContentQuery query = new TranslatedMediaContentQuery(contentQuery.Repository, mediaQuery.MediaFolder);

            StringVisitor visitor = new StringVisitor(query);

            visitor.Visite(contentQuery.Expression);

            return(query);
        }
Example #3
0
        private TranslatedQuery VisitInner(IExpression expression)
        {
            InnerQuery query = new InnerQuery();

            StringVisitor visitor = new StringVisitor(query);

            visitor.Visite(expression);
            //combine the order expressions.
            this.OrderFields.AddRange(visitor.OrderFields);

            return(query);
        }
Example #4
0
        public void Test1()
        {
            MockQuery query = new MockQuery();

            StringVisitor visitor = new StringVisitor(query);

            Expression ex = new WhereEqualsExpression(null, "Title", "title1");

            visitor.Visite(ex);

            Assert.AreEqual("Title = title1", query.ClauseText);
        }
Example #5
0
 public void Test2()
 {
     DataRuleContext context = new DataRuleContext(null, null) { ValueProvider = new NameValueCollectionValueProvider(new NameValueCollection()) };
     WhereClause[] clauses = new WhereClause[] {
         new WhereClause(){ FieldName="title", Operator = Operator.Contains, Value1= "title1",Logical = Logical.Or },
         new WhereClause(){ FieldName="title", Operator = Operator.Contains,Value1="title1",Logical = Logical.And },
         new WhereClause(){ FieldName="body", Operator = Operator.Contains,Value1="body1",Logical = Logical.Or },
         new WhereClause(){ FieldName="body", Operator = Operator.Contains,Value1="body2",Logical = Logical.Or },
         new WhereClause(){ FieldName="userkey", Operator = Operator.Contains,Value1="userkey1",Logical = Logical.Or }
     };
     var expression = WhereClauseToContentQueryHelper.Parse(clauses, context);
     var query = new TranslatedQueryMock();
     StringVisitor visitor = new StringVisitor(query);
     visitor.Visite(expression);
     Assert.AreEqual("((((((((title Conatins title1) OR (title Conatins title1))) AND (body Conatins body1))) OR (body Conatins body2))) OR (userkey Conatins userkey1))", query.ClauseText);
 }
Example #6
0
        private TranslatedQuery VisitInner(IExpression expression)
        {
            InnerQuery query = new InnerQuery();

            StringVisitor visitor = new StringVisitor(query);
            visitor.Visite(expression);
            //combine the order expressions.
            this.OrderFields.AddRange(visitor.OrderFields);

            return query;
        }