Search in sources :

Example 1 with CalendarManagement

use of com.axelor.apps.base.db.CalendarManagement in project axelor-open-suite by axelor.

the class CalendarService method showSharedCalendars.

public List<Long> showSharedCalendars(User user) {
    Team team = user.getActiveTeam();
    Set<User> followedUsers = user.getFollowersCalUserSet();
    List<Long> calendarIdlist = new ArrayList<Long>();
    for (User userIt : followedUsers) {
        for (CalendarManagement calendarManagement : userIt.getCalendarManagementList()) {
            if ((user.equals(calendarManagement.getUser())) || (team != null && team.equals(calendarManagement.getTeam()))) {
                List<ICalendar> icalList = icalRepo.all().filter("self.user.id = ?1", userIt.getId()).fetch();
                calendarIdlist.addAll(Lists.transform(icalList, it -> it.getId()));
            }
        }
    }
    List<ICalendar> icalList = icalRepo.all().filter("self.user.id = ?1", user.getId()).fetch();
    calendarIdlist.addAll(Lists.transform(icalList, it -> it.getId()));
    return calendarIdlist;
}
Also used : ICalendarEvent(com.axelor.apps.base.db.ICalendarEvent) CalendarManagement(com.axelor.apps.base.db.CalendarManagement) Inject(com.google.inject.Inject) LocalDateTime(java.time.LocalDateTime) Set(java.util.Set) Team(com.axelor.team.db.Team) ICalendarService(com.axelor.apps.base.ical.ICalendarService) ArrayList(java.util.ArrayList) EventRepository(com.axelor.apps.crm.db.repo.EventRepository) List(java.util.List) Lists(com.google.common.collect.Lists) Beans(com.axelor.inject.Beans) ICalendar(com.axelor.apps.base.db.ICalendar) ICalendarRepository(com.axelor.apps.base.db.repo.ICalendarRepository) User(com.axelor.auth.db.User) CalendarManagement(com.axelor.apps.base.db.CalendarManagement) User(com.axelor.auth.db.User) ArrayList(java.util.ArrayList) Team(com.axelor.team.db.Team) ICalendar(com.axelor.apps.base.db.ICalendar)

Aggregations

CalendarManagement (com.axelor.apps.base.db.CalendarManagement)1 ICalendar (com.axelor.apps.base.db.ICalendar)1 ICalendarEvent (com.axelor.apps.base.db.ICalendarEvent)1 ICalendarRepository (com.axelor.apps.base.db.repo.ICalendarRepository)1 ICalendarService (com.axelor.apps.base.ical.ICalendarService)1 EventRepository (com.axelor.apps.crm.db.repo.EventRepository)1 User (com.axelor.auth.db.User)1 Beans (com.axelor.inject.Beans)1 Team (com.axelor.team.db.Team)1 Lists (com.google.common.collect.Lists)1 Inject (com.google.inject.Inject)1 LocalDateTime (java.time.LocalDateTime)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Set (java.util.Set)1