source: src/main/java/it/finki/tinki/bootstrap/DataHolder.java@ a8e8545

Last change on this file since a8e8545 was a8e8545, checked in by Vzdra <vladko.zdravkovski@…>, 3 years ago

added dummy data for user skills and fixed bugs

  • Property mode set to 100644
File size: 2.8 KB
Line 
1package it.finki.tinki.bootstrap;
2
3import it.finki.tinki.model.Address;
4import it.finki.tinki.model.EmbeddedMatchId;
5import it.finki.tinki.model.Jobs.Job;
6import it.finki.tinki.model.Jobs.Work;
7import it.finki.tinki.model.Match;
8import it.finki.tinki.model.Skill;
9import it.finki.tinki.model.Users.Account;
10import it.finki.tinki.model.Users.Company;
11import it.finki.tinki.model.Users.User;
12import it.finki.tinki.model.enumerator.AccountType;
13import it.finki.tinki.model.enumerator.WorkType;
14import it.finki.tinki.repository.*;
15import it.finki.tinki.service.AccountService;
16import it.finki.tinki.service.WorkService;
17import org.springframework.beans.factory.annotation.Autowired;
18import org.springframework.stereotype.Component;
19
20import javax.annotation.PostConstruct;
21import java.util.ArrayList;
22import java.util.List;
23
24@Component
25public class DataHolder {
26
27 SkillRepository skillRepository;
28 AccountService accountService;
29 WorkService workService;
30 MatchRepository matchRepository;
31
32 public DataHolder(SkillRepository skillRepository,
33 AccountService accountService,
34 WorkService workService,
35 MatchRepository matchRepository) {
36 this.skillRepository = skillRepository;
37 this.accountService = accountService;
38 this.workService = workService;
39 this.matchRepository = matchRepository;
40 }
41
42 @PostConstruct
43 public void init(){
44 if(skillRepository.findAll().size()==0){
45 Skill s1 = new Skill("C++");
46 Skill s2 = new Skill("Java");
47 Skill s3 = new Skill("Python");
48 Skill s4 = new Skill("JavaScript");
49 Skill s5 = new Skill("React");
50 Skill s6 = new Skill("Spring");
51 Skill s7 = new Skill("C#");
52 Skill s8 = new Skill(".NET");
53 Skill s9 = new Skill("NodeJs");
54 Skill s0 = new Skill("Go");
55
56 skillRepository.save(s1);
57 skillRepository.save(s2);
58 skillRepository.save(s3);
59 skillRepository.save(s4);
60 skillRepository.save(s5);
61 skillRepository.save(s6);
62 skillRepository.save(s7);
63 skillRepository.save(s8);
64 skillRepository.save(s9);
65 skillRepository.save(s0);
66 }
67
68 List<Skill> lista;
69 lista = skillRepository.findAll();
70
71 List<Long> ids = new ArrayList<>();
72 lista.forEach(item -> {
73 ids.add(item.getId());
74 });
75
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
82 }
83
84}
Note: See TracBrowser for help on using the repository browser.