Builder for a search that finds the profiles or organisations eligible to participate in a promotion (a Reward), used to page and filter that participant set before counting, fetching or streaming it. Configure it with the with* methods, then pass it to PromotionsManager.countParticipants, findParticipants or useParticipants, or call count(), search() or useParticipants() directly once a promotion is set.
Group: Builders
Properties
| Property | Returns | Description |
|---|---|---|
| maxRows | Integer | Overall cap on the number of results returned across all pages. |
| orgs | Boolean | Whether the search matches organisations rather than profiles. |
| pageSize | Integer | Maximum number of results to return per page. |
| parentOrgs | List<Organisation> | Organisations that matching profiles or organisations must sit beneath. |
| promo | Reward | The promotion whose eligibility rules (groups, organisation type filters) the search is run against. |
| searchFields | List<String> | Names of the fields searched against when a search query is set. |
| searchQuery | String | Free-text term used to filter participants, matched against the fields named by getSearchFields. |
| startPos | Integer | Zero-based offset of the first result to return, for paging. |
Methods
getSearchQuery() · withSearchQuery(String searchQuery) · getSearchFields() · withSearchFields(List<String> searchFields) · getParentOrgs() · withParentOrgs(List<Organisation> parentOrgs) · getPromo() · withPromo(Reward promo) · getOrgs() · withOrgs(Boolean orgs) · getStartPos() · withStartPos(Integer startPos) · getPageSize() · withPageSize(Integer pageSize) · getMaxRows() · withMaxRows(Integer maxRows) · count() · search() · useParticipants(Consumer<BaseEntity> callback)
getSearchQuery()
Returns: String
Free-text term used to filter participants, matched against the fields named by getSearchFields.
withSearchQuery(String searchQuery)
Returns: ParticipantSearchBuilder
Sets the free-text term to filter participants by, matched against the fields set with withSearchFields.
| Parameter | Description |
|---|---|
searchQuery | the search term, or null to remove any text search |
getSearchFields()
Returns: List<String>
Names of the fields searched against when a search query is set.
withSearchFields(List<String> searchFields)
Returns: ParticipantSearchBuilder
Sets the field names to match the search query against.
| Parameter | Description |
|---|---|
searchFields | the searchable field names |
getParentOrgs()
Returns: List<Organisation>
Organisations that matching profiles or organisations must sit beneath.
withParentOrgs(List<Organisation> parentOrgs)
Returns: ParticipantSearchBuilder
Restricts the search to profiles or organisations that sit beneath one of the given parent organisations.
| Parameter | Description |
|---|---|
parentOrgs | the required parent organisations, or null to remove the restriction |
getPromo()
Returns: Reward
The promotion whose eligibility rules (groups, organisation type filters) the search is run against.
withPromo(Reward promo)
Returns: ParticipantSearchBuilder
Sets the promotion whose eligibility rules the search is run against.
| Parameter | Description |
|---|---|
promo | the promotion to find participants for |
getOrgs()
Returns: Boolean
Whether the search matches organisations rather than profiles.
withOrgs(Boolean orgs)
Returns: ParticipantSearchBuilder
Sets whether the search should match organisations rather than profiles.
| Parameter | Description |
|---|---|
orgs | true to search organisations, false or null to search profiles |
getStartPos()
Returns: Integer
Zero-based offset of the first result to return, for paging.
withStartPos(Integer startPos)
Returns: ParticipantSearchBuilder
Sets the zero-based offset of the first result to return, for paging.
| Parameter | Description |
|---|---|
startPos | the paging offset, or null to start from the first result |
getPageSize()
Returns: Integer
Maximum number of results to return per page.
withPageSize(Integer pageSize)
Returns: ParticipantSearchBuilder
Sets the maximum number of results to return per page.
| Parameter | Description |
|---|---|
pageSize | the page size, or null for no page size limit |
getMaxRows()
Returns: Integer
Overall cap on the number of results returned across all pages.
withMaxRows(Integer maxRows)
Returns: ParticipantSearchBuilder
Sets the overall cap on the number of results returned across all pages.
| Parameter | Description |
|---|---|
maxRows | the maximum number of rows, or null for no cap |
count()
Returns: int
Counts the profiles or organisations matching this search, without loading the full result set.
search()
Returns: Collection<BaseEntity>
Runs this search and returns the matching profiles or organisations, including any paging limits set on this builder.
useParticipants(Consumer<BaseEntity> callback)
Returns: void
Streams the profiles or organisations matching this search to a callback, one at a time, rather than loading them all into memory at once. Does nothing if the search has no criteria.
| Parameter | Description |
|---|---|
callback | invoked once for each matching profile or organisation |