Class FormSettingsService
java.lang.Object
sk.iway.iwcm.components.form_settings.rest.FormSettingsService
Prepares form settings for administration and bridges persisted settings with legacy attribute maps.
Also resolves available custom processors and upload restrictions for forms in the current domain.
-
Constructor Summary
ConstructorsConstructorDescriptionFormSettingsService(FormSettingsRepository formSettingsRepository, List<FormProcessorInterface> formProcessorInterfaces) -
Method Summary
Modifier and TypeMethodDescriptionfilterAttributes(Map<String, String[]> parameters) Extracts the first value of each request parameter whose name starts withattribute_.static FormFileRestrictiongetFileRestriction(String formName) Loads upload restrictions for a form in the current domain through the repository bean.static FormFileRestrictiongetFileRestriction(String formName, FormSettingsEntity formSettings) Builds upload restrictions from settings, treating unset numeric limits as zero.static FormFileRestrictiongetFileRestriction(String formName, FormSettingsRepository formSettingsRepository) Finds registered processor class names matching a case-insensitive substring.Loads settings for the current domain as legacy form attributes, excluding technical and editor-only fields.static FormSettingsEntityloadEntity(String formName) Loads form settings in the current domain without converting them to legacy attributes.static voidprepareSettingsForEdit(FormSettingsEntity formSettings, String formType) Populates transient page selections and the multistep processor field for the settings editor.voidprepareSettingsForSave(FormSettingsEntity formSettings, String formType) static voidprepareSettingsForSave(FormSettingsEntity formSettings, String formType, FormSettingsRepository formSettingsRepository) Updates settings in place with the existing record ID, processor configuration, and selected page IDs.static voidCreates or updates settings selected by form name and current domain using entity field names as keys.
-
Constructor Details
-
FormSettingsService
@Autowired public FormSettingsService(FormSettingsRepository formSettingsRepository, List<FormProcessorInterface> formProcessorInterfaces)
-
-
Method Details
-
prepareSettingsForSave
-
prepareSettingsForSave
public static void prepareSettingsForSave(FormSettingsEntity formSettings, String formType, FormSettingsRepository formSettingsRepository) Updates settings in place with the existing record ID, processor configuration, and selected page IDs. Assigns the current domain when none is set; does not persist the entity.- Parameters:
formSettings- settings to prepare, ornullto do nothingformType- form type used to map the multistep processor fieldformSettingsRepository- repository used to find the existing settings ID in the current domain
-
prepareSettingsForEdit
Populates transient page selections and the multistep processor field for the settings editor.- Parameters:
formSettings- settings to update in place, ornullto do nothingformType- form type determining whether the processor autocomplete is populated
-
getFormProcessorOptions
Finds registered processor class names matching a case-insensitive substring.- Parameters:
term- search text;null, blank, or%includes all registered processors- Returns:
- matching fully qualified class names
-
load
Loads settings for the current domain as legacy form attributes, excluding technical and editor-only fields.- Parameters:
formName- logical form name- Returns:
- attributes with nullable string values, or an empty map when the repository or settings are unavailable
-
loadEntity
Loads form settings in the current domain without converting them to legacy attributes.- Parameters:
formName- logical form name- Returns:
- settings, or
nullwhen the repository or settings are unavailable
-
save
Creates or updates settings selected by form name and current domain using entity field names as keys. Converts string, integer, long, and boolean fields; logs individual mapping failures and continues. Does nothing when the repository bean is unavailable.- Parameters:
formName- logical form name used to locate or initialize the settingsparameters- field values to apply, leaving unspecified fields unchanged
-
filterAttributes
Extracts the first value of each request parameter whose name starts withattribute_.- Parameters:
parameters- request parameters with at least one value per matching name- Returns:
- selected values keyed by names with
attribute_removed
-
getFileRestriction
Loads upload restrictions for a form in the current domain through the repository bean.- Parameters:
formName- logical form name- Returns:
- configured restrictions, defaults when settings are missing, or an empty restriction object when the repository bean is unavailable
-
getFileRestriction
public static FormFileRestriction getFileRestriction(String formName, FormSettingsRepository formSettingsRepository) -
getFileRestriction
public static FormFileRestriction getFileRestriction(String formName, FormSettingsEntity formSettings) Builds upload restrictions from settings, treating unset numeric limits as zero. Without settings, uses a 5000 KB per-file limit and 3000 by 2000 pixel image limits, with no extension filter or combined-size limit.- Parameters:
formName- logical form name attached to the restrictionsformSettings- settings to read, ornullto use the default limits- Returns:
- a new restriction object for the form
-