Cached, parsed representation of a tenant's query configuration repository: elastic search query definitions, reports, lookup tables, metrics, custom app-indexer fields and tables, and the JavaScript-defined rule types used for points, recognition and voucher expiry. QueryService builds and caches one instance per branch head hash of the account's query repository, and init runs the repository's own JavaScript sources against this instance so they can register additional indexed fields and tables. The intention is for this class to grow into the top level account settings object, holding queries as well as other account level configuration.
Properties
| Property | Returns | Description |
|---|---|---|
| dataSeriesContent | List<DataSeriesContent> | Per data-series display configuration, such as help text and which custom fields to show, loaded from the account's controllers.xml. |
| fields | List<AppIndexerField> | The custom search index fields registered against this account's app indexers via addAppIndexedField. |
| initException | Exception | The exception thrown while building the query script engine or initialising the account's rule types, if init failed. |
| lookupsList | List<LookupTableBean> | The lookup tables parsed from the ".lookup.xml" files in the account's query repository, used to map raw values to display values in reports. |
| mapOfMetrics | Map<String,List<Metric>> | Metrics grouped by the identifier of the thing they apply to, for example a promotion id such as "reward-mypromo". Built lazily on first call from the flat metrics list and cached. |
| metrics | List<Metric> | All metrics configured for the account, in the order they were declared. |
| pointsExpiryRuleTypes | List<JsPointsExpiryRuleType> | The custom rules, defined in the account's JavaScript, that calculate when earned reward points expire. |
| pointsRuleTypes | List<JsPointsRuleType> | The custom rules, defined in the account's JavaScript, that calculate how many reward points a record earns. |
| productCategoryContent | List<ProductCategoryContent> | Per product-category display configuration, such as help text and which custom fields to show, loaded from the account's controllers.xml. |
| queryList | List<QueryBean> | The elastic search query definitions parsed from the ".query.json" files in the account's query repository. |
| recognitionPointsRuleTypes | List<RecognitionPointsRuleType> | The rules, defined in the account's JavaScript, that calculate how many points a recognition award grants. |
| recordMatcherTypes | List<JsRecordMatcherType> | The custom rules, defined in the account's JavaScript, used to match records against other records or criteria. |
| reportList | List<ReportBean> | The report definitions parsed from the ".report.json" files in the account's query repository. |
| tables | Iterable<Table> | All tables available for querying and reporting: those declared in controllers.xml plus any join tables built at runtime via addJoinTable. A fresh combined list is built on every call. |
| voucherExpiryRuleTypes | List<JsVoucherExpiryRuleType> | The custom rules, defined in the account's JavaScript, that calculate when an issued voucher expires. |
Methods
getMapOfMetrics() · getInitException() · getQueryList() · getReportList() · getLookupsList() · getDataSeriesContent() · getProductCategoryContent() · findDataSeriesContent(String seriesName) · findProductCategoryContent(String categoryName) · lookupTable(String name) · getMetrics() · metric(String name) · getPointsRuleTypes() · getPointsExpiryRuleTypes() · getRecognitionPointsRuleTypes() · getRecordMatcherTypes() · getVoucherExpiryRuleTypes() · getTables() · getFields() · addTableDef(String id, String desc, String functionName) · joinTableBuilder() · addJoinTable(JoinTableBuilder b) · addAppIndexedField(String appIndexerName, String fieldName, String mappingType, boolean notAnalyzed, String mappingContentFn) · executeJs(String jsFunc, Object args)
getMapOfMetrics()
Returns: Map<String,List<Metric>>
Metrics grouped by the identifier of the thing they apply to, for example a promotion id such as "reward-mypromo". Built lazily on first call from the flat metrics list and cached.
getInitException()
Returns: Exception
The exception thrown while building the query script engine or initialising the account's rule types, if init failed.
getQueryList()
Returns: List<QueryBean>
The elastic search query definitions parsed from the ".query.json" files in the account's query repository.
getReportList()
Returns: List<ReportBean>
The report definitions parsed from the ".report.json" files in the account's query repository.
getLookupsList()
Returns: List<LookupTableBean>
The lookup tables parsed from the ".lookup.xml" files in the account's query repository, used to map raw values to display values in reports.
getDataSeriesContent()
Returns: List<DataSeriesContent>
Per data-series display configuration, such as help text and which custom fields to show, loaded from the account's controllers.xml.
getProductCategoryContent()
Returns: List<ProductCategoryContent>
Per product-category display configuration, such as help text and which custom fields to show, loaded from the account's controllers.xml.
findDataSeriesContent(String seriesName)
Returns: DataSeriesContent
Looks up the display configuration for a named data series.
| Parameter | Description |
|---|---|
seriesName | the name of the data series to look up |
findProductCategoryContent(String categoryName)
Returns: ProductCategoryContent
Looks up the display configuration for a named product category.
| Parameter | Description |
|---|---|
categoryName | the name of the product category to look up |
lookupTable(String name)
Returns: LookupTableBean
Finds a configured lookup table by name.
| Parameter | Description |
|---|---|
name | the name of the lookup table to find |
getMetrics()
Returns: List<Metric>
All metrics configured for the account, in the order they were declared.
metric(String name)
Returns: Metric
Finds a configured metric by its id.
| Parameter | Description |
|---|---|
name | the id of the metric to find |
getPointsRuleTypes()
Returns: List<JsPointsRuleType>
The custom rules, defined in the account's JavaScript, that calculate how many reward points a record earns.
getPointsExpiryRuleTypes()
Returns: List<JsPointsExpiryRuleType>
The custom rules, defined in the account's JavaScript, that calculate when earned reward points expire.
getRecognitionPointsRuleTypes()
Returns: List<RecognitionPointsRuleType>
The rules, defined in the account's JavaScript, that calculate how many points a recognition award grants.
getRecordMatcherTypes()
Returns: List<JsRecordMatcherType>
The custom rules, defined in the account's JavaScript, used to match records against other records or criteria.
getVoucherExpiryRuleTypes()
Returns: List<JsVoucherExpiryRuleType>
The custom rules, defined in the account's JavaScript, that calculate when an issued voucher expires.
getTables()
Returns: Iterable<Table>
All tables available for querying and reporting: those declared in controllers.xml plus any join tables built at runtime via addJoinTable. A fresh combined list is built on every call.
getFields()
Returns: List<AppIndexerField>
The custom search index fields registered against this account's app indexers via addAppIndexedField.
addTableDef(String id, String desc, String functionName)
Returns: QueryTable
Registers a query table backed by a JavaScript function, making the function's rows available to reports and admin table views. Chain addHeader calls on the returned definition to declare the column headings.
| Parameter | Description |
|---|---|
id | unique identifier for the table |
desc | human readable name for the table, shown when choosing a data source |
functionName | name of the global JavaScript function that loads the rows |
joinTableBuilder()
Returns: JoinTableBuilder
Starts building a join table, which combines several existing tables into one queryable table. Pass the configured builder to addJoinTable to register the result.
addJoinTable(JoinTableBuilder b)
Returns: JoinTable
Builds the join table described by the given builder and registers it against this account so it can be queried and reported on.
| Parameter | Description |
|---|---|
b | the configured join table builder |
addAppIndexedField(String appIndexerName, String fieldName, String mappingType, boolean notAnalyzed, String mappingContentFn)
Returns: void
Registers a custom field on a repo app's search index. The field's value for each item is computed by calling the named JavaScript function during indexing.
| Parameter | Description |
|---|---|
appIndexerName | the id of the app indexer to add the field to |
fieldName | name of the field as it appears in the search index |
mappingType | the search index mapping type, one of string, text, keyword, ip, ipfield, long, double, integer, geo, bool, boolean or date |
notAnalyzed | true if the field should be indexed without text analysis, for example for exact-match keyword fields |
mappingContentFn | name of the global JavaScript function that computes the field's value for an indexed item |
executeJs(String jsFunc, Object args)
Returns: Object
Invokes a named global function in this account's query JavaScript engine.
| Parameter | Description |
|---|---|
jsFunc | the name of the global JavaScript function to invoke |
args | the arguments to pass to the function |