Ignore:
Timestamp:
01/08/21 00:35:56 (4 years ago)
Author:
Vzdra <vladko.zdravkovski@…>
Branches:
master
Children:
4cec0a3
Parents:
509cb95
Message:

added dummy data for user skills and fixed bugs

Location:
src/main/java/it/finki/tinki/service/impl
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/it/finki/tinki/service/impl/AccountServiceImpl.java

    r509cb95 ra8e8545  
    22
    33import it.finki.tinki.model.Address;
     4import it.finki.tinki.model.Jobs.Internship;
     5import it.finki.tinki.model.Jobs.Job;
     6import it.finki.tinki.model.Jobs.Project;
    47import it.finki.tinki.model.Skill;
    58import it.finki.tinki.model.Users.Account;
     
    1013import it.finki.tinki.model.exception.InvalidArgumentsException;
    1114import it.finki.tinki.model.exception.UserExistsException;
    12 import it.finki.tinki.repository.AddressRepository;
    13 import it.finki.tinki.repository.CompanyRepository;
    14 import it.finki.tinki.repository.TeamRepository;
    15 import it.finki.tinki.repository.UserRepository;
     15import it.finki.tinki.repository.*;
    1616import it.finki.tinki.service.AccountService;
     17import it.finki.tinki.service.MatchmakerService;
     18import it.finki.tinki.service.WorkService;
    1719import org.springframework.stereotype.Service;
    1820
     
    2830    TeamRepository teamRepository;
    2931    CompanyRepository companyRepository;
     32    JobRepository jobRepository;
     33    ProjectRepository projectRepository;
     34    InternshipRepository internshipRepository;
     35    MatchmakerService matchmakerService;
    3036
    31     public AccountServiceImpl(AddressRepository addressRepository, UserRepository userRepository, TeamRepository teamRepository, CompanyRepository companyRepository) {
     37    public AccountServiceImpl(AddressRepository addressRepository,
     38                              UserRepository userRepository,
     39                              TeamRepository teamRepository,
     40                              CompanyRepository companyRepository,
     41                              MatchmakerService matchmakerService,
     42                              JobRepository jobRepository,
     43                              ProjectRepository projectRepository,
     44                              InternshipRepository internshipRepository) {
    3245        this.addressRepository = addressRepository;
    3346        this.userRepository = userRepository;
    3447        this.teamRepository = teamRepository;
    3548        this.companyRepository = companyRepository;
     49        this.jobRepository = jobRepository;
     50        this.projectRepository = projectRepository;
     51        this.internshipRepository = internshipRepository;
     52        this.matchmakerService = matchmakerService;
    3653    }
    3754
     
    6582
    6683        User u = new User(email, password, name, AccountType.USER, surname, retainedSkills, skillsToLearn);
    67         return this.userRepository.save(u);
     84        User ru = this.userRepository.save(u);
     85
     86        List<Job> jobs = this.jobRepository.findAll();
     87        List<Project> projects = this.projectRepository.findAll();
     88        List<Internship> internships = this.internshipRepository.findAll();
     89
     90        if(jobs.size()!=0){
     91            for (Job job : jobs) {
     92                this.matchmakerService.setUpUserJobMatches(job, u);
     93            }
     94        }
     95
     96        if(projects.size()!=0){
     97            for (Project project : projects) {
     98                this.matchmakerService.setUpUserProjectMatches(project, u);
     99            }
     100        }
     101
     102        if(internships.size()!=0){
     103            for(Internship internship : internships){
     104                this.matchmakerService.setUpUserInternshipMatches(internship, u);
     105            }
     106        }
     107
     108        return ru;
    68109    }
    69110
  • src/main/java/it/finki/tinki/service/impl/MatchmakerServiceImpl.java

    r509cb95 ra8e8545  
    1111import it.finki.tinki.model.Users.User;
    1212import it.finki.tinki.model.enumerator.WorkType;
     13import it.finki.tinki.repository.InternshipRepository;
     14import it.finki.tinki.repository.JobRepository;
    1315import it.finki.tinki.repository.MatchRepository;
     16import it.finki.tinki.repository.ProjectRepository;
    1417import it.finki.tinki.service.MatchmakerService;
    1518import org.springframework.stereotype.Service;
     
    2326
    2427    MatchRepository matchRepository;
     28    JobRepository jobRepository;
     29    InternshipRepository internshipRepository;
     30    ProjectRepository projectRepository;
    2531
    26     public MatchmakerServiceImpl(MatchRepository matchRepository) {
     32    public MatchmakerServiceImpl(MatchRepository matchRepository,
     33                                 JobRepository jobRepository,
     34                                 InternshipRepository internshipRepository,
     35                                 ProjectRepository projectRepository) {
    2736        this.matchRepository = matchRepository;
     37        this.jobRepository = jobRepository;
     38        this.internshipRepository = internshipRepository;
     39        this.projectRepository = projectRepository;
    2840    }
    2941
    3042    @Override
    3143    public List<Internship> getMatchingInternshipsForUser(User user) {
    32         List<Match> matches = this.matchRepository.getAllByCombinedId_User_IdAndTypeOrderByCoefficientDesc(user.getId(), WorkType.INTERNSHIP);
     44        List<Match> matches = this.matchRepository.getAllByEmbeddedMatchIdUserAndTypeOrderByCoefficientDesc(user.getId(), WorkType.INTERNSHIP);
     45//        List<Match> matches = this.matchRepository.getAllByUserIdAndTypeOrderByCoefficientDesc(user.getId(), WorkType.INTERNSHIP);
    3346
    3447        List<Internship> internships = new ArrayList<>();
    3548        matches.forEach(match -> {
    36             internships.add((Internship) match.getCombinedId().getWork());
     49            internships.add((Internship) match.getEmbeddedMatchId().getWork());
     50//            internships.add(this.internshipRepository.findById(match.getWorkId()).get());
    3751        });
    3852
     
    4256    @Override
    4357    public List<Job> getMatchingJobsForUser(User user) {
    44         List<Match> matches = this.matchRepository.getAllByCombinedId_User_IdAndTypeOrderByCoefficientDesc(user.getId(), WorkType.JOB);
     58        List<Match> matches = this.matchRepository.getAllByEmbeddedMatchIdUserAndTypeOrderByCoefficientDesc(user.getId(), WorkType.INTERNSHIP);
     59//        List<Match> matches = this.matchRepository.getAllByUserIdAndTypeOrderByCoefficientDesc(user.getId(), WorkType.JOB);
    4560
    4661        List<Job> jobs = new ArrayList<>();
    4762        matches.forEach(match -> {
    48             jobs.add((Job) match.getCombinedId().getWork());
     63            jobs.add((Job) match.getEmbeddedMatchId().getWork());
     64//            jobs.add(this.jobRepository.findById(match.getWorkId()).get());
    4965        });
    5066
     
    5470    @Override
    5571    public List<Project> getMatchingProjectsForUser(User user) {
    56         List<Match> matches = this.matchRepository.getAllByCombinedId_User_IdAndTypeOrderByCoefficientDesc(user.getId(), WorkType.PROJECT);
     72        List<Match> matches = this.matchRepository.getAllByEmbeddedMatchIdUserAndTypeOrderByCoefficientDesc(user.getId(), WorkType.INTERNSHIP);
     73//        List<Match> matches = this.matchRepository.getAllByUserIdAndTypeOrderByCoefficientDesc(user.getId(), WorkType.PROJECT);
    5774
    5875        List<Project> projects = new ArrayList<>();
    5976        matches.forEach(match -> {
    60             projects.add((Project) match.getCombinedId().getWork());
     77            projects.add((Project) match.getEmbeddedMatchId().getWork());
     78//            projects.add(this.projectRepository.findById(match.getWorkId()).get());
    6179        });
    6280
     
    7290
    7391        if(coef!=0){
    74             EmbeddedMatchId matchId = new EmbeddedMatchId(job, user);
    75             Match m = new Match(matchId, coef, WorkType.JOB);
     92            EmbeddedMatchId embeddedMatchId = new EmbeddedMatchId(job, user);
     93            Match m = new Match(embeddedMatchId, coef, WorkType.JOB);
     94//            Match m = new Match(job.getId(), user.getId(), coef, WorkType.JOB);
    7695            this.matchRepository.save(m);
    7796        }
     
    86105
    87106        if(coef!=0){
    88             EmbeddedMatchId matchId = new EmbeddedMatchId(project, user);
    89             Match m = new Match(matchId, coef, WorkType.PROJECT);
     107            EmbeddedMatchId embeddedMatchId = new EmbeddedMatchId(project, user);
     108            Match m = new Match(embeddedMatchId, coef, WorkType.PROJECT);
     109//            Match m = new Match(project.getId(), user.getId(), coef, WorkType.JOB);
    90110            this.matchRepository.save(m);
    91111        }
     
    100120
    101121        if(coef!=0){
    102             EmbeddedMatchId matchId = new EmbeddedMatchId(internship, user);
    103             Match m = new Match(matchId, coef, WorkType.INTERNSHIP);
     122            EmbeddedMatchId embeddedMatchId = new EmbeddedMatchId(internship, user);
     123            Match m = new Match(embeddedMatchId, coef, WorkType.PROJECT);
     124//            Match m = new Match(internship.getId(), user.getId(), coef, WorkType.JOB);
    104125            this.matchRepository.save(m);
    105126        }
  • src/main/java/it/finki/tinki/service/impl/SkillServiceImpl.java

    r509cb95 ra8e8545  
    2020
    2121    @Override
    22     public List<Skill> returnSkillsBasedOnId(List<Integer> skillIds) {
     22    public List<Skill> returnSkillsBasedOnId(List<Long> skillIds) {
    2323
    2424        List<Skill> list = new ArrayList<>();
    2525
    2626        skillIds.forEach(skill -> {
    27             this.skillRepository.findById(Long.valueOf(skill)).ifPresent(list::add);
     27            this.skillRepository.findById(skill).ifPresent(list::add);
    2828        });
    2929
  • src/main/java/it/finki/tinki/service/impl/WorkServiceImpl.java

    r509cb95 ra8e8545  
    7777
    7878    @Override
    79     public Job insertJob(String title, String description, Long adccId, int salary, List<Integer> skillsRequired, AccountType type) {
     79    public Job insertJob(String title, String description, Long adccId, int salary, List<Long> skillsRequired, AccountType type) {
    8080        List<Skill> skills = this.skillService.returnSkillsBasedOnId(skillsRequired);
    8181        Account account = this.accountService.findByIdAndType(adccId, type);
     
    8585
    8686    @Override
    87     public Internship insertInternship(String title, String description, Long adccId, int salary, List<Integer> skillsTrained, int openSpots, AccountType type) {
     87    public Internship insertInternship(String title, String description, Long adccId, int salary, List<Long> skillsTrained, int openSpots, AccountType type) {
    8888        List<Skill> skills = this.skillService.returnSkillsBasedOnId(skillsTrained);
    8989        Account account = this.accountService.findByIdAndType(adccId, type);
     
    9393
    9494    @Override
    95     public Project insertProject(String title, String description, Long adccId, int salary, List<Integer> skillsRequired, Date validUntil, AccountType type) {
     95    public Project insertProject(String title, String description, Long adccId, int salary, List<Long> skillsRequired, Date validUntil, AccountType type) {
    9696        List<Skill> skills = this.skillService.returnSkillsBasedOnId(skillsRequired);
    9797        Account account = this.accountService.findByIdAndType(adccId, type);
Note: See TracChangeset for help on using the changeset viewer.