Skip to content

Commit 18a958e

Browse files
committed
#13357 - Add description field to system configuration values
Introduced a description field, and update backend, API, and UI to support displaying and editing the description. : - `SystemConfigurationValue` - `SystemConfigurationValueDto` - `SystemConfigurationValueFacade` - `SystemConfigurationValueEjb` - `SystemConfigurationValueIndexDto` - `SystemConfigurationValueEditForm` - `SystemConfigurationValuesGrid` Updated SQL schema to add value_description column: - `sormas_schema.sql` Added i18n keys and English texts for email and SMS configuration value descriptions : - `Strings` - `strings.properties`
1 parent ef56169 commit 18a958e

File tree

10 files changed

+162
-13
lines changed

10 files changed

+162
-13
lines changed

sormas-api/src/main/java/de/symeda/sormas/api/i18n/Strings.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,6 +1122,11 @@ public interface Strings {
11221122
String infoSurveyResponseNotReceived = "infoSurveyResponseNotReceived";
11231123
String infoSurveyResponseReceived = "infoSurveyResponseReceived";
11241124
String infoSyncUsers = "infoSyncUsers";
1125+
String infoSystemConfigurationValueDescriptionEmailSenderAddress = "infoSystemConfigurationValueDescriptionEmailSenderAddress";
1126+
String infoSystemConfigurationValueDescriptionEmailSenderName = "infoSystemConfigurationValueDescriptionEmailSenderName";
1127+
String infoSystemConfigurationValueDescriptionSmsAuthKey = "infoSystemConfigurationValueDescriptionSmsAuthKey";
1128+
String infoSystemConfigurationValueDescriptionSmsAuthSecret = "infoSystemConfigurationValueDescriptionSmsAuthSecret";
1129+
String infoSystemConfigurationValueDescriptionSmsSenderName = "infoSystemConfigurationValueDescriptionSmsSenderName";
11251130
String infoTasksWithMultipleJurisdictionsSelected = "infoTasksWithMultipleJurisdictionsSelected";
11261131
String infoUploadDocumentTemplate = "infoUploadDocumentTemplate";
11271132
String infoUsageOfEditableCampaignGrids = "infoUsageOfEditableCampaignGrids";

sormas-api/src/main/java/de/symeda/sormas/api/systemconfiguration/SystemConfigurationValueDto.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public class SystemConfigurationValueDto extends EntityDto {
3535

3636
public static final String VALUE_PROPERTY_NAME = "value";
3737
public static final String KEY_PROPERTY_NAME = "key";
38+
public static final String DESCRIPTION_PROPERTY_NAME = "description";
3839
public static final String CATEGORY_PROPERTY_NAME = "category";
3940
public static final String OPTIONAL_PROPERTY_NAME = "optional";
4041
public static final String PATTERN_PROPERTY_NAME = "pattern";
@@ -56,6 +57,9 @@ public static SystemConfigurationValueDto build() {
5657
@Size(max = FieldConstraints.CHARACTER_LIMIT_TEXT, message = Validations.textTooLong)
5758
private String key;
5859

60+
@Size(max = FieldConstraints.CHARACTER_LIMIT_TEXT, message = Validations.textTooLong)
61+
private String description;
62+
5963
private SystemConfigurationCategoryReferenceDto category;
6064

6165
private Boolean optional;
@@ -91,6 +95,7 @@ public SystemConfigurationValueDto() {
9195
public SystemConfigurationValueDto(
9296
String value,
9397
String key,
98+
String description,
9499
SystemConfigurationCategoryReferenceDto category,
95100
Boolean optional,
96101
String pattern,
@@ -99,6 +104,7 @@ public SystemConfigurationValueDto(
99104
String validationMessage) {
100105
this.value = value;
101106
this.key = key;
107+
this.description = description;
102108
this.category = category;
103109
this.optional = optional;
104110
this.pattern = pattern;
@@ -123,6 +129,13 @@ public void setKey(final String key) {
123129
this.key = key;
124130
}
125131

132+
public String getDescription() {
133+
return description;
134+
}
135+
public void setDescription(final String description) {
136+
this.description = description;
137+
}
138+
126139
public SystemConfigurationCategoryReferenceDto getCategory() {
127140
return category;
128141
}

sormas-api/src/main/java/de/symeda/sormas/api/systemconfiguration/SystemConfigurationValueFacade.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import java.io.Serializable;
1919
import java.util.List;
20-
import java.util.Optional;
2120

2221
import javax.ejb.Remote;
2322

sormas-api/src/main/java/de/symeda/sormas/api/systemconfiguration/SystemConfigurationValueIndexDto.java

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,15 @@ public class SystemConfigurationValueIndexDto extends EntityDto {
2828

2929
public static final String KEY_PROPERTY_NAME = "key";
3030
public static final String VALUE_PROPERTY_NAME = "value";
31+
public static final String DESCRIPTION_PROPERTY_NAME = "description";
3132
public static final String ENCRYPTED_PROPERTY_NAME = "encrypted";
3233
public static final String CATEGORY_NAME_PROPERTY_NAME = "categoryName";
3334
public static final String CATEGORY_CAPTION_PROPERTY_NAME = "categoryCaption";
3435
public static final String CATEGORY_DESCRIPTION_PROPERTY_NAME = "categoryDescription";
3536

3637
private String value;
3738
private String key;
39+
private String description;
3840
private boolean encrypted;
3941
private String categoryName;
4042
private String categoryCaption;
@@ -52,7 +54,8 @@ public String getKey() {
5254
/**
5355
* Sets the key of the configuration.
5456
*
55-
* @param key the key to set
57+
* @param key
58+
* the key to set
5659
*/
5760
public void setKey(String key) {
5861
this.key = key;
@@ -70,7 +73,8 @@ public String getValue() {
7073
/**
7174
* Sets the value of the configuration.
7275
*
73-
* @param value the value to set
76+
* @param value
77+
* the value to set
7478
*/
7579
public void setValue(String value) {
7680
this.value = value;
@@ -88,12 +92,32 @@ public boolean isEncrypted() {
8892
/**
8993
* Sets the encryption status of the configuration value.
9094
*
91-
* @param encrypted the encryption status to set
95+
* @param encrypted
96+
* the encryption status to set
9297
*/
9398
public void setEncrypted(boolean encrypted) {
9499
this.encrypted = encrypted;
95100
}
96101

102+
/**
103+
* Gets the description of the configuration.
104+
*
105+
* @return the description
106+
*/
107+
public String getDescription() {
108+
return description;
109+
}
110+
111+
/**
112+
* Sets the description of the configuration.
113+
*
114+
* @param description
115+
* the description to set
116+
*/
117+
public void setDescription(String description) {
118+
this.description = description;
119+
}
120+
97121
/**
98122
* Gets the category name of the configuration.
99123
*
@@ -106,7 +130,8 @@ public String getCategoryName() {
106130
/**
107131
* Sets the category name of the configuration.
108132
*
109-
* @param categoryName the category name to set
133+
* @param categoryName
134+
* the category name to set
110135
*/
111136
public void setCategoryName(String categoryName) {
112137
this.categoryName = categoryName;
@@ -124,7 +149,8 @@ public String getCategoryCaption() {
124149
/**
125150
* Sets the category caption of the configuration.
126151
*
127-
* @param categoryCaption the category caption to set
152+
* @param categoryCaption
153+
* the category caption to set
128154
*/
129155
public void setCategoryCaption(String categoryCaption) {
130156
this.categoryCaption = categoryCaption;
@@ -142,7 +168,8 @@ public String getCategoryDescription() {
142168
/**
143169
* Sets the category description of the configuration.
144170
*
145-
* @param categoryDescription the category description to set
171+
* @param categoryDescription
172+
* the category description to set
146173
*/
147174
public void setCategoryDescription(String categoryDescription) {
148175
this.categoryDescription = categoryDescription;

sormas-api/src/main/resources/strings.properties

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1951,4 +1951,10 @@ confirmationSelfReportLinkContactsByCaseReference=Some contacts without a case h
19511951
headingSelfReportCaseReportWithSameReferenceFound=Case self report with same case reference found
19521952
confirmationSelfReportCaseReportWithSameReferenceFound=There is a case self report with the same case reference number as the processed self report.</br>It is recommended to process case reports first.</br></br>Do you want to continue processing this self report?
19531953
headingSelfReportCaseWithSameReferenceNumberFound=Case with same reference number found
1954-
confirmationSelfReportLinkContactToCaseWithSameReferenceNumber=There is a case with the same reference number as the contact found</br></br>Do you want to link this contact to that case?
1954+
confirmationSelfReportLinkContactToCaseWithSameReferenceNumber=There is a case with the same reference number as the contact found</br></br>Do you want to link this contact to that case?
1955+
1956+
infoSystemConfigurationValueDescriptionEmailSenderAddress=Email address that will be set as the sender of email notifications sent out by the system.
1957+
infoSystemConfigurationValueDescriptionEmailSenderName=Name that will be set as the sender of email notifications sent out by the system.
1958+
infoSystemConfigurationValueDescriptionSmsSenderName=Name that will be set as the sender of SMS notifications sent out by the system.
1959+
infoSystemConfigurationValueDescriptionSmsAuthKey=SORMAS supports the delivery of SMS notifications via Vonage (https://www.vonage.com/communications-apis/). You need to specify a valid authentication key and secret in order to use this feature. SORMAS will not attempt to send out SMS if these properties are left empty.
1960+
infoSystemConfigurationValueDescriptionSmsAuthSecret=Secret for SMS authentication.

sormas-backend/src/main/java/de/symeda/sormas/backend/systemconfiguration/SystemConfigurationValue.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public class SystemConfigurationValue extends AbstractDomainObject {
4141

4242
private String value;
4343
private String key;
44+
private String description;
4445
private SystemConfigurationCategory category;
4546
private Boolean optional;
4647
private String pattern;
@@ -66,6 +67,15 @@ public void setKey(String key) {
6667
this.key = key;
6768
}
6869

70+
@Column(nullable = true, name = "value_description")
71+
public String getDescription() {
72+
return description;
73+
}
74+
75+
public void setDescription(String description) {
76+
this.description = description;
77+
}
78+
6979
@ManyToOne(fetch = FetchType.LAZY, optional = false)
7080
public SystemConfigurationCategory getCategory() {
7181
return category;

sormas-backend/src/main/java/de/symeda/sormas/backend/systemconfiguration/SystemConfigurationValueEjb.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ protected SystemConfigurationValue fillOrBuildEntity(
382382

383383
target.setKey(source.getKey());
384384
target.setValue(source.getValue());
385+
target.setDescription(source.getDescription());
385386
target.setCategory(categoryService.getByReferenceDto(source.getCategory()));
386387
target.setOptional(source.getOptional() != null ? source.getOptional() : Boolean.FALSE);
387388
target.setEncrypt(source.getEncrypt());
@@ -414,6 +415,7 @@ protected SystemConfigurationValueDto toDto(final SystemConfigurationValue sourc
414415

415416
target.setKey(source.getKey());
416417
target.setValue(source.getValue());
418+
target.setDescription(source.getDescription());
417419
target.setCategory(
418420
source.getCategory() != null
419421
? categoryFacade.getReferenceByUuid(source.getCategory().getUuid())
@@ -518,6 +520,7 @@ private SystemConfigurationValueIndexDto toIndexDto(final SystemConfigurationVal
518520

519521
dto.setValue(entity.getValue());
520522
dto.setKey(entity.getKey());
523+
dto.setDescription(entity.getDescription());
521524
dto.setEncrypted(entity.getEncrypt()); // encrypt needed for list view
522525
dto.setCategoryName(entity.getCategory() != null ? entity.getCategory().getName() : null);
523526
dto.setCategoryCaption(entity.getCategory() != null ? entity.getCategory().getCaption() : null);

sormas-backend/src/main/resources/sql/sormas_schema.sql

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14197,4 +14197,35 @@ END $$
1419714197
LANGUAGE plpgsql;
1419814198

1419914199
INSERT INTO schema_version (version_number, comment) VALUES (569, 'Moving Email & SMS properties to the new system configuration structure #13311');
14200+
14201+
14202+
-- 2025-05-26 Add description to system configuration values #13357
14203+
14204+
ALTER TABLE systemconfigurationvalue ADD COLUMN value_description text;
14205+
ALTER TABLE systemconfigurationvalue_history ADD COLUMN value_description text;
14206+
14207+
DO $$ BEGIN
14208+
UPDATE systemconfigurationvalue
14209+
SET value_description = 'i18n/systemConfigurationValueDescriptionEmailSenderAddress'
14210+
WHERE config_key = 'EMAIL_SENDER_ADDRESS';
14211+
14212+
UPDATE systemconfigurationvalue
14213+
SET value_description = 'i18n/systemConfigurationValueDescriptionEmailSenderName'
14214+
WHERE config_key = 'EMAIL_SENDER_NAME';
14215+
14216+
UPDATE systemconfigurationvalue
14217+
SET value_description = 'i18n/systemConfigurationValueDescriptionSmsSenderName'
14218+
WHERE config_key = 'SMS_SENDER_NAME';
14219+
14220+
UPDATE systemconfigurationvalue
14221+
SET value_description = 'i18n/systemConfigurationValueDescriptionSmsAuthKey'
14222+
WHERE config_key = 'SMS_AUTH_KEY';
14223+
14224+
UPDATE systemconfigurationvalue
14225+
SET value_description = 'i18n/systemConfigurationValueDescriptionSmsAuthSecret'
14226+
WHERE config_key = 'SMS_AUTH_SECRET';
14227+
END $$ LANGUAGE plpgsql;
14228+
14229+
INSERT INTO schema_version (version_number, comment) VALUES (570, 'Added description to system configuration values #13357');
14230+
1420014231
-- *** Insert new sql commands BEFORE this line. Remember to always consider _history tables. ***

sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/system/SystemConfigurationValueEditForm.java

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@
1818
import static de.symeda.sormas.ui.utils.LayoutUtil.locs;
1919

2020
import com.vaadin.data.Binder;
21+
import com.vaadin.ui.Label;
22+
import com.vaadin.ui.themes.ValoTheme;
2123
import com.vaadin.v7.ui.PasswordField;
2224

25+
import de.symeda.sormas.api.i18n.Captions;
26+
import de.symeda.sormas.api.i18n.I18nProperties;
2327
import de.symeda.sormas.api.systemconfiguration.SystemConfigurationValueDto;
2428
import de.symeda.sormas.api.utils.fieldaccess.UiFieldAccessCheckers;
2529
import de.symeda.sormas.api.utils.fieldvisibility.FieldVisibilityCheckers;
@@ -30,9 +34,19 @@
3034
*/
3135
public class SystemConfigurationValueEditForm extends AbstractEditForm<SystemConfigurationValueDto> {
3236

33-
private static final String HTML_LAYOUT =
34-
locs(SystemConfigurationValueDtoWrapper.WRAPPED_OBJECT_PROPERTY_NAME, SystemConfigurationValueDto.VALIDATION_MESSAGE_PROPERTY_NAME);
37+
private static final String HTML_LAYOUT = locs(
38+
SystemConfigurationValueDto.DESCRIPTION_PROPERTY_NAME,
39+
SystemConfigurationValueDtoWrapper.WRAPPED_OBJECT_PROPERTY_NAME,
40+
SystemConfigurationValueDto.VALIDATION_MESSAGE_PROPERTY_NAME);
3541

42+
/**
43+
* The label for displaying the description of the system configuration value.
44+
*/
45+
private Label descriptionLabel;
46+
47+
/**
48+
* The dynamic input field for the system configuration value.
49+
*/
3650
private final SystemConfigurationValueDynamicInput dynamicInput;
3751

3852
/**
@@ -53,10 +67,25 @@ public SystemConfigurationValueEditForm(final SystemConfigurationValueDto value)
5367
setWidth(640, Unit.PIXELS);
5468
setValue(value);
5569

70+
71+
if (value.getDescription() != null && !value.getDescription().isEmpty()) {
72+
descriptionLabel = new Label(value.getDescription());
73+
74+
descriptionLabel.setWidth(600, Unit.PIXELS);
75+
descriptionLabel.addStyleName(ValoTheme.LABEL_H3);
76+
77+
SystemConfigurationI18nHelper.processI18nString(
78+
value.getDescription(),
79+
(key) -> descriptionLabel.setValue(I18nProperties.getString(key)));
80+
81+
getContent().addComponent(descriptionLabel, SystemConfigurationValueDto.DESCRIPTION_PROPERTY_NAME);
82+
}
83+
84+
dynamicInput = new SystemConfigurationValueDynamicInput();
85+
5686
final Binder<SystemConfigurationValueDtoWrapper> binder = new Binder<>(SystemConfigurationValueDtoWrapper.class);
5787
binder.setBean(new SystemConfigurationValueDtoWrapper(value));
5888

59-
dynamicInput = new SystemConfigurationValueDynamicInput();
6089
binder.forField(dynamicInput).bind(SystemConfigurationValueDtoWrapper.WRAPPED_OBJECT_PROPERTY_NAME);
6190
getContent().addComponent(dynamicInput, SystemConfigurationValueDtoWrapper.WRAPPED_OBJECT_PROPERTY_NAME);
6291

sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/system/SystemConfigurationValuesGrid.java

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
package de.symeda.sormas.ui.configuration.system;
1717

18+
import com.vaadin.ui.Grid.Column;
19+
1820
import de.symeda.sormas.api.FacadeProvider;
1921
import de.symeda.sormas.api.i18n.I18nProperties;
2022
import de.symeda.sormas.api.systemconfiguration.SystemConfigurationValueCriteria;
@@ -29,6 +31,9 @@ public class SystemConfigurationValuesGrid extends FilteredGrid<SystemConfigurat
2931

3032
private static final long serialVersionUID = 1L;
3133

34+
/**
35+
* The number of mask characters to generate for encrypted values.
36+
*/
3237
private static final int ENCRYPTED_VALUE_LENGTH = 15;
3338

3439
/**
@@ -58,14 +63,21 @@ private void configureColumns() {
5863

5964
removeColumn(SystemConfigurationValueIndexDto.VALUE_PROPERTY_NAME);
6065
addColumn(value -> value.isEncrypted() ? "*".repeat(ENCRYPTED_VALUE_LENGTH) : value.getValue())
61-
.setId(SystemConfigurationValueIndexDto.VALUE_PROPERTY_NAME);
66+
.setId(SystemConfigurationValueIndexDto.VALUE_PROPERTY_NAME)
67+
.setDescriptionGenerator(v -> this.getValueDescription(v));
6268

6369
removeColumn(SystemConfigurationValueIndexDto.CATEGORY_NAME_PROPERTY_NAME);
64-
addColumn(this::getCategoryCaption).setId(SystemConfigurationValueIndexDto.CATEGORY_NAME_PROPERTY_NAME);
70+
addColumn(this::getCategoryCaption).setId(SystemConfigurationValueIndexDto.CATEGORY_NAME_PROPERTY_NAME)
71+
.setDescriptionGenerator(v -> this.getValueDescription(v));
72+
73+
removeColumn(SystemConfigurationValueIndexDto.DESCRIPTION_PROPERTY_NAME);
74+
addColumn(this::getValueDescription).setId(SystemConfigurationValueIndexDto.DESCRIPTION_PROPERTY_NAME)
75+
.setDescriptionGenerator(v -> this.getValueDescription(v));
6576

6677
setColumns(
6778
SystemConfigurationValueIndexDto.CATEGORY_NAME_PROPERTY_NAME,
6879
SystemConfigurationValueIndexDto.KEY_PROPERTY_NAME,
80+
SystemConfigurationValueIndexDto.DESCRIPTION_PROPERTY_NAME,
6981
SystemConfigurationValueIndexDto.VALUE_PROPERTY_NAME);
7082

7183
addEditColumn(e -> ControllerProvider.getSystemConfigurationController().editSystemConfigurationValue(e.getUuid()));
@@ -89,6 +101,20 @@ private String getCategoryCaption(SystemConfigurationValueIndexDto value) {
89101
return caption.toString();
90102
}
91103

104+
private String getValueDescription(SystemConfigurationValueIndexDto value) {
105+
106+
if (value.getDescription() == null || value.getDescription().isEmpty()) {
107+
return "";
108+
}
109+
110+
final StringBuilder description = new StringBuilder();
111+
SystemConfigurationI18nHelper.processI18nString(value.getDescription(), (key) -> description.append(I18nProperties.getString(key)));
112+
if (description.length() == 0) {
113+
description.append(value.getDescription());
114+
}
115+
return description.toString();
116+
}
117+
92118
/**
93119
* Reloads the grid data.
94120
*/

0 commit comments

Comments
 (0)