Very cool title goes here and look you have plenty of room to write a

Enhancing the BB calendar
with Microsoft Excel
Batch Import and Export
Peter Jacobs
Catholic University Leuven Association
Belgium
© Blackboard, Inc. All rights reserved.
Toledo project
»
»
»
»
»
»
»
started in september 2001
11 institutes for higher education
56.000 active students
4.000 active professors
20.000 different users a day
over 1.000.000 hits a day
hosting the eloV server, used by 35.000 students
from 200 K-12 schools
2
Blackboard calendar
»
»
»
»
»
»
Basic features
Good integration with courses (access rights, UI)
Personal view (aggregation)
Real need for shared calendar
Integration with MS Outlook, other calendars?
Easy batch import and export?
3
Batch import/export of events
»
CSV: difficulties with separator, date format
»
MS Excel 97/2000/XP:
a standard and well known format, no ambiguities
No dependency on Microsoft software!
e.g. Open Office
4
Upload file
»
<form method="post" enctype="multipart/form-data">
select an Excel file:<br>
<input size="50" name="excelfile" type="file"><br>
<INPUT type="submit" value="import Excel file">
</form>
Process with Apache commons fileupload
commons-fileupload-1.0.jar
»
Result is an InputStream
»
»
5
Apache commons fileupload 1.0
»
if (FileUpload.isMultipartContent(request)) {
DiskFileUpload upload = new DiskFileUpload();
// upload.setSizeThreshold(yourMaxMemorySize);
upload.setSizeMax(1000000);
// upload.setRepositoryPath(yourTempDirectory);
List items = upload.parseRequest(request);
Iterator iter = items.iterator();
while (iter.hasNext()) {
FileItem item = (FileItem) iter.next();
if (!item.isFormField()) {
if (item.getFieldName().equals(formFieldName)) {
inputStream = item.getInputStream();
…
6
Apache POI - HSSF
http://en.wikipedia.org/wiki/HSSF
» Read and write Excel 97/2000/XP files
» Workbook, sheet, colors, borders, shapes, …
» Data formats!
»
7
HSSF - create Excel workbook
»
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("new sheet");
HSSFRow row = sheet.createRow((short)0);
»
HSSFCell cell = row.createCell((short)0);
cell.setCellValue(“this is a string”);
row.createCell((short)1).setCellValue(1.2);
»
OutputStream os = response.getOutputStream();
wb.write(os);
os.close();
8
HSSF – create date cell
»
HSSFCellStyle csDate = wb.createCellStyle();
HSSFDataFormat dateFormat =
wb.createDataFormat();
csDate.setDataFormat(
dateFormat.getFormat("m/d/yy h:mm"));
»
cell = row.createCell((short)0);
cell.setCellStyle(csDate);
cell.setCellValue(new Date());
9
HSSF – read workbook
»
POIFSFileSystem fs = new POIFSFileSystem(inputStream);
HSSFWorkbook hssfworkbook = new HSSFWorkbook(fs);
HSSFSheet sheet = hssfworkbook.getSheetAt(0);
int rows = sheet.getPhysicalNumberOfRows();
for (int r = 0; r < rows; r++) {
HSSFRow row = sheet.getRow(r);
if (row != null) {
int cells = row.getPhysicalNumberOfCells();
for (int c = 0; c < cells; c++) {
HSSFCell cell = row.getCell((short) c);
…
10
HSSF – read cell
»
if (cell != null) {
Object value = null;
switch (cell.getCellType()) {
case HSSFCell.CELL_TYPE_FORMULA:
value = "Error: formula";
break;
case HSSFCell.CELL_TYPE_NUMERIC:
value = new Double(cell.getNumericCellValue());
break;
case HSSFCell.CELL_TYPE_STRING:
value = cell.getStringCellValue();
break;
default:
}
}
11
Blackboard – course calendar entry
»
CalendarEntry entry = new CalendarEntry();
entry.setType(Type.COURSE);
entry.setStartDate(startDate);
entry.setEndDate(endDate);
entry.setTitle(title);
entry.setDescription(new FormattedText(
description, FormattedText.Type.DEFAULT));
entry.setCourseId(courseId);
entry.setCreatorUserId(userId);
12
Blackboard – create or delete calendar entry
»
CalendarEntryDbPersister calendarPersister =
CalendarEntryDbPersister.Default.getInstance();
»
calendarPersister.persist(entry);
»
calendarPersister.deleteById(entry.getId());
13
Blackboard – load course calendar entries
CalendarEntryDbLoader calendarLoader =
CalendarEntryDbLoader.Default.getInstance();
» BbList calendarEntries =
calendarLoader.loadByCourseId(courseId,
(Calendar) startDate.clone(),
(Calendar) endDate.clone());
»
»
loadByUserId(…), loadByCourseIdAndUserId(…),
loadByType(…), …
14
Issue: time zone
Only import with implicit time zone
» Create user preference?
» iCalendar format has extensive capabilities for
time zones and UTC
»
15
iCalendar
»
»
http://en.wikipedia.org/wiki/iCalendar
Google Calendar, Apple iCal, Outlook 2007,…
»
BEGIN:VCALENDAR
PRODID:-//Google Inc//Google Calendar 70.9054//EN
VERSION:2.0
X-WR-TIMEZONE:Europe/Paris
…
BEGIN:VEVENT
DTSTART;TZID=Europe/Paris:20060727T163000
DTEND;TZID=Europe/Paris:20060727T173000
SUMMARY:Toledo presentation
END:VEVENT
…
END:VCALENDAR
16
To do
»
»
»
»
»
»
»
Layout, navigation (breadcrumbs)
Name of calendar entry creator
Location parameter
Time zones
Recurring events, multi day events
Other import/export formats
Other types of events: institution, personal
17
More to do
Performance, caching iCalendar
» Date boundary checking
» Formatted text, HTML, …
» Update calendar events (unique id)
»
18
More info
»
»
»
http://perswww.kuleuven.be/peter_jacobs/bbcalendar/
[email protected]
Mailinglists
BB-OPEN_SRC
BBADMIN-L
BLKBRD-L
19