Aggregates the fields contributed by every active FieldProviderApplication and resolves kcode template placeholders and funnel rule queries against them. Reached from platform code as C(FieldsService.class), FieldsService is the single point apps go through to list available merge fields, look one up by id, substitute kcode placeholders such as inside a template, and turn a saved rules JSON expression into an Elasticsearch query, a match test, or a list of matching profiles. Results of getAllFields are cached per root folder.
Properties
| Property | Returns | Description |
|---|---|---|
| allFieldBeans | List<FieldBean> | Returns all fields available for the current root folder, converted to the JSON-serializable FieldBean form for sending to the admin UI. |
| allFields | List<Field> | Returns all fields available for the current root folder, from every active field-providing app, using the current root folder's cached list if one has already been built. |
| templatePattern | Pattern |
Methods
getAllFields() · findFields(int version) · getAllFields(RootFolder rootFolder) · fieldsForApps(FieldProviderApplication apps) · getAllFieldBeans() · getAllFieldBeans(RootFolder rootFolder) · getFieldById(String id, RootFolder rf) · getFieldById(String id, List<Field> fields) · getNumProfiles(String rulesJson) · loadRules(Group group) · loadRules(String rulesJson) · buildMembersQuery(String rulesJson)
getAllFields()
Returns: List<Field>
Returns all fields available for the current root folder, from every active field-providing app, using the current root folder's cached list if one has already been built.
findFields(int version)
Returns: List<Field>
Finds all available fields whose field system version matches the given version.
| Parameter | Description |
|---|---|
version | the field system version to match |
getAllFields(RootFolder rootFolder)
Returns: List<Field>
Returns all fields available for the given root folder, from every active field-providing app. The result includes fields from every field system version, and is cached against the root folder's attributes so later calls for the same root folder do not recompute it.
| Parameter | Description |
|---|---|
rootFolder | the root folder to resolve fields for, or null to compute without caching |
fieldsForApps(FieldProviderApplication apps)
Returns: List<Field>
Returns the fields contributed by the given apps only, with duplicate field ids removed.
| Parameter | Description |
|---|---|
apps | the field-providing apps to collect fields from |
getAllFieldBeans()
Returns: List<FieldBean>
Returns all fields available for the current root folder, converted to the JSON-serializable FieldBean form for sending to the admin UI.
getAllFieldBeans(RootFolder rootFolder)
Returns: List<FieldBean>
Returns all fields available for the given root folder, converted to the JSON-serializable FieldBean form. Prefer this over the no-argument version when asking about a website other than the one currently being served: the field catalogue differs per site, because a field only exists where the app contributing it is active.
| Parameter | Description |
|---|---|
rootFolder | the root folder to resolve fields for, or null to use the current one |
getFieldById(String id, RootFolder rf)
Returns: Field
Locates a field by its id among the fields available for the given root folder.
| Parameter | Description |
|---|---|
id | the field id to look up |
rf | the root folder to resolve available fields against |
getFieldById(String id, List<Field> fields)
Returns: Field
Locates a field by its id in the given list of fields.
| Parameter | Description |
|---|---|
id | the field id to look up, may be blank |
fields | the fields to search |
getNumProfiles(String rulesJson)
Returns: long
Counts the profiles that match the given rules JSON expression, without fetching the matching profiles themselves.
| Parameter | Description |
|---|---|
rulesJson | the saved rules expression to match profiles against |
loadRules(Group group)
Returns: Rules
Loads the query rules stored on the given group, if it is a rules-type group.
| Parameter | Description |
|---|---|
group | the group to load rules from |
loadRules(String rulesJson)
Returns: Rules
Parses a saved rules JSON expression into a Rules object that can build an Elasticsearch query.
| Parameter | Description |
|---|---|
rulesJson | the rules expression to parse |
buildMembersQuery(String rulesJson)
Returns: QueryBuilder
Builds the Elasticsearch query that selects the profiles matching the given rules JSON expression.
| Parameter | Description |
|---|---|
rulesJson | the saved rules expression to build a query from |