Search in sources :

Example 6 with ICalendarEvent

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;
}
Also used : ICalendarEvent(com.axelor.apps.base.db.ICalendarEvent)

Example 7 with ICalendarEvent

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);
        }
    }
}
Also used : ICalendarEvent(com.axelor.apps.base.db.ICalendarEvent) ICalendarEventRepository(com.axelor.apps.base.db.repo.ICalendarEventRepository) Transactional(com.google.inject.persist.Transactional)

Aggregations

ICalendarEvent (com.axelor.apps.base.db.ICalendarEvent)7 Transactional (com.google.inject.persist.Transactional)5 ICalendar (com.axelor.apps.base.db.ICalendar)2 AxelorException (com.axelor.exception.AxelorException)2 LocalDateTime (java.time.LocalDateTime)2 Calendar (net.fortuna.ical4j.model.Calendar)2 VEvent (net.fortuna.ical4j.model.component.VEvent)2 ICalendarUser (com.axelor.apps.base.db.ICalendarUser)1 WeeklyPlanning (com.axelor.apps.base.db.WeeklyPlanning)1 ICalendarEventRepository (com.axelor.apps.base.db.repo.ICalendarEventRepository)1 Employee (com.axelor.apps.hr.db.Employee)1 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 SocketException (java.net.SocketException)1 URISyntaxException (java.net.URISyntaxException)1 ParseException (java.text.ParseException)1 Instant (java.time.Instant)1 OffsetDateTime (java.time.OffsetDateTime)1 ZoneId (java.time.ZoneId)1 HashMap (java.util.HashMap)1