Ejemplo n.º 1
0
 public boolean equals(Object o) {
   Employee e = (Employee) o;
   Map<String, PhoneNumber> map = e.getPhoneNumbers();
   if (map.size() != phones.size()) return false;
   Collection<Map.Entry<String, PhoneNumber>> entries =
       (Collection<Map.Entry<String, PhoneNumber>>) phones.entrySet();
   for (Map.Entry<String, PhoneNumber> entry : entries) {
     String key = entry.getKey();
     PhoneNumber p = entry.getValue();
     PhoneNumber p0 = map.get(key);
     if (p.getNumber() != p0.getNumber()) return false;
   }
   return true;
 }
Ejemplo n.º 2
0
  /**
   * Method to call when we want to apply (grant or deny) an agreement visa
   *
   * @param employee
   * @param visaStatus
   * @param comment
   * @return
   */
  public Request applyAgreementVisa(
      Employee employee, RequestAgreementVisaStatus visaStatus, String comment) {
    if (!waitsForAnAgreementVisa()) {
      throw REQUEST_DOES_NOT_EXPECT_ANY_AGREEMENT_VISA.exception();
    }

    if (userHasAlreadyAppliedAVisa(employee.getId())) {
      throw EMPLOYEE_HAS_ALREADY_APPLIED_A_VISA.exception(employee.getFullName());
    }

    AgreementRuleVisaAud nextExpectedVisa =
        getNextExpectedAgreementVisa()
            .orElseThrow(() -> COULD_NOT_FIND_NEXT_EXPECTED_AGREEMENT_VISA.exception());

    Department department = employee.getDepartment();
    Seniority seniority = employee.getSeniority();

    if (!nextExpectedVisa.canBeAppliedBy(department, seniority)) {
      throw VISA_TO_APPLY_DOESNT_MATCH_NEXT_EXPECTED_ONE.exception(
          department.getName(), seniority.getValue(),
          nextExpectedVisa.getDepartment().getName(), nextExpectedVisa.getSeniority().getValue());
    }

    LocalDateTime now = LocalDateTime.now();

    RequestAgreementVisa appliedVisa =
        RequestAgreementVisa.build(
            this,
            null,
            employee,
            visaStatus,
            nextAgreementVisaRank,
            comment,
            department,
            seniority,
            now);

    addAgreementVisa(appliedVisa);

    updateUser = employee.getUid();
    updateDate = now;

    return this;
  }
Ejemplo n.º 3
0
 public Employee copy() {
   Employee emp = new Employee();
   emp.setEmployeeId(getEmployeeId());
   emp.setFirstName(getFirstName());
   emp.setLastName(getLastName());
   emp.setBirthDate(getBirthDate());
   emp.setDepartment(getDepartment());
   return emp;
 }
Ejemplo n.º 4
0
 public void addEmployee(Employee employee) {
   employees.add(employee);
   employee.getProjects().add(this);
 }
Ejemplo n.º 5
0
  public Employee removeEmployee(Employee employee) {
    getEmployees().remove(employee);
    employee.setDepartment(null);

    return employee;
  }
Ejemplo n.º 6
0
  public Employee addEmployee(Employee employee) {
    getEmployees().add(employee);
    employee.setDepartment(this);

    return employee;
  }