@Transactional public void update(final Employee employee) { // Following is added to prevent null values and empty assignment // objects getting persisted employee.setAssignments( employee .getAssignments() .parallelStream() .filter(assignment -> assignment.getPosition() != null) .collect(Collectors.toList())); for (final Assignment assign : employee.getAssignments()) { assign.setEmployee(employee); assign.setDepartment(assign.getDepartment()); for (final HeadOfDepartments hod : assign.getDeptSet()) hod.setAssignment(assign); } employee.setJurisdictions( employee .getJurisdictions() .parallelStream() .filter( Jurisdictions -> Jurisdictions.getBoundaryType() != null && Jurisdictions.getBoundary() != null) .collect(Collectors.toList())); for (final Jurisdiction jurisdiction : employee.getJurisdictions()) { jurisdiction.setEmployee(employee); jurisdiction.setBoundaryType(jurisdiction.getBoundaryType()); jurisdiction.setBoundary(jurisdiction.getBoundary()); } employeeRepository.saveAndFlush(employee); }
/** * Get List of employee objects by department ,designation and boundary ids * * @param deptId * @param desigId * @param boundaryId * @return List of employee objects */ public List<Employee> findByDepartmentDesignationAndBoundary( final Long deptId, final Long desigId, final Long boundaryId) { Set<Long> bndIds = new HashSet<Long>(); List<Boundary> boundaries = boundaryService.findActiveChildrenWithParent(boundaryId); boundaries.forEach((bndry) -> bndIds.add(bndry.getId())); return employeeRepository.findByDepartmentDesignationAndBoundary(deptId, desigId, bndIds); }
@Transactional public void create(final Employee employee) { employee.setPwdExpiryDate( new DateTime().plusDays(applicationProperties.userPasswordExpiryInDays()).toDate()); employee.setPassword(passwordEncoder.encode(EisConstants.DEFAULT_EMPLOYEE_PWD)); // Following is added to prevent null values and empty assignment // objects getting persisted employee.setAssignments( employee .getAssignments() .parallelStream() .filter(assignment -> assignment.getPosition() != null) .collect(Collectors.toList())); for (final Assignment assign : employee.getAssignments()) { assign.setEmployee(employee); assign.setDepartment(assign.getDepartment()); for (final HeadOfDepartments hod : assign.getDeptSet()) hod.setAssignment(assign); } employee.setJurisdictions( employee .getJurisdictions() .parallelStream() .filter( Jurisdictions -> Jurisdictions.getBoundaryType() != null && Jurisdictions.getBoundary() != null) .collect(Collectors.toList())); for (final Jurisdiction jurisdiction : employee.getJurisdictions()) { jurisdiction.setEmployee(employee); jurisdiction.setBoundaryType(jurisdiction.getBoundaryType()); jurisdiction.setBoundary(jurisdiction.getBoundary()); } employee.getRoles().add(roleService.getRoleByName(EisConstants.ROLE_EMPLOYEE)); employeeRepository.save(employee); }
public List<Employee> getAllEmployees() { return employeeRepository.findAll(); }
/** * Get employee by user name * * @param userName * @return Employee Object */ public Employee getEmployeeByUserName(final String userName) { return employeeRepository.findByUsername(userName); }
/** * Get list of employee objects by employee type * * @param id * @return List of employee objects */ public List<Employee> getEmployeesByType(final Long id) { return employeeRepository.findByEmployeeType_Id(id); }
/** * Get list of employee objects by employee status * * @param status * @return List of employee objects */ public List<Employee> getEmployeesByStatus(final EmployeeStatus status) { return employeeRepository.findByEmployeeStatus(status); }
/** * Get employee object by code * * @param code * @return Employee Object */ public Employee getEmployeeByCode(final String code) { return employeeRepository.findByCode(code); }
/** * Get employee object by id * * @param id * @return Employee Object */ public Employee getEmployeeById(final Long id) { return employeeRepository.findOne(id); }
@Transactional public void delete(final Employee employee) { employeeRepository.delete(employee); }