Search in sources :

Example 86 with HourType

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));
    }
}
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 87 with HourType

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

Example 88 with HourType

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());
}
Also used : HourType(com.artezio.arttime.datamodel.HourType) Test(org.junit.Test)

Example 89 with HourType

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());
}
Also used : HourType(com.artezio.arttime.datamodel.HourType) Test(org.junit.Test)

Example 90 with HourType

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);
}
Also used : HourType(com.artezio.arttime.datamodel.HourType) Test(org.junit.Test)

Aggregations

HourType (com.artezio.arttime.datamodel.HourType)172 Test (org.junit.Test)158 Project (com.artezio.arttime.datamodel.Project)120 Employee (com.artezio.arttime.datamodel.Employee)115 Hours (com.artezio.arttime.datamodel.Hours)103 Date (java.util.Date)60 CalendarUtils.getOffsetDate (com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate)54 Period (com.artezio.arttime.datamodel.Period)45 BigDecimal (java.math.BigDecimal)41 CalendarUtils.createPeriod (com.artezio.arttime.test.utils.CalendarUtils.createPeriod)21 HashMap (java.util.HashMap)16 HoursRepository (com.artezio.arttime.repositories.HoursRepository)13 Map (java.util.Map)11 Arrays.asList (java.util.Arrays.asList)10 List (java.util.List)10 Filter (com.artezio.arttime.filter.Filter)7 Mail (com.artezio.arttime.services.mailing.Mail)7 ArrayList (java.util.ArrayList)7 HourTypeRepository (com.artezio.arttime.repositories.HourTypeRepository)6 RangePeriodSelector (com.artezio.arttime.web.criteria.RangePeriodSelector)6