- Timestamp:
- 01/08/21 00:35:56 (4 years ago)
- Branches:
- master
- Children:
- 4cec0a3
- Parents:
- 509cb95
- Location:
- src/main/java/it/finki/tinki
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/it/finki/tinki/bootstrap/DataHolder.java
r509cb95 ra8e8545 2 2 3 3 import it.finki.tinki.model.Address; 4 import it.finki.tinki.model.EmbeddedMatchId; 5 import it.finki.tinki.model.Jobs.Job; 6 import it.finki.tinki.model.Jobs.Work; 7 import it.finki.tinki.model.Match; 4 8 import it.finki.tinki.model.Skill; 9 import it.finki.tinki.model.Users.Account; 5 10 import it.finki.tinki.model.Users.Company; 6 11 import it.finki.tinki.model.Users.User; 7 12 import it.finki.tinki.model.enumerator.AccountType; 13 import it.finki.tinki.model.enumerator.WorkType; 8 14 import it.finki.tinki.repository.*; 15 import it.finki.tinki.service.AccountService; 16 import it.finki.tinki.service.WorkService; 17 import org.springframework.beans.factory.annotation.Autowired; 9 18 import org.springframework.stereotype.Component; 10 19 … … 17 26 18 27 SkillRepository skillRepository; 19 UserRepository userRepository; 20 CompanyRepository companyRepository; 21 TeamRepository teamRepository; 22 AddressRepository addressRepository; 28 AccountService accountService; 29 WorkService workService; 30 MatchRepository matchRepository; 23 31 24 public DataHolder(SkillRepository skillRepository, UserRepository userRepository, CompanyRepository companyRepository, TeamRepository teamRepository, AddressRepository addressRepository) { 32 public DataHolder(SkillRepository skillRepository, 33 AccountService accountService, 34 WorkService workService, 35 MatchRepository matchRepository) { 25 36 this.skillRepository = skillRepository; 26 this.userRepository = userRepository; 27 this.companyRepository = companyRepository; 28 this.teamRepository = teamRepository; 29 this.addressRepository = addressRepository; 37 this.accountService = accountService; 38 this.workService = workService; 39 this.matchRepository = matchRepository; 30 40 } 31 41 … … 59 69 lista = skillRepository.findAll(); 60 70 61 userRepository.save(new User("asdf", "asdf", "Zoki", AccountType.USER, "Poki", lista, lista)); 71 List<Long> ids = new ArrayList<>(); 72 lista.forEach(item -> { 73 ids.add(item.getId()); 74 }); 62 75 63 addressRepository.save(new Address("asdf", "asdf", "asdf")); 64 companyRepository.save(new Company("asdf@asdf", "pass", "Co.co", AccountType.COMPANY, addressRepository.findAll().get(0))); 76 Account c = this.accountService.registerCompany("asdf@asdf", "pass", "Co.co", "Macedonia", "Skopje", "Pero Nakov"); 77 78 Job j = this.workService.insertJob("Asdf", "Asdfa", c.getId() ,5000, ids, AccountType.COMPANY); 79 80 Account u = this.accountService.registerUser("asdf", "asdf", "Zoki", "Poki", lista, lista); 81 65 82 } 66 83 -
src/main/java/it/finki/tinki/model/EmbeddedMatchId.java
r509cb95 ra8e8545 6 6 7 7 import javax.persistence.Embeddable; 8 import javax.persistence.FetchType; 8 9 import javax.persistence.OneToOne; 9 10 import java.io.Serializable; 11 import java.util.Objects; 10 12 11 13 @Embeddable … … 25 27 this.user = user; 26 28 } 27 28 29 } -
src/main/java/it/finki/tinki/model/Jobs/Internship.java
r509cb95 ra8e8545 12 12 public class Internship extends Work { 13 13 14 @ManyToMany 14 @ManyToMany(fetch = FetchType.EAGER) 15 15 List<Skill> skillsTrained; 16 16 -
src/main/java/it/finki/tinki/model/Jobs/Job.java
r509cb95 ra8e8545 12 12 public class Job extends Work { 13 13 14 @ManyToMany 14 @ManyToMany(fetch = FetchType.EAGER) 15 15 List<Skill> skillsRequired; 16 16 -
src/main/java/it/finki/tinki/model/Jobs/Project.java
r509cb95 ra8e8545 13 13 public class Project extends Work { 14 14 15 @ManyToMany 15 @ManyToMany(fetch = FetchType.EAGER) 16 16 List<Skill> skillsRequired; 17 17 -
src/main/java/it/finki/tinki/model/Match.java
r509cb95 ra8e8545 1 1 package it.finki.tinki.model; 2 2 3 import com.sun.istack.NotNull; 4 import it.finki.tinki.model.Jobs.Work; 5 import it.finki.tinki.model.Users.User; 3 6 import it.finki.tinki.model.enumerator.WorkType; 4 7 import lombok.Data; … … 10 13 public class Match { 11 14 15 // @Id 16 // @GeneratedValue(strategy = GenerationType.AUTO) 17 // Long id; 18 // 19 // @NotNull 20 // Long workId; 21 // 22 // @NotNull 23 // Long userId; 24 12 25 @Id 13 EmbeddedMatchId combinedId;26 EmbeddedMatchId embeddedMatchId; 14 27 15 28 float coefficient; … … 19 32 public Match(){} 20 33 34 // public Match(Long workId, Long userId, float coefficient, WorkType type) { 35 // this.workId = workId; 36 // this.userId = userId; 37 // this.coefficient = coefficient; 38 // this.type = type; 39 // } 40 21 41 public Match(EmbeddedMatchId embeddedMatchId, float coefficient, WorkType type) { 22 this. combinedId = embeddedMatchId;42 this.embeddedMatchId = embeddedMatchId; 23 43 this.coefficient = coefficient; 24 44 this.type = type; -
src/main/java/it/finki/tinki/repository/MatchRepository.java
r509cb95 ra8e8545 1 1 package it.finki.tinki.repository; 2 2 3 import it.finki.tinki.model.EmbeddedMatchId; 3 4 import it.finki.tinki.model.Match; 4 5 import it.finki.tinki.model.Users.User; … … 10 11 11 12 @Repository 12 public interface MatchRepository extends JpaRepository<Match, Long> { 13 List<Match> getAllByCombinedId_User_IdAndTypeOrderByCoefficientDesc(Long uId, WorkType type); 13 public interface MatchRepository extends JpaRepository<Match, EmbeddedMatchId> { 14 List<Match> getAllByEmbeddedMatchIdUserAndTypeOrderByCoefficientDesc(Long uId, WorkType type); 15 // List<Match> getAllByUserIdAndTypeOrderByCoefficientDesc(Long uId, WorkType type); 14 16 } -
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); -
src/main/java/it/finki/tinki/web/controller/RegisterController.java
r509cb95 ra8e8545 40 40 @RequestParam String name, 41 41 @RequestParam String surname, 42 @RequestParam List< Integer> retainedSkills,43 @RequestParam List< Integer> skillsToLearn){42 @RequestParam List<Long> retainedSkills, 43 @RequestParam List<Long> skillsToLearn){ 44 44 45 45 List<Skill> retained = this.skillService.returnSkillsBasedOnId(retainedSkills); … … 53 53 response.put("error", "There was an error when trying to register user."); 54 54 }else{ 55 List<Job> jobs = this.workService.getAllJobs();56 List<Project> projects = this.workService.getAllProjects();57 List<Internship> internships = this.workService.getAllInternships();58 59 jobs.forEach(job -> {60 this.matchmakerService.setUpUserJobMatches(job, (User) k);61 });62 63 projects.forEach(project -> {64 this.matchmakerService.setUpUserProjectMatches(project, (User) k);65 });66 67 internships.forEach(internship -> {68 this.matchmakerService.setUpUserInternshipMatches(internship, (User) k);69 });70 71 55 response.put("success", "Registration completed successfully."); 72 56 } … … 95 79 96 80 @RequestMapping(path = "/company", method = RequestMethod.POST) 97 private Map<String, String> registe rTeam(@RequestParam String email,98 @RequestParam String password,99 @RequestParam String name,100 @RequestParam String country,101 @RequestParam String city,102 @RequestParam String street){81 private Map<String, String> registeCompany(@RequestParam String email, 82 @RequestParam String password, 83 @RequestParam String name, 84 @RequestParam String country, 85 @RequestParam String city, 86 @RequestParam String street){ 103 87 104 88 Account k = this.accountService.registerCompany(email, password, name, country, city, street);
Note:
See TracChangeset
for help on using the changeset viewer.