Class ApplicationService

java.lang.Object
me.josephsf.jobportaljosephsfeir.service.ApplicationService

@Service public class ApplicationService extends Object
Service class for managing job applications in the Job Portal system.

This service provides methods for creating, retrieving, updating, and deleting job applications, as well as managing application statuses and generating application statistics. It interacts with the MongoDB database through the ApplicationRepository and handles related business logic.

Since:
2025-05-15
  • Constructor Details

    • ApplicationService

      public ApplicationService(ApplicationRepository applicationRepository)
      Constructs a new ApplicationService with required dependencies.
      Parameters:
      applicationRepository - Repository for job application data operations
  • Method Details

    • applyToJob

      public JobApplication applyToJob(ApplicationDto applicationDto)
      Creates a new job application. Checks if the candidate has already applied to the job to prevent duplicate applications.
      Parameters:
      applicationDto - The data transfer object containing application information
      Returns:
      The created application or null if the candidate has already applied
    • getApplicationById

      public JobApplication getApplicationById(String id)
      Retrieves an application by its ID.
      Parameters:
      id - The unique identifier of the application
      Returns:
      The application if found, null otherwise
    • getApplicationsByCandidate

      public org.springframework.data.domain.Page<JobApplication> getApplicationsByCandidate(String candidateId, org.springframework.data.domain.Pageable pageable)
      Retrieves applications submitted by a specific candidate with pagination support.
      Parameters:
      candidateId - The ID of the candidate
      pageable - Pagination and sorting parameters
      Returns:
      A page of job applications for the specified candidate
    • getApplicationsByJob

      public org.springframework.data.domain.Page<JobApplication> getApplicationsByJob(String jobId, org.springframework.data.domain.Pageable pageable)
      Retrieves applications for a specific job with pagination support.
      Parameters:
      jobId - The ID of the job
      pageable - Pagination and sorting parameters
      Returns:
      A page of job applications for the specified job
    • getApplicationsByStatus

      public List<JobApplication> getApplicationsByStatus(String status)
      Retrieves applications with a specific status.
      Parameters:
      status - The application status (e.g., APPLIED, REVIEWING, SHORTLISTED, REJECTED, ACCEPTED)
      Returns:
      List of applications with the specified status
    • updateApplicationStatus

      public JobApplication updateApplicationStatus(String id, String status, String reviewNotes)
      Updates the status of a job application and optionally adds review notes.
      Parameters:
      id - The unique identifier of the application
      status - The new status to set
      reviewNotes - Optional review notes to add
      Returns:
      The updated application or null if the application is not found
    • addReviewNotes

      public JobApplication addReviewNotes(String id, String reviewNotes)
      Adds review notes to an application.
      Parameters:
      id - The unique identifier of the application
      reviewNotes - The review notes to add
      Returns:
      The updated application or null if the application is not found
    • addInterviewNotes

      public JobApplication addInterviewNotes(String id, String interviewNotes)
      Adds interview notes to an application.
      Parameters:
      id - The unique identifier of the application
      interviewNotes - The interview notes to add
      Returns:
      The updated application or null if the application is not found
    • withdrawApplication

      public boolean withdrawApplication(String id)
      Withdraws (deletes) a job application.
      Parameters:
      id - The unique identifier of the application to withdraw
      Returns:
      true if the application was successfully withdrawn, false otherwise
    • getApplicationStats

      public Map<String,Long> getApplicationStats(String jobId)
      Generates statistics for applications to a specific job.
      Parameters:
      jobId - The ID of the job
      Returns:
      A map containing counts of applications in various statuses
    • getRecentApplications

      public List<JobApplication> getRecentApplications(int days)
      Retrieves applications submitted within a specific number of days.
      Parameters:
      days - The number of days to look back
      Returns:
      List of recent applications
    • countApplicationsByCandidate

      public long countApplicationsByCandidate(String candidateId)
      Counts the number of applications submitted by a specific candidate.
      Parameters:
      candidateId - The ID of the candidate
      Returns:
      The count of applications submitted by the candidate
    • getApplicationsInDateRange

      public List<JobApplication> getApplicationsInDateRange(LocalDateTime startDate, LocalDateTime endDate)
      Retrieves applications submitted within a specific date range.
      Parameters:
      startDate - The start date of the range
      endDate - The end date of the range
      Returns:
      List of applications submitted within the specified date range