diff --git a/src/main/java/org/olat/core/util/openxml/OpenXMLWorkbook.java b/src/main/java/org/olat/core/util/openxml/OpenXMLWorkbook.java index bb0e462795dbce156765f4f625b916373296ab38..1506d82a0d52fba02b6d11508679653c4836c69e 100644 --- a/src/main/java/org/olat/core/util/openxml/OpenXMLWorkbook.java +++ b/src/main/java/org/olat/core/util/openxml/OpenXMLWorkbook.java @@ -561,7 +561,11 @@ public class OpenXMLWorkbook implements Closeable { int count = 1; for(OpenXMLWorksheet sheet:worksheets) { writer.writeStartElement("sheet"); - writer.writeAttribute("name", "Sheet " + count); + if(StringHelper.containsNonWhitespace(sheet.getName())) { + writer.writeAttribute("name", sheet.getName()); + } else { + writer.writeAttribute("name", "Sheet " + count); + } writer.writeAttribute("sheetId", Integer.toString(count++)); writer.writeAttribute("r:id", sheet.getId()); writer.writeEndElement(); diff --git a/src/main/java/org/olat/core/util/openxml/OpenXMLWorksheet.java b/src/main/java/org/olat/core/util/openxml/OpenXMLWorksheet.java index 86c512f55d7d3e31c7ea07ea2c83b6dd52a0c04c..f0cd7776bc13a1eaadb87441d97afef7321a9a00 100644 --- a/src/main/java/org/olat/core/util/openxml/OpenXMLWorksheet.java +++ b/src/main/java/org/olat/core/util/openxml/OpenXMLWorksheet.java @@ -51,6 +51,7 @@ public class OpenXMLWorksheet { } private String id; + private String name; private final OpenXMLWorkbook workbook; private final ZipOutputStream zout; private XMLStreamWriter writer; @@ -72,6 +73,14 @@ public class OpenXMLWorksheet { return id; } + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + public int getHeaderRows() { return headerRows; } diff --git a/src/main/java/org/olat/course/run/CourseRuntimeController.java b/src/main/java/org/olat/course/run/CourseRuntimeController.java index 3632702891d2af53ed8963236cd499c448ad4e18..f0598a3c00afa984920ef8bbe3d1daf835c2e3c4 100644 --- a/src/main/java/org/olat/course/run/CourseRuntimeController.java +++ b/src/main/java/org/olat/course/run/CourseRuntimeController.java @@ -1383,7 +1383,7 @@ public class CourseRuntimeController extends RepositoryEntryRuntimeController im OLATResourceable ores = OresHelper.createOLATResourceableType("lecturesAdmin"); WindowControl swControl = addToHistory(ureq, ores, null); - LectureRepositoryAdminController ctrl = new LectureRepositoryAdminController(ureq, swControl, getRepositoryEntry()); + LectureRepositoryAdminController ctrl = new LectureRepositoryAdminController(ureq, swControl, toolbarPanel, getRepositoryEntry()); listenTo(ctrl); lecturesAdminCtrl = pushController(ureq, translate("command.options.lectures.admin"), ctrl); setActiveTool(lecturesAdminLink); diff --git a/src/main/java/org/olat/modules/lecture/LectureBlock.java b/src/main/java/org/olat/modules/lecture/LectureBlock.java index a4e3f58b8ce226315bbb852f25dbf80e6feb0a89..5cd302a1f3da08c61bf5d9fd5c1ab32fb3ce0acd 100644 --- a/src/main/java/org/olat/modules/lecture/LectureBlock.java +++ b/src/main/java/org/olat/modules/lecture/LectureBlock.java @@ -109,6 +109,8 @@ public interface LectureBlock extends LectureBlockRef, ModifiedInfo, CreateInfo, * @param rollCallStatus Cannot be null */ public void setRollCallStatus(LectureRollCallStatus rollCallStatus); + + public Date getAutoClosedDate(); public RepositoryEntry getEntry(); diff --git a/src/main/java/org/olat/modules/lecture/ui/LectureListRepositoryController.java b/src/main/java/org/olat/modules/lecture/ui/LectureListRepositoryController.java index 2c28fa96ac5655d415aaf5443f7a48ac13c3b5ea..7928221b7607ff38e04f8fe4d183eb65cd675dee 100644 --- a/src/main/java/org/olat/modules/lecture/ui/LectureListRepositoryController.java +++ b/src/main/java/org/olat/modules/lecture/ui/LectureListRepositoryController.java @@ -148,7 +148,7 @@ public class LectureListRepositoryController extends FormBasicController { FlexiTableSortOptions options = new FlexiTableSortOptions(); options.setDefaultOrderBy(new SortKey(BlockCols.date.name(), false)); tableEl.setSortSettings(options); - //TODO absence tableEl.setAndLoadPersistedPreferences(ureq, "repo-lecture-block-list"); + tableEl.setAndLoadPersistedPreferences(ureq, "repo-lecture-block-list"); } private void loadModel() { diff --git a/src/main/java/org/olat/modules/lecture/ui/LectureRepositoryAdminController.java b/src/main/java/org/olat/modules/lecture/ui/LectureRepositoryAdminController.java index 2cb6ef380918021a0f06fae0a1c13b5fa76175fe..8fe59266b656e9d814effadae1981817cd373e25 100644 --- a/src/main/java/org/olat/modules/lecture/ui/LectureRepositoryAdminController.java +++ b/src/main/java/org/olat/modules/lecture/ui/LectureRepositoryAdminController.java @@ -26,11 +26,15 @@ import org.olat.core.gui.components.link.LinkFactory; import org.olat.core.gui.components.segmentedview.SegmentViewComponent; import org.olat.core.gui.components.segmentedview.SegmentViewEvent; import org.olat.core.gui.components.segmentedview.SegmentViewFactory; +import org.olat.core.gui.components.stack.TooledController; +import org.olat.core.gui.components.stack.TooledStackedPanel; +import org.olat.core.gui.components.stack.TooledStackedPanel.Align; import org.olat.core.gui.components.velocity.VelocityContainer; import org.olat.core.gui.control.Controller; import org.olat.core.gui.control.Event; import org.olat.core.gui.control.WindowControl; import org.olat.core.gui.control.controller.BasicController; +import org.olat.modules.lecture.ui.export.LecturesBlocksEntryExport; import org.olat.repository.RepositoryEntry; /** @@ -39,10 +43,12 @@ import org.olat.repository.RepositoryEntry; * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com * */ -public class LectureRepositoryAdminController extends BasicController { +public class LectureRepositoryAdminController extends BasicController implements TooledController { + private Link archiveLink; private final VelocityContainer mainVC; private final SegmentViewComponent segmentView; + private final TooledStackedPanel stackPanel; private final Link lecturesLink, settingsLink, participantsLink; private LectureListRepositoryController lecturesCtrl; @@ -52,9 +58,11 @@ public class LectureRepositoryAdminController extends BasicController { private RepositoryEntry entry; private boolean configurationChanges = false; - public LectureRepositoryAdminController(UserRequest ureq, WindowControl wControl, RepositoryEntry entry) { + public LectureRepositoryAdminController(UserRequest ureq, WindowControl wControl, TooledStackedPanel stackPanel, + RepositoryEntry entry) { super(ureq, wControl); this.entry = entry; + this.stackPanel = stackPanel; mainVC = createVelocityContainer("admin_repository"); @@ -93,6 +101,14 @@ public class LectureRepositoryAdminController extends BasicController { // } + @Override + public void initTools() { + archiveLink = LinkFactory.createToolLink("archive.entry", translate("archive.entry"), this); + archiveLink.setIconLeftCSS("o_icon o_icon_archive_tool"); + archiveLink.setVisible(settingsCtrl.isLectureEnabled()); + stackPanel.addTool(archiveLink, Align.right); + } + @Override protected void event(UserRequest ureq, Component source, Event event) { if(source == segmentView) { @@ -108,6 +124,8 @@ public class LectureRepositoryAdminController extends BasicController { doOpenParticipants(ureq); } } + } else if(archiveLink == source) { + doExportArchive(ureq); } } @@ -156,4 +174,9 @@ public class LectureRepositoryAdminController extends BasicController { } mainVC.put("segmentCmp", participantsCtrl.getInitialComponent()); } + + private void doExportArchive(UserRequest ureq) { + LecturesBlocksEntryExport archive = new LecturesBlocksEntryExport(entry, getTranslator()); + ureq.getDispatchResult().setResultingMediaResource(archive); + } } \ No newline at end of file diff --git a/src/main/java/org/olat/modules/lecture/ui/ParticipantListRepositoryController.java b/src/main/java/org/olat/modules/lecture/ui/ParticipantListRepositoryController.java index 89c890cd8e6538bdbd74027c17c1f359184ff94b..647702de7f00bc001026dd0ef3e9dbc510b2d0df 100644 --- a/src/main/java/org/olat/modules/lecture/ui/ParticipantListRepositoryController.java +++ b/src/main/java/org/olat/modules/lecture/ui/ParticipantListRepositoryController.java @@ -69,7 +69,7 @@ import org.springframework.beans.factory.annotation.Autowired; */ public class ParticipantListRepositoryController extends FormBasicController { - protected static final String USER_PROPS_ID = ParticipantListRepositoryController.class.getCanonicalName(); + public static final String USER_PROPS_ID = ParticipantListRepositoryController.class.getCanonicalName(); public static final int USER_PROPS_OFFSET = 500; diff --git a/src/main/java/org/olat/modules/lecture/ui/TeacherLecturesTableController.java b/src/main/java/org/olat/modules/lecture/ui/TeacherLecturesTableController.java index 9c6cca2553e9a0a66d5aed0a2ad67044e2f61f2b..59da4ea416ab924ff4b7fa105597710c1c2ae982 100644 --- a/src/main/java/org/olat/modules/lecture/ui/TeacherLecturesTableController.java +++ b/src/main/java/org/olat/modules/lecture/ui/TeacherLecturesTableController.java @@ -66,6 +66,8 @@ import org.olat.modules.lecture.model.LectureBlockRow; import org.olat.modules.lecture.model.RollCallSecurityCallbackImpl; import org.olat.modules.lecture.ui.TeacherOverviewDataModel.TeachCols; import org.olat.modules.lecture.ui.component.LectureBlockStatusCellRenderer; +import org.olat.modules.lecture.ui.export.LectureBlockExport; +import org.olat.modules.lecture.ui.export.LecturesBlockPDFExport; import org.olat.user.UserManager; import org.springframework.beans.factory.annotation.Autowired; diff --git a/src/main/java/org/olat/modules/lecture/ui/TeacherRollCallController.java b/src/main/java/org/olat/modules/lecture/ui/TeacherRollCallController.java index 4c2bdf147e1e5a1db8eb41fe56f1685cf3455733..1106e197f3d2932297da4c59726815bcb806bc47 100644 --- a/src/main/java/org/olat/modules/lecture/ui/TeacherRollCallController.java +++ b/src/main/java/org/olat/modules/lecture/ui/TeacherRollCallController.java @@ -71,6 +71,7 @@ import org.olat.modules.lecture.LectureService; import org.olat.modules.lecture.RollCallSecurityCallback; import org.olat.modules.lecture.ui.TeacherRollCallDataModel.RollCols; import org.olat.modules.lecture.ui.component.LectureBlockRollCallStatusItem; +import org.olat.modules.lecture.ui.export.LecturesBlockPDFExport; import org.olat.user.UserManager; import org.olat.user.propertyhandlers.UserPropertyHandler; import org.springframework.beans.factory.annotation.Autowired; diff --git a/src/main/java/org/olat/modules/lecture/ui/_i18n/LocalStrings_de.properties b/src/main/java/org/olat/modules/lecture/ui/_i18n/LocalStrings_de.properties index 267e4e22c0a8078086fcf69bf2c0404a8913a84f..574d4142fc9be1c120a8f27e42c263a97a1887be 100644 --- a/src/main/java/org/olat/modules/lecture/ui/_i18n/LocalStrings_de.properties +++ b/src/main/java/org/olat/modules/lecture/ui/_i18n/LocalStrings_de.properties @@ -16,6 +16,7 @@ attendance.list=Anwesenheitsliste authorized.absence=Entschuldigt authorized.absence.reason=Begr\u00FCndung autoclosed=Autoerledigt +archive.entry=Archivierung bulk=Benutzername, $org.olat.user.propertyhandlers\:table.name.email oder $org.olat.user.propertyhandlers\:table.name.institutionalUserIdentifier bulk.example=test01<br>author02<br>test@openolat.org bulk.hint=Sie k\u00F6nenn eine Liste von Benutzername oder Email Adresse von Benutzer geben. @@ -188,6 +189,7 @@ table.header.absent.lectures=Abwesend table.header.actions=<i class\='o_icon o_icon_actions o_icon-lg'> </i> table.header.attended.lectures=Anwesend table.header.authorized.absence=Entschuldigt +table.header.auto.close.date=Auto closed am table.header.comment=Kommentar table.header.compulsory=<i class\='o_icon o_icon_compulsory o_icon-lg'> </i> table.header.date=Datum diff --git a/src/main/java/org/olat/modules/lecture/ui/_i18n/LocalStrings_en.properties b/src/main/java/org/olat/modules/lecture/ui/_i18n/LocalStrings_en.properties index d4f52641439f16960ded09e736712595e84383c9..ae9363dc00a933b93fa82f1b432cc873394ebc59 100644 --- a/src/main/java/org/olat/modules/lecture/ui/_i18n/LocalStrings_en.properties +++ b/src/main/java/org/olat/modules/lecture/ui/_i18n/LocalStrings_en.properties @@ -16,6 +16,7 @@ attendance.list=Attendance list authorized.absence=Authorized authorized.absence.reason=Reason autoclosed=Auto-closed +archive.entry=Archive bulk=User names, $org.olat.user.propertyhandlers\:table.name.email oder $org.olat.user.propertyhandlers\:table.name.institutionalUserIdentifier bulk.example=test01<br>author02<br>test@openolat.org bulk.hint=You can give a list of user names or email addresses separated by a return. @@ -187,6 +188,7 @@ table.header.absent.lectures=Absent table.header.actions=<i class\='o_icon o_icon_actions o_icon-lg'> </i> table.header.attended.lectures=Attended table.header.authorized.absence=Excused +table.header.auto.close.date=Auto closed at table.header.comment=Comment table.header.compulsory=<i class\='o_icon o_icon_compulsory o_icon-lg'> </i> table.header.date=Date diff --git a/src/main/java/org/olat/modules/lecture/ui/LectureBlockExport.java b/src/main/java/org/olat/modules/lecture/ui/export/LectureBlockExport.java similarity index 95% rename from src/main/java/org/olat/modules/lecture/ui/LectureBlockExport.java rename to src/main/java/org/olat/modules/lecture/ui/export/LectureBlockExport.java index c74b265db23c46471a506e0ca72c437163acbb71..b9e6492f5b3d38c8401a59123e80353f36d46f2c 100644 --- a/src/main/java/org/olat/modules/lecture/ui/LectureBlockExport.java +++ b/src/main/java/org/olat/modules/lecture/ui/export/LectureBlockExport.java @@ -17,7 +17,7 @@ * frentix GmbH, http://www.frentix.com * <p> */ -package org.olat.modules.lecture.ui; +package org.olat.modules.lecture.ui.export; import java.io.IOException; import java.io.OutputStream; @@ -40,6 +40,7 @@ import org.olat.core.util.openxml.OpenXMLWorksheet.Row; import org.olat.modules.lecture.LectureBlock; import org.olat.modules.lecture.LectureBlockRollCall; import org.olat.modules.lecture.LectureService; +import org.olat.modules.lecture.ui.ParticipantListRepositoryController; import org.olat.user.UserManager; import org.olat.user.propertyhandlers.UserPropertyHandler; @@ -86,17 +87,21 @@ public class LectureBlockExport extends OpenXMLWorkbookResource { protected void generate(OutputStream out) { try(OpenXMLWorkbook workbook = new OpenXMLWorkbook(out, 1)) { OpenXMLWorksheet exportSheet = workbook.nextWorksheet(); - exportSheet.setHeaderRows(3); - addHeaders_1(exportSheet); - addHeaders_2(exportSheet); - addHeaders_3(exportSheet); - addContent(exportSheet); - addFooter(exportSheet); + generate(exportSheet); } catch (IOException e) { log.error("", e); } } + protected void generate(OpenXMLWorksheet exportSheet) { + exportSheet.setHeaderRows(3); + addHeaders_1(exportSheet); + addHeaders_2(exportSheet); + addHeaders_3(exportSheet); + addContent(exportSheet); + addFooter(exportSheet); + } + private void addFooter(OpenXMLWorksheet exportSheet) { exportSheet.newRow(); exportSheet.newRow(); @@ -230,6 +235,4 @@ public class LectureBlockExport extends OpenXMLWorkbookResource { } } } - - } diff --git a/src/main/java/org/olat/modules/lecture/ui/LecturesBlockPDFExport.java b/src/main/java/org/olat/modules/lecture/ui/export/LecturesBlockPDFExport.java similarity index 99% rename from src/main/java/org/olat/modules/lecture/ui/LecturesBlockPDFExport.java rename to src/main/java/org/olat/modules/lecture/ui/export/LecturesBlockPDFExport.java index 68e09db815f3c8632538e3f00a2688240924bcb0..48c10f988a875b79ee47d80b7edb7e1924457244 100644 --- a/src/main/java/org/olat/modules/lecture/ui/LecturesBlockPDFExport.java +++ b/src/main/java/org/olat/modules/lecture/ui/export/LecturesBlockPDFExport.java @@ -17,7 +17,7 @@ * frentix GmbH, http://www.frentix.com * <p> */ -package org.olat.modules.lecture.ui; +package org.olat.modules.lecture.ui.export; import java.io.IOException; import java.io.InputStream; diff --git a/src/main/java/org/olat/modules/lecture/ui/export/LecturesBlocksEntryExport.java b/src/main/java/org/olat/modules/lecture/ui/export/LecturesBlocksEntryExport.java new file mode 100644 index 0000000000000000000000000000000000000000..32de1a83f9ed3f1354da45f0e7f9dd13b2399447 --- /dev/null +++ b/src/main/java/org/olat/modules/lecture/ui/export/LecturesBlocksEntryExport.java @@ -0,0 +1,185 @@ +/** + * <a href="http://www.openolat.org"> + * OpenOLAT - Online Learning and Training</a><br> + * <p> + * Licensed under the Apache License, Version 2.0 (the "License"); <br> + * you may not use this file except in compliance with the License.<br> + * You may obtain a copy of the License at the + * <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a> + * <p> + * Unless required by applicable law or agreed to in writing,<br> + * software distributed under the License is distributed on an "AS IS" BASIS, <br> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br> + * See the License for the specific language governing permissions and <br> + * limitations under the License. + * <p> + * Initial code contributed and copyrighted by<br> + * frentix GmbH, http://www.frentix.com + * <p> + */ +package org.olat.modules.lecture.ui.export; + +import java.io.IOException; +import java.io.OutputStream; +import java.util.Collections; +import java.util.Comparator; +import java.util.Date; +import java.util.List; + +import org.olat.core.CoreSpringFactory; +import org.olat.core.gui.translator.Translator; +import org.olat.core.id.Identity; +import org.olat.core.logging.OLog; +import org.olat.core.logging.Tracing; +import org.olat.core.util.Formatter; +import org.olat.core.util.StringHelper; +import org.olat.core.util.openxml.OpenXMLWorkbook; +import org.olat.core.util.openxml.OpenXMLWorkbookResource; +import org.olat.core.util.openxml.OpenXMLWorksheet; +import org.olat.core.util.openxml.OpenXMLWorksheet.Row; +import org.olat.modules.lecture.LectureBlock; +import org.olat.modules.lecture.LectureService; +import org.olat.modules.lecture.Reason; +import org.olat.modules.lecture.model.LectureBlockWithTeachers; +import org.olat.repository.RepositoryEntry; +import org.olat.user.UserManager; + +/** + * + * Initial date: 6 juil. 2017<br> + * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com + * + */ +public class LecturesBlocksEntryExport extends OpenXMLWorkbookResource { + + private static final OLog log = Tracing.createLoggerFor(LecturesBlocksEntryExport.class); + + private final Formatter formatter; + private final RepositoryEntry entry; + private final Translator translator; + private List<LectureBlockWithTeachers> blocks; + + private final UserManager userManager; + private final LectureService lectureService; + + public LecturesBlocksEntryExport(RepositoryEntry entry, Translator translator) { + super(label(entry)); + this.entry = entry; + this.translator = translator; + userManager = CoreSpringFactory.getImpl(UserManager.class); + lectureService = CoreSpringFactory.getImpl(LectureService.class); + formatter = Formatter.getInstance(translator.getLocale()); + } + + private static final String label(RepositoryEntry entry) { + return StringHelper.transformDisplayNameToFileSystemName(entry.getDisplayname()) + + "_" + Formatter.formatDatetimeFilesystemSave(new Date(System.currentTimeMillis())) + + ".xlsx"; + } + + @Override + protected void generate(OutputStream out) { + blocks = lectureService.getLectureBlocksWithTeachers(entry); + Collections.sort(blocks, new LectureBlockWithTeachersComparator()); + + try(OpenXMLWorkbook workbook = new OpenXMLWorkbook(out, 1 + blocks.size())) { + //overview of all lecture blocks + OpenXMLWorksheet exportSheet = workbook.nextWorksheet(); + exportSheet.setHeaderRows(1); + addHeaders(exportSheet); + addContent(exportSheet); + + for(LectureBlockWithTeachers block:blocks) { + OpenXMLWorksheet exportBlockSheet = workbook.nextWorksheet(); + LectureBlockExport lectureBlockExport = new LectureBlockExport(block.getLectureBlock(), block.getTeachers(), true, translator); + lectureBlockExport.generate(exportBlockSheet); + } + } catch (IOException e) { + log.error("", e); + } + } + + private void addHeaders(OpenXMLWorksheet exportSheet) { + Row headerRow = exportSheet.newRow(); + + int pos = 0; + headerRow.addCell(pos++, translator.translate("lecture.title", null)); + headerRow.addCell(pos++, translator.translate("lecture.location", null)); + headerRow.addCell(pos++, translator.translate("lecture.date", null)); + headerRow.addCell(pos++, translator.translate("table.header.start.time", null)); + headerRow.addCell(pos++, translator.translate("table.header.end.time", null)); + headerRow.addCell(pos++, translator.translate("table.header.teachers", null)); + headerRow.addCell(pos++, translator.translate("table.header.status", null)); + headerRow.addCell(pos++, translator.translate("table.header.auto.close.date", null)); + headerRow.addCell(pos++, translator.translate("planned.lectures", null)); + headerRow.addCell(pos++, translator.translate("table.header.effective.lectures", null)); + headerRow.addCell(pos++, translator.translate("lecture.block.effective.end", null)); + headerRow.addCell(pos++, translator.translate("lecture.block.effective.reason", null)); + headerRow.addCell(pos++, translator.translate("table.header.comment", null)); + } + + private void addContent(OpenXMLWorksheet exportSheet) { + for(LectureBlockWithTeachers block:blocks) { + Row row = exportSheet.newRow(); + LectureBlock lectureBlock = block.getLectureBlock(); + + int pos = 0; + row.addCell(pos++, lectureBlock.getTitle()); + row.addCell(pos++, lectureBlock.getLocation()); + row.addCell(pos++, formatDate(lectureBlock.getStartDate())); + row.addCell(pos++, formatTime(lectureBlock.getStartDate())); + row.addCell(pos++, formatTime(lectureBlock.getEndDate())); + + StringBuilder teachers = new StringBuilder(); + for(Identity teacher:block.getTeachers()) { + if(teachers.length() > 0) teachers.append(", "); + teachers.append(userManager.getUserDisplayName(teacher)); + } + row.addCell(pos++, teachers.toString()); + if(lectureBlock.getRollCallStatus() == null) { + pos++; + } else { + row.addCell(pos++, translator.translate(lectureBlock.getRollCallStatus().name())); + } + row.addCell(pos++, formatter.formatDate(lectureBlock.getAutoClosedDate())); + + row.addCell(pos++, toInt(lectureBlock.getPlannedLecturesNumber())); + row.addCell(pos++, toInt(lectureBlock.getEffectiveLecturesNumber())); + row.addCell(pos++, formatTime(lectureBlock.getEffectiveEndDate())); + + Reason reason = lectureBlock.getReasonEffectiveEnd(); + if(reason == null) { + pos++; + } else { + row.addCell(pos++, reason.getTitle()); + } + row.addCell(pos++, lectureBlock.getComment()); + + } + } + + private String toInt(int number) { + return number < 0 ? null : Integer.toString(number); + } + + private String formatTime(Date time) { + return time == null ? null : formatter.formatTimeShort(time); + } + + private String formatDate(Date date) { + return date == null ? null : formatter.formatDate(date); + } + + private static class LectureBlockWithTeachersComparator implements Comparator<LectureBlockWithTeachers> { + + @Override + public int compare(LectureBlockWithTeachers o1, LectureBlockWithTeachers o2) { + Date s1 = o1.getLectureBlock().getStartDate(); + Date s2 = o2.getLectureBlock().getStartDate(); + if(s1 == null && s2 == null) return 0; + if(s1 == null) return 1; + if(s2 == null) return -1; + return s1.compareTo(s2); + } + } +}