org.exoplatform.calendar.service.impl
Class CsvImportExport

java.lang.Object
  extended by org.exoplatform.calendar.service.impl.CsvImportExport
All Implemented Interfaces:
CalendarImportExport

public class CsvImportExport
extends java.lang.Object
implements CalendarImportExport

Created by The eXo Platform SAS Author : Pham Tuan tuan.pham@exoplatform.com Apr 1, 2008


Field Summary
static java.lang.String CSV_PATTERN
           
static java.lang.String EV_ALLDAY
           
static java.lang.String EV_ATTACTMENT
           
static java.lang.String EV_ATTENDEES
           
static java.lang.String EV_BILLINGINFO
           
static java.lang.String EV_CATEGORIES
           
static java.lang.String EV_DESCRIPTION
           
static java.lang.String EV_ENDDATE
           
static java.lang.String EV_ENDTIME
           
static java.lang.String EV_HASREMINDER
           
static java.lang.String EV_INVITATION
           
static java.lang.String EV_LOCATION
           
static java.lang.String EV_MEETINGORGANIZER
           
static java.lang.String EV_MILEAGE
           
static java.lang.String EV_PRIORITY
           
static java.lang.String EV_PRIVATE
           
static java.lang.String EV_REMINDERDATE
           
static java.lang.String EV_REMINDERTIME
           
static java.lang.String EV_SENSITIVITY
           
static java.lang.String EV_STARTDATE
           
static java.lang.String EV_STARTTIME
           
static java.lang.String EV_STATUS
           
static java.lang.String EV_SUMMARY
           
 
Constructor Summary
CsvImportExport(JCRDataStorage dataStore)
          Construct a regex-based CSV parser.
 
Method Summary
 java.io.OutputStream exportCalendar(java.lang.String username, java.util.List<java.lang.String> calendarIds, java.lang.String type)
          The method exports events form calendar to icalendar file (.ics) or .csv file
 java.io.OutputStream exportCalendar(java.lang.String username, java.util.List<java.lang.String> calendarIds, java.lang.String type, int number)
           
 java.io.OutputStream exportEventCalendar(org.exoplatform.services.jcr.ext.common.SessionProvider sProvider, java.lang.String username, java.lang.String calendarId, java.lang.String type, java.lang.String eventId)
          The method export calendar event to output stream by given event id
 java.util.List<CalendarEvent> getEventObjects(java.io.InputStream icalInputStream)
          The method maps the input stream to event object
 void importCalendar(org.exoplatform.services.jcr.ext.common.SessionProvider sProvider, java.lang.String username, java.io.InputStream csvInputStream, java.lang.String calendarName)
          The method imports events form icalendar(.ics) or outlook calendar exported .csv file to the system
 void importToCalendar(org.exoplatform.services.jcr.ext.common.SessionProvider sProvider, java.lang.String username, java.io.InputStream icalInputStream, java.lang.String calendarId)
          The method imports events form icalendar(.ics) or outlook calendar exported .csv file to the system
 boolean isValidate(java.io.InputStream icalInputStream)
          The method return true if the input stream is correct format
 java.util.List<java.lang.String> parse(java.lang.String line)
          Parse one line.
 java.util.List<CalendarEvent> process(java.io.BufferedReader in)
          Process one file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CSV_PATTERN

public static final java.lang.String CSV_PATTERN
See Also:
Constant Field Values

EV_SUMMARY

public static java.lang.String EV_SUMMARY

EV_STARTDATE

public static java.lang.String EV_STARTDATE

EV_STARTTIME

public static java.lang.String EV_STARTTIME

EV_ENDDATE

public static java.lang.String EV_ENDDATE

EV_ENDTIME

public static java.lang.String EV_ENDTIME

EV_ALLDAY

public static java.lang.String EV_ALLDAY

EV_HASREMINDER

public static java.lang.String EV_HASREMINDER

EV_REMINDERDATE

public static java.lang.String EV_REMINDERDATE

EV_REMINDERTIME

public static java.lang.String EV_REMINDERTIME

EV_MEETINGORGANIZER

public static java.lang.String EV_MEETINGORGANIZER

EV_ATTENDEES

public static java.lang.String EV_ATTENDEES

EV_INVITATION

public static java.lang.String EV_INVITATION

EV_ATTACTMENT

public static java.lang.String EV_ATTACTMENT

EV_BILLINGINFO

public static java.lang.String EV_BILLINGINFO

EV_CATEGORIES

public static java.lang.String EV_CATEGORIES

EV_DESCRIPTION

