use of com.axelor.apps.base.db.repo.ICalendarEventRepository in project axelor-open-suite by axelor.
the class ICalendarService method removeDeletedEventsInRange.
@Transactional
protected void removeDeletedEventsInRange(Set<String> allRemoteUids, ICalendar calendar, LocalDateTime startDate, LocalDateTime endDate) {
QueryBuilder<ICalendarEvent> queryBuilder = QueryBuilder.of(ICalendarEvent.class);
queryBuilder.add("self.uid NOT in (:uids)").bind("uids", allRemoteUids);
queryBuilder.add("self.calendar = :calendar").bind("calendar", calendar);
queryBuilder.add("self.archived = :archived OR self.archived IS NULL").bind("archived", false);
if (startDate != null && endDate != null) {
queryBuilder.add("self.startDateTime BETWEEN :start AND :end OR self.endDateTime BETWEEN :start AND :end").bind("start", startDate).bind("end", endDate);
}
ICalendarEventRepository repo = Beans.get(ICalendarEventRepository.class);
for (ICalendarEvent event : queryBuilder.build().fetch()) {
if (ICalendarRepository.ICAL_ONLY.equals(calendar.getSynchronizationSelect())) {
repo.remove(event);
} else {
event.setArchived(true);
}
}
}
Aggregations