EmailRecordSearchCriteria

public class EmailRecordSearchCriteria

The EmailRecordSearchCriteria class represents search criteria that may be used for searching org.motechproject.email.domain.EmailRecord entities in Motech Data Services. A consumer of this class may create search criteria to query on multiple fields by calling several of the with* methods. To perform the search, use org.motechproject.email.service.EmailAuditService.findEmailRecords(EmailRecordSearchCriteria).

Methods

getDeliveryStatuses

public Set<DeliveryStatus> getDeliveryStatuses()

Gets the delivery statuses criterion.

Returns:the delivery statuses criterion for this search criteria

getDeliveryTimeRange

public Range<DateTime> getDeliveryTimeRange()

Gets the delivery time range criterion.

Returns:the deliveryTimeRange criterion for this search criteria

getFromAddress

public String getFromAddress()

Gets the from address criterion.

Returns:the fromAddress criterion for this search criteria

getMessage

public String getMessage()

Gets the message body criterion.

Returns:the message criterion for this search criteria

getQueryParams

public QueryParams getQueryParams()

Gets the query paramaters that are used for controlling order and size of the query results for this search criteria.

Returns:the query params for this search criteria

getSubject

public String getSubject()

Gets the subject criterion.

Returns:the subject criterion for this search criteria

getToAddress

public String getToAddress()

Gets the to address criterion.

Returns:the toAddress criterion for this search criteria

withDeliveryStatuses

public EmailRecordSearchCriteria withDeliveryStatuses(Set<DeliveryStatus> deliveryStatuses)

Sets the delivery statuses criterion to the set specified

Parameters:
  • deliveryStatuses – the delivery statuses on which to search
Returns:

this EmailRecordSearchCriteria with its deliveryStatuses criterion set to the provided statuses

withDeliveryStatuses

public EmailRecordSearchCriteria withDeliveryStatuses(DeliveryStatus... deliveryStatuses)

Sets the delivery statuses criterion to the set specified

Parameters:
  • deliveryStatuses – the delivery statuses on which to search
Returns:

this EmailRecordSearchCriteria with its deliveryStatuses criterion set to the provided statuses

withFromAddress

public EmailRecordSearchCriteria withFromAddress(String fromAddress)

Sets the fromAddress criterion to the address specified

Parameters:
  • fromAddress – the sender email address on which to search
Returns:

this EmailRecordSearchCriteria with its fromAddress criterion set to the provided address

withMessage

public EmailRecordSearchCriteria withMessage(String message)

Sets the message criterion to the message specified

Parameters:
  • message – the email message body on which to search
Returns:

this EmailRecordSearchCriteria with its message criterion set to the provided message

withMessageTime

public EmailRecordSearchCriteria withMessageTime(DateTime deliveryTimeRange)

Sets the send time criterion to the time specified. Use this method to search on a specific date/time; if a range is needed, use withMessageTimeRange instead.

Parameters:
  • deliveryTimeRange – the specific time on which to search
Returns:

this EmailRecordSearchCriteria with its deliveryTimeRange criterion set to the specified date/time

withMessageTimeRange

public EmailRecordSearchCriteria withMessageTimeRange(Range<DateTime> deliveryTimeRange)

Sets the sent time criterion to the range specified. Use this method to search on a time range; if searching on a specific date/time is needed, use withMessageTime instead.

Parameters:
  • deliveryTimeRange – the date/time range on which to search
Returns:

this EmailRecordSearchCriteria with its deliveryTimeRange criterion set to the specified date/time range

withQueryParams

public EmailRecordSearchCriteria withQueryParams(QueryParams queryParams)

Sets the queryParams of the search criteria to the parameters specified. Use this method when it is necessary to specify order and size of query results. This is used mainly for paging/ordering queries from the UI.

Parameters:
  • queryParams – the query parameters to include with the search criteria
Returns:

this EmailRecordSearchCriteria with its queryParams set to the provided parameters

withSubject

public EmailRecordSearchCriteria withSubject(String subject)

Sets the subject criterion to the subject specified

Parameters:
  • subject – the subject on which to search
Returns:

this EmailRecordSearchCriteria with its subject criterion set to the provided subject

withToAddress

public EmailRecordSearchCriteria withToAddress(String toAddress)

Sets the toAddress criterion to the address specified

Parameters:
  • toAddress – the recipient email address on which to search
Returns:

this EmailRecordSearchCriteria with its toAddress criterion set to the provided address