Search in sources :

Example 96 with Employee

use of com.artezio.arttime.datamodel.Employee in project ART-TIME by Artezio.

the class ManageProjectPermissionFilter method isAccessAllowed.

@Override
protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) throws Exception {
    final Subject subject = getSubject(request, response);
    if (subject.hasRole(UserRoles.EXEC_ROLE)) {
        return true;
    }
    if (subject.hasRole(UserRoles.PM_ROLE)) {
        HttpServletRequest httpServletRequest = (HttpServletRequest) request;
        String projectId = httpServletRequest.getParameter("project");
        if (projectId != null) {
            Long id = Long.parseLong(projectId);
            Project project = getProjectRepository().findProject(id);
            String username = fetchUserNameWithoutDomain((String) subject.getPrincipal());
            Employee employee = getEmployeeRepository().find(username);
            return project.canBeManaged(employee);
        }
    }
    return false;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) Project(com.artezio.arttime.datamodel.Project) Employee(com.artezio.arttime.datamodel.Employee) Subject(org.apache.shiro.subject.Subject)

Example 97 with Employee

use of com.artezio.arttime.datamodel.Employee in project ART-TIME by Artezio.

the class EmployeeSynchronizer method synchronizeEmployees.

public void synchronizeEmployees() {
    List<Employee> employees = employeeRepository.getAll();
    for (Employee employee : employees) {
        String userName = employee.getUserName();
        Employee externalEmployee = employeeService.findEmployee(userName);
        if (externalEmployee != null) {
            employee.setFirstName(externalEmployee.getFirstName());
            employee.setLastName(externalEmployee.getLastName());
            employee.setEmail(externalEmployee.getEmail());
            employee.setDepartment(externalEmployee.getDepartment());
            employee.setFormer(false);
        } else {
            employee.setFormer(true);
        }
        employeeRepository.update(employee);
    }
}
Also used : Employee(com.artezio.arttime.datamodel.Employee)

Example 98 with Employee

use of com.artezio.arttime.datamodel.Employee 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 99 with Employee

use of com.artezio.arttime.datamodel.Employee in project ART-TIME by Artezio.

the class NotificationManager method notificatePmAboutTimeProblems.

protected void notificatePmAboutTimeProblems(List<Employee> employees, Period period, String comment) throws MessagingException {
    List<Project> projects = getProjects(employees);
    Set<Employee> projectManagers = getProjectManagers(projects);
    Map<Employee, Map<Date, BigDecimal>> timeProblems = workTimeService.getApprovedWorkTimeProblems(period, employees);
    HourType actualTime = hourTypeRepository.findActual();
    for (Employee projectManager : projectManagers) {
        Map<String, Object> params = new HashMap<>();
        params.put("recipient", projectManager);
        params.put("hourType", actualTime);
        params.put("period", period);
        params.put("comment", comment);
        Set<SubordinateProblem> subordinateProblems = getSubordinateProblems(projectManager, projects, timeProblems);
        params.put("subordinateProblems", subordinateProblems);
        params.put("appHost", settings.getApplicationBaseUrl());
        params.put("userNames", getSubordinatesAsString(subordinateProblems));
        String body = mailTemplateManager.getTemplateText(MailTemplate.TIME_PROBLEM_BODY_FOR_PM.getFileName(), params);
        String subject = mailTemplateManager.getTemplateText(MailTemplate.TIME_PROBLEM_SUBJECT.getFileName(), params);
        mailingEngine.sendAsync(projectManager.getEmail(), new Mail(subject, body));
    }
}
Also used : HourType(com.artezio.arttime.datamodel.HourType) HashMap(java.util.HashMap) Project(com.artezio.arttime.datamodel.Project) Employee(com.artezio.arttime.datamodel.Employee) Mail(com.artezio.arttime.services.mailing.Mail) HashMap(java.util.HashMap) Map(java.util.Map)

Example 100 with Employee

use of com.artezio.arttime.datamodel.Employee in project ART-TIME by Artezio.

the class NotificationManager method notificateAboutOwnTimeProblems.

protected void notificateAboutOwnTimeProblems(List<Employee> employees, Period period, String comment) throws MessagingException {
    Map<Employee, Map<Date, BigDecimal>> timeProblems = workTimeService.getApprovedWorkTimeProblems(period, employees);
    HourType actualTime = hourTypeRepository.findActual();
    for (Employee employee : employees) {
        Map<Date, BigDecimal> approvedWorkTimeProblems = timeProblems.get(employee);
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("recipient", employee);
        params.put("hourType", actualTime);
        params.put("deviation", sumDeviation(approvedWorkTimeProblems.values()));
        params.put("period", period);
        params.put("comment", comment);
        params.put("deviationDetails", approvedWorkTimeProblems.entrySet().toArray());
        params.put("appHost", settings.getApplicationBaseUrl());
        String body = mailTemplateManager.getTemplateText(MailTemplate.TIME_PROBLEM_BODY.getFileName(), params);
        String subject = mailTemplateManager.getTemplateText(MailTemplate.TIME_PROBLEM_SUBJECT.getFileName(), params);
        mailingEngine.sendAsync(employee.getEmail(), new Mail(subject, body));
    }
}
Also used : Employee(com.artezio.arttime.datamodel.Employee) HourType(com.artezio.arttime.datamodel.HourType) Mail(com.artezio.arttime.services.mailing.Mail) HashMap(java.util.HashMap) HashMap(java.util.HashMap) Map(java.util.Map) Date(java.util.Date) BigDecimal(java.math.BigDecimal)

Aggregations

Employee (com.artezio.arttime.datamodel.Employee)201 Test (org.junit.Test)173 Project (com.artezio.arttime.datamodel.Project)121 HourType (com.artezio.arttime.datamodel.HourType)74 Hours (com.artezio.arttime.datamodel.Hours)65 Date (java.util.Date)39 BigDecimal (java.math.BigDecimal)33 Period (com.artezio.arttime.datamodel.Period)28 Filter (com.artezio.arttime.filter.Filter)23 ArrayList (java.util.ArrayList)20 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)19 CalendarUtils.getOffsetDate (com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate)18 CalendarUtils.createPeriod (com.artezio.arttime.test.utils.CalendarUtils.createPeriod)15 TeamFilter (com.artezio.arttime.datamodel.TeamFilter)13 HashMap (java.util.HashMap)12 WorkdaysCalendar (com.artezio.arttime.datamodel.WorkdaysCalendar)7 Mail (com.artezio.arttime.services.mailing.Mail)7 ProjectRepository (com.artezio.arttime.services.repositories.ProjectRepository)7 List (java.util.List)7 Map (java.util.Map)7