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

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

finalized register and login and added insert options for jobs

  • Property mode set to 100644
File size: 2.3 KB
Line 
1package it.finki.tinki.bootstrap;
2
3import it.finki.tinki.model.Address;
4import it.finki.tinki.model.Skill;
5import it.finki.tinki.model.Users.Company;
6import it.finki.tinki.model.Users.User;
7import it.finki.tinki.model.enumerator.AccountType;
8import it.finki.tinki.repository.*;
9import org.springframework.stereotype.Component;
10
11import javax.annotation.PostConstruct;
12import java.util.ArrayList;
13import java.util.List;
14
15@Component
16public 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 List<Skill> lista;
59 lista = skillRepository.findAll();
60
61 userRepository.save(new User("asdf", "asdf", "Zoki", AccountType.USER, "Poki", lista, lista));
62
63 addressRepository.save(new Address("asdf", "asdf", "asdf"));
64 companyRepository.save(new Company("asdf@asdf", "pass", "Co.co", AccountType.COMPANY, addressRepository.findAll().get(0)));
65 }
66
67}
Note: See TracBrowser for help on using the repository browser.