Skip to content

Commit

Permalink
SAK-41021 - Date/Time screens for Signup events: confirmed and (sakai…
Browse files Browse the repository at this point in the history
…project#6378)

waitlisted

Commit to register and show the date and time in which a student signed
up to event. This information is also shown in exported Excel files.
Order in both Inscription (by name) and Waiting (by list_index) lists is
not modified.
  • Loading branch information
adrianmticarum authored and ern committed Dec 12, 2018
1 parent cccc0e7 commit bd9846d
Show file tree
Hide file tree
Showing 18 changed files with 180 additions and 114 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<column name="attended" default="0"/>
</property>
<!-- <property name="attended" column="attended" type="boolean" not-null="false" /> -->
<property name="inscriptionTime" column="inscription_time" type="org.sakaiproject.springframework.orm.hibernate.type.InstantType" not-null="false" />
</composite-element>
</list>
<list name="waitingList" cascade="all" table="signup_ts_waitinglist" fetch="join">
Expand All @@ -51,6 +52,7 @@
<property name="attended" type="boolean" >
<column name="attended" default="0"/>
</property>
<property name="inscriptionTime" column="inscription_time" type="org.sakaiproject.springframework.orm.hibernate.type.InstantType" not-null="false" />
</composite-element>
</list>
</class>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

package org.sakaiproject.signup.logic;

import java.time.Instant;
import java.util.Date;
import java.util.List;

Expand Down Expand Up @@ -465,5 +466,12 @@ public interface SignupMeetingService {
* @throws Exception
*/
List<String> getAllCategories(String siteId) throws Exception;

/**
*
* @param instant - The Instant that is going to be converted to display to the user, based on the locale
* @return a string with the converted instant to display, based on the locale
*/
String getUsersLocalDateTimeString(Instant instant);

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,15 @@

package org.sakaiproject.signup.model;

import java.time.Instant;

/**
* <p>
* This class holds the information for signup attendee. It's mapped directly to
* the DB storage by Hibernate
* </p>
*/
public class SignupAttendee implements Comparable{
public class SignupAttendee implements Comparable<SignupAttendee>{

/* sakai user id */
private String attendeeUserId;
Expand All @@ -58,6 +59,7 @@ public class SignupAttendee implements Comparable{

private boolean attended;

private Instant inscriptionTime;

/**
* Constructor
Expand Down Expand Up @@ -199,28 +201,27 @@ public void setDisplayName(String displayName) {
this.displayName = displayName;
}

public Instant getInscriptionTime() {
return inscriptionTime;
}

public void setInscriptionTime(Instant inscriptionTime) {
this.inscriptionTime = inscriptionTime;
}

/**
* for sorting purpose. It's according to string alphabetic order. Last name
* comes first
*/
public int compareTo(Object o) {
if (o == null)
@Override
public int compareTo(SignupAttendee signupAttendeeToCompare) {
if (signupAttendeeToCompare == null)
return -1;
if (!(o instanceof SignupAttendee))
throw new ClassCastException("Not type of SignupAttendee");

SignupAttendee other = (SignupAttendee) o;

if (displayName == null)
return -1;

int value = displayName.compareTo(other.getDisplayName());
if (value != 0)
return value;


return 0;

return displayName.compareTo(signupAttendeeToCompare.getDisplayName());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
package org.sakaiproject.signup.logic;

import java.text.MessageFormat;
import java.time.Instant;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.format.FormatStyle;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
Expand Down Expand Up @@ -70,6 +74,7 @@
import org.sakaiproject.time.api.Time;
import org.sakaiproject.time.api.TimeRange;
import org.sakaiproject.time.api.TimeService;
import org.sakaiproject.time.api.UserTimeService;
import org.sakaiproject.util.ResourceLoader;

/**
Expand Down Expand Up @@ -97,6 +102,9 @@ public class SignupMeetingServiceImpl implements SignupMeetingService, Retry, Me
@Getter @Setter
private SignupEmailFacade signupEmailFacade;

@Setter
private UserTimeService userTimeService;

protected static ResourceLoader rb = new ResourceLoader("emailMessage");

public void init() {
Expand Down Expand Up @@ -1170,6 +1178,13 @@ public List<String> getAllCategories(String siteId) throws Exception {
}



@Override
public String getUsersLocalDateTimeString(final Instant date) {
final ZoneId zone = userTimeService.getLocalTimeZone().toZoneId();
final DateTimeFormatter df = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM, FormatStyle.SHORT)
.withZone(zone)
.withLocale(rb.getLocale());
return df.format(date);
}

}
1 change: 1 addition & 0 deletions signup/impl/src/webapp/WEB-INF/components.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
<property name="sakaiFacade" ref="org.sakaiproject.signup.logic.SakaiFacade" />
<property name="signupEmailFacade" ref="org.sakaiproject.signup.logic.SignupEmailFacade" />
<property name="signupCacheService" ref="org.sakaiproject.signup.logic.signupCacheService" />
<property name="userTimeService" ref="org.sakaiproject.time.api.UserTimeService"/>
</bean>

<bean id="org.sakaiproject.signup.logic.SignupCalendarHelper" class="org.sakaiproject.signup.logic.SignupCalendarHelperImpl">
Expand Down
4 changes: 4 additions & 0 deletions signup/tool/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
2 changes: 2 additions & 0 deletions signup/tool/src/bundle/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,8 @@ tab_waiting_list = Wait List

tab_waiting_list_disabled = &nbsp;[disabled]

tab_date_inscription = Date of Inscription

timeperiod_divider = &nbsp;&nbsp;-&nbsp;&nbsp;

timeslot.just.canceled = This time slot has been canceled and is no longer available.
Expand Down
2 changes: 2 additions & 0 deletions signup/tool/src/bundle/messages_es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,8 @@ tab_waiting_list=Lista de espera

tab_waiting_list_disabled=&nbsp;[deshabilitado]

tab_date_inscription=Fecha de Inscripci\u00f3n

timeperiod_divider=&nbsp;&nbsp;-&nbsp;&nbsp;

timeslot.just.canceled=Este intervalo de tiempo ha sido cancelado y ya no est\u00e1 disponible.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ private void downloadExcelSpreadsheet(List<SignupMeetingWrapper> smWrappers,
excelSpreadsheet(out, smWrappers, downloadType);

out.flush();
} catch (IOException ex) {
} catch (Exception ex) {
log.warn("Error generating XLS spreadsheet for download event:" + ex.getMessage());
} finally {
if (out != null)
Expand Down Expand Up @@ -288,6 +288,7 @@ public String downloadSelections() {
private void excelSpreadsheet(OutputStream os, List<SignupMeetingWrapper> meetingWrappers,
String downloadType) throws IOException {
EventWorksheet worksheet = new EventWorksheet(getSakaiFacade());
worksheet.setSignupMeetingService(getSignupMeetingService());

Workbook wb = worksheet.getEventWorkbook(meetingWrappers, downloadType);
wb.write(os);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
import java.util.List;
import java.util.Map;

import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.common.usermodel.HyperlinkType;
import org.apache.poi.ss.usermodel.Cell;
Expand All @@ -59,6 +61,7 @@

import org.sakaiproject.exception.IdUnusedException;
import org.sakaiproject.signup.logic.SakaiFacade;
import org.sakaiproject.signup.logic.SignupMeetingService;
import org.sakaiproject.signup.model.MeetingTypes;
import org.sakaiproject.signup.model.SignupAttachment;
import org.sakaiproject.signup.model.SignupAttendee;
Expand All @@ -82,6 +85,10 @@
@Slf4j
public class EventWorksheet implements MeetingTypes, SignupBeanConstants {

private static final int COLUMNS_NOT_GROUPING_BY_SLOT = 8;

private static final int COLUMNS_GROUPING_BY_SLOT = 7;

private ResourceLoader rb = new ResourceLoader("messages");

private String[] tabTitles_Organizor;
Expand All @@ -103,6 +110,9 @@ public class EventWorksheet implements MeetingTypes, SignupBeanConstants {
CreationHelper createHelper = null;

private SakaiFacade sakaiFacade;

@Getter @Setter
private SignupMeetingService signupMeetingService;

/**
* Constructor
Expand Down Expand Up @@ -645,13 +655,23 @@ private void createWorksheet(SignupMeetingWrapper wrapper, int serialNum, boolea

return;
}

int numberOfColumns = 0;
boolean groupBySlot = sakaiFacade.getServerConfigurationService().getBoolean("signup.export.group.participants.by.slot", true);

if(groupBySlot) {
numberOfColumns = COLUMNS_GROUPING_BY_SLOT;
}
else {
numberOfColumns = COLUMNS_NOT_GROUPING_BY_SLOT;
}

/* Case: for group and individual events */
// Table titles row
cur_rowNum = cur_rowNum + 2;
row = sheet.createRow(cur_rowNum);
row.setHeightInPoints(rowHigh);
for (int i = 2; i <= 7; i++) {
for (int i = 2; i <= numberOfColumns; i++) {
row.createCell(i).setCellStyle(styles.get("tabColNames"));
}
cell = row.getCell(2);
Expand All @@ -660,20 +680,16 @@ private void createWorksheet(SignupMeetingWrapper wrapper, int serialNum, boolea
cell.setCellValue(currentTabTitles[0]);
sheet.addMergedRegion(CellRangeAddress.valueOf("$C$" + (cur_rowNum + 1) + ":$D$"
+ (cur_rowNum + 1)));
cell = row.getCell(4);
cell.setCellValue(currentTabTitles[1]);
cell = row.getCell(5);
cell.setCellValue(currentTabTitles[2]);
cell = row.getCell(6);
cell.setCellValue(currentTabTitles[3]);
cell = row.getCell(7);
cell.setCellValue(currentTabTitles[4]);

for (int i = 4; i <= numberOfColumns && (i-3<currentTabTitles.length); i++) {
cell = row.getCell(i);
cell.setCellValue(currentTabTitles[i-3]);
}

// Table schedule Info
int rowNum = cur_rowNum;
final List<SignupTimeslot> tsItems = wrapper.getMeeting().getSignupTimeSlots();

boolean groupBySlot = sakaiFacade.getServerConfigurationService().getBoolean("signup.export.group.participants.by.slot", true);

if(groupBySlot) {
rowNum = getTableScheduleInfoStudentsGroupBySlot(wrapper, sheet, rowNum, tsItems);
}
Expand All @@ -683,7 +699,7 @@ private void createWorksheet(SignupMeetingWrapper wrapper, int serialNum, boolea

// end of table line
row = sheet.createRow(rowNum);
for (int i = 2; i <= 7; i++) {
for (int i = 2; i <= numberOfColumns; i++) {
row.createCell(i).setCellStyle(styles.get("tab_endline"));
}

Expand All @@ -692,7 +708,7 @@ private void createWorksheet(SignupMeetingWrapper wrapper, int serialNum, boolea
// Comment Title row
Row commentsRow = sheet.createRow(rowNum);
commentsRow.setHeightInPoints(25);
for (int i = 1; i <= 7; i++) {
for (int i = 1; i <= numberOfColumns; i++) {
commentsRow.createCell(i).setCellStyle(styles.get("commentTitle"));
}
Cell commentsCell = commentsRow.getCell(2);
Expand All @@ -719,7 +735,7 @@ private void createWorksheet(SignupMeetingWrapper wrapper, int serialNum, boolea
String comment = att.getComments();
if (comment != null && comment.trim().length() > 0) {
row = sheet.createRow(rowNum++);
for (int i = 1; i <= 7; i++) {
for (int i = 1; i <= numberOfColumns; i++) {
row.createCell(i);
}
cell = row.getCell(2);
Expand Down Expand Up @@ -758,7 +774,7 @@ private void createWorksheet(SignupMeetingWrapper wrapper, int serialNum, boolea
sheet.setColumnWidth(0, 3 * 256);
sheet.setColumnWidth(1, 3 * 256);

for (int i = 2; i <= 7; i++) {
for (int i = 2; i <= numberOfColumns; i++) {
sheet.autoSizeColumn(i);
}

Expand Down Expand Up @@ -896,7 +912,7 @@ private int getTableScheduleInfoOneStudentPerRow(SignupMeetingWrapper wrapper, f
private void fillAttendeeRow(final SignupMeetingWrapper wrapper, final Sheet sheet, int rowNum, final SignupTimeslot tsItem,
final List<SignupAttendee> attendees, final SignupAttendee signupAttendee, boolean isWaiting) {
final Row row = sheet.createRow(rowNum);
for (int i = 1; i <= 7; i++) {
for (int i = 1; i <= COLUMNS_NOT_GROUPING_BY_SLOT; i++) {
row.createCell(i).setCellStyle(styles.get("tabItem_fields"));
}
// timeslot period
Expand Down Expand Up @@ -968,6 +984,12 @@ else if (tsItem.isCanceled())
cell.setCellValue(fieldValue);
cell.setCellStyle(styles.get("attendee_layout"));
}

// Inscription date and time
cell = row.getCell(8);
String fieldValue = signupMeetingService.getUsersLocalDateTimeString(signupAttendee.getInscriptionTime());
cell.setCellValue(fieldValue);
cell.setCellStyle(styles.get("attendee_layout"));
}
// set row high
row.setHeightInPoints(rowHigh * rowHighNum);
Expand Down Expand Up @@ -1045,7 +1067,7 @@ private String getNames(List<SignupAttendee> attendees, boolean needSorting) {
Collections.sort(attendees);

for (SignupAttendee att : attendees) {
sb.append(att.getDisplayName());
sb.append(att.getDisplayName() + " - " + signupMeetingService.getUsersLocalDateTimeString(att.getInscriptionTime()));
sb.append("\n");
}
/* remove the last'\n' one */
Expand Down Expand Up @@ -1208,12 +1230,13 @@ private Hyperlink setAttachmentURLLinks(SignupAttachment attach) {
}

private void initTableThRow() {
tabTitles_Organizor = new String[5];
tabTitles_Organizor = new String[6];
tabTitles_Organizor[0] = rb.getString("tab_time_slot", "Time Slot");
tabTitles_Organizor[1] = rb.getString("tab_max_attendee", "Max # of Participants");
tabTitles_Organizor[2] = rb.getString("tab_attendees", "Participants");
tabTitles_Organizor[3] = rb.getString("tab_attendees_eids", "Participants User IDs");
tabTitles_Organizor[4] = rb.getString("tab_waiting_list", "Wait List");
tabTitles_Organizor[5] = rb.getString("tab_date_inscription", "Date of Inscription");

tabTitles_Participant = new String[5];
tabTitles_Participant[0] = rb.getString("tab_time_slot", "Time Slot");
Expand Down
Loading

0 comments on commit bd9846d

Please sign in to comment.