Skip to content

Commit

Permalink
Finished adding all Google event mappings
Browse files Browse the repository at this point in the history
Not all implemented yet, but all are mapped at least
  • Loading branch information
bmoeskau committed Aug 28, 2012
1 parent da20682 commit 025c0b0
Showing 1 changed file with 209 additions and 33 deletions.
242 changes: 209 additions & 33 deletions src/calendar/google/EventMappings.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
* classes, provide the interchange between Google's calendar event API and Extensible's data model.
*
* See Google's Event API reference here:
* https://developers.google.com/google-apps/calendar/v3/reference/events
* https://developers.google.com/google-apps/calendar/v3/reference/events
*
* Note that attendees are handled separately via an Ext hasMany association defined in
* {@link Extensible.calendar.data.EventModel}. There are separate
* {@link Extensible.calendar.data.EventAttendeeModel model} and
* {@link Extensible.calendar.data.EventAttendeeMappings mappings} classes for attendees.
*/
Ext.require([
'Extensible.calendar.data.EventModel'
Expand All @@ -26,15 +31,15 @@ function() {
type: 'string'
},
StartDate: {
name: 'StartDate',
mapping: 'start.date',
type: 'date',
name: 'StartDate',
mapping: 'start.date',
type: 'date',
dateFormat: 'Y-m-d'
},
EndDate: {
name: 'EndDate',
mapping: 'end.date',
type: 'date',
name: 'EndDate',
mapping: 'end.date',
type: 'date',
dateFormat: 'Y-m-d'
},
IsAllDay: {
Expand All @@ -57,39 +62,73 @@ function() {
type: 'string'
},

//
// Recurrence-specific mappings.
//
// Recurrence is handled differently between Google and Extensible. Extensible expects a single
// RRule mapping while Google provides an array of multiple strings, each of which could be an
// RRULE, RDATE, EXRULE or EXDATE. This will have to be handled specially inside the reader.
//
Recurrence: {
name: 'Recurrence',
mapping: 'recurrence'
},
OriginalEventId: {
name: 'OriginalEventId',
mapping: 'recurringEventId',
type: 'string'
},
OriginalStartDate: {
name: 'OriginalStartDate',
mapping: 'originalStartTime.date',
type: 'date',
dateFormat: 'Y-m-d'
},
OriginalStartTimeZone: {
name: 'OriginalStartTimeZone',
mapping: 'originalStartTime.timeZone',
type: 'string'
},

//
// Additional core Extensible fields that require more customized mappings
//

// TODO: Google does not directly provide a calendar id...
// CalendarId: {
// name: 'CalendarId',
// mapping: 'cid',
// type: 'string'
// },
CalendarId: {
name: 'CalendarId',
mapping: 'colorId', // ???
type: 'string'
},

// TODO: Google provides a more robust reminder API than Extensible requires...
// Reminder: {
// name: 'Reminder',
// mapping: 'rem',
// type: 'string'
// },
// TODO: Google provides a more robust reminder API than Extensible requires. I think we're going
// to have to process this in the reader...
Reminder: {
name: 'Reminder',
mapping: 'reminders'
},

// The Google API provides both start.date and start.dateTime, and only one will ever be
// included in each response (the other will be undefined in the JSON). Because of this
// we have to map both explicitly, and then we have custom logic in
// Extensible.calendar.google.CalendarReader.extractData() that normalizes these fields
// for Extensible's consumption. Same appiles to end date.
StartDateTime: {
name: 'StartDateTime',
mapping: 'start.dateTime',
type: 'date',
name: 'StartDateTime',
mapping: 'start.dateTime',
type: 'date',
dateFormat: 'c'
},
EndDateTime: {
name: 'EndDateTime',
mapping: 'end.dateTime',
type: 'date',
name: 'EndDateTime',
mapping: 'end.dateTime',
type: 'date',
dateFormat: 'c'
},
OriginalStartDateTime: {
name: 'OriginalStartDateTime',
mapping: 'originalStartTime.dateTime',
type: 'date',
dateFormat: 'c'
},

Expand All @@ -98,19 +137,41 @@ function() {
// but are required for Extensible to provide equivalent functionality to Google calendar.
//
Status: {
name: 'Status',
name: 'Status',
mapping: 'status',
type: 'string'
type: 'string'
},

//
// Additional mappings provided by the Google API, but not used in Extensible by default.
// Mapped here for completeness and potential future use.
// Everything from here below are additional mappings provided by the Google API, but not used
// in Extensible by default. Mapped here for completeness and potential future use.
//
Kind: {
name: 'Kind',
mapping: 'kind',
type: 'string'
},
Etag: {
name: 'Etag',
mapping: 'etag',
type: 'string'
},
CreateDate: {
name: 'CreateDate',
mapping: 'created',
type: 'date',
dateFormat: 'c'
},
UpdateDate: {
name: 'UpdateDate',
mapping: 'updated',
type: 'date',
dateFormat: 'c'
},
AccessRole: {
name: 'AccessRole',
name: 'AccessRole',
mapping: 'accessRole',
type: 'string'
type: 'string'
},
StartTimeZone: {
name: 'StartTimeZone',
Expand All @@ -122,11 +183,126 @@ function() {
mapping: 'end.timeZone',
type: 'string'
},
Locked: {
name: 'Locked',
EndTimeUnspecified: {
name: 'EndTimeUnspecified',
mapping: 'endTimeUnspecified',
type: 'string'
},
Transparency: {
name: 'Transparency',
mapping: 'transparency',
type: 'string'
},
Visibility: {
name: 'Visibility',
mapping: 'visibility',
type: 'string'
},
ICalUID: {
name: 'ICalUID',
mapping: 'iCalUID',
type: 'string'
},
Sequence: {
name: 'Sequence',
mapping: 'sequence',
type: 'int'
},
AttendeesOmitted: {
name: 'AttendeesOmitted',
mapping: 'attendeesOmitted',
type: 'boolean'
},
AnyoneCanAddSelf: {
name: 'AnyoneCanAddSelf',
mapping: 'anyoneCanAddSelf',
type: 'boolean'
},
GuestsCanInviteOthers: {
name: 'GuestsCanInviteOthers',
mapping: 'guestsCanInviteOthers',
type: 'boolean'
},
GuestsCanModify: {
name: 'GuestsCanModify',
mapping: 'guestsCanModify',
type: 'boolean'
},
GuestsCanSeeOtherGuests: {
name: 'GuestsCanSeeOtherGuests',
mapping: 'guestsCanSeeOtherGuests',
type: 'boolean'
},
IsPrivateCopy: {
name: 'IsPrivateCopy',
mapping: 'privateCopy',
type: 'boolean'
},
IsLocked: {
name: 'IsLocked',
mapping: 'locked',
type: 'boolean'
}
},

// Creator fields
CreatorId: {
name: 'CreatorId',
mapping: 'creator.id',
type: 'string'
},
CreatorEmail: {
name: 'CreatorEmail',
mapping: 'creator.email',
type: 'string'
},
CreatorName: {
name: 'CreatorName',
mapping: 'creator.displayName',
type: 'string'
},
IsCreator: {
name: 'IsCreator',
mapping: 'creator.self',
type: 'boolean'
},

// Organizer fields
OrganizerId: {
name: 'OrganizerId',
mapping: 'organizer.id',
type: 'string'
},
OrganizerEmail: {
name: 'OrganizerEmail',
mapping: 'organizer.email',
type: 'string'
},
OrganizerName: {
name: 'OrganizerName',
mapping: 'organizer.displayName',
type: 'string'
},
IsOrganizer: {
name: 'IsOrganizer',
mapping: 'organizer.self',
type: 'boolean'
},

//
// Unsupported properties that are mapped, but probably won't ever do anything useful
//
ExtendedProperties: {
// This is actually a complex object, but it does not have a specified data model as
// it is used to store custom key/value pairs. This mapping will simply dump the raw object
// into the record's data, but it will not be otherwise explicitly used.
name: 'ExtendedProperties',
mapping: 'extendedProperties'
},
Gadget: {
// This is also a complex object, but is only used in the context of Google's calendar UI
name: 'Gadget',
mapping: 'gadget'
},
};

Extensible.calendar.data.EventModel.prototype.mappingClass = 'Extensible.calendar.google.EventMappings';
Expand Down

0 comments on commit 025c0b0

Please sign in to comment.