1 | package it.finki.tinki.bootstrap;
|
---|
2 |
|
---|
3 | import it.finki.tinki.model.Address;
|
---|
4 | import it.finki.tinki.model.Skill;
|
---|
5 | import it.finki.tinki.model.Users.Company;
|
---|
6 | import it.finki.tinki.model.Users.User;
|
---|
7 | import it.finki.tinki.model.enumerator.AccountType;
|
---|
8 | import it.finki.tinki.repository.*;
|
---|
9 | import org.springframework.stereotype.Component;
|
---|
10 |
|
---|
11 | import javax.annotation.PostConstruct;
|
---|
12 | import java.util.ArrayList;
|
---|
13 | import java.util.List;
|
---|
14 |
|
---|
15 | @Component
|
---|
16 | public class DataHolder {
|
---|
17 |
|
---|
18 | SkillRepository skillRepository;
|
---|
19 | UserRepository userRepository;
|
---|
20 | CompanyRepository companyRepository;
|
---|
21 | TeamRepository teamRepository;
|
---|
22 | AddressRepository addressRepository;
|
---|
23 |
|
---|
24 | public DataHolder(SkillRepository skillRepository, UserRepository userRepository, CompanyRepository companyRepository, TeamRepository teamRepository, AddressRepository addressRepository) {
|
---|
25 | this.skillRepository = skillRepository;
|
---|
26 | this.userRepository = userRepository;
|
---|
27 | this.companyRepository = companyRepository;
|
---|
28 | this.teamRepository = teamRepository;
|
---|
29 | this.addressRepository = addressRepository;
|
---|
30 | }
|
---|
31 |
|
---|
32 | @PostConstruct
|
---|
33 | public void init(){
|
---|
34 | if(skillRepository.findAll().size()==0){
|
---|
35 | Skill s1 = new Skill("C++");
|
---|
36 | Skill s2 = new Skill("Java");
|
---|
37 | Skill s3 = new Skill("Python");
|
---|
38 | Skill s4 = new Skill("JavaScript");
|
---|
39 | Skill s5 = new Skill("React");
|
---|
40 | Skill s6 = new Skill("Spring");
|
---|
41 | Skill s7 = new Skill("C#");
|
---|
42 | Skill s8 = new Skill(".NET");
|
---|
43 | Skill s9 = new Skill("NodeJs");
|
---|
44 | Skill s0 = new Skill("Go");
|
---|
45 |
|
---|
46 | skillRepository.save(s1);
|
---|
47 | skillRepository.save(s2);
|
---|
48 | skillRepository.save(s3);
|
---|
49 | skillRepository.save(s4);
|
---|
50 | skillRepository.save(s5);
|
---|
51 | skillRepository.save(s6);
|
---|
52 | skillRepository.save(s7);
|
---|
53 | skillRepository.save(s8);
|
---|
54 | skillRepository.save(s9);
|
---|
55 | skillRepository.save(s0);
|
---|
56 | }
|
---|
57 |
|
---|
58 | addressRepository.save(new Address("asdf", "asdf", "asdf"));
|
---|
59 | companyRepository.save(new Company("asdf@asdf", "pass", "Co.co", AccountType.COMPANY, addressRepository.findAll().get(0)));
|
---|
60 | }
|
---|
61 |
|
---|
62 | }
|
---|