From 54f84f7ec0b726e74922cff470703c87fa8e00a6 Mon Sep 17 00:00:00 2001 From: Martin Ledvinka Date: Mon, 16 Sep 2024 08:51:07 +0200 Subject: [PATCH] [Enhancement #298] Support configuring ASCII-only identifiers. --- .../cvut/kbss/termit/util/Configuration.java | 31 ++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/src/main/java/cz/cvut/kbss/termit/util/Configuration.java b/src/main/java/cz/cvut/kbss/termit/util/Configuration.java index b9be4a7db..fdbcfa4b1 100644 --- a/src/main/java/cz/cvut/kbss/termit/util/Configuration.java +++ b/src/main/java/cz/cvut/kbss/termit/util/Configuration.java @@ -18,9 +18,7 @@ package cz.cvut.kbss.termit.util; import cz.cvut.kbss.termit.model.acl.AccessLevel; -import cz.cvut.kbss.termit.util.throttle.ThrottleAspect; import jakarta.validation.Valid; -import jakarta.validation.constraints.Future; import jakarta.validation.constraints.Min; import jakarta.validation.constraints.NotNull; import org.springframework.boot.context.properties.ConfigurationProperties; @@ -61,15 +59,16 @@ public class Configuration { /** * The number of threads for thread pool executing asynchronous and long-running tasks. + * * @configurationdoc.default The number of processors available to the Java virtual machine. */ @Min(1) private Integer asyncThreadCount = Runtime.getRuntime().availableProcessors(); /** - * The amount of time in which calls of throttled methods - * should be merged. - * The value must be positive ({@code > 0}). + * The amount of time in which calls of throttled methods should be merged. The value must be positive + * ({@code > 0}). + * * @configurationdoc.default 10 seconds * @see cz.cvut.kbss.termit.util.throttle.Throttle * @see cz.cvut.kbss.termit.util.throttle.ThrottleAspect @@ -77,12 +76,22 @@ public class Configuration { private Duration throttleThreshold = Duration.ofSeconds(10); /** - * After how much time, should objects with completed futures be discarded. - * The value must be positive ({@code > 0}). + * After how much time, should objects with completed futures be discarded. The value must be positive + * ({@code > 0}). + * * @configurationdoc.default 1 minute */ private Duration throttleDiscardThreshold = Duration.ofMinutes(1); + /** + * Whether to generate ASCII-only identifiers. + *

+ * By default, generated identifiers may contain accented characters (like č). Setting this configuration to + * {@code true} ensures all generated identifiers are ASCII-only and accented character are normalized to ASCII. + * @configurationdoc.default false + */ + private boolean asciiIdentifiers = false; + @Valid private Persistence persistence = new Persistence(); @Valid @@ -146,6 +155,14 @@ public void setAsyncThreadCount(@Min(1) Integer asyncThreadCount) { this.asyncThreadCount = asyncThreadCount; } + public boolean isAsciiIdentifiers() { + return asciiIdentifiers; + } + + public void setAsciiIdentifiers(boolean asciiIdentifiers) { + this.asciiIdentifiers = asciiIdentifiers; + } + public Persistence getPersistence() { return persistence; }