コード例 #1
0
        public SearchCriteriaQuery CreateCriteriaQuery(SearchCriteriaContract searchCriteriaContract, Dictionary <string, object> metadataParameters)
        {
            var wordListCriteria  = (WordListCriteriaContract)searchCriteriaContract;
            var resourceAlias     = string.Format("r{0:N}", Guid.NewGuid());
            var pageResourceAlias = string.Format("pr{0:N}", Guid.NewGuid());
            var termAlias         = string.Format("t{0:N}", Guid.NewGuid());
            var whereBuilder      = new StringBuilder();

            foreach (WordCriteriaContract wordCriteria in wordListCriteria.Disjunctions)
            {
                if (whereBuilder.Length > 0)
                {
                    whereBuilder.Append(" or");
                }

                var uniqueParameterName = $"param{metadataParameters.Count}";
                whereBuilder.AppendFormat(" {0}.Text like (:{1})", termAlias, uniqueParameterName);
                metadataParameters.Add(uniqueParameterName, CriteriaConditionBuilder.Create(wordCriteria));
            }

            return(new SearchCriteriaQuery
            {
                CriteriaKey = CriteriaKey,
                Join = string.Format("inner join project.Resources {0} inner join {0}.ResourceVersions {1} inner join {1}.Terms {2}", resourceAlias, pageResourceAlias, termAlias),
                Where = whereBuilder.ToString(),
            });
        }
コード例 #2
0
        public SearchCriteriaQuery CreateCriteriaQuery(SearchCriteriaContract searchCriteriaContract, Dictionary <string, object> metadataParameters)
        {
            var wordListCriteria           = (WordListCriteriaContract)searchCriteriaContract;
            var projectOriginalAuthorAlias = string.Format("poa{0:N}", Guid.NewGuid());
            var originalAuthorAlias        = string.Format("oa{0:N}", Guid.NewGuid());

            var whereBuilder = new StringBuilder();

            foreach (WordCriteriaContract wordCriteria in wordListCriteria.Disjunctions)
            {
                if (whereBuilder.Length > 0)
                {
                    whereBuilder.Append(" or");
                }

                var uniqueParameterName = $"param{metadataParameters.Count}";
                whereBuilder.AppendFormat(" concat({0}.FirstName, ' ', {0}.LastName) like (:{1})", originalAuthorAlias, uniqueParameterName);
                whereBuilder.AppendFormat(" or concat({0}.LastName, ' ', {0}.FirstName) like (:{1})", originalAuthorAlias, uniqueParameterName);
                metadataParameters.Add(uniqueParameterName, CriteriaConditionBuilder.Create(wordCriteria));
            }

            return(new SearchCriteriaQuery
            {
                CriteriaKey = CriteriaKey,
                Join = string.Format("inner join project.Authors {0} inner join {0}.OriginalAuthor {1}", projectOriginalAuthorAlias, originalAuthorAlias),
                Where = whereBuilder.ToString()
            });
        }
コード例 #3
0
        public SearchCriteriaQuery CreateCriteriaQuery(SearchCriteriaContract searchCriteriaContract, Dictionary <string, object> metadataParameters)
        {
            var wordListCriteria = (WordListCriteriaContract)searchCriteriaContract;
            var pageAlias        = string.Format("pa{0}", Guid.NewGuid().ToString("N"));
            var termAlias        = string.Format("ta{0}", Guid.NewGuid().ToString("N"));
            var whereBuilder     = new StringBuilder();

            foreach (WordCriteriaContract wordCriteria in wordListCriteria.Disjunctions)
            {
                if (whereBuilder.Length > 0)
                {
                    whereBuilder.Append(" or");
                }

                var uniqueParameterName = string.Format("up{0}", Guid.NewGuid().ToString("N"));
                whereBuilder.AppendFormat(" {0}.Text like (:{1})", termAlias, uniqueParameterName);
                metadataParameters.Add(uniqueParameterName, CriteriaConditionBuilder.Create(wordCriteria));
            }

            return(new SearchCriteriaQuery
            {
                Join = string.Format("inner join bv.BookPages {0} inner join {0}.Terms {1}", pageAlias, termAlias),
                Where = whereBuilder.ToString(),
            });
        }
