Ignore:
Timestamp:
01/07/21 22:32:22 (3 years ago)
Author:
Vzdra <vladko.zdravkovski@…>
Branches:
master
Children:
a8e8545
Parents:
723994f
Message:

finalized register and login and added insert options for jobs

Location:
src/main/java/it/finki/tinki/service/impl
Files:
1 added
2 edited

Legend:

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

    r723994f r509cb95  
    9696        return this.companyRepository.save(c);
    9797    }
     98
     99    public Account findByIdAndType(Long id, AccountType type){
     100        switch (type){
     101            case COMPANY:
     102                return this.companyRepository.findById(id).get();
     103            case TEAM:
     104                return this.teamRepository.findById(id).get();
     105            case USER:
     106                return this.userRepository.findById(id).get();
     107        }
     108
     109        return null;
     110    }
    98111}
  • src/main/java/it/finki/tinki/service/impl/MatchmakerServiceImpl.java

    r723994f r509cb95  
    11package it.finki.tinki.service.impl;
    22
     3import it.finki.tinki.helper.Matchmaker;
     4import it.finki.tinki.model.EmbeddedMatchId;
    35import it.finki.tinki.model.Jobs.Internship;
    46import it.finki.tinki.model.Jobs.Job;
    57import it.finki.tinki.model.Jobs.Project;
     8import it.finki.tinki.model.Jobs.Work;
    69import it.finki.tinki.model.Match;
    7 import it.finki.tinki.model.Users.Team;
     10import it.finki.tinki.model.Skill;
    811import it.finki.tinki.model.Users.User;
    912import it.finki.tinki.model.enumerator.WorkType;
     
    2730    @Override
    2831    public List<Internship> getMatchingInternshipsForUser(User user) {
    29         List<Match> matches = this.matchRepository.getAllByCombinedId_UserAndTypeOrderByCoefficientDesc(user, WorkType.INTERNSHIP);
     32        List<Match> matches = this.matchRepository.getAllByCombinedId_User_IdAndTypeOrderByCoefficientDesc(user.getId(), WorkType.INTERNSHIP);
    3033
    3134        List<Internship> internships = new ArrayList<>();
     
    3942    @Override
    4043    public List<Job> getMatchingJobsForUser(User user) {
    41         List<Match> matches = this.matchRepository.getAllByCombinedId_UserAndTypeOrderByCoefficientDesc(user, WorkType.JOB);
     44        List<Match> matches = this.matchRepository.getAllByCombinedId_User_IdAndTypeOrderByCoefficientDesc(user.getId(), WorkType.JOB);
    4245
    4346        List<Job> jobs = new ArrayList<>();
     
    5154    @Override
    5255    public List<Project> getMatchingProjectsForUser(User user) {
    53         List<Match> matches = this.matchRepository.getAllByCombinedId_UserAndTypeOrderByCoefficientDesc(user, WorkType.PROJECT);
     56        List<Match> matches = this.matchRepository.getAllByCombinedId_User_IdAndTypeOrderByCoefficientDesc(user.getId(), WorkType.PROJECT);
    5457
    5558        List<Project> projects = new ArrayList<>();
     
    6063        return projects;
    6164    }
     65
     66    @Override
     67    public void setUpUserJobMatches(Job job, User user) {
     68        List<Skill> jobSkill = job.getSkillsRequired();
     69        List<Skill> userSkill = user.getRetainedSkills();
     70
     71        float coef = Matchmaker.match(jobSkill, userSkill);
     72
     73        if(coef!=0){
     74            EmbeddedMatchId matchId = new EmbeddedMatchId(job, user);
     75            Match m = new Match(matchId, coef, WorkType.JOB);
     76            this.matchRepository.save(m);
     77        }
     78    }
     79
     80    @Override
     81    public void setUpUserProjectMatches(Project project, User user) {
     82        List<Skill> projectSkills = project.getSkillsRequired();
     83        List<Skill> userSkill = user.getRetainedSkills();
     84
     85        float coef = Matchmaker.match(projectSkills, userSkill);
     86
     87        if(coef!=0){
     88            EmbeddedMatchId matchId = new EmbeddedMatchId(project, user);
     89            Match m = new Match(matchId, coef, WorkType.PROJECT);
     90            this.matchRepository.save(m);
     91        }
     92    }
     93
     94    @Override
     95    public void setUpUserInternshipMatches(Internship internship, User user) {
     96        List<Skill> internshipSkills = internship.getSkillsTrained();
     97        List<Skill> userSkill = user.getSkillsToLearn();
     98
     99        float coef = Matchmaker.match(internshipSkills, userSkill);
     100
     101        if(coef!=0){
     102            EmbeddedMatchId matchId = new EmbeddedMatchId(internship, user);
     103            Match m = new Match(matchId, coef, WorkType.INTERNSHIP);
     104            this.matchRepository.save(m);
     105        }
     106    }
     107
     108
    62109}
Note: See TracChangeset for help on using the changeset viewer.