1 | package it.finki.tinki.service.impl;
|
---|
2 |
|
---|
3 | import it.finki.tinki.model.Jobs.Internship;
|
---|
4 | import it.finki.tinki.model.Jobs.Job;
|
---|
5 | import it.finki.tinki.model.Jobs.Project;
|
---|
6 | import it.finki.tinki.model.Match;
|
---|
7 | import it.finki.tinki.model.Users.Team;
|
---|
8 | import it.finki.tinki.model.Users.User;
|
---|
9 | import it.finki.tinki.model.enumerator.WorkType;
|
---|
10 | import it.finki.tinki.repository.MatchRepository;
|
---|
11 | import it.finki.tinki.service.MatchmakerService;
|
---|
12 | import org.springframework.stereotype.Service;
|
---|
13 |
|
---|
14 | import java.util.ArrayList;
|
---|
15 | import java.util.List;
|
---|
16 |
|
---|
17 |
|
---|
18 | @Service
|
---|
19 | public class MatchmakerServiceImpl implements MatchmakerService {
|
---|
20 |
|
---|
21 | MatchRepository matchRepository;
|
---|
22 |
|
---|
23 | public MatchmakerServiceImpl(MatchRepository matchRepository) {
|
---|
24 | this.matchRepository = matchRepository;
|
---|
25 | }
|
---|
26 |
|
---|
27 | @Override
|
---|
28 | public List<Internship> getMatchingInternshipsForUser(User user) {
|
---|
29 | List<Match> matches = this.matchRepository.getAllByCombinedId_UserAndTypeOrderByCoefficientDesc(user, WorkType.INTERNSHIP);
|
---|
30 |
|
---|
31 | List<Internship> internships = new ArrayList<>();
|
---|
32 | matches.forEach(match -> {
|
---|
33 | internships.add((Internship) match.getCombinedId().getWork());
|
---|
34 | });
|
---|
35 |
|
---|
36 | return internships;
|
---|
37 | }
|
---|
38 |
|
---|
39 | @Override
|
---|
40 | public List<Job> getMatchingJobsForUser(User user) {
|
---|
41 | List<Match> matches = this.matchRepository.getAllByCombinedId_UserAndTypeOrderByCoefficientDesc(user, WorkType.JOB);
|
---|
42 |
|
---|
43 | List<Job> jobs = new ArrayList<>();
|
---|
44 | matches.forEach(match -> {
|
---|
45 | jobs.add((Job) match.getCombinedId().getWork());
|
---|
46 | });
|
---|
47 |
|
---|
48 | return jobs;
|
---|
49 | }
|
---|
50 |
|
---|
51 | @Override
|
---|
52 | public List<Project> getMatchingProjectsForUser(User user) {
|
---|
53 | List<Match> matches = this.matchRepository.getAllByCombinedId_UserAndTypeOrderByCoefficientDesc(user, WorkType.PROJECT);
|
---|
54 |
|
---|
55 | List<Project> projects = new ArrayList<>();
|
---|
56 | matches.forEach(match -> {
|
---|
57 | projects.add((Project) match.getCombinedId().getWork());
|
---|
58 | });
|
---|
59 |
|
---|
60 | return projects;
|
---|
61 | }
|
---|
62 | }
|
---|