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