Advertisement
Guest User

Untitled

a guest
Aug 26th, 2018
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.37 KB | None | 0 0
  1. ``` public void init(){
  2.  
  3. Role role0 = new Role("USER");
  4. Role role1 = new Role("ADMIN");
  5. Role role2 = new Role("TEACHER");
  6. Role role3 = new Role("SPONSOR");
  7. Role role4 = new Role("OWNER");
  8. Role role5 = new Role("MENTOR");
  9. Role role6 = new Role("MODERATOR");
  10. Role role7 = new Role("KID");
  11.  
  12. roleService.addRole(role0);
  13. roleService.addRole(role1);
  14. roleService.addRole(role2);
  15. roleService.addRole(role3);
  16. roleService.addRole(role4);
  17. roleService.addRole(role5);
  18. roleService.addRole(role6);
  19. roleService.addRole(role7);
  20.  
  21. Role roleUser = roleService.getByName("USER");
  22. Role roleAdmin = roleService.getByName("ADMIN");
  23. Role roleTeacher = roleService.getByName("TEACHER");
  24. Role roleSponsor = roleService.getByName("SPONSOR");
  25. Role roleOwner = roleService.getByName("OWNER");
  26. Role roleMentor = roleService.getByName("MENTOR");
  27. Role roleModerator = roleService.getByName("MODERATOR");
  28. Role roleKid = roleService.getByName("KID");
  29.  
  30. List<Role> roles = new ArrayList<>();
  31. Collections.addAll(roles, roleAdmin, roleTeacher, roleSponsor, roleOwner,
  32. roleMentor, roleModerator, roleKid, roleUser);
  33. List<Role> kidRoles = new ArrayList<>(Arrays.asList(roleUser, roleKid, roleSponsor));
  34. List<Role> teacherRoles = new ArrayList<>(Arrays.asList(roleUser, roleTeacher, roleSponsor));
  35. List<Role> mentorRoles = new ArrayList<>(Arrays.asList(roleUser, roleMentor, roleSponsor));
  36.  
  37. User user1 = new User("Ivan","Ivanov","Ivanovich","qwer","1234",
  38. roles, 23, "MALE","23-12-34","admin@mail.ru","RUSSIA","house 8");
  39.  
  40. User user2 = new User("Vovan","Vovanov","Huevich","user2","qwer",
  41. roles,28, "MALE","23-12-34","user@mail.ru","Ukraine","house 15");
  42.  
  43. User kidUser1 = new User("Kid","Kid","Kid","kid","qwer",
  44. kidRoles,28, "MALE","23-12-34","Kid@mail.ru","RUSSIA","house 15");
  45.  
  46. User kidUser2 = new User("Kid2","Kid2","Kid2","kid2","qwer2",
  47. kidRoles,32, "MALE","23-12-34","Kid2@mail.ru","RUSSIA","house 15");
  48.  
  49.  
  50. User teacherUser1 = new User("Teacher","Teacher","Teacher","teacher","qwer",
  51. teacherRoles,28, "MALE","23-12-34","Teacher@mail.ru","RUSSIA","house 15");
  52.  
  53. User teacherUser2 = new User("Teacher2","Teacher2","Teacher","teacher2","qwer",
  54. teacherRoles,28, "MALE","23-12-34","Teacher@mail.ru","RUSSIA","house 15");
  55.  
  56. User mentorUser = new User("Mentor","Mentor","Mentor","mentor","qwer",
  57. mentorRoles,28, "MALE","23-12-34","Mentor@mail.ru","RUSSIA","house 15");
  58.  
  59.  
  60. user1 = userService.addUser(user1);
  61. user2 = userService.addUser(user2);
  62. kidUser1 = userService.addUser(kidUser1);
  63. kidUser2 = userService.addUser(kidUser2);
  64. teacherUser1 = userService.addUser(teacherUser1);
  65. teacherUser2 = userService.addUser(teacherUser2);
  66. mentorUser = userService.addUser(mentorUser);
  67.  
  68. Tag tag1 = tagService.addTag(new Tag("Программирование", new HashSet<>()));
  69. Tag tag2 = tagService.addTag(new Tag("Фронтенд", new HashSet<>()));
  70. Tag tag3 = tagService.addTag(new Tag("Бэкаенд", new HashSet<>()));
  71.  
  72. Account acc1 = new Account(1500L, 500L);
  73. Account acc2 = new Account(2500L, 0L);
  74. Account acc3 = new Account(4000L, 0L);
  75. Account acc4 = new Account(5000L, 0L);
  76.  
  77. acc1 = accountService.addAccount(acc1);
  78. acc2 = accountService.addAccount(acc2);
  79. acc3 = accountService.addAccount(acc3);
  80. acc4 = accountService.addAccount(acc4);
  81.  
  82. Organization org1 = new Organization("Name1","adress1","Мавродия", "mak@l2ff.ru", 8944,LocalDateTime.now(), acc1);
  83. Organization org2 = new Organization("Name2","adress2","Мавродия", "mak@lf4f.ru", 8944,LocalDateTime.now(), acc2);
  84. Organization org3 = new Organization("Name3","adress3","Мавродия", "mak@lf5f.ru", 8944,LocalDateTime.now(), acc3);
  85. Organization org4 = new Organization("Name4","adress4","Мавродия", "mak@lf6f.ru", 8944,LocalDateTime.now(), acc4);
  86.  
  87. org1 = organizationService.addOrganization(org1);
  88. org2 = organizationService.addOrganization(org2);
  89. org3 = organizationService.addOrganization(org3);
  90. org4 = organizationService.addOrganization(org4);
  91.  
  92. Owner owner1 = new Owner(null, user1);
  93. Owner owner2 = new Owner(null, user2);
  94.  
  95. ownerService.addOwner(owner1);
  96. ownerService.addOwner(owner2);
  97.  
  98.  
  99. Job job1 = jobService.addJob(new Job("Java", "Топовый язык"));
  100. Job job2 = jobService.addJob(new Job("JavaScript", "Какашка"));
  101.  
  102. Kid kid1 = kidService.addKid(new Kid(kidUser1, new HashSet<>(Collections.singletonList(job1))));
  103. Kid kid2 = kidService.addKid(new Kid(kidUser2, new HashSet<>(Collections.singletonList(job2))));
  104.  
  105. Teacher teacher1 = teacherService.addTeacher(new Teacher(teacherUser1, new HashSet<>(Collections.singletonList(job1))));
  106. Teacher teacher2 = teacherService.addTeacher(new Teacher(teacherUser2, new HashSet<>(Collections.singletonList(job2))));
  107.  
  108. Mentor mentor1 = mentorService.addMentor(new Mentor(mentorUser, new HashSet<>(Collections.singletonList(job1)), 3, "Description"));
  109. Mentor mentor2 = mentorService.addMentor(new Mentor(mentorUser, new HashSet<>(Collections.singletonList(job2)), 7, "Pergription"));
  110.  
  111. Request request1 = new Request("Заявка на обучение", job1, new HashSet<>(Collections.singletonList(kid1)), new HashSet<>(Collections.singletonList(teacher1)),
  112. 1500L, new HashSet<>(Collections.singletonList(user1)), mentor1, acc1, owner1, Request.RequestStatus.IN_PROGRESS);
  113.  
  114. Request request2 = new Request("Хочет учиться", job2, new HashSet<>(Collections.singletonList(kid2)), new HashSet<>(Collections.singletonList(teacher2)),
  115. 2000L, new HashSet<>(Collections.singletonList(user2)), mentor2, acc2, owner2, Request.RequestStatus.IN_PROGRESS);
  116.  
  117. requestService.addRequest(request1);
  118. requestService.addRequest(request2);
  119.  
  120.  
  121. jobService.updateJob(job1);
  122. jobService.updateJob(job2);
  123. }
  124. }```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement