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));
|
assertEquals("2011-07-27T", events.getJSONObject(6).getJSONObject("startAt").getString("iso8601").substring(0,11));
|
||||||
// 3rd repeat Friday
|
// 3rd repeat Friday
|
||||||
assertEquals("2011-07-29T", events.getJSONObject(7).getJSONObject("startAt").getString("iso8601").substring(0,11));
|
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);
|
results.add(result);
|
||||||
|
|
||||||
// Handle recurring as needed
|
// Handle recurring as needed
|
||||||
boolean orderChanged = handleRecurring(entry, result, results, fromDate, repeatingFirstOnly);
|
boolean orderChanged = handleRecurring(entry, result, results, fromDate, toDate, repeatingFirstOnly);
|
||||||
if (orderChanged)
|
if (orderChanged)
|
||||||
{
|
{
|
||||||
resortNeeded = true;
|
resortNeeded = true;
|
||||||
@@ -305,7 +305,7 @@ public class UserCalendarEntriesGet extends AbstractCalendarWebScript
|
|||||||
* @return If dates have been tweaked, and a sort may be required
|
* @return If dates have been tweaked, and a sort may be required
|
||||||
*/
|
*/
|
||||||
private boolean handleRecurring(CalendarEntry entry, Map<String, Object> entryResult,
|
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)
|
if (entry.getRecurrenceRule() == null)
|
||||||
{
|
{
|
||||||
@@ -319,17 +319,21 @@ public class UserCalendarEntriesGet extends AbstractCalendarWebScript
|
|||||||
from = entry.getStart();
|
from = entry.getStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Do we nee dto limit ourselves?
|
||||||
// Should we limit ourselves?
|
// Should we limit ourselves?
|
||||||
Date until = null;
|
|
||||||
if (!repeatingFirstOnly)
|
if (!repeatingFirstOnly)
|
||||||
{
|
{
|
||||||
// Only repeating instances for the next 60 days, to keep the list sane
|
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)
|
// (It's normally only used for a month view anyway)
|
||||||
Calendar c = Calendar.getInstance();
|
Calendar c = Calendar.getInstance();
|
||||||
c.setTime(from);
|
c.setTime(from);
|
||||||
c.add(Calendar.DATE, 60);
|
c.add(Calendar.DATE, 60);
|
||||||
until = c.getTime();
|
until = c.getTime();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// How long is it?
|
// How long is it?
|
||||||
long duration = entry.getEnd().getTime() - entry.getStart().getTime();
|
long duration = entry.getEnd().getTime() - entry.getStart().getTime();
|
||||||
|
Reference in New Issue
Block a user