Changeset 4cec0a3 for src/main/java/it/finki
- Timestamp:
- 01/08/21 02:08:22 (4 years ago)
- Branches:
- master
- Children:
- b24fe9b
- Parents:
- a8e8545
- Location:
- src/main/java/it/finki/tinki
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/it/finki/tinki/bootstrap/DataHolder.java
ra8e8545 r4cec0a3 69 69 lista = skillRepository.findAll(); 70 70 71 List<Skill> l2 = new ArrayList<>(); 72 l2.add(skillRepository.getOne(3L)); 73 l2.add(skillRepository.getOne(0L)); 74 l2.add(skillRepository.getOne(1L)); 75 l2.add(skillRepository.getOne(2L)); 76 l2.add(skillRepository.getOne(4L)); 77 l2.add(skillRepository.getOne(5L)); 78 l2.add(skillRepository.getOne(6L)); 79 l2.add(skillRepository.getOne(7L)); 80 81 82 List<Skill> l3 = new ArrayList<>(); 83 l3.add(skillRepository.getOne(3L)); 84 l3.add(skillRepository.getOne(0L)); 85 l3.add(skillRepository.getOne(5L)); 86 l3.add(skillRepository.getOne(6L)); 87 l3.add(skillRepository.getOne(7L)); 88 71 89 List<Long> ids = new ArrayList<>(); 72 90 lista.forEach(item -> { … … 74 92 }); 75 93 94 List<Long> smalls = new ArrayList<>(); 95 l2.forEach(item -> { 96 smalls.add(item.getId()); 97 }); 98 99 List<Long> sm2 = new ArrayList<>(); 100 l3.forEach(item -> { 101 sm2.add(item.getId()); 102 }); 103 76 104 Account c = this.accountService.registerCompany("asdf@asdf", "pass", "Co.co", "Macedonia", "Skopje", "Pero Nakov"); 105 Account m = this.accountService.registerTeam("asdf", "asd", "TeamRocket", 3); 77 106 78 107 Job j = this.workService.insertJob("Asdf", "Asdfa", c.getId() ,5000, ids, AccountType.COMPANY); 108 Job k = this.workService.insertJob("Asdf", "Asdfa", m.getId() ,5000, ids, AccountType.TEAM); 109 Job z = this.workService.insertJob("asdfq", "asdfqw", m.getId() ,5000, smalls, AccountType.TEAM); 110 Job n = this.workService.insertJob("asdfq", "asdfqw", c.getId() ,5000, sm2, AccountType.COMPANY); 79 111 80 112 Account u = this.accountService.registerUser("asdf", "asdf", "Zoki", "Poki", lista, lista); -
src/main/java/it/finki/tinki/model/dto/UserResponseDTO.java
ra8e8545 r4cec0a3 7 7 import lombok.Data; 8 8 9 import java.util.ArrayList; 9 10 import java.util.List; 10 11 … … 14 15 private List<Skill> retained; 15 16 private List<Skill> toLearn; 16 private List<Job > jobs;17 private List<JobResponseDTO> jobs; 17 18 private List<Internship> internships; 18 19 private List<Project> projects; 20 21 public UserResponseDTO(){ 22 retained = new ArrayList<>(); 23 toLearn = new ArrayList<>(); 24 jobs = new ArrayList<>(); 25 internships = new ArrayList<>(); 26 projects = new ArrayList<>(); 27 } 19 28 } -
src/main/java/it/finki/tinki/repository/MatchRepository.java
ra8e8545 r4cec0a3 12 12 @Repository 13 13 public interface MatchRepository extends JpaRepository<Match, EmbeddedMatchId> { 14 List<Match> getAllByEmbeddedMatchIdUserAndTypeOrderByCoefficientDesc(Long uId, WorkType type);14 List<Match> findAllByEmbeddedMatchIdUserAndTypeOrderByCoefficientDesc(User user, WorkType type); 15 15 // List<Match> getAllByUserIdAndTypeOrderByCoefficientDesc(Long uId, WorkType type); 16 16 } -
src/main/java/it/finki/tinki/service/impl/MatchmakerServiceImpl.java
ra8e8545 r4cec0a3 42 42 @Override 43 43 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); 46 45 47 46 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 } 52 52 53 53 return internships; … … 56 56 @Override 57 57 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); 60 59 61 60 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 } 66 66 67 67 return jobs; … … 70 70 @Override 71 71 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); 74 73 75 74 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 } 80 80 81 81 return projects; … … 92 92 EmbeddedMatchId embeddedMatchId = new EmbeddedMatchId(job, user); 93 93 Match m = new Match(embeddedMatchId, coef, WorkType.JOB); 94 // Match m = new Match(job.getId(), user.getId(), coef, WorkType.JOB);95 94 this.matchRepository.save(m); 96 95 } … … 107 106 EmbeddedMatchId embeddedMatchId = new EmbeddedMatchId(project, user); 108 107 Match m = new Match(embeddedMatchId, coef, WorkType.PROJECT); 109 // Match m = new Match(project.getId(), user.getId(), coef, WorkType.JOB);110 108 this.matchRepository.save(m); 111 109 } … … 122 120 EmbeddedMatchId embeddedMatchId = new EmbeddedMatchId(internship, user); 123 121 Match m = new Match(embeddedMatchId, coef, WorkType.PROJECT); 124 // Match m = new Match(internship.getId(), user.getId(), coef, WorkType.JOB);125 122 this.matchRepository.save(m); 126 123 } -
src/main/java/it/finki/tinki/web/controller/LoginController.java
ra8e8545 r4cec0a3 1 1 package it.finki.tinki.web.controller; 2 2 3 import it.finki.tinki.model.Jobs.Internship; 4 import it.finki.tinki.model.Jobs.Job; 3 5 import it.finki.tinki.model.Users.Account; 4 6 import it.finki.tinki.model.Users.Company; … … 14 16 import org.springframework.web.server.ResponseStatusException; 15 17 18 import java.util.List; 16 19 import java.util.Map; 17 20 … … 54 57 uDto.setToLearn(((User) a1).getSkillsToLearn()); 55 58 56 uDto.setInternships(this.matchmakerService.getMatchingInternshipsForUser((User) a1)); 57 uDto.setJobs(this.matchmakerService.getMatchingJobsForUser((User) a1)); 58 uDto.setProjects(this.matchmakerService.getMatchingProjectsForUser((User) a1)); 59 List<Job> matchedJobs = this.matchmakerService.getMatchingJobsForUser((User) a1); 60 61 matchedJobs.forEach(job -> { 62 JobResponseDTO dto = new JobResponseDTO(job); 63 uDto.getJobs().add(dto); 64 }); 65 59 66 60 67 return uDto;
Note:
See TracChangeset
for help on using the changeset viewer.