示例#1
0
        static Expression <Func <Journal, bool> > AddSwotMatrixFilter(JournalFilter filter)
        {
            var predicate = PredicateBuilder.False <Journal>();

            foreach (var swot in filter.SwotMatrix)
            {
                switch (swot)
                {
                case SwotVerdict.StrongJournal:
                    predicate = predicate.Or(j => j.OverallScore.AverageScore >= 3 && j.ValuationScore.AverageScore >= 3);
                    break;

                case SwotVerdict.WeakerJournal:
                    predicate = predicate.Or(j => j.OverallScore.AverageScore < 3 && j.ValuationScore.AverageScore < 3);
                    break;

                case SwotVerdict.ThreatToAuthor:
                    predicate = predicate.Or(j => j.OverallScore.AverageScore >= 3 && j.ValuationScore.AverageScore < 3);
                    break;

                case SwotVerdict.OpportunityToPublisher:
                    predicate = predicate.Or(j => j.OverallScore.AverageScore < 3 && j.ValuationScore.AverageScore >= 3);
                    break;
                }
            }

            return(predicate);
        }
        public IActionResult Get(string filter, int page, int pageSize, string orderBy)
        {
            var filtered = JournalFilter.Deserializer(filter);
            var response = _journalService.QueryJournalCount(page, pageSize, filtered, orderBy);

            return(Ok(response));
        }
