Changeset a8e8545 for src/main/java/it/finki/tinki/service
- Timestamp:
- 01/08/21 00:35:56 (4 years ago)
- Branches:
- master
- Children:
- 4cec0a3
- Parents:
- 509cb95
- Location:
- src/main/java/it/finki/tinki/service
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/it/finki/tinki/service/SkillService.java
r509cb95 ra8e8545 6 6 7 7 public interface SkillService { 8 List<Skill> returnSkillsBasedOnId(List< Integer> skillIds);8 List<Skill> returnSkillsBasedOnId(List<Long> skillIds); 9 9 } -
src/main/java/it/finki/tinki/service/WorkService.java
r509cb95 ra8e8545 16 16 List<Internship> getAllInternships(); 17 17 List<Project> getAllProjects(); 18 Job insertJob(String title, String description, Long accId, int salary, List< Integer> skillsRequired, AccountType type);19 Internship insertInternship(String title, String description, Long adccId, int salary, List< Integer> skillsTrained, int openSpots, AccountType type);20 Project insertProject(String title, String description, Long adccId, int salary, List< Integer> skillsRequired, Date validUntil, AccountType type);18 Job insertJob(String title, String description, Long accId, int salary, List<Long> skillsRequired, AccountType type); 19 Internship insertInternship(String title, String description, Long adccId, int salary, List<Long> skillsTrained, int openSpots, AccountType type); 20 Project insertProject(String title, String description, Long adccId, int salary, List<Long> skillsRequired, Date validUntil, AccountType type); 21 21 } -
src/main/java/it/finki/tinki/service/impl/AccountServiceImpl.java
r509cb95 ra8e8545 2 2 3 3 import it.finki.tinki.model.Address; 4 import it.finki.tinki.model.Jobs.Internship; 5 import it.finki.tinki.model.Jobs.Job; 6 import it.finki.tinki.model.Jobs.Project; 4 7 import it.finki.tinki.model.Skill; 5 8 import it.finki.tinki.model.Users.Account; … … 10 13 import it.finki.tinki.model.exception.InvalidArgumentsException; 11 14 import 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; 15 import it.finki.tinki.repository.*; 16 16 import it.finki.tinki.service.AccountService; 17 import it.finki.tinki.service.MatchmakerService; 18 import it.finki.tinki.service.WorkService; 17 19 import org.springframework.stereotype.Service; 18 20 … … 28 30 TeamRepository teamRepository; 29 31 CompanyRepository companyRepository; 32 JobRepository jobRepository; 33 ProjectRepository projectRepository; 34 InternshipRepository internshipRepository; 35 MatchmakerService matchmakerService; 30 36 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) { 32 45 this.addressRepository = addressRepository; 33 46 this.userRepository = userRepository; 34 47 this.teamRepository = teamRepository; 35 48 this.companyRepository = companyRepository; 49 this.jobRepository = jobRepository; 50 this.projectRepository = projectRepository; 51 this.internshipRepository = internshipRepository; 52 this.matchmakerService = matchmakerService; 36 53 } 37 54 … … 65 82 66 83 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; 68 109 } 69 110 -
src/main/java/it/finki/tinki/service/impl/MatchmakerServiceImpl.java
r509cb95 ra8e8545 11 11 import it.finki.tinki.model.Users.User; 12 12 import it.finki.tinki.model.enumerator.WorkType; 13 import it.finki.tinki.repository.InternshipRepository; 14 import it.finki.tinki.repository.JobRepository; 13 15 import it.finki.tinki.repository.MatchRepository; 16 import it.finki.tinki.repository.ProjectRepository; 14 17 import it.finki.tinki.service.MatchmakerService; 15 18 import org.springframework.stereotype.Service; … … 23 26 24 27 MatchRepository matchRepository; 28 JobRepository jobRepository; 29 InternshipRepository internshipRepository; 30 ProjectRepository projectRepository; 25 31 26 public MatchmakerServiceImpl(MatchRepository matchRepository) { 32 public MatchmakerServiceImpl(MatchRepository matchRepository, 33 JobRepository jobRepository, 34 InternshipRepository internshipRepository, 35 ProjectRepository projectRepository) { 27 36 this.matchRepository = matchRepository; 37 this.jobRepository = jobRepository; 38 this.internshipRepository = internshipRepository; 39 this.projectRepository = projectRepository; 28 40 } 29 41 30 42 @Override 31 43 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); 33 46 34 47 List<Internship> internships = new ArrayList<>(); 35 48 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()); 37 51 }); 38 52 … … 42 56 @Override 43 57 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); 45 60 46 61 List<Job> jobs = new ArrayList<>(); 47 62 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()); 49 65 }); 50 66 … … 54 70 @Override 55 71 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); 57 74 58 75 List<Project> projects = new ArrayList<>(); 59 76 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()); 61 79 }); 62 80 … … 72 90 73 91 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); 76 95 this.matchRepository.save(m); 77 96 } … … 86 105 87 106 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); 90 110 this.matchRepository.save(m); 91 111 } … … 100 120 101 121 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); 104 125 this.matchRepository.save(m); 105 126 } -
src/main/java/it/finki/tinki/service/impl/SkillServiceImpl.java
r509cb95 ra8e8545 20 20 21 21 @Override 22 public List<Skill> returnSkillsBasedOnId(List< Integer> skillIds) {22 public List<Skill> returnSkillsBasedOnId(List<Long> skillIds) { 23 23 24 24 List<Skill> list = new ArrayList<>(); 25 25 26 26 skillIds.forEach(skill -> { 27 this.skillRepository.findById( Long.valueOf(skill)).ifPresent(list::add);27 this.skillRepository.findById(skill).ifPresent(list::add); 28 28 }); 29 29 -
src/main/java/it/finki/tinki/service/impl/WorkServiceImpl.java
r509cb95 ra8e8545 77 77 78 78 @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) { 80 80 List<Skill> skills = this.skillService.returnSkillsBasedOnId(skillsRequired); 81 81 Account account = this.accountService.findByIdAndType(adccId, type); … … 85 85 86 86 @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) { 88 88 List<Skill> skills = this.skillService.returnSkillsBasedOnId(skillsTrained); 89 89 Account account = this.accountService.findByIdAndType(adccId, type); … … 93 93 94 94 @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) { 96 96 List<Skill> skills = this.skillService.returnSkillsBasedOnId(skillsRequired); 97 97 Account account = this.accountService.findByIdAndType(adccId, type);
Note:
See TracChangeset
for help on using the changeset viewer.