Ignore:
Timestamp:
01/08/21 02:08:22 (4 years ago)
Author:
Vzdra <vladko.zdravkovski@…>
Branches:
master
Children:
b24fe9b
Parents:
a8e8545
Message:

added response dto for job response

File:
1 edited

Legend:

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

    ra8e8545 r4cec0a3  
    4242    @Override
    4343    public List<Internship> getMatchingInternshipsForUser(User user) {
    44         List<Match> matches = this.matchRepository.getAllByEmbeddedMatchIdUserAndTypeOrderByCoefficientDesc(user.getId(), WorkType.INTERNSHIP);
    45 //        List<Match> matches = this.matchRepository.getAllByUserIdAndTypeOrderByCoefficientDesc(user.getId(), WorkType.INTERNSHIP);
     44        List<Match> matches = this.matchRepository.findAllByEmbeddedMatchIdUserAndTypeOrderByCoefficientDesc(user, WorkType.INTERNSHIP);
    4645
    4746        List<Internship> internships = new ArrayList<>();
    48         matches.forEach(match -> {
    49             internships.add((Internship) match.getEmbeddedMatchId().getWork());
    50 //            internships.add(this.internshipRepository.findById(match.getWorkId()).get());
    51         });
     47        if(matches.size()!=0){
     48            matches.forEach(match -> {
     49                internships.add((Internship) match.getEmbeddedMatchId().getWork());
     50            });
     51        }
    5252
    5353        return internships;
     
    5656    @Override
    5757    public List<Job> getMatchingJobsForUser(User user) {
    58         List<Match> matches = this.matchRepository.getAllByEmbeddedMatchIdUserAndTypeOrderByCoefficientDesc(user.getId(), WorkType.INTERNSHIP);
    59 //        List<Match> matches = this.matchRepository.getAllByUserIdAndTypeOrderByCoefficientDesc(user.getId(), WorkType.JOB);
     58        List<Match> matches = this.matchRepository.findAllByEmbeddedMatchIdUserAndTypeOrderByCoefficientDesc(user, WorkType.JOB);
    6059
    6160        List<Job> jobs = new ArrayList<>();
    62         matches.forEach(match -> {
    63             jobs.add((Job) match.getEmbeddedMatchId().getWork());
    64 //            jobs.add(this.jobRepository.findById(match.getWorkId()).get());
    65         });
     61        if(matches.size()!=0) {
     62            matches.forEach(match -> {
     63                jobs.add((Job) match.getEmbeddedMatchId().getWork());
     64            });
     65        }
    6666
    6767        return jobs;
     
    7070    @Override
    7171    public List<Project> getMatchingProjectsForUser(User user) {
    72         List<Match> matches = this.matchRepository.getAllByEmbeddedMatchIdUserAndTypeOrderByCoefficientDesc(user.getId(), WorkType.INTERNSHIP);
    73 //        List<Match> matches = this.matchRepository.getAllByUserIdAndTypeOrderByCoefficientDesc(user.getId(), WorkType.PROJECT);
     72        List<Match> matches = this.matchRepository.findAllByEmbeddedMatchIdUserAndTypeOrderByCoefficientDesc(user, WorkType.PROJECT);
    7473
    7574        List<Project> projects = new ArrayList<>();
    76         matches.forEach(match -> {
    77             projects.add((Project) match.getEmbeddedMatchId().getWork());
    78 //            projects.add(this.projectRepository.findById(match.getWorkId()).get());
    79         });
     75        if(matches.size()!=0) {
     76            matches.forEach(match -> {
     77                projects.add((Project) match.getEmbeddedMatchId().getWork());
     78            });
     79        }
    8080
    8181        return projects;
     
    9292            EmbeddedMatchId embeddedMatchId = new EmbeddedMatchId(job, user);
    9393            Match m = new Match(embeddedMatchId, coef, WorkType.JOB);
    94 //            Match m = new Match(job.getId(), user.getId(), coef, WorkType.JOB);
    9594            this.matchRepository.save(m);
    9695        }
     
    107106            EmbeddedMatchId embeddedMatchId = new EmbeddedMatchId(project, user);
    108107            Match m = new Match(embeddedMatchId, coef, WorkType.PROJECT);
    109 //            Match m = new Match(project.getId(), user.getId(), coef, WorkType.JOB);
    110108            this.matchRepository.save(m);
    111109        }
     
    122120            EmbeddedMatchId embeddedMatchId = new EmbeddedMatchId(internship, user);
    123121            Match m = new Match(embeddedMatchId, coef, WorkType.PROJECT);
    124 //            Match m = new Match(internship.getId(), user.getId(), coef, WorkType.JOB);
    125122            this.matchRepository.save(m);
    126123        }
Note: See TracChangeset for help on using the changeset viewer.