use of com.axelor.apps.base.db.ICalendarEvent in project axelor-open-suite by axelor.
the class ICalendarService method createEvent.
public ICalendarEvent createEvent(LocalDateTime fromDateTime, LocalDateTime toDateTime, User user, String description, int type, String subject) {
ICalendarEvent event = new ICalendarEvent();
event.setSubject(subject);
event.setStartDateTime(fromDateTime);
event.setEndDateTime(toDateTime);
event.setTypeSelect(type);
event.setUser(user);
event.setCalendar(user.getiCalendar());
if (!Strings.isNullOrEmpty(description)) {
event.setDescription(description);
}
return event;
}
use of com.axelor.apps.base.db.ICalendarEvent 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