Ejemplo n.º 1
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.QueryComplete);
            }
            else
            {
                return null;
            }
        }
Ejemplo n.º 2
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);
            }
        }
Ejemplo n.º 3
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.QueryComplete);
        }
Ejemplo n.º 4
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));
        }
Ejemplo n.º 5
0
        protected override global::MongoDB.Driver.MongoCursor<global::MongoDB.Bson.BsonDocument> Query(MongoDBVisitor visitor)
        {
            var childrenQuery = (ChildrenQuery)this.ContentQuery;

            MongoDBQueryTranslator translator = new MongoDBQueryTranslator();

            var parents = ((IEnumerable<TextContent>)(translator.Translate(childrenQuery.ParentQuery)).Execute());

            if (childrenQuery.EmbeddedFolder != null)
            {
                visitor.SetQuery(MongoDBHelper.EQIgnoreCase("FolderName", childrenQuery.EmbeddedFolder.FullName));
            }
            if (parents.Count() > 0)
            {
                visitor.SetQuery(QueryBuilder.Query.In("ParentUUID", parents.Select(it => BsonHelper.Create(it.UUID)).ToArray()));

                return childrenQuery.ChildSchema.GetCollection().Find(visitor.MongoQuery);
            }

            return null;
        }
Ejemplo n.º 6
0
        protected override global::MongoDB.Driver.MongoCursor <global::MongoDB.Bson.BsonDocument> Query(MongoDBVisitor visitor)
        {
            var childrenQuery = (ChildrenQuery)this.ContentQuery;

            MongoDBQueryTranslator translator = new MongoDBQueryTranslator();

            var parents = ((IEnumerable <TextContent>)(translator.Translate(childrenQuery.ParentQuery)).Execute());

            if (childrenQuery.EmbeddedFolder != null)
            {
                visitor.SetQuery(MongoDBHelper.EQIgnoreCase("FolderName", childrenQuery.EmbeddedFolder.FullName));
            }
            if (parents.Count() > 0)
            {
                visitor.SetQuery(QueryBuilder.Query.In("ParentUUID", parents.Select(it => BsonHelper.Create(it.UUID)).ToArray()));

                return(childrenQuery.ChildSchema.GetCollection().Find(visitor.MongoQuery));
            }

            return(null);
        }
Ejemplo n.º 7
0
 public object Execute(IContentQuery <Models.TextContent> query)
 {
     Query.MongoDBQueryTranslator translator = new Query.MongoDBQueryTranslator();
     return(translator.Translate(query).Execute());
 }
Ejemplo n.º 8
0
 public object Execute(IContentQuery<Models.TextContent> query)
 {
     Query.MongoDBQueryTranslator translator = new Query.MongoDBQueryTranslator();
     return translator.Translate(query).Execute();
 }