Search in sources :

Example 56 with Filter

use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.

the class EffortsBeanTest method testInitByGetRequest.

@Test
public void testInitByGetRequest() throws Exception {
    Filter filter = new Filter();
    List<Employee> employees = Arrays.asList(new Employee());
    FilterBean filterBean = createMock(FilterBean.class);
    Period period = new Period(sdf.parse("1-01-2015"), sdf.parse("15-01-2015"));
    setField(effortsBean, "filterBean", filterBean);
    setField(effortsBean, "period", period);
    setField(effortsBean, "employees", employees);
    expect(filterBean.getCurrentFilter()).andReturn(filter);
    replay(filterBean);
    effortsBean.initByGetRequest();
    verify(filterBean);
    assertEquals(period, filter.getPeriod());
    ListAssert.assertEquals(employees, new ArrayList<>(filter.getEmployees()));
}
Also used : Filter(com.artezio.arttime.filter.Filter) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 57 with Filter

use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.

the class FilterService method createPersonalTimesheetFilter.

public Filter createPersonalTimesheetFilter(Filter currentFilter, Employee employee) {
    Filter result = new Filter();
    result.setRangePeriodSelector(currentFilter.getRangePeriodSelector());
    result.setDepartments(departmentRepository.getDepartments());
    result.setHourTypes(hourTypeRepository.getAll());
    List<Employee> employees = new ArrayList<>();
    employees.add(employee);
    result.setEmployees(employees);
    result.setProjects(projectRepository.getActiveAndReportedProjects(employee, result.getPeriod()));
    return result;
}
Also used : Employee(com.artezio.arttime.datamodel.Employee) Filter(com.artezio.arttime.filter.Filter) ArrayList(java.util.ArrayList)

Example 58 with Filter

use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.

the class WorkTimeService method getWorkSchedule.

protected Map<Date, Boolean> getWorkSchedule(List<Project> activeProjects, Employee employee, Period period) {
    Map<Date, Boolean> workSchedule = generateWorkScheduleTemplate(period);
    WorkdaysCalendar calendar = employee.getCalendar();
    if (isTeamMember(activeProjects, employee)) {
        workdaysCalendarRepository.getDays(calendar, period).stream().filter(day -> !workSchedule.get(day.getDate())).forEach(day -> workSchedule.put(day.getDate(), day.isWorking()));
    }
    return workSchedule;
}
Also used : Stateless(javax.ejb.Stateless) Arrays(java.util.Arrays) Filter(com.artezio.arttime.filter.Filter) Scope(com.artezio.arttime.admin_tool.cache.WebCached.Scope) Period(com.artezio.arttime.datamodel.Period) Date(java.util.Date) ProjectRepository(com.artezio.arttime.services.repositories.ProjectRepository) HashMap(java.util.HashMap) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) Employee(com.artezio.arttime.datamodel.Employee) Inject(javax.inject.Inject) BigDecimal(java.math.BigDecimal) Project(com.artezio.arttime.datamodel.Project) List(java.util.List) WorkdaysCalendarRepository(com.artezio.arttime.services.repositories.WorkdaysCalendarRepository) EmployeeRepository(com.artezio.arttime.services.repositories.EmployeeRepository) TreeMap(java.util.TreeMap) HoursRepository(com.artezio.arttime.services.repositories.HoursRepository) Map(java.util.Map) WorkdaysCalendar(com.artezio.arttime.datamodel.WorkdaysCalendar) Named(javax.inject.Named) Hours(com.artezio.arttime.datamodel.Hours) WebCached(com.artezio.arttime.admin_tool.cache.WebCached) WorkdaysCalendar(com.artezio.arttime.datamodel.WorkdaysCalendar) Date(java.util.Date)

Example 59 with Filter

use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.

the class FilterBean method setDefaultFilter.

public void setDefaultFilter() {
    Filter defaultFilter = filterService.getActiveProjectsFilter(loggedEmployee);
    setCurrentFilter(defaultFilter);
}
Also used : Filter(com.artezio.arttime.filter.Filter)

Example 60 with Filter

use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.

the class WorkTimeServiceTest method testGetApprovedWorkTimeProblems_ifEmployeeWorkLoadIsNull.

@Test
@Ignore
public void testGetApprovedWorkTimeProblems_ifEmployeeWorkLoadIsNull() throws ParseException, NoSuchFieldException {
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    Date start = sdf.parse("2015-03-10");
    Date finish = sdf.parse("2015-03-12");
    Period period = new Period(start, finish);
    Employee employee1 = new Employee("employee1");
    employee1.setWorkLoad(null);
    Employee employee2 = new Employee("employee2");
    employee2.setFormer(true);
    List<Employee> employees = Arrays.asList(employee1, employee2);
    WorkdaysCalendar calendar = new WorkdaysCalendar("calendar");
    Day day1 = new Day(start, calendar, true);
    Day day2 = new Day(sdf.parse("2015-03-11"), calendar, true);
    employee1.setCalendar(calendar);
    employee2.setCalendar(calendar);
    Project project = new Project();
    project.addTeamMember(employee1);
    project.addTeamMember(employee2);
    HourType actualTime = new HourType("actual time");
    actualTime.setActualTime(true);
    Hours hours1 = createHours(project, employee1, start, actualTime, new BigDecimal(8));
    Hours hours2 = createHours(project, employee2, start, actualTime, new BigDecimal(8));
    hours1.setApproved(true);
    hours2.setApproved(true);
    Filter filter = new Filter();
    filter.setCustomPeriod(period);
    filter.setEmployees(employees);
    entityManager.persist(employee1);
    entityManager.persist(employee2);
    entityManager.persist(calendar);
    entityManager.persist(day1);
    entityManager.persist(day2);
    entityManager.persist(actualTime);
    entityManager.persist(project);
    entityManager.persist(hours1);
    entityManager.persist(hours2);
    entityManager.flush();
    entityManager.clear();
    setField(workTimeService, "employeeRepository", employeeRepository);
    expect(employeeRepository.getEmployeesByDepartments(filter)).andReturn(employees);
    replay(employeeRepository);
    List<WorkTimeService.Efforts> actual = workTimeService.getEmployeesTimeProblems(filter);
    assertTrue(actual.isEmpty());
}
Also used : Efforts(com.artezio.arttime.services.WorkTimeService.Efforts) BigDecimal(java.math.BigDecimal) Filter(com.artezio.arttime.filter.Filter) SimpleDateFormat(java.text.SimpleDateFormat) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

Filter (com.artezio.arttime.filter.Filter)126 Test (org.junit.Test)110 Project (com.artezio.arttime.datamodel.Project)32 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)25 Employee (com.artezio.arttime.datamodel.Employee)24 RangePeriodSelector (com.artezio.arttime.web.criteria.RangePeriodSelector)16 Date (java.util.Date)9 BigDecimal (java.math.BigDecimal)8 Hours (com.artezio.arttime.datamodel.Hours)7 Arrays.asList (java.util.Arrays.asList)7 List (java.util.List)7 HourType (com.artezio.arttime.datamodel.HourType)5 Efforts (com.artezio.arttime.services.WorkTimeService.Efforts)5 CalendarUtils.getOffsetDate (com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate)5 ArrayList (java.util.ArrayList)4 Collections.emptyList (java.util.Collections.emptyList)4 HashMap (java.util.HashMap)4 Map (java.util.Map)4 Period (com.artezio.arttime.datamodel.Period)3 EmployeeRepository (com.artezio.arttime.repositories.EmployeeRepository)3