コード例 #4
0
        public SearchCriteriaQuery CreateCriteriaQuery(SearchCriteriaContract searchCriteriaContract, Dictionary <string, object> metadataParameters)
        {
            var wordListCriteria        = (WordListCriteriaContract)searchCriteriaContract;
            var projectResponsibleAlias = string.Format("prp{0:N}", Guid.NewGuid());
            var responsiblePersonAlias  = string.Format("rp{0:N}", Guid.NewGuid());
            var responsibleTypeAlias    = string.Format("rt{0:N}", Guid.NewGuid());
            var whereBuilder            = new StringBuilder();

            if (wordListCriteria.Disjunctions.Count > 0)
            {
                whereBuilder.Append('(');

                foreach (WordCriteriaContract wordCriteria in wordListCriteria.Disjunctions)
                {
                    if (whereBuilder.Length > 1)
                    {
                        whereBuilder.Append(" or");
                    }

                    var uniqueParameterName = $"param{metadataParameters.Count}";
                    whereBuilder.AppendFormat(" concat({0}.FirstName, ' ', {0}.LastName) like (:{1}) ", responsiblePersonAlias, uniqueParameterName);
                    whereBuilder.AppendFormat(" or concat({0}.LastName, ' ', {0}.FirstName) like (:{1}) ", responsiblePersonAlias, uniqueParameterName);
                    metadataParameters.Add(uniqueParameterName, CriteriaConditionBuilder.Create(wordCriteria));
                }

                whereBuilder.Append(')');
            }

            if (whereBuilder.Length > 0)
            {
                whereBuilder.Append(" and ");
            }

            var responsibleTypeParameter = $"param{metadataParameters.Count}";

            whereBuilder.AppendFormat("{0}.Type = :{1}", responsibleTypeAlias, responsibleTypeParameter);
            metadataParameters.Add(responsibleTypeParameter, ResponsibleTypeEnum.Editor);

            return(new SearchCriteriaQuery
            {
                CriteriaKey = CriteriaKey,
                Join = string.Format("inner join project.ResponsiblePersons {0} inner join {0}.ResponsiblePerson {1} inner join {0}.ResponsibleType {2}", projectResponsibleAlias, responsiblePersonAlias, responsibleTypeAlias),
                Where = whereBuilder.ToString(),
            });
        }
コード例 #5
0
        public void AddCriteria(SearchCriteriaContract contract)
        {
            var wordListCriteria = contract as WordListCriteriaContract;

            if (contract.Key != CriteriaKey || wordListCriteria == null)
            {
                return;
            }

            var newCriteria = new ConjunctionCriteria();

            foreach (var wordCriteria in wordListCriteria.Disjunctions)
            {
                newCriteria.Disjunctions.Add(CriteriaConditionBuilder.Create(wordCriteria));
            }

            CriteriaList.Add(newCriteria);
        }
コード例 #6
0
ファイル: SearchManager.cs プロジェクト: daliboris/ITJakub
        private string GetSingleHeadwordQuery(IList <SearchCriteriaContract> searchCriteria)
        {
            var headwordCriteria =
                searchCriteria.Where(x => x.Key == CriteriaKey.Headword)
                .OfType <WordListCriteriaContract>()
                .SingleOrDefault();

            if (headwordCriteria == null)
            {
                return(null);
            }

            var wordCriteria = headwordCriteria.Disjunctions.SingleOrDefault();

            if (wordCriteria == null)
            {
                return(null);
            }

            return(CriteriaConditionBuilder.Create(wordCriteria));
        }
コード例 #7
0
        public SearchCriteriaQuery CreateCriteriaQuery(SearchCriteriaContract searchCriteriaContract, Dictionary <string, object> metadataParameters)
        {
            HeadwordItem headwordItemAlias = null;
            var          wordListCriteria  = (WordListCriteriaContract)searchCriteriaContract;
            var          disjunction       = new Disjunction();

            foreach (WordCriteriaContract wordCriteria in wordListCriteria.Disjunctions)
            {
                var parameter   = CriteriaConditionBuilder.Create(wordCriteria);
                var restriction = Restrictions.Like(Projections.Property(() => headwordItemAlias.Headword), parameter, MatchMode.Exact);

                disjunction.Add(restriction);
            }

            return(new SearchCriteriaQuery
            {
                CriteriaKey = CriteriaKey,
                Join = string.Empty,
                Where = string.Empty,
                Restriction = disjunction,
            });
        }
コード例 #8
0
        public SearchCriteriaQuery CreateCriteriaQuery(SearchCriteriaContract searchCriteriaContract, Dictionary <string, object> metadataParameters)
        {
            var wordListCriteria = (WordListCriteriaContract)searchCriteriaContract;
            var whereBuilder     = new StringBuilder();

            foreach (WordCriteriaContract wordCriteria in wordListCriteria.Disjunctions)
            {
                if (whereBuilder.Length > 0)
                {
                    whereBuilder.Append(" or");
                }

                var uniqueParameterName = string.Format("up{0}", Guid.NewGuid().ToString("N"));
                whereBuilder.AppendFormat(" bv.Title like (:{0})", uniqueParameterName);
                metadataParameters.Add(uniqueParameterName, CriteriaConditionBuilder.Create(wordCriteria));
            }

            return(new SearchCriteriaQuery
            {
                Join = string.Empty,
                Where = whereBuilder.ToString(),
            });
        }