
Untitled
By: a guest on
Feb 10th, 2012 | syntax:
Groovy | size: 1.34 KB | hits: 140 | expires: Never
import org.joda.time.DateTime
import static org.joda.time.DateTimeConstants.MONDAY
import static org.joda.time.DateTimeConstants.WEDNESDAY
import static org.joda.time.DateTimeConstants.FRIDAY
// Re. the blog post: location, description, recuruntil, recurcount missing from last domain class example
// Creating dates for our test events
def now = new DateTime()
def tomorrow = now.plusDays(1)
// Creating a weekly event that occurs every MWF
def event = new Event(title: 'Repeating MWF Event').with {
startTime = now.toDate()
endTime = now.plusHours(1).toDate()
location = "Regular location"
recurType = EventRecurType.WEEKLY
[MONDAY, WEDNESDAY, FRIDAY]*.toInteger().each { addToRecurDaysOfWeek(it) }
addToExcludeDays(now.withDayOfWeek(MONDAY).plusWeeks(1).toDate())
isRecurring = true
save(flush: true)
}
// Non-repeating single event that replaces the one excluded next Monday
def event2 = new Event(title: event.title).with {
sourceEvent = event
startTime = event.startTime
endTime = event.endTime
location = "New one-time location"
isRecurring = false
save()
}
// Plain old non-repeating event
def event3 = new Event(title: 'Just a normal event').with {
startTime = tomorrow.toDate()
endTime = tomorrow.plusMinutes(30).toDate()
isRecurring = false
save()
}