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;
}
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;
}
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;
}
Aggregations