/**
  * Returns a list of all available employees.
  *
  * @return a list of all available employees.
  */
 public synchronized EmployeeList getAll() {
   final EmployeeList employees = new EmployeeList();
   for (final Employee employee : this.employees.values()) {
     employees.add(createSmall(employee));
   }
   return employees;
 }
Example #2
0
 /**
  * This method takes in an int for employeeID and uses it to remove that specific employee from
  * the database and the eList. If the ID doesn't exist a message is printed and nothing else
  * happens.
  *
  * @param employeeID
  */
 public void removeEmployee(int employeeID) {
   if (eList.isEmployee(employeeID) == true) {
     eList.removeEmployee(employeeID);
     DBHandler db = DBHandler.getInstance();
     db.openConnection("sql595207", "nT1*rF4!");
     db.removeEmployee(employeeID);
     db.closeConnection();
   } else {
     System.out.println("No valid employee ID entered.");
   }
 }
Example #3
0
  /**
   * Log employee into system. It can be looped in a main method if the login information is
   * incorrect. Returns true if login is successful.
   *
   * @param employeeId
   * @param password
   */
  public boolean login(int employeeId, String password) {
    Employee e = this.eList.findEmployee(employeeId);
    boolean successful = false;

    try {
      if (eList.checkPassword(employeeId, password)) {
        loggedOnEmployees.addEmployee(eList.findEmployee(employeeId));
        successful = true;
      }
    } catch (NullPointerException ex) {
      System.out.println("Error: employeeID not found.");
    }
    return successful;
  }
Example #4
0
 /**
  * Takes in an employeeID and logs that employee out of the system. If employee is not in the
  * loggedOnList it catches the error and prints out that no valid ID was entered.
  *
  * @param employeeId
  * @return
  */
 public boolean logout(int employeeId) {
   boolean successful = false;
   try {
     loggedOnEmployees.removeEmployee(employeeId);
     successful = true;
   } catch (NullPointerException e) {
     System.out.println("Error: employeeID not currently logged on.");
   }
   return successful;
 }
Example #5
0
 /**
  * Same as cashier method except with the boolean value for isManager set to true.
  *
  * @param name
  * @param password
  * @return
  */
 public Employee addManager(String name, String password) {
   DBHandler db = DBHandler.getInstance();
   db.openConnection("sql595207", "nT1*rF4!");
   this.userID = db.getNextUserID();
   // for now I'm going to assume there is valid input for name and password
   Employee newEmployee = new Employee(userID, true, name, password);
   db.addEmployee(newEmployee);
   db.closeConnection();
   eList.addEmployee(newEmployee);
   return newEmployee;
 }
Example #6
0
  public boolean checkEmployee(int employeeId, String password) {
    boolean successful = false;

    try {
      if (eList.checkPassword(employeeId, password)) {
        successful = true;
      }
    } catch (NullPointerException ex) {
      System.out.println("Error: employeeID not found.");
    }
    return successful;
  }
Example #7
0
 /**
  * This method is used to add an employee with already given data to the eList. It is used by the
  * database handler when loading in employees to populate the local eList.
  *
  * @param employeeID
  * @param isManager
  * @param employeeName
  * @param employeePassword
  * @return
  */
 public Employee setExistingEmployee(
     int employeeID, Boolean isManager, String employeeName, String employeePassword) {
   Employee newEmployee = new Employee(employeeID, isManager, employeeName, employeePassword);
   eList.addEmployee(newEmployee);
   return newEmployee;
 }