1515
1616package de .symeda .sormas .backend .systemconfiguration ;
1717
18- import de .symeda .sormas .api .i18n .I18nProperties ;
19- import de .symeda .sormas .api .i18n .Validations ;
20- import de .symeda .sormas .api .systemconfiguration .SystemConfigurationValueCriteria ;
21- import de .symeda .sormas .api .systemconfiguration .SystemConfigurationValueDataProvider ;
22- import de .symeda .sormas .api .systemconfiguration .SystemConfigurationValueDto ;
23- import de .symeda .sormas .api .systemconfiguration .SystemConfigurationValueFacade ;
24- import de .symeda .sormas .api .systemconfiguration .SystemConfigurationValueHelper ;
25- import de .symeda .sormas .api .systemconfiguration .SystemConfigurationValueIndexDto ;
26- import de .symeda .sormas .api .systemconfiguration .SystemConfigurationValueReferenceDto ;
27- import de .symeda .sormas .api .user .UserRight ;
28- import de .symeda .sormas .api .utils .SortProperty ;
29- import de .symeda .sormas .api .utils .ValidationRuntimeException ;
30- import de .symeda .sormas .backend .common .AbstractBaseEjb ;
31- import de .symeda .sormas .backend .common .AbstractDomainObject ;
32- import de .symeda .sormas .backend .common .CriteriaBuilderHelper ;
33- import de .symeda .sormas .backend .util .DtoHelper ;
34- import de .symeda .sormas .backend .util .Pseudonymizer ;
35- import de .symeda .sormas .backend .util .QueryHelper ;
36- import de .symeda .sormas .backend .util .RightsAllowed ;
37- import org .slf4j .Logger ;
38- import org .slf4j .LoggerFactory ;
18+ import java .util .List ;
19+ import java .util .Optional ;
20+ import java .util .TreeMap ;
21+ import java .util .stream .Collectors ;
3922
4023import javax .annotation .PostConstruct ;
4124import javax .annotation .security .PermitAll ;
5639import javax .persistence .criteria .Root ;
5740import javax .validation .Valid ;
5841import javax .validation .constraints .NotNull ;
59- import java .util .List ;
60- import java .util .Optional ;
61- import java .util .TreeMap ;
62- import java .util .stream .Collectors ;
42+
43+ import org .slf4j .Logger ;
44+ import org .slf4j .LoggerFactory ;
45+
46+ import de .symeda .sormas .api .i18n .I18nProperties ;
47+ import de .symeda .sormas .api .i18n .Validations ;
48+ import de .symeda .sormas .api .systemconfiguration .SystemConfigurationValueCriteria ;
49+ import de .symeda .sormas .api .systemconfiguration .SystemConfigurationValueDataProvider ;
50+ import de .symeda .sormas .api .systemconfiguration .SystemConfigurationValueDto ;
51+ import de .symeda .sormas .api .systemconfiguration .SystemConfigurationValueFacade ;
52+ import de .symeda .sormas .api .systemconfiguration .SystemConfigurationValueHelper ;
53+ import de .symeda .sormas .api .systemconfiguration .SystemConfigurationValueIndexDto ;
54+ import de .symeda .sormas .api .systemconfiguration .SystemConfigurationValueReferenceDto ;
55+ import de .symeda .sormas .api .user .UserRight ;
56+ import de .symeda .sormas .api .utils .SortProperty ;
57+ import de .symeda .sormas .api .utils .ValidationRuntimeException ;
58+ import de .symeda .sormas .backend .common .AbstractBaseEjb ;
59+ import de .symeda .sormas .backend .common .AbstractDomainObject ;
60+ import de .symeda .sormas .backend .common .CriteriaBuilderHelper ;
61+ import de .symeda .sormas .backend .util .DtoHelper ;
62+ import de .symeda .sormas .backend .util .Pseudonymizer ;
63+ import de .symeda .sormas .backend .util .QueryHelper ;
64+ import de .symeda .sormas .backend .util .RightsAllowed ;
6365
6466/**
6567 * Implementation of the {@link SystemConfigurationValueFacade} interface.
7173@ TransactionManagement (TransactionManagementType .CONTAINER )
7274@ RightsAllowed (UserRight ._SYSTEM_CONFIGURATION )
7375public class SystemConfigurationValueEjb
74- extends
75- AbstractBaseEjb <SystemConfigurationValue , SystemConfigurationValueDto , SystemConfigurationValueIndexDto , SystemConfigurationValueReferenceDto , SystemConfigurationValueService , SystemConfigurationValueCriteria >
76- implements SystemConfigurationValueFacade {
76+ extends
77+ AbstractBaseEjb <SystemConfigurationValue , SystemConfigurationValueDto , SystemConfigurationValueIndexDto , SystemConfigurationValueReferenceDto , SystemConfigurationValueService , SystemConfigurationValueCriteria >
78+ implements SystemConfigurationValueFacade {
7779
7880 private static final long serialVersionUID = 1L ;
7981
@@ -114,7 +116,8 @@ public void setService(final SystemConfigurationValueService service) {
114116 /**
115117 * Retrieves a configuration value associated with the given key.
116118 *
117- * @param key The key of the configuration value to retrieve.
119+ * @param key
120+ * The key of the configuration value to retrieve.
118121 * @return An {@link Optional} containing the value if found, or an empty {@link Optional} if not found.
119122 */
120123 @ PermitAll
@@ -136,7 +139,8 @@ public boolean exists(final String key) {
136139 /**
137140 * Saves a system configuration value.
138141 *
139- * @param dto The {@link SystemConfigurationValueDto} to save.
142+ * @param dto
143+ * The {@link SystemConfigurationValueDto} to save.
140144 * @return The saved {@link SystemConfigurationValueDto}.
141145 */
142146 @ Lock (LockType .READ )
@@ -164,7 +168,8 @@ public SystemConfigurationValueDto save(final SystemConfigurationValueDto dto) {
164168 /**
165169 * Counts the number of system configuration values matching the given criteria.
166170 *
167- * @param criteria The {@link SystemConfigurationValueCriteria} to match.
171+ * @param criteria
172+ * The {@link SystemConfigurationValueCriteria} to match.
168173 * @return The count of matching system configuration values.
169174 */
170175 @ Lock (LockType .READ )
@@ -189,7 +194,8 @@ public long count(final SystemConfigurationValueCriteria criteria) {
189194 /**
190195 * Retrieves system configuration values by their UUIDs.
191196 *
192- * @param uuids The list of UUIDs to retrieve.
197+ * @param uuids
198+ * The list of UUIDs to retrieve.
193199 * @return A list of {@link SystemConfigurationValueDto} objects.
194200 */
195201 @ Lock (LockType .READ )
@@ -215,27 +221,31 @@ public List<String> getAllUuids() {
215221 * Retrieves a list of {@link SystemConfigurationValueIndexDto} objects for frontend filtering and display.
216222 * This method applies filtering, sorting, and pagination based on the provided criteria.
217223 *
218- * @param criteria The filtering criteria, or {@code null} for no filtering.
219- * @param first The index of the first result to retrieve (for pagination), or {@code null} to start from the beginning.
220- * @param max The maximum number of results to retrieve (for pagination), or {@code null} for no limit.
221- * @param sortProperties The list of sort properties to apply to the results.
224+ * @param criteria
225+ * The filtering criteria, or {@code null} for no filtering.
226+ * @param first
227+ * The index of the first result to retrieve (for pagination), or {@code null} to start from the beginning.
228+ * @param max
229+ * The maximum number of results to retrieve (for pagination), or {@code null} for no limit.
230+ * @param sortProperties
231+ * The list of sort properties to apply to the results.
222232 * @return A list of {@link SystemConfigurationValueIndexDto} objects matching the criteria.
223233 */
224234 @ Lock (LockType .READ )
225235 @ RightsAllowed (UserRight ._SYSTEM_CONFIGURATION )
226236 @ Override
227237 public List <SystemConfigurationValueIndexDto > getIndexList (
228- final SystemConfigurationValueCriteria criteria ,
229- final Integer first ,
230- final Integer max ,
231- final List <SortProperty > sortProperties ) {
238+ final SystemConfigurationValueCriteria criteria ,
239+ final Integer first ,
240+ final Integer max ,
241+ final List <SortProperty > sortProperties ) {
232242
233243 LOGGER .debug (
234- "Retrieving SystemConfigurationValueIndexDto list with criteria: {}, first: {}, max: {}, sortProperties: {}" ,
235- criteria ,
236- first ,
237- max ,
238- sortProperties );
244+ "Retrieving SystemConfigurationValueIndexDto list with criteria: {}, first: {}, max: {}, sortProperties: {}" ,
245+ criteria ,
246+ first ,
247+ max ,
248+ sortProperties );
239249 final CriteriaBuilder cb = em .getCriteriaBuilder ();
240250 final CriteriaQuery <SystemConfigurationValue > cq = cb .createQuery (SystemConfigurationValue .class );
241251 final Root <SystemConfigurationValue > root = cq .from (SystemConfigurationValue .class );
@@ -253,18 +263,18 @@ public List<SystemConfigurationValueIndexDto> getIndexList(
253263 final List <Order > order = sortProperties .stream ().map (sortProperty -> {
254264 final Expression <?> expression ;
255265 switch (sortProperty .propertyName ) {
256- case SystemConfigurationValue .KEY_FIELD_NAME :
257- expression = cb .lower (root .get (sortProperty .propertyName ));
258- break ;
259- case SystemConfigurationValue .VALUE_FIELD_NAME :
260- expression = root .get (sortProperty .propertyName );
261- break ;
262- case SystemConfigurationValue .DESCRIPTION :
263- expression = cb .lower (root .get (sortProperty .propertyName ));
264- break ;
265- default :
266- LOGGER .error ("Invalid sort property {}." , sortProperty .propertyName );
267- throw new IllegalArgumentException (sortProperty .propertyName );
266+ case SystemConfigurationValue .KEY_FIELD_NAME :
267+ expression = cb .lower (root .get (sortProperty .propertyName ));
268+ break ;
269+ case SystemConfigurationValue .VALUE_FIELD_NAME :
270+ expression = root .get (sortProperty .propertyName );
271+ break ;
272+ case SystemConfigurationValue .DESCRIPTION :
273+ expression = cb .lower (root .get (sortProperty .propertyName ));
274+ break ;
275+ default :
276+ LOGGER .error ("Invalid sort property {}." , sortProperty .propertyName );
277+ throw new IllegalArgumentException (sortProperty .propertyName );
268278 }
269279 return sortProperty .ascending ? cb .asc (expression ) : cb .desc (expression );
270280 }).collect (Collectors .toList ());
@@ -285,8 +295,10 @@ public List<SystemConfigurationValueIndexDto> getIndexList(
285295 * The method also checks if the value matches the pattern if a pattern is provided.
286296 * If the value is encrypted, the validation for the value will not be performed.
287297 *
288- * @param dto The {@link SystemConfigurationValueDto} data transfer object to validate.
289- * @throws ValidationRuntimeException if the key or value in the DTO is invalid.
298+ * @param dto
299+ * The {@link SystemConfigurationValueDto} data transfer object to validate.
300+ * @throws ValidationRuntimeException
301+ * if the key or value in the DTO is invalid.
290302 */
291303 @ RightsAllowed (UserRight ._SYSTEM_CONFIGURATION )
292304 @ Override
@@ -314,8 +326,8 @@ public void validate(@Valid final SystemConfigurationValueDto dto) throws Valida
314326 }
315327
316328 if (dto .getPattern () != null
317- && !dto .getPattern ().isBlank ()
318- && !SystemConfigurationValueHelper .isConfigurationValueMatchingPattern (dto .getValue (), dto .getPattern ())) {
329+ && !dto .getPattern ().isBlank ()
330+ && !SystemConfigurationValueHelper .isConfigurationValueMatchingPattern (dto .getValue (), dto .getPattern ())) {
319331 LOGGER .warn ("Invalid value in SystemConfigurationValueDto: {}" , dto );
320332
321333 String message = null ;
@@ -352,17 +364,21 @@ public void loadData() {
352364 * Converts a {@link SystemConfigurationValueDto} data transfer object to a {@link SystemConfigurationValue} entity.
353365 * If a target entity is provided, it will be filled with the data from the DTO; otherwise, a new entity will be created.
354366 *
355- * @param source The {@link SystemConfigurationValueDto} data transfer object to convert. Must not be {@code null}.
356- * @param target The target {@link SystemConfigurationValue} entity to fill, or {@code null} to create a new entity.
357- * @param checkChangeDate Whether to check the change date during the fill or build process.
367+ * @param source
368+ * The {@link SystemConfigurationValueDto} data transfer object to convert. Must not be {@code null}.
369+ * @param target
370+ * The target {@link SystemConfigurationValue} entity to fill, or {@code null} to create a new entity.
371+ * @param checkChangeDate
372+ * Whether to check the change date during the fill or build process.
358373 * @return The filled or newly created {@link SystemConfigurationValue} entity.
359- * @throws NullPointerException if the source DTO is {@code null}.
374+ * @throws NullPointerException
375+ * if the source DTO is {@code null}.
360376 */
361377 @ Override
362378 protected SystemConfigurationValue fillOrBuildEntity (
363- @ NotNull final SystemConfigurationValueDto source ,
364- SystemConfigurationValue target ,
365- final boolean checkChangeDate ) {
379+ @ NotNull final SystemConfigurationValueDto source ,
380+ SystemConfigurationValue target ,
381+ final boolean checkChangeDate ) {
366382
367383 target = DtoHelper .fillOrBuildEntity (source , target , SystemConfigurationValue ::new , checkChangeDate );
368384
@@ -384,9 +400,10 @@ protected SystemConfigurationValue fillOrBuildEntity(
384400 /**
385401 * Converts a {@link SystemConfigurationValue} entity to a {@link SystemConfigurationValueDto} data transfer object.
386402 *
387- * @param source The {@link SystemConfigurationValue} entity to convert.
403+ * @param source
404+ * The {@link SystemConfigurationValue} entity to convert.
388405 * @return The corresponding {@link SystemConfigurationValueDto} data transfer object, or {@code null} if the source entity is
389- * {@code null}.
406+ * {@code null}.
390407 */
391408 @ Override
392409 protected SystemConfigurationValueDto toDto (final SystemConfigurationValue source ) {
@@ -402,9 +419,9 @@ protected SystemConfigurationValueDto toDto(final SystemConfigurationValue sourc
402419 target .setValue (source .getValue ());
403420 target .setDescription (source .getDescription ());
404421 target .setCategory (
405- source .getCategory () != null
406- ? categoryFacade .getReferenceByUuid (source .getCategory ().getUuid ())
407- : categoryFacade .getDefaultCategoryReferenceDto ());
422+ source .getCategory () != null
423+ ? categoryFacade .getReferenceByUuid (source .getCategory ().getUuid ())
424+ : categoryFacade .getDefaultCategoryReferenceDto ());
408425 target .setOptional (source .getOptional () != null ? source .getOptional () : Boolean .FALSE );
409426 target .setPattern (source .getPattern ());
410427 target .setEncrypt (source .getEncrypt ());
@@ -414,7 +431,7 @@ protected SystemConfigurationValueDto toDto(final SystemConfigurationValue sourc
414431 try {
415432 final Class <?> clazz = Class .forName (source .getDataProvider ());
416433 final SystemConfigurationValueDataProvider dataProvider =
417- (SystemConfigurationValueDataProvider ) clazz .getDeclaredConstructor ().newInstance ();
434+ (SystemConfigurationValueDataProvider ) clazz .getDeclaredConstructor ().newInstance ();
418435 target .setDataProvider (dataProvider );
419436 } catch (final Exception e ) {
420437 LOGGER .error ("Failed to instantiate SystemConfigurationValueDataProvider" , e );
@@ -429,7 +446,8 @@ protected SystemConfigurationValueDto toDto(final SystemConfigurationValue sourc
429446 /**
430447 * Converts a {@link SystemConfigurationValue} entity to a {@link SystemConfigurationValueReferenceDto}.
431448 *
432- * @param source The {@link SystemConfigurationValue} entity to convert.
449+ * @param source
450+ * The {@link SystemConfigurationValue} entity to convert.
433451 * @return The corresponding {@link SystemConfigurationValueReferenceDto}, or {@code null} if the source is {@code null}.
434452 */
435453 @ Override
@@ -446,42 +464,51 @@ protected SystemConfigurationValueReferenceDto toRefDto(final SystemConfiguratio
446464 * Pseudonymizes a {@link SystemConfigurationValueDto} data transfer object.
447465 * This method is currently not required for system configuration values.
448466 *
449- * @param source The {@link SystemConfigurationValue} entity to pseudonymize.
450- * @param dto The {@link SystemConfigurationValueDto} data transfer object to pseudonymize.
451- * @param pseudonymizer The pseudonymizer to use.
452- * @param inJurisdiction Whether the pseudonymization is within jurisdiction.
467+ * @param source
468+ * The {@link SystemConfigurationValue} entity to pseudonymize.
469+ * @param dto
470+ * The {@link SystemConfigurationValueDto} data transfer object to pseudonymize.
471+ * @param pseudonymizer
472+ * The pseudonymizer to use.
473+ * @param inJurisdiction
474+ * Whether the pseudonymization is within jurisdiction.
453475 */
454476 @ Override
455477 protected void pseudonymizeDto (
456- final SystemConfigurationValue source ,
457- final SystemConfigurationValueDto dto ,
458- final Pseudonymizer <SystemConfigurationValueDto > pseudonymizer ,
459- final boolean inJurisdiction ) {
478+ final SystemConfigurationValue source ,
479+ final SystemConfigurationValueDto dto ,
480+ final Pseudonymizer <SystemConfigurationValueDto > pseudonymizer ,
481+ final boolean inJurisdiction ) {
460482 LOGGER .debug ("Pseudonymizing SystemConfigurationValue ignored: {}" , source );
461483 }
462484
463485 /**
464486 * Restores a pseudonymized {@link SystemConfigurationValueDto} data transfer object.
465487 * This method is currently not required for system configuration values.
466488 *
467- * @param dto The {@link SystemConfigurationValueDto} data transfer object to restore.
468- * @param existingDto The existing {@link SystemConfigurationValueDto} data transfer object.
469- * @param entity The {@link SystemConfigurationValue} entity.
470- * @param pseudonymizer The pseudonymizer to use.
489+ * @param dto
490+ * The {@link SystemConfigurationValueDto} data transfer object to restore.
491+ * @param existingDto
492+ * The existing {@link SystemConfigurationValueDto} data transfer object.
493+ * @param entity
494+ * The {@link SystemConfigurationValue} entity.
495+ * @param pseudonymizer
496+ * The pseudonymizer to use.
471497 */
472498 @ Override
473499 protected void restorePseudonymizedDto (
474- final SystemConfigurationValueDto dto ,
475- final SystemConfigurationValueDto existingDto ,
476- final SystemConfigurationValue entity ,
477- final Pseudonymizer <SystemConfigurationValueDto > pseudonymizer ) {
500+ final SystemConfigurationValueDto dto ,
501+ final SystemConfigurationValueDto existingDto ,
502+ final SystemConfigurationValue entity ,
503+ final Pseudonymizer <SystemConfigurationValueDto > pseudonymizer ) {
478504 LOGGER .debug ("Restoring pseudonymized SystemConfigurationValue ignored: {}" , dto );
479505 }
480506
481507 /**
482508 * Converts a {@link SystemConfigurationValue} entity to a {@link SystemConfigurationValueIndexDto}.
483509 *
484- * @param entity The {@link SystemConfigurationValue} entity to convert.
510+ * @param entity
511+ * The {@link SystemConfigurationValue} entity to convert.
485512 * @return The corresponding {@link SystemConfigurationValueIndexDto}, or {@code null} if the entity is {@code null}.
486513 */
487514 private SystemConfigurationValueIndexDto toIndexDto (final SystemConfigurationValue entity ) {
0 commit comments