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