예제 #1
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="baseHql"></param>
		/// <param name="conditions"></param>
		/// <param name="sorts"></param>
		/// <param name="page"></param>
		public HqlQuery(string baseHql, IEnumerable<HqlCondition> conditions, IEnumerable<HqlSort> sorts, SearchResultPage page)
		{
			_baseQuery = baseHql;
			_page = page;
			_where = new HqlAnd(conditions);
			_sorts = new List<HqlSort>(sorts);
		}
예제 #2
0
파일: HqlQuery.cs 프로젝트: hksonngan/Xian
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="baseHql"></param>
 /// <param name="conditions"></param>
 /// <param name="sorts"></param>
 /// <param name="page"></param>
 public HqlQuery(string baseHql, IEnumerable <HqlCondition> conditions, IEnumerable <HqlSort> sorts, SearchResultPage page)
 {
     _baseQuery = baseHql;
     _page      = page;
     _where     = new HqlAnd(conditions);
     _sorts     = new List <HqlSort>(sorts);
 }
예제 #3
0
		/// <summary>
		/// Adds the specified criteria to the specified query, pre-pending the specified qualifier.
		/// </summary>
		/// <param name="qualifier"></param>
		/// <param name="criteria"></param>
		/// <param name="query"></param>
		/// <param name="remapHqlExprFunction"></param>
		/// <remarks>
		/// All HQL dot expressions are passed through the <paramref name="remapHqlExprFunction"/>, allowing the expression
		/// to be modified prior to be added to the query.
		/// </remarks>
		public static void AddCriteriaToQuery(string qualifier, WorklistItemSearchCriteria[] criteria, HqlProjectionQuery query,
			Converter<string, string> remapHqlExprFunction)
		{
			var or = new HqlOr();
			foreach (var c in criteria)
			{
				if(c.IsEmpty)
					continue;

				var conditions = HqlCondition.FromSearchCriteria(qualifier, c, remapHqlExprFunction);
				var and = new HqlAnd(conditions);
				if (and.Conditions.Count > 0)
					or.Conditions.Add(and);
			}

			if (or.Conditions.Count > 0)
				query.Conditions.Add(or);
		}
예제 #4
0
		private static HqlProjectionQuery BuildSentQuery(Notebox notebox, INoteboxQueryContext nqc, bool countQuery)
		{
			var query = GetBaseQuery(nqc, countQuery, "n", typeof(Note), SentItemProjection, SentItemsJoins);

			var or = new HqlOr();
			foreach (var criteria in notebox.GetInvariantCriteria(nqc))
			{
				var and = new HqlAnd();

				// for sent items, IsAcknowledged means fully acknowledged (all readers have acknowledged)
				and.Conditions.Add(new HqlCondition("n.IsFullyAcknowledged = ?", criteria.IsAcknowledged));

				if (criteria.SentByMe)
					and.Conditions.Add(new HqlCondition("n.Author = ?", nqc.Staff));

				or.Conditions.Add(and);
			}
			query.Conditions.Add(or);
			query.Conditions.Add(new HqlCondition("n.HasPostings = ?", true));

			if (!countQuery)
				query.Sorts.AddRange(SentItemOrdering);

			return query;
		}
예제 #5
0
		private static HqlProjectionQuery BuildInboxQuery(Notebox notebox, INoteboxQueryContext nqc, bool countQuery)
		{
			var query = GetBaseQuery(nqc, countQuery, "np", typeof(NotePosting), InboxItemProjection, InboxItemsJoins);

			var or = new HqlOr();
			foreach (var criteria in notebox.GetInvariantCriteria(nqc))
			{
				var and = new HqlAnd();
				and.Conditions.Add(new HqlCondition("np.IsAcknowledged = ?", criteria.IsAcknowledged));

				if (criteria.SentToMe)
					and.Conditions.Add(new HqlCondition("np.Recipient = ?", nqc.Staff));
				if (criteria.SentToGroupIncludingMe)
					and.Conditions.Add(new HqlCondition("np.Recipient = ?", nqc.StaffGroup));
				
				or.Conditions.Add(and);
			}
			query.Conditions.Add(or);
			//query.Conditions.Add(ConditionMostRecentNote);

			if (!countQuery)
				query.Sorts.AddRange(InboxItemOrdering);

			return query;
		}