Search in sources :

Example 66 with WorkdaysCalendar

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;
}
Also used : WorkdaysCalendar(com.artezio.arttime.datamodel.WorkdaysCalendar) Employee(com.artezio.arttime.datamodel.Employee)

Example 67 with WorkdaysCalendar

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);
}
Also used : WorkdaysCalendar(com.artezio.arttime.datamodel.WorkdaysCalendar)

Example 68 with WorkdaysCalendar

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());
}
Also used : WorkdaysCalendar(com.artezio.arttime.datamodel.WorkdaysCalendar) Period(com.artezio.arttime.datamodel.Period) Day(com.artezio.arttime.datamodel.Day) CalendarUtils.getOffsetDate(com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate) Test(org.junit.Test)

Example 69 with WorkdaysCalendar

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));
}
Also used : WorkdaysCalendar(com.artezio.arttime.datamodel.WorkdaysCalendar) Period(com.artezio.arttime.datamodel.Period) Day(com.artezio.arttime.datamodel.Day) CalendarUtils.getOffsetDate(com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate) Test(org.junit.Test)

Example 70 with WorkdaysCalendar

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());
}
Also used : WorkdaysCalendar(com.artezio.arttime.datamodel.WorkdaysCalendar) Day(com.artezio.arttime.datamodel.Day) CalendarUtils.getOffsetDate(com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate) Test(org.junit.Test)

Aggregations

WorkdaysCalendar (com.artezio.arttime.datamodel.WorkdaysCalendar)76 Test (org.junit.Test)65 Day (com.artezio.arttime.datamodel.Day)23 CalendarUtils.getOffsetDate (com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate)17 Employee (com.artezio.arttime.datamodel.Employee)16 Period (com.artezio.arttime.datamodel.Period)11 Date (java.util.Date)10 Project (com.artezio.arttime.datamodel.Project)8 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)7 SimpleDateFormat (java.text.SimpleDateFormat)5 DateFormat (java.text.DateFormat)3 Before (org.junit.Before)3 HourType (com.artezio.arttime.datamodel.HourType)2 Hours (com.artezio.arttime.datamodel.Hours)2 EmployeeRepository (com.artezio.arttime.repositories.EmployeeRepository)2 BigDecimal (java.math.BigDecimal)2 GregorianCalendar (java.util.GregorianCalendar)2 HashMap (java.util.HashMap)2 WebCached (com.artezio.arttime.admin_tool.cache.WebCached)1 Scope (com.artezio.arttime.admin_tool.cache.WebCached.Scope)1