use of io.lavagna.service.calendarutils.CalendarEvents in project lavagna by digitalfondue.
the class CalendarServiceTest method testGetStandardCalendar.
@Test
public void testGetStandardCalendar() throws URISyntaxException, ParseException {
Card assignedCard = cardService.createCard("card1", col.getId(), new Date(), user);
cardDataService.updateDescription(assignedCard.getId(), "Desc", new Date(), user.getId());
Card watchedCard = cardService.createCard("card2", col.getId(), new Date(), user);
Date now = new Date();
CardLabel assigned = cardLabelRepository.findLabelByName(project.getId(), SYSTEM_LABEL_ASSIGNED, LabelDomain.SYSTEM);
labelService.addLabelValueToCard(assigned, assignedCard.getId(), new CardLabelValue.LabelValue(user.getId()), user, now);
CardLabel watched = cardLabelRepository.findLabelByName(project.getId(), SYSTEM_LABEL_WATCHED_BY, LabelDomain.SYSTEM);
labelService.addLabelValueToCard(watched, watchedCard.getId(), new CardLabelValue.LabelValue(user.getId()), user, now);
CardLabel dueDate = cardLabelRepository.findLabelByName(project.getId(), SYSTEM_LABEL_DUE_DATE, LabelDomain.SYSTEM);
labelService.addLabelValueToCard(dueDate, assignedCard.getId(), new CardLabelValue.LabelValue(now), user, now);
labelService.addLabelValueToCard(dueDate, watchedCard.getId(), new CardLabelValue.LabelValue(now), user, now);
UserWithPermission uwpGlobalRead = new UserWithPermission(user, EnumSet.of(Permission.READ), Collections.<String, Set<Permission>>emptyMap(), Collections.<Integer, Set<Permission>>emptyMap());
CalendarEvents events = calendarService.getUserCalendar(uwpGlobalRead);
Assert.assertNotNull(events);
Assert.assertEquals(2, events.getDailyEvents().values().iterator().next().getCards().size());
}
use of io.lavagna.service.calendarutils.CalendarEvents 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.CalendarEvents 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;
}
use of io.lavagna.service.calendarutils.CalendarEvents in project lavagna by digitalfondue.
the class CalendarServiceTest method testGetProjectStandardCalendar.
@Test
public void testGetProjectStandardCalendar() throws URISyntaxException, ParseException {
Card assignedCard = cardService.createCard("card1", col.getId(), new Date(), user);
cardDataService.updateDescription(assignedCard.getId(), "Desc", new Date(), user.getId());
Card watchedCard = cardService.createCard("card2", col.getId(), new Date(), user);
Date now = new Date();
CardLabel dueDate = cardLabelRepository.findLabelByName(project.getId(), SYSTEM_LABEL_DUE_DATE, LabelDomain.SYSTEM);
labelService.addLabelValueToCard(dueDate, assignedCard.getId(), new CardLabelValue.LabelValue(now), user, now);
labelService.addLabelValueToCard(dueDate, watchedCard.getId(), new CardLabelValue.LabelValue(now), user, now);
UserWithPermission uwpGlobalRead = new UserWithPermission(user, EnumSet.of(Permission.READ), Collections.<String, Set<Permission>>emptyMap(), Collections.<Integer, Set<Permission>>emptyMap());
CalendarEvents events = calendarService.getProjectCalendar(project.getShortName(), uwpGlobalRead);
Assert.assertNotNull(events);
Assert.assertEquals(2, events.getDailyEvents().values().iterator().next().getCards().size());
}
Aggregations