Search in sources :

Example 1 with CalendarEventHandler

use of io.lavagna.service.calendarutils.CalendarEventHandler in project lavagna by digitalfondue.

the class CalendarService method getUserCalendar.

public CalendarEvents getUserCalendar(UserWithPermission user) throws URISyntaxException, ParseException {
    final CalendarEvents events = new CalendarEvents(new HashMap<Date, CalendarEvents.MilestoneDayEvents>());
    final CalendarEventHandler handler = new StandardCalendarEventHandler(events);
    // Milestones
    addMilestoneEvents(handler, user);
    // Cards
    addCardEvents(handler, user);
    return events;
}
Also used : StandardCalendarEventHandler(io.lavagna.service.calendarutils.StandardCalendarEventHandler) CalendarEventHandler(io.lavagna.service.calendarutils.CalendarEventHandler) CalendarEvents(io.lavagna.service.calendarutils.CalendarEvents) StandardCalendarEventHandler(io.lavagna.service.calendarutils.StandardCalendarEventHandler)

Example 2 with CalendarEventHandler

use of io.lavagna.service.calendarutils.CalendarEventHandler in project lavagna by digitalfondue.

the class CalendarService method getCalDavCalendar.

public Calendar getCalDavCalendar(String userToken) throws URISyntaxException, ParseException {
    UserWithPermission user;
    try {
        user = findUserFromCalendarToken(userToken);
    } catch (EmptyResultDataAccessException ex) {
        throw new SecurityException("Invalid token");
    }
    if (userRepository.isCalendarFeedDisabled(user)) {
        throw new SecurityException("Calendar feed disabled");
    }
    final Calendar calendar = new Calendar();
    calendar.getProperties().add(new ProdId("-//Lavagna//iCal4j 1.0//EN"));
    calendar.getProperties().add(Version.VERSION_2_0);
    calendar.getProperties().add(CalScale.GREGORIAN);
    calendar.getProperties().add(Method.PUBLISH);
    final List<VEvent> events = new ArrayList<>();
    final String applicationUrl = StringUtils.appendIfMissing(configurationRepository.getValue(Key.BASE_APPLICATION_URL), "/");
    final CalendarEventHandler handler = new CalendarVEventHandler(applicationUrl, cardDataService, userRepository, events);
    // Milestones
    addMilestoneEvents(handler, user);
    // Cards
    addCardEvents(handler, user);
    calendar.getComponents().addAll(events);
    return calendar;
}
Also used : VEvent(net.fortuna.ical4j.model.component.VEvent) StandardCalendarEventHandler(io.lavagna.service.calendarutils.StandardCalendarEventHandler) CalendarEventHandler(io.lavagna.service.calendarutils.CalendarEventHandler) Calendar(net.fortuna.ical4j.model.Calendar) EmptyResultDataAccessException(org.springframework.dao.EmptyResultDataAccessException) ProdId(net.fortuna.ical4j.model.property.ProdId) CalendarVEventHandler(io.lavagna.service.calendarutils.CalendarVEventHandler)

Example 3 with CalendarEventHandler

use of io.lavagna.service.calendarutils.CalendarEventHandler in project lavagna by digitalfondue.

the class CalendarService method getProjectCalendar.

public CalendarEvents getProjectCalendar(String projectShortName, UserWithPermission user) throws URISyntaxException, ParseException {
    final CalendarEvents events = new CalendarEvents(new HashMap<Date, CalendarEvents.MilestoneDayEvents>());
    final CalendarEventHandler handler = new StandardCalendarEventHandler(events);
    Project project = projectService.findByShortName(projectShortName);
    // Milestones
    getMilestoneEventsFromProject(handler, user, project);
    // Cards
    SearchFilter locationFilter = filter(SearchFilter.FilterType.LOCATION, SearchFilter.ValueType.STRING, BoardColumn.BoardColumnLocation.BOARD.toString());
    for (CardFullWithCounts card : searchService.find(Arrays.asList(locationFilter), project.getId(), null, user).getFound()) {
        for (LabelAndValue lav : card.getLabelsWithType(LabelType.TIMESTAMP)) {
            handler.addCardEvent(card, lav);
        }
    }
    return events;
}
Also used : StandardCalendarEventHandler(io.lavagna.service.calendarutils.StandardCalendarEventHandler) CalendarEventHandler(io.lavagna.service.calendarutils.CalendarEventHandler) CalendarEvents(io.lavagna.service.calendarutils.CalendarEvents) StandardCalendarEventHandler(io.lavagna.service.calendarutils.StandardCalendarEventHandler)

Aggregations

CalendarEventHandler (io.lavagna.service.calendarutils.CalendarEventHandler)3 StandardCalendarEventHandler (io.lavagna.service.calendarutils.StandardCalendarEventHandler)3 CalendarEvents (io.lavagna.service.calendarutils.CalendarEvents)2 CalendarVEventHandler (io.lavagna.service.calendarutils.CalendarVEventHandler)1 Calendar (net.fortuna.ical4j.model.Calendar)1 VEvent (net.fortuna.ical4j.model.component.VEvent)1 ProdId (net.fortuna.ical4j.model.property.ProdId)1 EmptyResultDataAccessException (org.springframework.dao.EmptyResultDataAccessException)1