public String retrieveOne(@Context final UriInfo uriInfo, @PathParam("centerId") final Long centerId,
@DefaultValue("false") @QueryParam("staffInSelectedOfficeOnly") final boolean staffInSelectedOfficeOnly) {
this.context.authenticatedUser().validateHasReadPermission(GroupingTypesApiConstants.CENTER_RESOURCE_NAME);
final Set<String> associationParameters = ApiParameterHelper.extractAssociationsForResponseIfProvided(uriInfo.getQueryParameters());
CalendarData collectionMeetingCalendar = null;
Collection<GroupGeneralData> groups = null;
CenterData center = this.centerReadPlatformService.retrieveOne(centerId);
final boolean template = ApiParameterHelper.template(uriInfo.getQueryParameters());
if (template) {
final CenterData templateCenter = this.centerReadPlatformService.retrieveTemplate(center.officeId(), staffInSelectedOfficeOnly);
center = CenterData.withTemplate(templateCenter, center);
}
if (!associationParameters.isEmpty()) {
if (associationParameters.contains("groupMembers")) {
groups = this.centerReadPlatformService.retrieveAssociatedGroups(centerId);
}
if (associationParameters.contains("collectionMeetingCalendar")) {
collectionMeetingCalendar = this.calendarReadPlatformService.retrieveCollctionCalendarByEntity(centerId,
CalendarEntityType.CENTERS.getValue());
if (collectionMeetingCalendar != null) {
final boolean withHistory = true;
final LocalDate tillDate = null;
final Collection<LocalDate> recurringDates = this.calendarReadPlatformService.generateRecurringDates(
collectionMeetingCalendar, withHistory, tillDate);
final Collection<LocalDate> nextTenRecurringDates = this.calendarReadPlatformService
.generateNextTenRecurringDates(collectionMeetingCalendar);
final MeetingData lastMeeting = this.meetingReadPlatformService.retrieveLastMeeting(collectionMeetingCalendar
.getCalendarInstanceId());
final LocalDate recentEligibleMeetingDate = this.calendarReadPlatformService
.generateNextEligibleMeetingDateForCollection(collectionMeetingCalendar, lastMeeting);
collectionMeetingCalendar = CalendarData.withRecurringDates(collectionMeetingCalendar, recurringDates,
nextTenRecurringDates, recentEligibleMeetingDate);