示例#3
0
        static IOrderedQueryable <Journal> ApplyOrdering(IQueryable <Journal> query, JournalFilter filter)
        {
            switch (filter.SortMode)
            {
            case JournalSortMode.RobustScores:
                return(filter.SortDirection == SortDirection.Ascending ?
                       query.OrderBy(WeightedSort()).ThenBy(u => u.Title) :
                       query.OrderByDescending(WeightedSort()).ThenBy(u => u.Title));

            case JournalSortMode.BaseScore:
                return(filter.SortDirection == SortDirection.Ascending ?
                       query.OrderBy(j => j.OverallScore.AverageScore).ThenBy(j => j.ValuationScore.AverageScore).ThenBy(j => j.Title) :
                       query.OrderByDescending(j => j.OverallScore.AverageScore).ThenByDescending(j => j.ValuationScore.AverageScore).ThenBy(j => j.Title));

            case JournalSortMode.ValuationScore:
                return(filter.SortDirection == SortDirection.Ascending ?
                       query.OrderBy(j => j.ValuationScore.AverageScore).ThenBy(j => j.OverallScore.AverageScore).ThenBy(j => j.Title) :
                       query.OrderByDescending(j => j.ValuationScore.AverageScore).ThenByDescending(j => j.OverallScore.AverageScore).ThenBy(j => j.Title));

            case JournalSortMode.Name:
                return(filter.SortDirection == SortDirection.Ascending ? query.OrderBy(j => j.Title) : query.OrderByDescending(j => j.Title));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
示例#4
0
        public IPagedList <Journal> Search(JournalFilter filter)
        {
            var query = this.DbContext.Journals
                        .Include(j => j.Publisher)
                        .Include(j => j.Languages)
                        .Include(j => j.Subjects);

            return(query.Search(filter));
        }
示例#5
0
        public IEnumerable <JournalItem> QueryThesis(int page, int count, JournalFilter filterExpression = null,
                                                     string orderByExpression = null)
        {
            var orderBy = OrderExpression.Deserializer(orderByExpression);
            //var entities = _repository.GetJournalPaged(page, count, filterExpression, orderBy).Where(x => x.Applicant.Id == orderByExpression);
            var entities = _repository.GetJournalPaged(page, count, filterExpression, orderBy).ToList();

            return(ProcessQuery(entities));
        }
示例#6
0
        public IPagedList <Journal> Search(JournalFilter filter)
        {
            var query = this.DbContext.Journals
                        .Include(j => j.Publisher)
                        .Include(j => j.Languages)
                        .Include(j => j.Subjects)
                        .Include(j => j.JournalScore).
                        AsExpandable();

            if (!string.IsNullOrWhiteSpace(filter.Title))
            {
                query = query.Where(j => j.Title.ToLower().Contains(filter.Title.ToLower()));
            }

            if (!string.IsNullOrWhiteSpace(filter.Issn))
            {
                query = query.Where(j => j.ISSN.ToLower().Contains(filter.Issn.ToLower()));
            }

            if (!string.IsNullOrWhiteSpace(filter.Publisher))
            {
                query = query.Where(j => j.Publisher.Name.ToLower().Contains(filter.Publisher.ToLower()));
            }

            if (filter.Discipline.HasValue)
            {
                query = query.Where(j => j.Subjects.Any(k => k.Id == filter.Discipline));
            }

            if (filter.Language.HasValue)
            {
                query = query.Where(j => j.Languages.Any(l => l.Id == filter.Language));
            }

            if (filter.SubmittedOnly)
            {
                query = query.Where(j => j.ValuationScoreCards.Any(v => v.State == ScoreCardState.Published));
            }

            if (filter.MustHaveBeenScored && filter.SwotMatrix.Count == 0)
            {
                query = query.Where(j => j.JournalScore.NumberOfBaseReviewers > 0 || j.JournalScore.NumberOfValuationReviewers > 0);
            }
            else if (filter.MustHaveBeenScored && filter.SwotMatrix.Count > 0)
            {
                query = query.Where(j => j.JournalScore.NumberOfBaseReviewers > 0 && j.JournalScore.NumberOfValuationReviewers > 0);
            }

            if (filter.SwotMatrix.Count > 0)
            {
                query = query.Where(AddSwotMatrixFilter(filter));
            }

            return(ApplyOrdering(query, filter).ToPagedList(filter.PageNumber, filter.PageSize));
        }
示例#7
0
        public IList <Journal> SearchAll(JournalFilter filter)
        {
            var query = this.DbContext.Journals.AsQueryable();

            if (filter.PublisherId.HasValue)
            {
                query = query.Where(j => j.PublisherId == filter.PublisherId.Value);
            }

            return(query.ToList());
        }
示例#8
0
        public CounterModel <JournalItem> QueryJournalCount(int page, int count, JournalFilter filter = null, string expression = null)
        {
            int totalCount;
            var orderBy  = OrderExpression.Deserializer(expression);
            var entities = _repository.GetJournalPaged(page, count, out totalCount, filter, orderBy).ToList();

            return(new CounterModel <JournalItem>()
            {
                Total = totalCount,
                Items = ProcessQuery(entities)
            });
        }
 public JournalQueryObject(JournalFilter filter)
 {
     if (filter != null)
     {
         if (filter.Id > 0)
         {
             And(c => c.Id == filter.Id);
         }
         if (!string.IsNullOrWhiteSpace(filter.Title))
         {
             And(c => c.Title.Contains(filter.Title));
         }
         if (!string.IsNullOrWhiteSpace(filter.SupervisorName))
         {
             And(c => c.SupervisorName.Contains(filter.SupervisorName));
         }
         if (!string.IsNullOrWhiteSpace(filter.Author))
         {
             And(c => c.Author == filter.Author);
         }
         if (!string.IsNullOrWhiteSpace(filter.FirstName))
         {
             And(c => c.Applicant.FirstName == filter.FirstName);
         }
         if (!string.IsNullOrWhiteSpace(filter.LastName))
         {
             And(c => c.Applicant.LastName == filter.LastName);
         }
         if (filter.DateCreatedFrom.HasValue)
         {
             And(c => c.DateSubmitted >= filter.DateCreatedFrom.Value);
         }
         if (filter.DateCreatedTo.HasValue)
         {
             And(c => c.DateSubmitted <= filter.DateCreatedTo.Value);
         }
     }
 }
示例#10
0
        public static IPagedList <Journal> Search(this IQueryable <Journal> query, JournalFilter filter)
        {
            query = query.AsExpandable();

            if (!string.IsNullOrWhiteSpace(filter.Title))
            {
                query = query.Where(j => j.Title.ToLower().Contains(filter.Title.ToLower()));
            }

            if (!string.IsNullOrWhiteSpace(filter.Issn))
            {
                query = query.Where(j => j.ISSN.ToLower().Contains(filter.Issn.ToLower()));
            }

            if (!string.IsNullOrWhiteSpace(filter.Publisher))
            {
                query = query.Where(j => j.Publisher.Name.ToLower().Contains(filter.Publisher.ToLower()));
            }

            if (filter.Disciplines.Any())
            {
                query = filter.Disciplines.Aggregate(query, (current, discipline) => current.Where(j => j.Subjects.Any(s => s.Id == discipline)));
            }

            if (filter.Languages.Any())
            {
                foreach (var language in filter.Languages)
                {
                    query = query.Where(j => j.Languages.Any(l => l.Name.ToLower().Contains(language.ToLower())));
                }
            }

            if (filter.OpenAccess.HasValue)
            {
                query = query.Where(j => j.OpenAccess == filter.OpenAccess.Value);
            }

            if (filter.InstitutionalDiscounts.HasValue)
            {
                query = query.Where(j => j.InstitutionJournalPrices.Any() == filter.InstitutionalDiscounts.Value);
            }

            if (filter.InJournalTOCs.HasValue)
            {
                query = filter.InJournalTOCs.Value ? query.Where(j => j.DataSource == JournalsImportSource.JournalTOCs.ToString()) : query.Where(j => j.DataSource != JournalsImportSource.JournalTOCs.ToString());
            }

            if (filter.SubmittedOnly)
            {
                query = query.Where(j => j.ValuationScoreCards.Any(v => v.State == ScoreCardState.Published));
            }

            if (filter.MustHaveBeenScored && filter.SwotMatrix.Count == 0)
            {
                query = query.Where(j => j.NumberOfBaseReviewers > 0 || j.NumberOfValuationReviewers > 0);
            }
            else if (filter.MustHaveBeenScored && filter.SwotMatrix.Count > 0)
            {
                query = query.Where(j => j.NumberOfBaseReviewers > 0 && j.NumberOfValuationReviewers > 0);
            }

            if (filter.SwotMatrix.Count > 0)
            {
                query = query.Where(AddSwotMatrixFilter(filter));
            }

            return(ApplyOrdering(query, filter).ToPagedList(filter.PageNumber, filter.PageSize));
        }
        public IEnumerable <Journal> GetJournalPaged(int page, int count, JournalFilter filter = null, OrderExpression orderExpression = null)
        {
            var expression = new JournalQueryObject(filter).Expression;

            return(JournalPaged(page, count, expression, orderExpression));
        }