ConfigManager Technical Documentation (Insights Dashboards)

Location

  • Source: CalculationLogic/ID_Lib_Manager/elements/ConfigManager.groovy

Purpose

ConfigManager provides a centralized access layer for model-specific and dashboard-related configuration values.

It is designed as:

  • A lightweight, stateless facade exposed as a Map of callable closures.

  • A cache-aware accessor layer wrapping model/configuration lookups.

  • A shared dependency consumed by dashboard modules through out.ConfigManager or direct library call.

Access Pattern

Primary entrypoint:

Groovy
Map configManager = libs.ID_Lib_Manager.ConfigManager.getInstance()

getInstance() returns a map exposing callable functions such as:

Groovy
configManager.getModelName()
configManager.getCurrencyCode()
configManager.getHealthScoreDefinition()

Internal Design

1. Facade Map

getInstance() builds a map whose keys are public API method names and values are closures delegating to protected methods.

2. Caching

All protected getters use:

Groovy
getOrSet(String key, Closure closure, List additionalParameters = [])

which delegates to:

Groovy
libs.SharedLib.CacheUtils.getOrSet(key, additionalParameters, closure)

This avoids repeated expensive lookups (Model Object query calls, configuration reads) during script execution.

3. Model-Centric Resolution

Most methods resolve the active model via getModelName() and then retrieve model-scoped configuration from ConfigurationUtils or processing constants.

Public API (via getInstance())

Model Identity

  • getModelName()

    • Returns selected Insights model unique name.

    • Source: libs.ID_Lib_Model.ModelSelectorUtils.getModelForInsightsDashboards().

  • getModelTypedId()

    • Returns MO typedId for the active model.

    • Lookup: api.find("MO", ..., Filter.equal("uniqueName", modelName)).

  • getModelId()

    • Returns MO numeric id for the active model.

    • Lookup: api.find("MO", ..., ["id"], Filter.equal("uniqueName", modelName)).

Processing Table Configurations

  • getAggregatedTransactionsTableConfig()

    • Returns ConstConfig.AGGREGATED_TRANSACTIONS_TABLE_CONFIG.

  • getCustomerRollingPeriodTableConfig()

    • Returns ConstConfig.CUSTOMER_ROLLING_PERIOD_TABLE_CONFIG.

  • getCustomerProductRollingPeriodTableConfig()

    • Returns ConstConfig.CUSTOMER_PRODUCT_ROLLING_PERIOD_TABLE_CONFIG.

  • getCrossSellRollingPeriodTableConfig()

    • Returns ConstConfig.CROSS_SELL_ROLLING_PERIOD_TABLE_CONFIG.

Hierarchy Metadata

  • getProductHierarchyFieldNameToLabelMapping()

    • Returns map: product hierarchy fieldName -> label.

  • getCustomerHierarchyFieldNameToLabelMapping()

    • Returns map: customer hierarchy fieldName -> label.

  • getProductHierarchyFieldNames()

    • Returns product hierarchy field names list.

  • getCustomerHierarchyFieldNames()

    • Returns customer hierarchy field names list.

Scoring and Thresholds

  • getRevenueShare()

    • Returns configured revenue share (BigDecimal) for health score logic.

  • getHealthScoreDefinition()

    • Returns health score definition structure from model configuration.

  • getTrendsThresholds()

    • Returns trend threshold values used for directional classification.

  • getHealthScoreBucketTiers()

    • Returns health score bucket tier labels from configuration utils.

Ranking and Dashboard Settings

  • getProductRanks()

    • Returns [1..N] where N = getNumberOfProductRanks(modelName).

  • getCustomerRanks()

    • Returns [1..N] where N = getNumberOfCustomerRanks(modelName).

  • getWaterfallConfiguration()

    • Returns waterfallInputMatrix from processing model configuration provider.

Currency

  • getCurrencySymbol()

    • Returns base currency symbol for active model.

  • getCurrencyCode()

    • Returns base currency code for active model.

Dependencies

ConfigManager depends on the following libraries/services:

  • libs.SharedLib.CacheUtils for memoization.

  • libs.ID_Lib_Model.ModelSelectorUtils for active model selection.

  • libs.ID_Lib_Model.ConfigurationUtils for model configuration access.

  • libs.ID_Lib_Processing.ConstConfig for static processing table configuration.

  • libs.ID_Lib_Processing.ModelConfigurationProviderUtils for waterfall configuration.

  • api.find(...) + Filter.equal(...) for MO lookup.

Typical Consumers

Many dashboard modules expose a local wrapper ConfigManager.groovy containing:

Groovy
return libs.ID_Lib_Manager.ConfigManager.getInstance()

and then read values through out.ConfigManager:

Groovy
Map configManager = out.ConfigManager
String modelName = configManager.getModelName()
List hierarchy = configManager.getProductHierarchyFieldNames()

Notes and Caveats

  • Caching keys are method-specific; callers do not pass additionalParameters currently.

  • Returned data types are not strongly enforced by interfaces, so consumers should treat outputs as trusted runtime structures.

  • If model selection changes within an execution context, previously cached values may still be reused by key.

Extension Guidelines

When adding a new configuration getter:

  1. Add closure exposure in getInstance() map.

  2. Implement protected method using getOrSet("uniqueKey") { ... }.

  3. Keep retrieval model-aware via getModelName() if model-scoped.

  4. Return stable data shapes expected by dashboard formulas.

  5. Prefer reusing ConfigurationUtils/provider libs over duplicating retrieval logic.

Quick Validation Checklist

After modifying ConfigManager:

  • Verify all existing keys in getInstance() still resolve.

  • Verify dependent dashboards can still call out.ConfigManager.<method>().

  • Spot-check cached methods for correct return type and null safety.

  • Validate Model Object lookup assumptions (uniqueName uniqueness).