public static java.lang.String EV_DESCRIPTION

EV_LOCATION

public static java.lang.String EV_LOCATION

EV_MILEAGE

public static java.lang.String EV_MILEAGE

EV_PRIORITY

public static java.lang.String EV_PRIORITY

EV_PRIVATE

public static java.lang.String EV_PRIVATE

EV_SENSITIVITY

public static java.lang.String EV_SENSITIVITY

EV_STATUS

public static java.lang.String EV_STATUS
Constructor Detail

CsvImportExport

public CsvImportExport(JCRDataStorage dataStore)
Construct a regex-based CSV parser.

Method Detail

process

public java.util.List<CalendarEvent> process(java.io.BufferedReader in)
                                      throws java.lang.Exception
Process one file. Delegates to parse() a line at a time

Throws:
java.lang.Exception

parse

public java.util.List<java.lang.String> parse(java.lang.String line)
Parse one line.

Returns:
List of Strings, minus their double quotes

exportCalendar

public java.io.OutputStream exportCalendar(java.lang.String username,
                                           java.util.List<java.lang.String> calendarIds,
                                           java.lang.String type)
                                    throws java.lang.Exception
Description copied from interface: CalendarImportExport
The method exports events form calendar to icalendar file (.ics) or .csv file

Specified by:
exportCalendar in interface CalendarImportExport
Parameters:
username - current user name or id
calendarIds - the group calendar ids, if you want to export events from public calendars
type - The type of calendar will be exported
Returns:
data output stream
Throws:
java.lang.Exception

exportEventCalendar

public java.io.OutputStream exportEventCalendar(org.exoplatform.services.jcr.ext.common.SessionProvider sProvider,
                                                java.lang.String username,
                                                java.lang.String calendarId,
                                                java.lang.String type,
                                                java.lang.String eventId)
                                         throws java.lang.Exception
Description copied from interface: CalendarImportExport
The method export calendar event to output stream by given event id

Specified by:
exportEventCalendar in interface CalendarImportExport
Parameters:
sProvider - session of current user
username - current user name or id
calendarId - given calendar id, the calendar event belong to
type - The type of calendar will be exported
eventId - given event id
Returns:
data output stream
Throws:
java.lang.Exception

importCalendar

public void importCalendar(org.exoplatform.services.jcr.ext.common.SessionProvider sProvider,
                           java.lang.String username,
                           java.io.InputStream csvInputStream,
                           java.lang.String calendarName)
                    throws java.lang.Exception
Description copied from interface: CalendarImportExport
The method imports events form icalendar(.ics) or outlook calendar exported .csv file to the system

Specified by:
importCalendar in interface CalendarImportExport
Parameters:
sProvider - session of current user
username - current user name or id
csvInputStream - data input stream
calendarName - given calendar name, if the name is null, default calendar name is file name
Throws:
java.lang.Exception

getEventObjects

public java.util.List<CalendarEvent> getEventObjects(java.io.InputStream icalInputStream)
                                              throws java.lang.Exception
Description copied from interface: CalendarImportExport
The method maps the input stream to event object

Specified by:
getEventObjects in interface CalendarImportExport
Parameters:
icalInputStream - the input stream
Returns:
List of calendar event objects contant infomations
Throws:
java.lang.Exception

importToCalendar

public void importToCalendar(org.exoplatform.services.jcr.ext.common.SessionProvider sProvider,
                             java.lang.String username,
                             java.io.InputStream icalInputStream,
                             java.lang.String calendarId)
                      throws java.lang.Exception
Description copied from interface: CalendarImportExport
The method imports events form icalendar(.ics) or outlook calendar exported .csv file to the system

Specified by:
importToCalendar in interface CalendarImportExport
Parameters:
sProvider - session of current user
username - current user name or id
icalInputStream - data input stream
calendarId - given existed calendar id
Throws:
java.lang.Exception

isValidate

public boolean isValidate(java.io.InputStream icalInputStream)
                   throws java.lang.Exception
Description copied from interface: CalendarImportExport
The method return true if the input stream is correct format

Specified by:
isValidate in interface CalendarImportExport
Parameters:
icalInputStream - the input stream
Throws:
java.lang.Exception

exportCalendar

public java.io.OutputStream exportCalendar(java.lang.String username,
                                           java.util.List<java.lang.String> calendarIds,
                                           java.lang.String type,
                                           int number)
                                    throws java.lang.Exception
Specified by:
exportCalendar in interface CalendarImportExport
Throws:
java.lang.Exception


Copyright © 2011 eXo Platform SAS. All Rights Reserved.