Search in sources :

Example 1 with Appraisal

use of com.axelor.apps.talent.db.Appraisal in project axelor-open-suite by axelor.

the class AppraisalController method createAppraisals.

public void createAppraisals(ActionRequest request, ActionResponse response) {
    try {
        Context context = request.getContext();
        Set<Map<String, Object>> employeeSet = new HashSet<Map<String, Object>>();
        employeeSet.addAll((Collection<? extends Map<String, Object>>) context.get("employeeSet"));
        Set<Employee> employees = new HashSet<Employee>();
        EmployeeRepository employeeRepo = Beans.get(EmployeeRepository.class);
        for (Map<String, Object> emp : employeeSet) {
            Long empId = Long.parseLong(emp.get("id").toString());
            employees.add(employeeRepo.find(empId));
        }
        Long templateId = Long.parseLong(context.get("templateId").toString());
        Appraisal appraisalTemplate = Beans.get(AppraisalRepository.class).find(templateId);
        Boolean send = (Boolean) context.get("sendAppraisals");
        Set<Long> createdIds = Beans.get(AppraisalService.class).createAppraisals(appraisalTemplate, employees, send);
        response.setView(ActionView.define("Appraisal").model(Appraisal.class.getName()).add("grid", "appraisal-grid").add("form", "appraisal-form").param("search-filters", "appraisal-fitlers").domain("self.id in :createdIds").context("createdIds", createdIds).map());
        response.setCanClose(true);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : Context(com.axelor.rpc.Context) Appraisal(com.axelor.apps.talent.db.Appraisal) EmployeeRepository(com.axelor.apps.hr.db.repo.EmployeeRepository) Employee(com.axelor.apps.hr.db.Employee) AppraisalRepository(com.axelor.apps.talent.db.repo.AppraisalRepository) Map(java.util.Map) AppraisalService(com.axelor.apps.talent.service.AppraisalService) HashSet(java.util.HashSet)

Example 2 with Appraisal

use of com.axelor.apps.talent.db.Appraisal in project axelor-open-suite by axelor.

the class AppraisalServiceImpl method createAppraisals.

@Transactional(rollbackOn = { Exception.class })
@Override
public Set<Long> createAppraisals(Appraisal appraisalTemplate, Set<Employee> employees, Boolean send) throws ClassNotFoundException, InstantiationException, IllegalAccessException, AxelorException, IOException, MessagingException {
    Set<Long> appraisalIds = new HashSet<Long>();
    if (appraisalTemplate == null) {
        return appraisalIds;
    }
    for (Employee employee : employees.stream().filter(Objects::nonNull).collect(Collectors.toList())) {
        if (EmployeeHRRepository.isEmployeeFormerNewOrArchived(employee)) {
            continue;
        }
        Appraisal appraisal = appraisalRepo.copy(appraisalTemplate, false);
        appraisal.setEmployee(employee);
        if (appraisal.getCompany() == null) {
            EmploymentContract employmentContract = employee.getMainEmploymentContract();
            if (employmentContract != null) {
                appraisal.setCompany(employmentContract.getPayCompany());
            }
        }
        appraisal.setIsTemplate(false);
        appraisal = appraisalRepo.save(appraisal);
        if (send != null && send) {
            send(appraisal);
        }
        appraisalIds.add(appraisal.getId());
    }
    return appraisalIds;
}
Also used : EmploymentContract(com.axelor.apps.hr.db.EmploymentContract) Employee(com.axelor.apps.hr.db.Employee) Appraisal(com.axelor.apps.talent.db.Appraisal) HashSet(java.util.HashSet) Transactional(com.google.inject.persist.Transactional)

Example 3 with Appraisal

use of com.axelor.apps.talent.db.Appraisal in project axelor-open-suite by axelor.

the class AppraisalController method cancel.

public void cancel(ActionRequest request, ActionResponse response) {
    Appraisal appraisal = request.getContext().asType(Appraisal.class);
    try {
        appraisal = Beans.get(AppraisalRepository.class).find(appraisal.getId());
        Beans.get(AppraisalService.class).cancel(appraisal);
        response.setReload(true);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : Appraisal(com.axelor.apps.talent.db.Appraisal) AppraisalService(com.axelor.apps.talent.service.AppraisalService)

Example 4 with Appraisal

use of com.axelor.apps.talent.db.Appraisal in project axelor-open-suite by axelor.

the class AppraisalController method draft.

public void draft(ActionRequest request, ActionResponse response) {
    Appraisal appraisal = request.getContext().asType(Appraisal.class);
    try {
        appraisal = Beans.get(AppraisalRepository.class).find(appraisal.getId());
        Beans.get(AppraisalService.class).draft(appraisal);
        response.setReload(true);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : Appraisal(com.axelor.apps.talent.db.Appraisal) AppraisalService(com.axelor.apps.talent.service.AppraisalService)

Example 5 with Appraisal

use of com.axelor.apps.talent.db.Appraisal in project axelor-open-suite by axelor.

the class AppraisalController method realize.

public void realize(ActionRequest request, ActionResponse response) {
    Appraisal appraisal = request.getContext().asType(Appraisal.class);
    try {
        appraisal = Beans.get(AppraisalRepository.class).find(appraisal.getId());
        Beans.get(AppraisalService.class).realize(appraisal);
        response.setReload(true);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : Appraisal(com.axelor.apps.talent.db.Appraisal) AppraisalService(com.axelor.apps.talent.service.AppraisalService)

Aggregations

Appraisal (com.axelor.apps.talent.db.Appraisal)6 AppraisalService (com.axelor.apps.talent.service.AppraisalService)5 Employee (com.axelor.apps.hr.db.Employee)2 HashSet (java.util.HashSet)2 EmploymentContract (com.axelor.apps.hr.db.EmploymentContract)1 EmployeeRepository (com.axelor.apps.hr.db.repo.EmployeeRepository)1 AppraisalRepository (com.axelor.apps.talent.db.repo.AppraisalRepository)1 Context (com.axelor.rpc.Context)1 Transactional (com.google.inject.persist.Transactional)1 Map (java.util.Map)1