Skip to content

Commit

Permalink
DASH-111
Browse files Browse the repository at this point in the history
Added methods for updating time of repeating event.


git-svn-id: https://source.sakaiproject.org/svn/dashboard/trunk@313039 66ffb92e-73f9-0310-93c1-f5514f145a0a
  • Loading branch information
jimeng committed Nov 15, 2011
1 parent 42ae0ce commit e98f205
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,9 @@ public void reviseRepeatingCalendarItemsLabelKey(String entityReference,
public void reviseRepeatingCalendarItemSubtype(String entityReference,
String labelKey, String newSubtype);

public void reviseRepeatingCalendarItemTitle(String entityReference, String labelKey, String newTitle);
public void reviseRepeatingCalendarItemTime(String entityReference, Date newTime);

public void reviseRepeatingCalendarItemTitle(String entityReference, String newTitle);

/**
* If an entity uses some form of scheduled release, this method is called to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,9 @@ public List<NewsItem> getNewsItemsByGroupId(String sakaiUserId,
public boolean updateRepeatingCalendarItemsSubtype(String entityReference,
String labelKey, String newSubtype);

public boolean updateRepeatingCalendarItemTime(String entityReference,
Date newTime);

public boolean updateRepeatingCalendarItemTitle(String entityReference,
String newTitle);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1671,6 +1671,23 @@ public boolean updateRepeatingCalendarItemsSubtype(String entityReference, Strin
return false;
}
}

public boolean updateRepeatingCalendarItemTime(String entityReference,
Date newTime) {
if(log.isDebugEnabled()) {
log.debug("updateRepeatingCalendarItemTime( " + entityReference + "," + newTime + ")");
}

try {
getJdbcTemplate().update(getStatement("update.RepeatingEventsTime.entityReference"),
new Object[]{newTime, entityReference}
);
return true;
} catch (DataAccessException ex) {
log.error("updateRepeatingCalendarItemTime: Error executing query: " + ex.getClass() + ":" + ex.getMessage());
return false;
}
}

public boolean updateRepeatingCalendarItemTitle(String entityReference, String newTitle) {
if(log.isDebugEnabled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ public void processEvent(Event event) {
dashboardLogic.reviseCalendarItemsTitle(cEvent.getReference(), title);
} else {
// update repeating calendar item
dashboardLogic.reviseRepeatingCalendarItemTitle(cEvent.getReference(), key, title);
dashboardLogic.reviseRepeatingCalendarItemTitle(cEvent.getReference(), title);
// update all instances of repeating calendar item
dashboardLogic.reviseCalendarItemsTitle(cEvent.getReference(), title);
}
Expand Down Expand Up @@ -578,15 +578,17 @@ public void processEvent(Event event) {
CalendarEvent cEvent = (CalendarEvent) entity;
TimeRange range = cEvent.getRange();
String calendarTimeLabelKey = scheduleEventTypeMap.get(cEvent.getType());

Date newTime = new Date(range.firstTime().getTime());
if(cEvent.getRecurrenceRule() != null) {
// change times for the repeating calendar item and all instances
RepeatingCalendarItem item = dashboardLogic.getRepeatingCalendarItem(entityReference, calendarTimeLabelKey);
// remove and replace existing instances? Or better yet update the time of each instance?
dashboardLogic.reviseRepeatingCalendarItemTime(entityReference, newTime);
dashboardLogic.reviseCalendarItemsTime(entityReference, newTime);

} else {
// update calendar item title
dashboardLogic.reviseCalendarItemsTime(cEvent.getReference(), new Date(range.firstTime().getTime()));
dashboardLogic.reviseCalendarItemsTime(entityReference, newTime);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,12 @@ public void reviseRepeatingCalendarItemSubtype(String entityReference, String la
dao.updateRepeatingCalendarItemsSubtype(entityReference, labelKey, newSubtype);
}

public void reviseRepeatingCalendarItemTitle(String entityReference, String labelKey, String newTitle) {
public void reviseRepeatingCalendarItemTime(String entityReference, Date newTime) {
boolean done = dao.updateRepeatingCalendarItemTime(entityReference, newTime);
}


public void reviseRepeatingCalendarItemTitle(String entityReference, String newTitle) {
dao.updateRepeatingCalendarItemTitle(entityReference, newTitle);
}

Expand Down
2 changes: 2 additions & 0 deletions dashboard/impl/src/resources/hsqldb.properties
Original file line number Diff line number Diff line change
Expand Up @@ -562,5 +562,7 @@ update.RepeatingEventsLabelKey.entityReference.oldLabelKey = update dash_repeati

update.RepeatingEventsSubtype.entityReference.labelKey = update dash_repeating_event set subtype=? where entity_ref=? and calendar_time_label_key=?

update.RepeatingEventsTime.entityReference = update dash_repeating_event set news_time=? where entity_ref=?

update.RepeatingEventsTitle.entityReference = update dash_repeating_event set title=? where entity_ref=?

2 changes: 2 additions & 0 deletions dashboard/impl/src/resources/mysql.properties
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,8 @@ update.RepeatingEventsLabelKey.entityReference.oldLabelKey = update dash_repeati

update.RepeatingEventsSubtype.entityReference.labelKey = update dash_repeating_event set subtype=? where entity_ref=? and calendar_time_label_key=?

update.RepeatingEventsTime.entityReference = update dash_repeating_event set news_time=? where entity_ref=?

update.RepeatingEventsTitle.entityReference = update dash_repeating_event set title=? where entity_ref=?


2 changes: 2 additions & 0 deletions dashboard/impl/src/resources/oracle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,8 @@ update.RepeatingEventsLabelKey.entityReference.oldLabelKey = update dash_repeati

update.RepeatingEventsSubtype.entityReference.labelKey = update dash_repeating_event set subtype=? where entity_ref=? and calendar_time_label_key=?

update.RepeatingEventsTime.entityReference = update dash_repeating_event set news_time=? where entity_ref=?

update.RepeatingEventsTitle.entityReference = update dash_repeating_event set title=? where entity_ref=?


0 comments on commit e98f205

Please sign in to comment.