1

change createGroup Methode in ControllerService

This commit is contained in:
tomvahl
2020-03-17 11:09:27 +01:00
parent 1b8fa04826
commit 8387b58e35

View File

@ -29,36 +29,40 @@ public class ControllerService {
*/ */
public void createGroup(Account account, String title, String description, Boolean visibility) { public void createGroup(Account account, String title, String description, Boolean visibility) {
Visibility visibility1; Visibility visibility1;
Long group_id = eventService.checkGroup();
if (visibility){ if (visibility){
visibility1 = Visibility.PUBLIC; visibility1 = Visibility.PUBLIC;
}else{ }else{
visibility1 = Visibility.PRIVATE; visibility1 = Visibility.PRIVATE;
} }
List<Event> eventList = new ArrayList<>();
Group group = new Group(); CreateGroupEvent createGroupEvent = new CreateGroupEvent(group_id, account.getName(), null , GroupType.LECTURE, visibility1);
//Erstellen der Events eventService.saveEvent(createGroupEvent);
CreateGroupEvent createGroupEvent = new CreateGroupEvent(eventService.checkGroup(), account.getName(), null , GroupType.LECTURE, visibility1);
AddUserEvent addUserEvent = new AddUserEvent(eventService.checkGroup(),account.getName(),account.getGivenname(),account.getFamilyname(),account.getEmail()); addUser(account, group_id);
UpdateGroupTitleEvent updateGroupTitleEvent = new UpdateGroupTitleEvent(eventService.checkGroup(),account.getName(),title); updateTitle(account, group_id, title);
UpdateGroupDescriptionEvent updateGroupDescriptionEvent = new UpdateGroupDescriptionEvent(eventService.checkGroup(),account.getName(),description); updateDescription(account, group_id, description);
UpdateRoleEvent updateRoleEvent = new UpdateRoleEvent(eventService.checkGroup(),account.getName(),Role.ADMIN); updateRole(account, group_id);
//Gruppe erzeugen aber eigentlich unnötig?
createGroupEvent.apply(group);
addUserEvent.apply(group);
updateGroupTitleEvent.apply(group);
updateGroupDescriptionEvent.apply(group);
updateRoleEvent.apply(group);
//Speichern in DB
eventList.add(createGroupEvent);
eventList.add(addUserEvent);
eventList.add(updateGroupTitleEvent);
eventList.add(updateGroupDescriptionEvent);
eventList.add(updateRoleEvent);
eventService.saveEventList(eventList);
} }
/*public void addUser(Account account, Group group){ public void addUser(Account account, Long group_id){
AddUserEvent addUserEvent = new AddUserEvent(eventService.checkGroup(),group.getId(),account.getName(),account.getGivenname(),account.getFamilyname(),account.getEmail()); AddUserEvent addUserEvent = new AddUserEvent(group_id,account.getName(),account.getGivenname(),account.getFamilyname(),account.getEmail());
eventService.saveEvent(addUserEvent); eventService.saveEvent(addUserEvent);
}*/ }
public void updateTitle(Account account, Long group_id, String title){
UpdateGroupTitleEvent updateGroupTitleEvent = new UpdateGroupTitleEvent(group_id,account.getName(),title);
eventService.saveEvent(updateGroupTitleEvent);
}
public void updateDescription(Account account, Long group_id, String description){
UpdateGroupDescriptionEvent updateGroupDescriptionEvent = new UpdateGroupDescriptionEvent(group_id,account.getName(),description);
eventService.saveEvent(updateGroupDescriptionEvent);
}
public void updateRole(Account account,Long group_id){
UpdateRoleEvent updateRoleEvent = new UpdateRoleEvent(group_id,account.getName(),Role.ADMIN);
eventService.saveEvent(updateRoleEvent);
}
} }