use of com.artezio.arttime.datamodel.WorkdaysCalendar in project ART-TIME by Artezio.
the class LdapAdapter method createEmployee.
Employee createEmployee(UserInfo userInfo) {
Employee employee = new Employee(userInfo.getUsername(), userInfo.getFirstName(), userInfo.getLastName(), userInfo.getEmail(), userInfo.getDepartment());
WorkdaysCalendar calendar = workdaysCalendarRepository.findDefaultCalendar(employee.getDepartment());
employee.setCalendar(calendar);
return employee;
}
use of com.artezio.arttime.datamodel.WorkdaysCalendar in project ART-TIME by Artezio.
the class EmployeesBean method filterByCalendar.
public boolean filterByCalendar(Object value, Object filter, Locale locale) {
if (filter == null) {
return true;
}
Collection<WorkdaysCalendar> filterCalendars = (Collection<WorkdaysCalendar>) filter;
if (value == null) {
if (filterCalendars.isEmpty()) {
return true;
} else {
return filterCalendars.contains(null);
}
}
WorkdaysCalendar currentCalendarElement = (WorkdaysCalendar) value;
return filterCalendars.isEmpty() || filterCalendars.stream().anyMatch(currentCalendarElement::equals);
}
use of com.artezio.arttime.datamodel.WorkdaysCalendar in project ART-TIME by Artezio.
the class WorkdaysCalendarServiceTest method testGetDays.
@Test
public void testGetDays() {
Date start = new Date();
Date finish = getOffsetDate(2);
Period period = new Period(start, finish);
WorkdaysCalendar calendar = new WorkdaysCalendar("calendar");
Day day = new Day(new Date(), calendar);
expect(workdaysCalendarRepository.getSpecialDays(anyObject(), anyObject())).andReturn(new ArrayList<>());
replay(workdaysCalendarRepository);
List<Day> actual = workdaysCalendarService.getDays(calendar, period);
assertNotNull(actual);
assertEquals(3, actual.size());
}
use of com.artezio.arttime.datamodel.WorkdaysCalendar in project ART-TIME by Artezio.
the class WorkdaysCalendarRepositoryTest method testGetSpecialDays_ByCalendar.
@Test
public void testGetSpecialDays_ByCalendar() {
WorkdaysCalendar expectedCalendar = new WorkdaysCalendar();
WorkdaysCalendar unexpectedCalendar = new WorkdaysCalendar();
String expectedName = "expected calendar name";
String unexpectedName = "unexpected calendar name";
expectedCalendar.setName(expectedName);
unexpectedCalendar.setName(unexpectedName);
Date start = new Date();
Date finish = getOffsetDate(1);
Day expectedDay = new Day(start, expectedCalendar);
Day unexpectedDay = new Day(start, unexpectedCalendar);
entityManager.persist(expectedCalendar);
entityManager.persist(unexpectedCalendar);
entityManager.persist(expectedDay);
entityManager.persist(unexpectedDay);
Period period = new Period(start, finish);
List<Day> actuals = workdaysCalendarRepository.getSpecialDays(expectedCalendar, period);
assertEquals(1, actuals.size());
assertTrue(actuals.contains(expectedDay));
}
use of com.artezio.arttime.datamodel.WorkdaysCalendar in project ART-TIME by Artezio.
the class WorkdaysCalendarRepositoryTest method testSaveDayWithNullFieldsThenLoadNotNull.
@Test
public void testSaveDayWithNullFieldsThenLoadNotNull() {
WorkdaysCalendar workdaysCalendar = new WorkdaysCalendar("calendar");
Day day = new Day(new Date(), workdaysCalendar);
day.setHoliday(null);
day.setWorking(null);
entityManager.persist(workdaysCalendar);
entityManager.persist(day);
Long dayId = day.getId();
entityManager.flush();
entityManager.clear();
Day persistedDay = entityManager.find(Day.class, dayId);
assertNotNull(persistedDay.isWorking());
assertNotNull(persistedDay.isHoliday());
assertFalse(persistedDay.isHoliday());
}
Aggregations