Package leave.manager

Class LeaveManager

java.lang.Object
leave.manager.LeaveManager
All Implemented Interfaces:
LeaveManagement

public class LeaveManager extends Object implements LeaveManagement
  • Constructor Details

    • LeaveManager

      public LeaveManager(LeaveDataService leaveDataService, LeaveBalanceDataService leaveBalanceDataService)
      Constructs a LeaveManager object with the specified LeaveDataService and LeaveBalanceDataService.
      Parameters:
      leaveDataService - the data service for leave records
      leaveBalanceDataService - the data service for leave balance records
  • Method Details

    • approveLeave

      public void approveLeave(String leaveID)
      Approves leave with the specified leave ID.
      Specified by:
      approveLeave in interface LeaveManagement
      Parameters:
      leaveID - the ID of the leave to approve
    • rejectLeave

      public void rejectLeave(String leaveID, int employeeID, String leaveType, int duration)
      Rejects leave with the specified leave ID, employee ID, leave type, and duration.
      Specified by:
      rejectLeave in interface LeaveManagement
      Parameters:
      leaveID - the ID of the leave to reject
      employeeID - the ID of the employee associated with the leave
      leaveType - the type of leave to reject
      duration - the duration of the leave to reject
    • getLeaveRecord

      public LeaveRecord getLeaveRecord(String leaveID)
      Retrieves the leave record with the specified leave ID.
      Specified by:
      getLeaveRecord in interface LeaveManagement
      Parameters:
      leaveID - the ID of the leave record to retrieve
      Returns:
      the leave record
    • getLeaveRecord_List

      public List<LeaveRecord> getLeaveRecord_List(int employeeID)
      Retrieves a list of leave records associated with the specified employee ID.
      Specified by:
      getLeaveRecord_List in interface LeaveManagement
      Parameters:
      employeeID - the ID of the employee
      Returns:
      a list of leave records
    • getLeaveRecord_List

      public List<LeaveRecord> getLeaveRecord_List()
      Retrieves a list of all leave records.
      Specified by:
      getLeaveRecord_List in interface LeaveManagement
      Returns:
      a list of all leave records
    • getAllLeaveRecords

      public List<LeaveRecord> getAllLeaveRecords()
      Retrieves a list of all leave records.
      Specified by:
      getAllLeaveRecords in interface LeaveManagement
      Returns:
      a list of all leave records
    • addLeaveRecord

      public void addLeaveRecord(LeaveRecord newLeaveRecord, LeaveBalanceRecord leaveBalanceRecord) throws LeaveException
      Adds a new leave record and updates the leave balance.
      Specified by:
      addLeaveRecord in interface LeaveManagement
      Parameters:
      newLeaveRecord - the new leave record to add
      leaveBalanceRecord - the leave balance record to update
      Throws:
      LeaveException - if an error occurs while adding the leave record
    • getLeaveBalanceRecord

      public LeaveBalanceRecord getLeaveBalanceRecord(int employeeID)
      Retrieves the leave balance record associated with the specified employee ID.
      Specified by:
      getLeaveBalanceRecord in interface LeaveManagement
      Parameters:
      employeeID - the ID of the employee
      Returns:
      the leave balance record
    • getLeaveBalance_OfType

      public int getLeaveBalance_OfType(int employeeID, String leaveType)
      Retrieves the leave balance of the specified leave type for the employee with the given ID.
      Specified by:
      getLeaveBalance_OfType in interface LeaveManagement
      Parameters:
      employeeID - the ID of the employee
      leaveType - the type of leave
      Returns:
      the leave balance of the specified leave type
    • getLeaveBalance_OfType

      public int getLeaveBalance_OfType(LeaveBalanceRecord leaveBalance, String leaveType)
      Retrieves the leave balance of the specified leave type from the provided LeaveBalanceRecord.
      Specified by:
      getLeaveBalance_OfType in interface LeaveManagement
      Parameters:
      leaveBalance - the LeaveBalanceRecord containing leave balances
      leaveType - the type of leave
      Returns:
      the leave balance of the specified leave type
    • updateLeaveBalance

      public void updateLeaveBalance(LeaveBalanceRecord leaveBalanceRecord, String leaveType, int newBalance)
      Updates the leave balance record with the new balance for the specified leave type.
      Specified by:
      updateLeaveBalance in interface LeaveManagement
      Parameters:
      leaveBalanceRecord - the leave balance record to update
      leaveType - the type of leave
      newBalance - the new balance for the specified leave type