// get the destination calendar
final CalendarInstance destinationGroupCalendarInstance = this.calendarInstanceRepository
.findByEntityIdAndEntityTypeIdAndCalendarTypeId(destinationGroup.getId(), CalendarEntityType.GROUPS.getValue(),
CalendarType.COLLECTION.getValue());
if (destinationGroupCalendarInstance == null) { throw new TransferNotSupportedException(
TRANSFER_NOT_SUPPORTED_REASON.DESTINATION_GROUP_HAS_NO_MEETING, destinationGroup.getId());
}
final Calendar sourceGroupCalendar = sourceGroupCalendarInstance.getCalendar();
final Calendar destinationGroupCalendar = destinationGroupCalendarInstance.getCalendar();
/***
* Ensure that the recurrence pattern are same for collection
* meeting in both the source and the destination calendar
***/
if (!(CalendarUtils.isFrequencySame(sourceGroupCalendar.getRecurrence(), destinationGroupCalendar.getRecurrence()) && CalendarUtils
.isIntervalSame(sourceGroupCalendar.getRecurrence(), destinationGroupCalendar.getRecurrence()))) { throw new TransferNotSupportedException(
TRANSFER_NOT_SUPPORTED_REASON.DESTINATION_GROUP_MEETING_FREQUENCY_MISMATCH, sourceGroup.getId(),
destinationGroup.getId()); }
/** map all JLG loans for this client to the destinationGroup **/
for (final CalendarInstance calendarInstance : activeLoanCalendarInstances) {