示例#1
0
  public boolean addShift(Shift aShift) {
    boolean wasAdded = false;
    if (shifts.contains(aShift)) {
      return false;
    }
    if (shifts.contains(aShift)) {
      return false;
    }
    if (shifts.contains(aShift)) {
      return false;
    }
    Employee existingEmployee = aShift.getEmployee();
    boolean isNewEmployee = existingEmployee != null && !this.equals(existingEmployee);

    if (isNewEmployee && existingEmployee.numberOfShifts() <= minimumNumberOfShifts()) {
      return wasAdded;
    }
    if (isNewEmployee) {
      aShift.setEmployee(this);
    } else {
      shifts.add(aShift);
    }
    wasAdded = true;
    return wasAdded;
  }
示例#2
0
 public void delete() {
   for (int i = shifts.size(); i > 0; i--) {
     Shift aShift = shifts.get(i - 1);
     aShift.delete();
   }
   for (int i = privileges.size(); i > 0; i--) {
     Privilege aPrivilege = privileges.get(i - 1);
     aPrivilege.delete();
   }
   Hospital placeholderHospital = hospital;
   this.hospital = null;
   placeholderHospital.removeEmployee(this);
   ArrayList<Ward> copyOfWards = new ArrayList<Ward>(wards);
   wards.clear();
   for (Ward aWard : copyOfWards) {
     aWard.removeEmployee(this);
   }
 }
示例#3
0
  public boolean removeShift(Shift aShift) {
    boolean wasRemoved = false;
    // Unable to remove aShift, as it must always have a employee
    if (this.equals(aShift.getEmployee())) {
      return wasRemoved;
    }

    // employee already at minimum (1)
    if (numberOfShifts() <= minimumNumberOfShifts()) {
      return wasRemoved;
    }

    shifts.remove(aShift);
    wasRemoved = true;
    return wasRemoved;
  }