Exemplo n.º 1
0
        protected override void VisitWhereBetween(Content.Query.Expressions.WhereBetweenExpression expression)
        {
            var query = QueryBuilder.Query.GT(expression.FieldName, BsonHelper.Create(expression.Start))
                        .LT(BsonHelper.Create(expression.End));

            SetQuery(query);
        }
Exemplo n.º 2
0
        protected override global::MongoDB.Driver.MongoCursor <global::MongoDB.Bson.BsonDocument> Query(MongoDBVisitor visitor)
        {
            var parentQuery = (ParentQuery)this.ContentQuery;

            MongoDBQueryTranslator translator = new MongoDBQueryTranslator();

            var children = ((IEnumerable <TextContent>)(translator.Translate(parentQuery.ChildrenQuery)).Execute());

            if (parentQuery.ParentFolder != null)
            {
                visitor.SetQuery(MongoDBHelper.EQIgnoreCase("FolderName", parentQuery.ParentFolder.FullName));
            }

            if (children.Count() > 0)
            {
                visitor.SetQuery(QueryBuilder.Query.In("UUID", children.Select(it => BsonHelper.Create(it.ParentUUID)).ToArray()));

                return(parentQuery.ParentSchema.GetCollection().Find(visitor.QueryComplete));
            }

            return(null);
        }
Exemplo n.º 3
0
        protected override void VisitWhereNotIn(WhereNotInExpression expression)
        {
            var query = QueryBuilder.Query.NotIn(expression.FieldName, expression.Values.Select(it => BsonHelper.Create(it)).ToArray());

            SetQuery(query);
        }
Exemplo n.º 4
0
        protected override void VisitWhereLessThanOrEqual(WhereLessThanOrEqualExpression expression)
        {
            var query = QueryBuilder.Query.LTE(expression.FieldName, BsonHelper.Create(expression.Value));

            SetQuery(query);
        }
Exemplo n.º 5
0
        protected override void VisitWhereGreaterThanOrEqual(Content.Query.Expressions.WhereGreaterThanOrEqualExpression expression)
        {
            var query = QueryBuilder.Query.GTE(expression.FieldName, BsonHelper.Create(expression.Value));

            SetQuery(query);
        }
Exemplo n.º 6
0
        protected override global::MongoDB.Driver.MongoCursor <global::MongoDB.Bson.BsonDocument> Query(MongoDBVisitor visitor)
        {
            var textContentQuery = (TextContentQuery)ContentQuery;

            if (textContentQuery.Folder != null)
            {
                visitor.SetQuery(MongoDBHelper.EQIgnoreCase("FolderName", textContentQuery.Folder.FullName));
            }

            if (visitor.CategoryQueries != null && visitor.CategoryQueries.Count() > 0)
            {
                MongoDBQueryTranslator translator = new MongoDBQueryTranslator();

                IEnumerable <BsonDocument> categoryContents = null;

                foreach (var categoryQuery in visitor.CategoryQueries)
                {
                    var categories = ((IEnumerable <TextContent>)translator.Translate(categoryQuery).Execute()).ToArray();

                    if (categories.Count() > 0)
                    {
                        var categoryQueryComplete = MongoDBHelper.EQIgnoreCase("CategoryFolder", ((TextContentQueryBase)categoryQuery).Folder.FullName);
                        var inCategories          = QueryBuilder.Query.In("CategoryUUID", categories.Select(it => BsonHelper.Create(it.UUID)).ToArray());
                        var relation = textContentQuery.Repository.GetCategoriesCollection().Find(QueryBuilder.Query.And(categoryQueryComplete, inCategories));

                        if (categoryContents == null)
                        {
                            categoryContents = relation;
                        }
                        else
                        {
                            //intersection of sets
                            categoryContents = categoryContents
                                               .Where(it => relation.Any(r => r["ContentUUID"].AsString == it["ContentUUID"].AsString));
                        }
                    }
                }
                if (categoryContents != null && categoryContents.Count() != 0)
                {
                    visitor.SetQuery(QueryBuilder.Query.In("UUID", categoryContents.Select(it => it["ContentUUID"]).ToArray()));
                }
                else
                {
                    visitor.SetQuery(QueryBuilder.Query.Where(new BsonJavaScript("false")));
                }
            }

            return(textContentQuery.Schema.GetCollection().Find(visitor.MongoQuery));
        }
Exemplo n.º 7
0
        protected override global::MongoDB.Driver.MongoCursor <global::MongoDB.Bson.BsonDocument> Query(MongoDBVisitor visitor)
        {
            var categoriesQuery = (CategoriesQuery)ContentQuery;
            MongoDBQueryTranslator translator = new MongoDBQueryTranslator();


            if (categoriesQuery.CategoryFolder != null)
            {
                visitor.SetQuery(MongoDBHelper.EQIgnoreCase("FolderName", categoriesQuery.CategoryFolder.FullName));
            }

            var subQuery = translator.Translate(categoriesQuery.InnerQuery);
            var contents = ((IEnumerable <TextContent>)subQuery.Execute());

            if (contents.Count() > 0)
            {
                var categoryQueryComplete = MongoDBHelper.EQIgnoreCase("CategoryFolder", categoriesQuery.CategoryFolder.FullName);

                var inCategories = QueryBuilder.Query.In("ContentUUID", contents.Select(it => BsonHelper.Create(it.UUID)).ToArray());

                var relation = categoriesQuery.Repository.GetCategoriesCollection().Find(QueryBuilder.Query.And(categoryQueryComplete, inCategories));

                visitor.SetQuery(QueryBuilder.Query.In("UUID", relation.Select(it => it["CategoryUUID"]).ToArray()));


                return(categoriesQuery.CategoryFolder.GetSchema().GetCollection().Find(visitor.MongoQuery));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 8
0
        protected override void VisitWhereBetweenOrEqual(Content.Query.Expressions.WhereBetweenOrEqualExpression expression)
        {
            var query = QueryBuilder.Query.And(QueryBuilder.Query.GTE(expression.FieldName, BsonHelper.Create(expression.Start)),
                                               QueryBuilder.Query.LTE(expression.FieldName, BsonHelper.Create(expression.End)));

            SetQuery(query);
        }