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); }
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); }
public override NoteboxItemSearchCriteria[] GetInvariantCriteria(INoteboxQueryContext wqc) { NoteboxItemSearchCriteria where = new NoteboxItemSearchCriteria(); where.IsAcknowledged = false; where.SentToGroupIncludingMe = true; return new NoteboxItemSearchCriteria[] { where }; }
public override NoteboxItemSearchCriteria[] GetInvariantCriteria(INoteboxQueryContext wqc) { NoteboxItemSearchCriteria where = new NoteboxItemSearchCriteria(); where.IsAcknowledged = false; where.SentToGroupIncludingMe = true; return(new NoteboxItemSearchCriteria[] { where }); }
private static HqlProjectionQuery GetBaseQuery(INoteboxQueryContext nqc, bool countQuery, string entityAlias, Type fromEntityType, HqlSelect[] itemProjection, HqlJoin[] itemJoins) { var joins = countQuery ? new HqlJoin[] { } : itemJoins; var query = new HqlProjectionQuery(new HqlFrom(fromEntityType.Name, entityAlias, joins)); if (countQuery) { query.Selects.AddRange(CountProjection); } else { query.Selects.AddRange(itemProjection); // need this in case orderNote was sent to staff and staffgroup containing same staff //query.SelectDistinct = true; // add paging if not a count query query.Page = nqc.Page; } return(query); }
public int CountSentItems(Notebox notebox, INoteboxQueryContext nqc) { var query = BuildSentQuery(notebox, nqc, true); return DoQueryCount(query); }
public IList GetSentItems(Notebox notebox, INoteboxQueryContext nqc) { var query = BuildSentQuery(notebox, nqc, false); return DoQuery(query); }
public override int GetItemCount(INoteboxQueryContext nqc) { return GetBroker(nqc).CountInboxItems(this, nqc); }
public override IList GetItems(INoteboxQueryContext nqc) { return GetBroker(nqc).GetInboxItems(this, nqc); }
/// <summary> /// Queries the notebox for a count of its contents. /// </summary> /// <param name="nqc"></param> /// <returns></returns> public abstract int GetItemCount(INoteboxQueryContext nqc);
/// <summary> /// Helper method to get a broker. /// </summary> /// <param name="nqc"></param> /// <returns></returns> protected IOrderNoteboxItemBroker GetBroker(INoteboxQueryContext nqc) { return(nqc.GetBroker <IOrderNoteboxItemBroker>()); }
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; }
public int CountSentItems(Notebox notebox, INoteboxQueryContext nqc) { var query = BuildSentQuery(notebox, nqc, true); return(DoQueryCount(query)); }
public IList GetSentItems(Notebox notebox, INoteboxQueryContext nqc) { var query = BuildSentQuery(notebox, nqc, false); return(DoQuery(query)); }
public override int GetItemCount(INoteboxQueryContext nqc) { return(GetBroker(nqc).CountInboxItems(this, nqc)); }
public override IList GetItems(INoteboxQueryContext nqc) { return(GetBroker(nqc).GetInboxItems(this, nqc)); }
private static HqlProjectionQuery GetBaseQuery(INoteboxQueryContext nqc, bool countQuery, string entityAlias, Type fromEntityType, HqlSelect[] itemProjection, HqlJoin[] itemJoins) { var joins = countQuery ? new HqlJoin[] { } : itemJoins; var query = new HqlProjectionQuery(new HqlFrom(fromEntityType.Name, entityAlias, joins)); if (countQuery) { query.Selects.AddRange(CountProjection); } else { query.Selects.AddRange(itemProjection); // need this in case orderNote was sent to staff and staffgroup containing same staff //query.SelectDistinct = true; // add paging if not a count query query.Page = nqc.Page; } return query; }
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; }
/// <summary> /// Gets the invariant criteria for this class of notebox. /// </summary> /// <param name="wqc"></param> /// <returns></returns> public abstract NoteboxItemSearchCriteria[] GetInvariantCriteria(INoteboxQueryContext wqc);
/// <summary> /// Queries the notebox for its contents. /// </summary> /// <param name="nqc"></param> /// <returns></returns> public abstract IList GetItems(INoteboxQueryContext nqc);
/// <summary> /// Helper method to get a broker. /// </summary> /// <param name="nqc"></param> /// <returns></returns> protected IOrderNoteboxItemBroker GetBroker(INoteboxQueryContext nqc) { return nqc.GetBroker<IOrderNoteboxItemBroker>(); }