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