protected override string BuildIfClause(CouchbaseVisitor visitor, out string viewName, out string[] keys)
        {
            CouchbaseQueryTranslator translator = new CouchbaseQueryTranslator();
            string clause = visitor.WhereClause;

            viewName = visitor.ViewName;

            if (this._categoriesQuery.CategoryFolder != null)
            {
                var folderName = visitor.MakeValue(this._categoriesQuery.CategoryFolder.FullName);
                clause += string.Format("{0}({1}=={2})",
                                        string.IsNullOrEmpty(clause) ? string.Empty : "&&",
                                        "doc[\\\"FolderName\\\"]",
                                        folderName);

                viewName = string.Format("FolderName_EQ_{0}_", visitor.AsViewNameString(this._categoriesQuery.CategoryFolder.FullName)) + viewName;
            }
            keys = null;
            var subQuery = translator.Translate(this._categoriesQuery.InnerQuery);
            var contents = ((IEnumerable <TextContent>)subQuery.Execute()).ToList();

            if (contents.Count() > 0)
            {
                var uuids = contents.Select(it => it.UUID);
                keys = uuids.SelectMany(it => QueryCategories(this._categoriesQuery.Repository, it)).ToArray();
            }
            else
            {
                keys = new string[0];
            }

            return(clause);
        }
        protected override string BuildIfClause(CouchbaseVisitor visitor, out string viewName, out string[] keys)
        {
            keys = null;

            string clause = visitor.WhereClause;

            viewName = visitor.ViewName;

            CouchbaseQueryTranslator translator = new CouchbaseQueryTranslator();

            if (this._parentQuery.ParentFolder != null)
            {
                var folderName = visitor.MakeValue(this._parentQuery.ParentFolder.FullName);
                clause += string.Format("{0}({1}=={2})",
                                        string.IsNullOrEmpty(clause) ? string.Empty : "&&",
                                        "doc[\\\"FolderName\\\"]",
                                        folderName);

                viewName = string.Format("FolderName_EQ_{0}_", visitor.AsViewNameString(this._parentQuery.ParentFolder.FullName)) + viewName;
            }

            var children = ((IEnumerable <TextContent>)(translator.Translate(this._parentQuery.ChildrenQuery)).Execute()).ToList();

            if (children.Count() > 0)
            {
                keys = children.Select(it => it.ParentUUID).ToArray();
            }
            else
            {
                keys = new string[0];
            }

            return(clause);
        }
Example #3
0
        protected override string BuildIfClause(CouchbaseVisitor visitor, out string viewName, out string[] keys)
        {
            keys = null;


            string clause = visitor.WhereClause;
            viewName = visitor.ViewName;
            CouchbaseQueryTranslator translator = new CouchbaseQueryTranslator();
            if (this._childrenQuery.EmbeddedFolder != null)
            {
                var folderName = visitor.MakeValue(this._childrenQuery.EmbeddedFolder.FullName);
                clause += string.Format("{0}({1}=={2})",
                    string.IsNullOrEmpty(clause) ? string.Empty : "&&",
                    "doc[\\\"FolderName\\\"]",
                    folderName);

                viewName = string.Format("FolderName_EQ_{0}_", visitor.AsViewNameString(this._childrenQuery.EmbeddedFolder.FullName)) + viewName;
            }

            var parents = ((IEnumerable<TextContent>)(translator.Translate(this._childrenQuery.ParentQuery)).Execute()).ToList();
            if (parents.Count() > 0)
            {
                keys = parents.SelectMany(it => QueryChildren(this.ContentQuery.Repository, it.UUID)).ToArray();
            }
            else
            {
                keys = new string[0];
            }

            return clause;
        }
Example #4
0
        protected override string BuildIfClause(CouchbaseVisitor visitor, out string viewName, out string[] keys)
        {

            CouchbaseQueryTranslator translator = new CouchbaseQueryTranslator();
            string clause = visitor.WhereClause;
            viewName = visitor.ViewName;

            if (this._categoriesQuery.CategoryFolder != null)
            {
                var folderName = visitor.MakeValue(this._categoriesQuery.CategoryFolder.FullName);
                clause += string.Format("{0}({1}=={2})",
                    string.IsNullOrEmpty(clause) ? string.Empty : "&&",
                    "doc[\\\"FolderName\\\"]",
                    folderName);

                viewName = string.Format("FolderName_EQ_{0}_", visitor.AsViewNameString(this._categoriesQuery.CategoryFolder.FullName)) + viewName;
            }
            keys = null;
            var subQuery = translator.Translate(this._categoriesQuery.InnerQuery);
            var contents = ((IEnumerable<TextContent>)subQuery.Execute()).ToList();
            if (contents.Count() > 0)
            {
                var uuids = contents.Select(it => it.UUID);
                keys = uuids.SelectMany(it => QueryCategories(this._categoriesQuery.Repository, it)).ToArray();
            }
            else
            {
                keys = new string[0];
            }

            return clause;
        }
