@Override public GwtRpcResponseList<WeekInterface> execute( WeekSelectorRequest command, SessionContext context) { GwtRpcResponseList<WeekInterface> ret = new GwtRpcResponseList<WeekInterface>(); Session session = SessionDAO.getInstance().get(command.getSessionId()); Calendar c = Calendar.getInstance(Locale.US); c.setTime(session.getEventBeginDate()); while (c.get(Calendar.DAY_OF_WEEK) != Calendar.MONDAY) { c.add(Calendar.DAY_OF_YEAR, -1); } int sessionYear = session.getSessionStartYear(); Formats.Format<Date> df = Formats.getDateFormat(Formats.Pattern.DATE_EVENT_SHORT); while (!c.getTime().after(session.getEventEndDate())) { int dayOfYear = c.get(Calendar.DAY_OF_YEAR); if (c.get(Calendar.YEAR) < sessionYear) { Calendar x = Calendar.getInstance(Locale.US); x.set(c.get(Calendar.YEAR), 11, 31, 0, 0, 0); dayOfYear -= x.get(Calendar.DAY_OF_YEAR); } else if (c.get(Calendar.YEAR) > sessionYear) { Calendar x = Calendar.getInstance(Locale.US); x.set(sessionYear, 11, 31, 0, 0, 0); dayOfYear += x.get(Calendar.DAY_OF_YEAR); } WeekInterface week = new WeekInterface(); week.setDayOfYear(dayOfYear); for (int i = 0; i < 7; i++) { week.addDayName( new DateInterface( df.format(c.getTime()), c.get(Calendar.MONTH) + 1, c.get(Calendar.DAY_OF_MONTH))); c.add(Calendar.DAY_OF_YEAR, 1); } ret.add(week); } return ret; }
protected void print(Printer out, List<EventInterface> events) throws IOException { out.printHeader( /* 0 */ MESSAGES.colName(), /* 1 */ MESSAGES.colSection(), /* 2 */ MESSAGES.colType(), /* 3 */ MESSAGES.colTitle(), /* 4 */ MESSAGES.colNote(), /* 5 */ MESSAGES.colDayOfWeek(), /* 6 */ MESSAGES.colFirstDate(), /* 7 */ MESSAGES.colLastDate(), /* 8 */ MESSAGES.colPublishedStartTime(), /* 9 */ MESSAGES.colPublishedEndTime(), /* 10 */ MESSAGES.colAllocatedStartTime(), /* 11 */ MESSAGES.colAllocatedEndTime(), /* 12 */ MESSAGES.colSetupTimeShort(), /* 13 */ MESSAGES.colTeardownTimeShort(), /* 14 */ MESSAGES.colLocation(), /* 15 */ MESSAGES.colCapacity(), /* 16 */ MESSAGES.colEnrollment(), /* 17 */ MESSAGES.colLimit(), /* 18 */ MESSAGES.colSponsorOrInstructor(), /* 19 */ MESSAGES.colEmail(), /* 20 */ MESSAGES.colMainContact(), /* 21 */ MESSAGES.colEmail(), /* 22 */ MESSAGES.colApproval(), /* 23 */ MESSAGES.colLastChange()); Formats.Format<Date> df = Formats.getDateFormat(Formats.Pattern.DATE_EVENT); for (EventInterface event : events) { for (MultiMeetingInterface multi : EventInterface.getMultiMeetings(event.getMeetings(), false)) { MeetingInterface meeting = multi.getMeetings().first(); out.printLine( getName(event), getSection(event), event.hasInstruction() ? event.getInstruction() : event.getType().getAbbreviation(CONSTANTS), getTitle(event), event.hasEventNote() ? event.getEventNote("\n").replace("<br>", "\n") : "", multi.getDays(CONSTANTS.shortDays(), CONSTANTS.shortDays(), CONSTANTS.daily()), multi.getFirstMeetingDate() == null ? "" : df.format(multi.getFirstMeetingDate()), multi.getLastMeetingDate() == null ? "" : multi.getNrMeetings() == 1 ? null : df.format(multi.getLastMeetingDate()), meeting.isArrangeHours() ? "" : meeting.getStartTime(CONSTANTS, true), meeting.isArrangeHours() ? "" : meeting.getEndTime(CONSTANTS, true), meeting.isArrangeHours() ? "" : meeting.getStartTime(CONSTANTS, false), meeting.isArrangeHours() ? "" : meeting.getEndTime(CONSTANTS, false), meeting.isArrangeHours() ? "" : String.valueOf(meeting.getStartOffset()), meeting.isArrangeHours() ? "" : String.valueOf(-meeting.getEndOffset()), meeting.getLocationName(), meeting.hasLocation() && meeting.getLocation().hasSize() ? meeting.getLocation().getSize().toString() : null, event.hasEnrollment() ? event.getEnrollment().toString() : null, event.hasMaxCapacity() ? event.getMaxCapacity().toString() : null, event.hasInstructors() ? event.getInstructorNames("\n", MESSAGES) : event.hasSponsor() ? event.getSponsor().getName() : null, event.hasInstructors() ? event.getInstructorEmails("\n") : event.hasSponsor() ? event.getSponsor().getEmail() : null, event.hasContact() ? event.getContact().getName(MESSAGES) : null, event.hasContact() ? event.getContact().getEmail() : null, event.getType() == EventType.Unavailabile ? "" : multi.getApprovalStatus() == ApprovalStatus.Approved ? df.format(multi.getApprovalDate()) : multi.getApprovalStatus() == ApprovalStatus.Cancelled ? MESSAGES.approvalCancelled() : multi.getApprovalStatus() == ApprovalStatus.Rejected ? MESSAGES.approvalRejected() : multi.getApprovalStatus() == ApprovalStatus.Deleted ? MESSAGES.approvalDeleted() : multi.isPast() ? MESSAGES.approvalNotApprovedPast() : event.getExpirationDate() != null ? MESSAGES.approvalExpire( df.format(event.getExpirationDate())) : MESSAGES.approvalNotApproved(), event.getLastNote() != null ? df.format(event.getLastNote().getDate()) + " " + event.getLastNote().getType().getName() : null); } out.flush(); } out.close(); }