Skip to content

Commit

Permalink
:dependabot: Bump actions/setup-java from 4.0.0 to 4.1.0
Browse files Browse the repository at this point in the history
* :dependabot: Bump actions/setup-java from 4.0.0 to 4.1.0

Bumps [actions/setup-java](https://github.com/actions/setup-java) from 4.0.0 to 4.1.0.
- [Release notes](https://github.com/actions/setup-java/releases)
- [Commits](actions/setup-java@v4.0.0...v4.1.0)

---
updated-dependencies:
- dependency-name: actions/setup-java
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* lint: fix coupling && visibility issues

* lint: further decoupling

* fix some code smells in ui data model

* polishing

* rm unnecessary field injection

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: JKatzwinkel <JKatzwinkel@users.noreply.github.com>
  • Loading branch information
dependabot[bot] and JKatzwinkel authored Mar 1, 2024
1 parent 7fd8045 commit 9033f73
Show file tree
Hide file tree
Showing 17 changed files with 81 additions and 82 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
uses: actions/checkout@v4.1.1

- name: set up jdk
uses: actions/setup-java@v4.0.0
uses: actions/setup-java@v4.1.0
with:
distribution: temurin
java-version: ${{ matrix.java-version }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/submit_dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
steps:
- uses: actions/checkout@v4.1.1

- uses: actions/setup-java@v4.0.0
- uses: actions/setup-java@v4.1.0
with:
distribution: temurin
java-version: 21
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
![build](https://github.com/JKatzwinkel/tla-web/workflows/build/badge.svg)
![deploy](https://github.com/JKatzwinkel/tla-web/workflows/deploy/badge.svg)
![LINE](https://img.shields.io/badge/line--coverage-91.00%25-brightgreen.svg)
![METHOD](https://img.shields.io/badge/method--coverage-92.46%25-brightgreen.svg)
![LINE](https://img.shields.io/badge/line--coverage-91.20%25-brightgreen.svg)
![METHOD](https://img.shields.io/badge/method--coverage-92.61%25-brightgreen.svg)

TLA web frontend.

Expand Down
6 changes: 5 additions & 1 deletion src/main/java/tla/web/model/mappings/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
@Slf4j
public class Util {

private Util() {
//
}

public static final String SERIF_FONT_MARKUP_REGEX = "\\$([^$]+)\\$";
public static final String SERIF_FONT_MARKUP_REPLACEMENT = "<span class=\"bbaw-libertine\">$1</span>";

Expand Down Expand Up @@ -109,7 +113,7 @@ public static String escapeMarkup(String text) {
SERIF_FONT_MARKUP_REPLACEMENT
);
if (escaped != null) {
return escaped.replaceAll("\\n", "<br/>");
return escaped.replace("\\n", "<br/>");
}
return escaped;
}
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/tla/web/model/meta/ObjectDetails.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;

import lombok.Getter;
Expand Down Expand Up @@ -35,8 +36,7 @@ public ObjectDetails(T object, Map<String, Map<String, TLAObject>> related) {
* Map payload and related objects from DTO to domain model types.
*/
public static ObjectDetails<? extends TLAObject> from(SingleDocumentWrapper<? extends AbstractDto> wrapper) {
var container = new ObjectDetails<>(wrapper);
return container;
return new ObjectDetails<>(wrapper);
}

/**
Expand All @@ -49,9 +49,9 @@ public Map<String, List<TLAObject>> extractRelatedObjects() {
Collectors.toMap(
entry -> entry.getKey(),
entry -> entry.getValue().stream().map(
reference -> this.expandRelatedObject(reference)
this::expandRelatedObject
).filter(
o -> o != null
Objects::nonNull
).toList()
)
);
Expand Down
29 changes: 14 additions & 15 deletions src/main/java/tla/web/model/ui/Pagination.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package tla.web.model.ui;

import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.IntStream;
Expand All @@ -14,7 +13,7 @@
@Getter
public class Pagination {

public final static int OMISSION_THRESHOLD = 2;
public static final int OMISSION_THRESHOLD = 2;

private long fromResult;
private long toResult;
Expand All @@ -32,8 +31,8 @@ public Pagination(PageInfo dtoPage) {
if (dtoPage != null) {
this.currentPage = dtoPage.getNumber() + 1;
this.totalResults = dtoPage.getTotalElements();
this.fromResult = (this.currentPage - 1) * dtoPage.getSize() + 1;
this.toResult = (this.currentPage - 1) * dtoPage.getSize() + dtoPage.getNumberOfElements();
this.fromResult = (this.currentPage - 1l) * dtoPage.getSize() + 1;
this.toResult = (this.currentPage - 1l) * dtoPage.getSize() + dtoPage.getNumberOfElements();
this.lastPage = Math.max(dtoPage.getTotalPages(), 1);
this.pages = this.makePageLinks();
} else {
Expand All @@ -49,15 +48,15 @@ public Pagination(PageInfo dtoPage) {
* @return
*/
protected int distanceToRequiredPage(int page) {
return Arrays.asList(
return List.of(
1,
this.currentPage,
this.lastPage
).stream().map(
requiredPage -> Math.abs(requiredPage - page)
).reduce(
Math::min
).get();
).orElseThrow();
}

/**
Expand All @@ -66,24 +65,24 @@ protected int distanceToRequiredPage(int page) {
* ellipsis placeholders (n pages omitted).
*/
protected List<Integer> makePageLinks() {
List<Integer> pages = new LinkedList<Integer>();
List<Integer> omitted = new LinkedList<Integer>();
List<Integer> included = new LinkedList<>();
List<Integer> omitted = new LinkedList<>();
IntStream.rangeClosed(1, this.lastPage).forEach(
p -> {
if (this.distanceToRequiredPage(p) > OMISSION_THRESHOLD) {
omitted.add(p);
page-> {
if (this.distanceToRequiredPage(page) > OMISSION_THRESHOLD) {
omitted.add(page);
} else {
if (omitted.size() > 1) {
pages.add(null);
included.add(null);
} else {
pages.addAll(omitted);
included.addAll(omitted);
}
omitted.clear();
pages.add(p);
included.add(page);
}
}
);
return pages;
return included;
}

}
3 changes: 0 additions & 3 deletions src/main/java/tla/web/model/ui/SearchFormExpansionState.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
import lombok.AllArgsConstructor;
import lombok.Getter;

import lombok.Getter;
import lombok.AllArgsConstructor;

/**
* Simple single-purpose POJO for initializing search form collapsible
* expansion states (which search form currently has the focus)
Expand Down
43 changes: 22 additions & 21 deletions src/main/java/tla/web/mvc/EditorialContentController.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import jakarta.servlet.http.HttpServletRequest;

import org.jooq.lambda.Seq;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.MessageSource;
Expand Down Expand Up @@ -45,18 +44,24 @@
@RequestMapping("/")
public class EditorialContentController {

@Autowired
private MessageSource l10n;

@Autowired
private LocaleResolver localeResolver;

@Autowired
private EditorialRegistry editorialRegistry;

@Autowired
private RequestMappingHandlerMapping handlerMapping;

public EditorialContentController(
MessageSource l10n, LocaleResolver localeResolver,
EditorialRegistry editorialRegistry, RequestMappingHandlerMapping handlerMapping
) {
this.l10n = l10n;
this.localeResolver = localeResolver;
this.editorialRegistry = editorialRegistry;
this.handlerMapping = handlerMapping;
}

@Value("${tla.editorials.path}")
private String editorialsDir;

Expand Down Expand Up @@ -112,7 +117,7 @@ private HttpHeaders preferContentLanguage(String lang, HttpHeaders header) {
/**
* build i18n message key for an editorial page's title.
*/
public static String getPageTitleMsgKey(String path, String lang) {
public static String getPageTitleMsgKey(String path) {
return "editorial_title_" + Seq.toString(
Stream.of(
path.split("/")
Expand All @@ -131,7 +136,7 @@ public static String getPageTitleMsgKey(String path, String lang) {
*/
public String getPageTitle(String path, String lang) {
return l10n.getMessage(
getPageTitleMsgKey(path, lang),
getPageTitleMsgKey(path),
null,
path,
Locale.forLanguageTag(lang)
Expand Down Expand Up @@ -186,7 +191,7 @@ public String renderEditorial(
List.of(
BREADCRUMB_HOME,
BreadCrumb.of(
getPageTitleMsgKey(path, lang)
getPageTitleMsgKey(path)
)
)
);
Expand All @@ -208,19 +213,15 @@ public void onApplicationReady(ApplicationReadyEvent event) throws NoSuchMethodE
HttpHeaders.class,
Model.class
);
try {
this.editorialRegistry.getLangSupport().forEach(
(path, supportedLanguages) -> {
handlerMapping.registerMapping(
RequestMappingInfo.paths(path).methods(RequestMethod.GET).options(
handlerMapping.getBuilderConfiguration()
).build(),
this,
handlerMethod
);
}
);
} catch (Exception e) {}
this.editorialRegistry.getLangSupport().forEach(
(path, supportedLanguages) -> handlerMapping.registerMapping(
RequestMappingInfo.paths(path).methods(RequestMethod.GET).options(
handlerMapping.getBuilderConfiguration()
).build(),
this,
handlerMethod
)
);
}

}
5 changes: 2 additions & 3 deletions src/main/java/tla/web/mvc/GlobalControllerAdvisor.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import jakarta.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.info.BuildProperties;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.http.HttpStatus;
Expand All @@ -27,13 +26,13 @@ public class GlobalControllerAdvisor extends DefaultHandlerExceptionResolver {

public static final BreadCrumb BREADCRUMB_HOME = BreadCrumb.of("/", "menu_global_home");

@Autowired
private BuildProperties buildProperties;

private ApplicationProperties applicationProperties;

public GlobalControllerAdvisor(ApplicationProperties properties) {
public GlobalControllerAdvisor(ApplicationProperties properties, BuildProperties buildProperties) {
this.applicationProperties = properties;
this.buildProperties = buildProperties;
}

@ModelAttribute("env")
Expand Down
17 changes: 9 additions & 8 deletions src/main/java/tla/web/mvc/LemmaController.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import java.util.Collections;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.MultiValueMap;
Expand All @@ -30,18 +29,21 @@
@TemplateModelName("lemma")
public class LemmaController extends ObjectController<Lemma, LemmaSearch> {

@Autowired
private LemmaService lemmaService;

@Autowired
private LemmaSearchProperties searchConfig;

public static final Script[] SEARCHABLE_SCRIPTS = {
public LemmaController(LemmaService lemmaService, LemmaSearchProperties searchConfig) {
this.lemmaService = lemmaService;
this.searchConfig = searchConfig;
}

static final Script[] SEARCHABLE_SCRIPTS = {
Script.HIERATIC,
Script.DEMOTIC
};

public static final Language[] SEARCHABLE_TRANSLATION_LANGUAGES = {
static final Language[] SEARCHABLE_TRANSLATION_LANGUAGES = {
Language.DE,
Language.EN,
Language.FR
Expand Down Expand Up @@ -82,11 +84,10 @@ public String getSearchResultsPage(

@Override
protected Model extendSearchResultsPageModel(Model model, SearchResults results, SearchCommand<?> searchForm) {
if (searchForm instanceof LemmaSearch) {
LemmaSearch form = (LemmaSearch) searchForm;
if (searchForm instanceof LemmaSearch form) {
model.addAttribute(
"allTranslationLanguages",
(form.getTranscription() != null) ? form.getTranslation().getLang() : Collections.EMPTY_LIST
(form.getTranscription() != null) ? form.getTranslation().getLang() : Collections.emptyList()
);
model.addAttribute("allScripts", form.getScript());
}
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/tla/web/mvc/ObjectController.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static tla.web.mvc.GlobalControllerAdvisor.BREADCRUMB_HOME;

import java.lang.annotation.Annotation;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedList;
Expand Down Expand Up @@ -60,7 +61,7 @@ public abstract class ObjectController<T extends TLAObject, S extends SearchComm

private String templatePath = null;

public ObjectController() {
ObjectController() {
controllers.add(this);
}

Expand All @@ -70,10 +71,9 @@ public ObjectController() {
* @return URL path prefix
*/
public String getRequestMapping() {
for (Annotation a : this.getClass().getAnnotationsByType(RequestMapping.class)) {
return ((RequestMapping) a).value()[0];
}
return null;
return Arrays.stream(this.getClass().getAnnotationsByType(RequestMapping.class)).map(
requestmapping -> requestmapping.value()[0]
).findFirst().orElse(null);
}

/**
Expand Down Expand Up @@ -132,8 +132,8 @@ public static BreadCrumb createLink(Resolvable ref) {
public String getTemplatePath() {
if (this.templatePath == null) {
for (Annotation a : getClass().getAnnotations()) {
if (a instanceof TemplateModelName) {
this.templatePath = ((TemplateModelName) a).value();
if (a instanceof TemplateModelName tmn) {
this.templatePath = tmn.value();
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/tla/web/mvc/SearchController.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public String mainSearchPage(
*/
private Function<String, SearchFormExpansionState> expandFormExpression(MultiValueMap<String, String> params) {
if (SEARCH_FORMS.stream().anyMatch(
key -> params.containsKey(key)
params::containsKey
)) {
return key -> new SearchFormExpansionState(
key, params.containsKey(key)
Expand Down
Loading

0 comments on commit 9033f73

Please sign in to comment.