Package sk.iway.iwcm.components.welcome
Class DashboardSettingsRepository
java.lang.Object
sk.iway.iwcm.components.welcome.DashboardSettingsRepository
Persists dashboard records in the administration settings table with account-level locking for writes.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionread(int userId) Reads all dashboard records for an account directly from the database.voidReplaces the global layout and current-domain options in one transaction.Atomically replaces layout, widget, news and domain records using a locked account snapshot.
-
Constructor Details
-
DashboardSettingsRepository
public DashboardSettingsRepository()
-
-
Method Details
-
read
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 settingsdomainKey- decimal root group ID selecting the domain options to replacerecords- validated records to insert after removing the superseded settingsinstanceIds- widget instance IDs present in the replacement layout- Throws:
IllegalStateException- if the database mutation fails
-
reset
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 resetretain- 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
-