Class CandidateService

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

@Service public class CandidateService extends Object
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 Details

    • CandidateService

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

    • getCandidateById

      public Candidate getCandidateById(String id)
      Retrieves a candidate by their ID.
      Parameters:
      id - The unique identifier of the candidate
      Returns:
      The candidate if found, null otherwise
    • getCandidateByUserId

      public Candidate getCandidateByUserId(String userId)
      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

      public Candidate createCandidateProfile(CandidateDto candidateDto)
      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

      public Candidate updateCandidateProfile(String id, CandidateDto candidateDto)
      Updates an existing candidate profile.
      Parameters:
      id - The unique identifier of the candidate to update
      candidateDto - The data transfer object containing updated candidate information
      Returns:
      The updated candidate profile or null if the candidate is not found
    • deleteCandidateProfile

      public boolean deleteCandidateProfile(String id)
      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 for
      minExperience - Minimum years of experience required
      location - Geographic location to filter by
      experienceLevel - Experience level (e.g., ENTRY, JUNIOR, MID, SENIOR, EXECUTIVE)
      Returns:
      List of candidates matching the search criteria
    • getCandidatesBySkill

      public List<Candidate> getCandidatesBySkill(String skill)
      Finds candidates who have a specific skill.
      Parameters:
      skill - The skill to search for
      Returns:
      List of candidates with the specified skill
    • getCandidatesByExperienceLevel

      public List<Candidate> getCandidatesByExperienceLevel(String experienceLevel)
      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

      public Candidate updateResume(String id, String resumeUrl)
      Updates the resume URL for a candidate.
      Parameters:
      id - The unique identifier of the candidate
      resumeUrl - The new resume URL
      Returns:
      The updated candidate or null if the candidate is not found
    • updateAvailability

      public Candidate updateAvailability(String id, Boolean isAvailable)
      Updates the availability status of a candidate.
      Parameters:
      id - The unique identifier of the candidate
      isAvailable - The new availability status
      Returns:
      The updated candidate or null if the candidate is not found
    • getAvailableCandidates

      public List<Candidate> getAvailableCandidates()
      Retrieves all candidates who are marked as available.
      Returns:
      List of available candidates
    • getCandidateStats

      public Map<String,Object> getCandidateStats(String candidateId)
      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