Skip to content

Commit

Permalink
prepareX can can now override the sorting order.
Browse files Browse the repository at this point in the history
  • Loading branch information
jflamy committed Aug 20, 2024
1 parent 2397acb commit cc9659d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1189,14 +1190,14 @@ private List<KitElement> prepareSchedule(List<Group> selectedItems, BiConsumer<T
// schedule is currently a variation on starting list
JXLSStartingListDocs xlsWriter = new JXLSStartingListDocs();
// group may have been edited since the page was loaded
xlsWriter.setGroup(
getGroup() != null ? GroupRepository.getById(getGroup().getId()) : null);
// get current version of athletes.
List<Athlete> 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<Athlete> 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")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -29,7 +28,6 @@ public class JXLSCategoriesListDocs extends JXLSWorkbookStreamSource {
}

public JXLSCategoriesListDocs() {
System.err.println("JXLSCategoriesListDocs "+LoggerUtils.whereFrom());
this.setExcludeNotWeighed(false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,11 @@ public void createTeamColumns(int listColumn, int catColumn) {
});
}

@Override
public boolean isEmptyOk() {
return true;
}

public Consumer<Workbook> getPostProcessor() {
return this.postProcessor;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit cc9659d

Please sign in to comment.