Class CandidateService
java.lang.Object
me.josephsf.jobportaljosephsfeir.service.CandidateService
Service class for managing candidate data and operations in the Job Portal system.
This service provides methods for creating, updating, and managing candidate profiles, as well as searching candidates based on various criteria. It interacts with the MongoDB database through the CandidateRepository and handles related business logic.
- Since:
- 2025-05-15
-
Constructor Summary
ConstructorsConstructorDescriptionCandidateService(CandidateRepository candidateRepository, ApplicationRepository applicationRepository) Constructs a new CandidateService with required dependencies. -
Method Summary
Modifier and TypeMethodDescriptioncreateCandidateProfile(CandidateDto candidateDto) Creates a new candidate profile.booleanDeletes a candidate profile.Retrieves all candidates who are marked as available.Retrieves a candidate by their ID.getCandidateByUserId(String userId) Retrieves a candidate by their user ID.getCandidatesByExperienceLevel(String experienceLevel) Finds candidates with a specific experience level.getCandidatesBySkill(String skill) Finds candidates who have a specific skill.getCandidateStats(String candidateId) Generates statistics for a candidate.searchCandidates(List<String> skills, Integer minExperience, String location, String experienceLevel) Searches for candidates based on various criteria.updateAvailability(String id, Boolean isAvailable) Updates the availability status of a candidate.updateCandidateProfile(String id, CandidateDto candidateDto) Updates an existing candidate profile.updateResume(String id, String resumeUrl) Updates the resume URL for a candidate.
-
Constructor Details
-
CandidateService
public CandidateService(CandidateRepository candidateRepository, ApplicationRepository applicationRepository) Constructs a new CandidateService with required dependencies.- Parameters:
candidateRepository- Repository for candidate data operationsapplicationRepository- Repository for job application data operations
-
-
Method Details
-
getCandidateById
Retrieves a candidate by their ID.- Parameters:
id- The unique identifier of the candidate- Returns:
- The candidate if found, null otherwise
-
getCandidateByUserId
Retrieves a candidate by their user ID.- Parameters:
userId- The user ID associated with the candidate profile- Returns:
- The candidate if found, null otherwise
-
createCandidateProfile
Creates a new candidate profile.- Parameters:
candidateDto- The data transfer object containing candidate information- Returns:
- The created candidate profile or null if a profile already exists for the user
-
updateCandidateProfile
Updates an existing candidate profile.- Parameters:
id- The unique identifier of the candidate to updatecandidateDto- The data transfer object containing updated candidate information- Returns:
- The updated candidate profile or null if the candidate is not found
-
deleteCandidateProfile
Deletes a candidate profile.- Parameters:
id- The unique identifier of the candidate to delete- Returns:
- true if the candidate was successfully deleted, false otherwise
-
searchCandidates
public List<Candidate> searchCandidates(List<String> skills, Integer minExperience, String location, String experienceLevel) Searches for candidates based on various criteria.- Parameters:
skills- List of skills to search forminExperience- Minimum years of experience requiredlocation- Geographic location to filter byexperienceLevel- Experience level (e.g., ENTRY, JUNIOR, MID, SENIOR, EXECUTIVE)- Returns:
- List of candidates matching the search criteria
-
getCandidatesBySkill
Finds candidates who have a specific skill.- Parameters:
skill- The skill to search for- Returns:
- List of candidates with the specified skill
-
getCandidatesByExperienceLevel
Finds candidates with a specific experience level.- Parameters:
experienceLevel- The experience level to filter by- Returns:
- List of candidates with the specified experience level
-
updateResume
Updates the resume URL for a candidate.- Parameters:
id- The unique identifier of the candidateresumeUrl- The new resume URL- Returns:
- The updated candidate or null if the candidate is not found
-
updateAvailability
Updates the availability status of a candidate.- Parameters:
id- The unique identifier of the candidateisAvailable- The new availability status- Returns:
- The updated candidate or null if the candidate is not found
-
getAvailableCandidates
Retrieves all candidates who are marked as available.- Returns:
- List of available candidates
-
getCandidateStats
Generates statistics for a candidate.- Parameters:
candidateId- The unique identifier of the candidate- Returns:
- A map containing various statistics about the candidate's applications and profile
-