ronaldkwandy

Untitled

Sep 14th, 2018
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.18 KB | None | 0 0
  1.     @Transactional
  2.     public Workplace edit(Workplace workplace, Boolean isWorkplaceAsPayrollGroup, Boolean isWorkplaceAsAttendanceGroup) {
  3.         valWorkplaceRequired(workplace);
  4.         valRequiredBoolean(isWorkplaceAsPayrollGroup, "completeWorkplace.workplaceAsPayrollGroup.required");
  5.         valRequiredBoolean(isWorkplaceAsAttendanceGroup, "completeWorkplace.workplaceAsAttendanceGroup.required");
  6.         throwBatchError();
  7.        
  8.         Workplace oldWorkplace = workplaceService.find(workplace.getId()).orElse(null);
  9.         PayrollGroup oldPayrollGroup = payrollGroupService.findByBk(oldWorkplace.getName()).orElse(null);
  10.         AttendanceGroup oldAttendanceGroup = attendanceGroupService.findByBk(oldWorkplace.getCode()).orElse(null);
  11.        
  12.         workplace = workplaceService.edit(workplace);
  13.  
  14.         if (isWorkplaceAsPayrollGroup) {
  15.             if (payrollGroup != null) {
  16.                 payrollGroup.setPayrollGroupName(workplace.getName());
  17.                 payrollGroupService.edit(payrollGroup);
  18.             }
  19.         }
  20.  
  21.         if (isWorkplaceAsAttendanceGroup) {
  22.             if (attendanceGroup != null) {
  23.                 attendanceGroup.setCode(workplace.getCode());
  24.                 attendanceGroup.setName(workplace.getName());
  25.                 attendanceGroupService.edit(attendanceGroup);
  26.             }
  27.         }
  28.        
  29.         return workplace;
  30.     }
Advertisement
Add Comment
Please, Sign In to add comment