class SakaiInfo::CalendarEvent

Attributes

calendar_id[R]
dbrow[R]
event_end[R]
event_start[R]
range_end[R]
range_start[R]

Public Class Methods

all_serializations() click to toggle source
# File lib/sakai-info/calendar.rb, line 253
def self.all_serializations
  [
   :default,
   :attributes,
   :properties,
   :mod,
   :xml,
  ]
end
clear_cache() click to toggle source
# File lib/sakai-info/calendar.rb, line 160
def self.clear_cache
  @@cache = {}
end
count_by_calendar_id(calendar_id) click to toggle source
# File lib/sakai-info/calendar.rb, line 199
def self.count_by_calendar_id(calendar_id)
  CalendarEvent.query_by_calendar_id(calendar_id).count
end
find(id) click to toggle source
# File lib/sakai-info/calendar.rb, line 175
def self.find(id)
  if @@cache[id].nil?
    xml = ""
    row = DB.connect[:calendar_event].where(:event_id => id).first
    if row.nil?
      raise ObjectNotFoundException.new(CalendarEvent, id)
    end
    @@cache[id] = CalendarEvent.new(row)
  end
  @@cache[id]
end
find_by_calendar_id(calendar_id) click to toggle source
# File lib/sakai-info/calendar.rb, line 203
def self.find_by_calendar_id(calendar_id)
  CalendarEvent.query_by_calendar_id(calendar_id).all.collect do |row|
    @@cache[row[:event_id]] = CalendarEvent.new(row)
  end
end
new(dbrow) click to toggle source
# File lib/sakai-info/calendar.rb, line 165
def initialize(dbrow)
  @dbrow = dbrow
  @id = dbrow[:event_id]
  @calendar_id = dbrow[:calendar_id]
  @range_start = dbrow[:range_start]
  @range_end = dbrow[:range_end]

  parse_xml
end
query_by_calendar_id(calendar_id) click to toggle source
# File lib/sakai-info/calendar.rb, line 195
def self.query_by_calendar_id(calendar_id)
  DB.connect[:calendar_event].where(:calendar_id => calendar_id)
end

Public Instance Methods

calendar() click to toggle source
# File lib/sakai-info/calendar.rb, line 209
def calendar
  @calendar ||= Calendar.find(self.calendar_id)
end
default_serialization() click to toggle source

serialization

# File lib/sakai-info/calendar.rb, line 226
def default_serialization
  {
    "id" => self.id,
    "calendar_id" => self.calendar_id,
    "display_name" => self.display_name,
    "description" => self.description,
    "type" => self.type,
    "event_start" => self.event_start,
    "event_end" => self.event_end,
  }
end
description() click to toggle source
# File lib/sakai-info/calendar.rb, line 217
def description
  @description ||= self.properties["CHEF:description"]
end
display_name() click to toggle source
# File lib/sakai-info/calendar.rb, line 213
def display_name
  @display_name ||= self.properties["DAV:displayname"]
end
summary_serialization() click to toggle source
# File lib/sakai-info/calendar.rb, line 238
def summary_serialization
  {
    "id" => self.id,
    "display_name" => self.display_name,
    "type" => self.type,
    "event_start_date" => self.event_start.strftime("%Y-%m-%d"),
  }
end
type() click to toggle source
# File lib/sakai-info/calendar.rb, line 221
def type
  @type ||= self.properties["CHEF:calendar-type"]
end
xml_serialization() click to toggle source
# File lib/sakai-info/calendar.rb, line 247
def xml_serialization
  {
    "xml" => self.xml
  }
end