Example #5
0
        protected override string BuildIfClause(CouchbaseVisitor visitor, out string viewName, out string[] keys)
        {
            string clause = visitor.WhereClause;

            viewName = visitor.ViewName;

            if (this._textContentQuery.Folder != null)
            {
                var folderName = visitor.MakeValue(this._textContentQuery.Folder.FullName);
                clause += string.Format("{0}({1}=={2})",
                                        string.IsNullOrEmpty(clause) ? string.Empty : "&&",
                                        "doc[\\\"FolderName\\\"]",
                                        folderName);
                viewName = string.Format("FolderName_EQ_{0}_", visitor.AsViewNameString(this._textContentQuery.Folder.FullName)) + viewName;
            }
            else if (this._textContentQuery.Schema != null)
            {
                clause += string.Format("{0}({1}=={2})",
                                        string.IsNullOrEmpty(clause) ? string.Empty : "&&",
                                        "doc[\\\"SchemaName\\\"]",
                                        visitor.MakeValue(this._textContentQuery.Schema.Name));
                viewName = string.Format("SchemaName_EQ_{0}_", visitor.AsViewNameString(this._textContentQuery.Schema.Name)) + viewName;
            }

            keys = null;
            IEnumerable <string> categoryContents = new string[0];

            if (visitor.CategoryQueries != null && visitor.CategoryQueries.Count() > 0)
            {
                CouchbaseQueryTranslator translator = new CouchbaseQueryTranslator();
                //TODO
                foreach (var item in visitor.CategoryQueries)
                {
                    var categories = ((IEnumerable <TextContent>)translator.Translate(item).Execute()).ToArray();
                    if (categories.Length > 0)
                    {
                        var categoryUUIDs = categories.SelectMany(it => QueryByCategory(this._textContentQuery.Repository, it.UUID)).ToArray();
                        categoryContents = categoryContents.Concat(categoryUUIDs);
                    }
                }

                keys = categoryContents.Distinct().ToArray();
            }

            return(clause);
        }
Example #6
0
        protected override string BuildIfClause(CouchbaseVisitor visitor, out string viewName, out string[] keys)
        {

            string clause = visitor.WhereClause;
            viewName = visitor.ViewName;

            if (this._textContentQuery.Folder != null)
            {
                var folderName = visitor.MakeValue(this._textContentQuery.Folder.FullName);
                clause += string.Format("{0}({1}=={2})",
                    string.IsNullOrEmpty(clause) ? string.Empty : "&&",
                    "doc[\\\"FolderName\\\"]",
                    folderName);
                viewName = string.Format("FolderName_EQ_{0}_", visitor.AsViewNameString(this._textContentQuery.Folder.FullName)) + viewName;
            }
            else if (this._textContentQuery.Schema != null)
            {
                clause += string.Format("{0}({1}=={2})",
                    string.IsNullOrEmpty(clause) ? string.Empty : "&&",
                    "doc[\\\"SchemaName\\\"]",
                    visitor.MakeValue(this._textContentQuery.Schema.Name));
                viewName = string.Format("SchemaName_EQ_{0}_", visitor.AsViewNameString(this._textContentQuery.Schema.Name)) + viewName;
            }

            keys = null;
            IEnumerable<string> categoryContents = new string[0];
            if (visitor.CategoryQueries != null && visitor.CategoryQueries.Count() > 0)
            {
                CouchbaseQueryTranslator translator = new CouchbaseQueryTranslator();
                //TODO
                foreach (var item in visitor.CategoryQueries)
                {
                    var categories = ((IEnumerable<TextContent>)translator.Translate(item).Execute()).ToArray();
                    if (categories.Length > 0)
                    {
                        var categoryUUIDs = categories.SelectMany(it => QueryByCategory(this._textContentQuery.Repository, it.UUID)).ToArray();
                        categoryContents = categoryContents.Concat(categoryUUIDs);
                    }
                }

                keys = categoryContents.Distinct().ToArray();
            }

            return clause;
        }
Example #7
0
 public object Execute(IContentQuery <Models.TextContent> query)
 {
     Query.CouchbaseQueryTranslator translator = new Query.CouchbaseQueryTranslator();
     return(translator.Translate(query).Execute());
 }
Example #8
0
 public object Execute(IContentQuery<Models.TextContent> query)
 {
     Query.CouchbaseQueryTranslator translator = new Query.CouchbaseQueryTranslator();
     return translator.Translate(query).Execute();
 }