mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
ALF-11500 Correct the repeating events finding to use the To date, and add additional repeating event webscript unit tests
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@32054 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -880,5 +880,28 @@ public class CalendarRestApiTest extends BaseWebScriptTest
|
||||
assertEquals("2011-07-27T", events.getJSONObject(6).getJSONObject("startAt").getString("iso8601").substring(0,11));
|
||||
// 3rd repeat Friday
|
||||
assertEquals("2011-07-29T", events.getJSONObject(7).getJSONObject("startAt").getString("iso8601").substring(0,11));
|
||||
|
||||
|
||||
// Ask for events from a date in the future
|
||||
// We shouldn't get either of the original events, but we
|
||||
// should get the repeating instances of the 2nd one
|
||||
result = getEntries("admin", "2011/08/20");
|
||||
events = result.getJSONArray("events");
|
||||
assertEquals(4, events.length());
|
||||
|
||||
// The repeating event runs until 2011-09-11, a Sunday
|
||||
assertEquals(entryName2, events.getJSONObject(0).getString("name"));
|
||||
assertEquals(entryName2, events.getJSONObject(1).getString("name"));
|
||||
assertEquals(entryName2, events.getJSONObject(2).getString("name"));
|
||||
assertEquals(entryName2, events.getJSONObject(3).getString("name"));
|
||||
|
||||
// First Wednesday after the start date
|
||||
assertEquals("2011-08-24T", events.getJSONObject(0).getJSONObject("startAt").getString("iso8601").substring(0,11));
|
||||
// Friday
|
||||
assertEquals("2011-08-26T", events.getJSONObject(1).getJSONObject("startAt").getString("iso8601").substring(0,11));
|
||||
// Wednesday, 2 weeks later
|
||||
assertEquals("2011-09-07T", events.getJSONObject(2).getJSONObject("startAt").getString("iso8601").substring(0,11));
|
||||
// Friday, final repeating instance date
|
||||
assertEquals("2011-09-09T", events.getJSONObject(3).getJSONObject("startAt").getString("iso8601").substring(0,11));
|
||||
}
|
||||
}
|
@@ -196,7 +196,7 @@ public class UserCalendarEntriesGet extends AbstractCalendarWebScript
|
||||
results.add(result);
|
||||
|
||||
// Handle recurring as needed
|
||||
boolean orderChanged = handleRecurring(entry, result, results, fromDate, repeatingFirstOnly);
|
||||
boolean orderChanged = handleRecurring(entry, result, results, fromDate, toDate, repeatingFirstOnly);
|
||||
if (orderChanged)
|
||||
{
|
||||
resortNeeded = true;
|
||||
@@ -305,7 +305,7 @@ public class UserCalendarEntriesGet extends AbstractCalendarWebScript
|
||||
* @return If dates have been tweaked, and a sort may be required
|
||||
*/
|
||||
private boolean handleRecurring(CalendarEntry entry, Map<String, Object> entryResult,
|
||||
List<Map<String, Object>> allResults, Date from, boolean repeatingFirstOnly)
|
||||
List<Map<String, Object>> allResults, Date from, Date until, boolean repeatingFirstOnly)
|
||||
{
|
||||
if (entry.getRecurrenceRule() == null)
|
||||
{
|
||||
@@ -319,16 +319,20 @@ public class UserCalendarEntriesGet extends AbstractCalendarWebScript
|
||||
from = entry.getStart();
|
||||
}
|
||||
|
||||
// Do we nee dto limit ourselves?
|
||||
// Should we limit ourselves?
|
||||
Date until = null;
|
||||
if (!repeatingFirstOnly)
|
||||
{
|
||||
// Only repeating instances for the next 60 days, to keep the list sane
|
||||
// (It's normally only used for a month view anyway)
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.setTime(from);
|
||||
c.add(Calendar.DATE, 60);
|
||||
until = c.getTime();
|
||||
if (until == null)
|
||||
{
|
||||
// If no end date was given, only allow repeating instances
|
||||
// for next 60 days, to keep the list sane
|
||||
// (It's normally only used for a month view anyway)
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.setTime(from);
|
||||
c.add(Calendar.DATE, 60);
|
||||
until = c.getTime();
|
||||
}
|
||||
}
|
||||
|
||||
// How long is it?
|
||||
|
Reference in New Issue
Block a user