use of org.sagebionetworks.bridge.BridgeConstants.API_MAXIMUM_PAGE_SIZE in project BridgeServer2 by Sage-Bionetworks.
the class ScheduledActivityService method retrieveAllPersistedActivitiesIntoMap.
private Map<String, ScheduledActivity> retrieveAllPersistedActivitiesIntoMap(ScheduleContext context, List<ScheduledActivity> scheduledActivities) {
Set<String> activityGuids = scheduledActivities.stream().map((activity) -> {
return activity.getGuid().split(":")[0];
}).collect(Collectors.toSet());
Map<String, ScheduledActivity> dbMap = Maps.newHashMap();
// lose existing activities. So during the time window the user is looking at, we will return any activities that exist.
for (String activityGuid : activityGuids) {
ForwardCursorPagedResourceList<ScheduledActivity> list = activityDao.getActivityHistoryV2(context.getCriteriaContext().getHealthCode(), activityGuid, context.getStartsOn(), context.getEndsOn(), null, API_MAXIMUM_PAGE_SIZE);
if (list != null) {
for (ScheduledActivity activity : list.getItems()) {
dbMap.put(activity.getGuid(), activity);
}
}
}
// IA-587: When a one-time task falls outside the schedule window, it's not returned by the
// query above, so it is recreated, and it loses its finished state. Load all remaining scheduled activities.
String healthCode = context.getCriteriaContext().getHealthCode();
for (ScheduledActivity activity : scheduledActivities) {
if (!dbMap.containsKey(activity.getGuid())) {
ScheduledActivity dbActivity = activityDao.getActivity(context.getStartsOn().getZone(), healthCode, activity.getGuid(), false);
if (dbActivity != null) {
dbMap.put(dbActivity.getGuid(), dbActivity);
}
}
}
return dbMap;
}
Aggregations