use of com.artezio.arttime.datamodel.HourType 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.HourType 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));
}
}
use of com.artezio.arttime.datamodel.HourType in project ART-TIME by Artezio.
the class HourTypeRepositoryTest method testSetAsActualTime_OnlyOneActual.
@Test
public void testSetAsActualTime_OnlyOneActual() {
HourType expectedType1 = new HourType("type 1");
HourType expectedType2 = new HourType("type 2");
expectedType1.setActualTime(false);
expectedType2.setActualTime(true);
entityManager.persist(expectedType1);
entityManager.persist(expectedType2);
HourType actual = hourTypeRepository.setAsActualTime(expectedType1);
entityManager.flush();
entityManager.clear();
List<HourType> actualList = entityManager.createQuery("SELECT h FROM HourType h ORDER BY h.type", HourType.class).getResultList();
assertTrue(actual.isActualTime());
assertTrue(actualList.get(0).isActualTime());
assertFalse(actualList.get(1).isActualTime());
}
use of com.artezio.arttime.datamodel.HourType in project ART-TIME by Artezio.
the class HourTypeRepositoryTest method testSetAsActualTime.
@Test
public void testSetAsActualTime() {
HourType expectedType = new HourType("type");
entityManager.persist(expectedType);
HourType actual = hourTypeRepository.setAsActualTime(expectedType);
assertTrue(actual.isActualTime());
}
use of com.artezio.arttime.datamodel.HourType in project ART-TIME by Artezio.
the class HourTypeRepositoryTest method testCreateHourType.
@Test
public void testCreateHourType() {
HourType hourType = new HourType();
hourTypeRepository.create(hourType);
Long id = hourType.getId();
assertNotNull(id);
HourType actual = entityManager.find(HourType.class, id);
assertEquals(hourType, actual);
}
Aggregations