Class ApplicationService
java.lang.Object
me.josephsf.jobportaljosephsfeir.service.ApplicationService
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 Summary
ConstructorsConstructorDescriptionApplicationService(ApplicationRepository applicationRepository) Constructs a new ApplicationService with required dependencies. -
Method Summary
Modifier and TypeMethodDescriptionaddInterviewNotes(String id, String interviewNotes) Adds interview notes to an application.addReviewNotes(String id, String reviewNotes) Adds review notes to an application.applyToJob(ApplicationDto applicationDto) Creates a new job application.longcountApplicationsByCandidate(String candidateId) Counts the number of applications submitted by a specific candidate.Retrieves an application by its ID.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.org.springframework.data.domain.Page<JobApplication> getApplicationsByJob(String jobId, org.springframework.data.domain.Pageable pageable) Retrieves applications for a specific job with pagination support.getApplicationsByStatus(String status) Retrieves applications with a specific status.getApplicationsInDateRange(LocalDateTime startDate, LocalDateTime endDate) Retrieves applications submitted within a specific date range.getApplicationStats(String jobId) Generates statistics for applications to a specific job.getRecentApplications(int days) Retrieves applications submitted within a specific number of days.updateApplicationStatus(String id, String status, String reviewNotes) Updates the status of a job application and optionally adds review notes.booleanWithdraws (deletes) a job application.
-
Constructor Details
-
ApplicationService
Constructs a new ApplicationService with required dependencies.- Parameters:
applicationRepository- Repository for job application data operations
-
-
Method Details
-
applyToJob
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
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 candidatepageable- 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 jobpageable- Pagination and sorting parameters- Returns:
- A page of job applications for the specified job
-
getApplicationsByStatus
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
Updates the status of a job application and optionally adds review notes.- Parameters:
id- The unique identifier of the applicationstatus- The new status to setreviewNotes- Optional review notes to add- Returns:
- The updated application or null if the application is not found
-
addReviewNotes
Adds review notes to an application.- Parameters:
id- The unique identifier of the applicationreviewNotes- The review notes to add- Returns:
- The updated application or null if the application is not found
-
addInterviewNotes
Adds interview notes to an application.- Parameters:
id- The unique identifier of the applicationinterviewNotes- The interview notes to add- Returns:
- The updated application or null if the application is not found
-
withdrawApplication
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
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
Retrieves applications submitted within a specific number of days.- Parameters:
days- The number of days to look back- Returns:
- List of recent applications
-
countApplicationsByCandidate
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 rangeendDate- The end date of the range- Returns:
- List of applications submitted within the specified date range
-