Esempio n. 1
0
 @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);
 }
Esempio n. 2
0
 /**
  * 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);
 }
Esempio n. 3
0
  @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);
  }
Esempio n. 4
0
 public List<Employee> getAllEmployees() {
   return employeeRepository.findAll();
 }
Esempio n. 5
0
 /**
  * Get employee by user name
  *
  * @param userName
  * @return Employee Object
  */
 public Employee getEmployeeByUserName(final String userName) {
   return employeeRepository.findByUsername(userName);
 }
Esempio n. 6
0
 /**
  * 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);
 }
Esempio n. 7
0
 /**
  * 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);
 }
Esempio n. 8
0
 /**
  * Get employee object by code
  *
  * @param code
  * @return Employee Object
  */
 public Employee getEmployeeByCode(final String code) {
   return employeeRepository.findByCode(code);
 }
Esempio n. 9
0
 /**
  * Get employee object by id
  *
  * @param id
  * @return Employee Object
  */
 public Employee getEmployeeById(final Long id) {
   return employeeRepository.findOne(id);
 }
Esempio n. 10
0
 @Transactional
 public void delete(final Employee employee) {
   employeeRepository.delete(employee);
 }