From cc9659d6d0423cfbee04081ba0fd7baca2558eb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Lamy?= Date: Tue, 20 Aug 2024 18:48:17 -0400 Subject: [PATCH] prepareX can can now override the sorting order. --- .../nui/preparation/DocumentsContent.java | 17 +++++++++-------- .../spreadsheet/JXLSCategoriesListDocs.java | 2 -- .../spreadsheet/JXLSStartingListDocs.java | 5 +++++ .../spreadsheet/JXLSWorkbookStreamSource.java | 2 +- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/owlcms/src/main/java/app/owlcms/nui/preparation/DocumentsContent.java b/owlcms/src/main/java/app/owlcms/nui/preparation/DocumentsContent.java index dfafc7491..6094e570d 100644 --- a/owlcms/src/main/java/app/owlcms/nui/preparation/DocumentsContent.java +++ b/owlcms/src/main/java/app/owlcms/nui/preparation/DocumentsContent.java @@ -75,6 +75,7 @@ import app.owlcms.data.category.Category; import app.owlcms.data.category.Participation; import app.owlcms.data.competition.Competition; +import app.owlcms.data.config.Config; import app.owlcms.data.group.Group; import app.owlcms.data.group.GroupRepository; import app.owlcms.data.platform.Platform; @@ -1189,14 +1190,14 @@ private List prepareSchedule(List selectedItems, BiConsumer athletesFindAll = athletesFindAll(true); - xlsWriter.setSortedAthletes(athletesFindAll); - - String tn = Competition.getCurrent().getComputedStartListTemplateFileName(); - if (tn.equals("Schedule.xlsx")) { +// xlsWriter.setGroup( +// getGroup() != null ? GroupRepository.getById(getGroup().getId()) : null); +// // get current version of athletes. +// List athletesFindAll = athletesFindAll(true); +// xlsWriter.setSortedAthletes(athletesFindAll); + + String tn = Competition.getCurrent().getScheduleTemplateFileName(); + if (tn.equals("Schedule.xlsx") && Config.getCurrent().featureSwitch("usaw")) { // FIXME: read this from the jxls3 directives xlsWriter.setPostProcessor((w) -> fixMerges(w, 4, List.of(1, 2))); } else if (tn.endsWith("Schedule.xlsx")) { diff --git a/owlcms/src/main/java/app/owlcms/spreadsheet/JXLSCategoriesListDocs.java b/owlcms/src/main/java/app/owlcms/spreadsheet/JXLSCategoriesListDocs.java index fc1a5a259..b9991e62c 100644 --- a/owlcms/src/main/java/app/owlcms/spreadsheet/JXLSCategoriesListDocs.java +++ b/owlcms/src/main/java/app/owlcms/spreadsheet/JXLSCategoriesListDocs.java @@ -8,7 +8,6 @@ import org.slf4j.LoggerFactory; -import app.owlcms.utils.LoggerUtils; import ch.qos.logback.classic.Level; import ch.qos.logback.classic.Logger; @@ -29,7 +28,6 @@ public class JXLSCategoriesListDocs extends JXLSWorkbookStreamSource { } public JXLSCategoriesListDocs() { - System.err.println("JXLSCategoriesListDocs "+LoggerUtils.whereFrom()); this.setExcludeNotWeighed(false); } } diff --git a/owlcms/src/main/java/app/owlcms/spreadsheet/JXLSStartingListDocs.java b/owlcms/src/main/java/app/owlcms/spreadsheet/JXLSStartingListDocs.java index 07cb8eefd..2ba27228a 100644 --- a/owlcms/src/main/java/app/owlcms/spreadsheet/JXLSStartingListDocs.java +++ b/owlcms/src/main/java/app/owlcms/spreadsheet/JXLSStartingListDocs.java @@ -210,6 +210,11 @@ public void createTeamColumns(int listColumn, int catColumn) { }); } + @Override + public boolean isEmptyOk() { + return true; + } + public Consumer getPostProcessor() { return this.postProcessor; } diff --git a/owlcms/src/main/java/app/owlcms/spreadsheet/JXLSWorkbookStreamSource.java b/owlcms/src/main/java/app/owlcms/spreadsheet/JXLSWorkbookStreamSource.java index f133be4b3..c3f5f8ba2 100644 --- a/owlcms/src/main/java/app/owlcms/spreadsheet/JXLSWorkbookStreamSource.java +++ b/owlcms/src/main/java/app/owlcms/spreadsheet/JXLSWorkbookStreamSource.java @@ -527,7 +527,7 @@ private void jxls3Transform(OutputStream stream, File templateFile) { } } else { String message; - if (athletes.size() == 0) { + if (athletes == null || athletes.size() == 0) { message = Translator.translate("NoAthletes"); logger./**/warn("no athletes: empty report."); } else {