Class DashboardSettingsRepository

java.lang.Object
sk.iway.iwcm.components.welcome.DashboardSettingsRepository

@Repository public class DashboardSettingsRepository extends Object
Persists dashboard records in the administration settings table with account-level locking for writes.
  • Constructor Details

    • DashboardSettingsRepository

      public DashboardSettingsRepository()
  • Method Details

    • read

      public Map<String,String> read(int userId)
      Reads all dashboard records for an account directly from the database. On SQL Server, the read takes the account lock in a transaction to coordinate with writes.
      Parameters:
      userId - ID of the account that owns the settings
      Returns:
      stored dashboard values keyed by administration settings keys, including options for all domains
      Throws:
      IllegalStateException - if the database read fails
    • replace

      public void replace(int userId, String domainKey, Map<String,String> records, Set<String> instanceIds)
      Replaces the global layout and current-domain options in one transaction. Other domains retain options for current instances and instances from the previous layout, allowing an immediately removed widget to be restored by undo.
      Parameters:
      userId - ID of the account that owns the settings
      domainKey - decimal root group ID selecting the domain options to replace
      records - validated records to insert after removing the superseded settings
      instanceIds - widget instance IDs present in the replacement layout
      Throws:
      IllegalStateException - if the database mutation fails
    • reset

      public Map<String,String> reset(int userId, Function<Map<String,String>,Map<String,String>> retain)
      Atomically replaces layout, widget, news and domain records using a locked account snapshot. The callback computes the replacement records before any existing records are removed.
      Parameters:
      userId - ID of the account whose settings are reset
      retain - callback that builds replacement records from the account's current dashboard records
      Returns:
      replacement records persisted by the transaction
      Throws:
      IllegalStateException - if the database mutation fails