@ -54,8 +54,8 @@ public class APIController {
|
||||
@ApiOperation("Gibt die Gruppe mit der als Parameter mitgegebenden groupId zurück")
|
||||
public Group getGroupFromId(@ApiParam("GruppenId der gefordeten Gruppe") @PathVariable Long groupId) throws EventException {
|
||||
List<Event> eventList = eventService.getEventsOfGroup(groupId);
|
||||
|
||||
List<Group> groups = groupService.projectEventList(eventList);
|
||||
|
||||
return groups.get(0);
|
||||
}
|
||||
|
||||
|
||||
@ -98,14 +98,14 @@ public class Gruppen2Controller {
|
||||
|
||||
@RolesAllowed({"ROLE_orga", "ROLE_actuator)"})
|
||||
@PostMapping("/details/members/addUsersFromCsv")
|
||||
public String addUsersFromCsv(@RequestParam("group_id") Long group_id,
|
||||
public String addUsersFromCsv(@RequestParam("group_id") Long groupId,
|
||||
@RequestParam(value = "file", required = false) MultipartFile file) throws IOException {
|
||||
List<User> userList = new ArrayList<>();
|
||||
if (!file.isEmpty()) {
|
||||
userList = CsvService.read(file.getInputStream());
|
||||
}
|
||||
controllerService.addUserList(userList, group_id);
|
||||
return "redirect:/gruppen2/details/members/" + group_id;
|
||||
controllerService.addUserList(userList, groupId);
|
||||
return "redirect:/gruppen2/details/members/" + groupId;
|
||||
}
|
||||
|
||||
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator)"})
|
||||
@ -117,11 +117,11 @@ public class Gruppen2Controller {
|
||||
|
||||
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator"})
|
||||
@GetMapping("/findGroup")
|
||||
public String findGroup(KeycloakAuthenticationToken token, Model model, @RequestParam(value = "suchbegriff", required = false) String suchbegriff) throws EventException {
|
||||
public String findGroup(KeycloakAuthenticationToken token, Model model, @RequestParam(value = "suchbegriff", required = false) String search) throws EventException {
|
||||
Account account = keyCloakService.createAccountFromPrincipal(token);
|
||||
List<Group> groupse = new ArrayList<>();
|
||||
if (suchbegriff != null) {
|
||||
groupse = groupService.findGroupWith(suchbegriff, account);
|
||||
if (search != null) {
|
||||
groupse = groupService.findGroupWith(search, account);
|
||||
}
|
||||
model.addAttribute("account", keyCloakService.createAccountFromPrincipal(token));
|
||||
model.addAttribute("gruppen", groupse);
|
||||
@ -144,10 +144,10 @@ public class Gruppen2Controller {
|
||||
|
||||
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator)"})
|
||||
@GetMapping("/details/{id}")
|
||||
public String showGroupDetails(KeycloakAuthenticationToken token, Model model, @PathVariable("id") Long id) throws EventException, ResponseStatusException {
|
||||
public String showGroupDetails(KeycloakAuthenticationToken token, Model model, @PathVariable("id") Long groupId) throws EventException, ResponseStatusException {
|
||||
|
||||
model.addAttribute("account", keyCloakService.createAccountFromPrincipal(token));
|
||||
Group group = userService.getGroupById(id);
|
||||
Group group = userService.getGroupById(groupId);
|
||||
Account account = keyCloakService.createAccountFromPrincipal(token);
|
||||
User user = new User(account.getName(), account.getGivenname(), account.getFamilyname(), account.getEmail());
|
||||
if (group != null) {
|
||||
@ -162,23 +162,23 @@ public class Gruppen2Controller {
|
||||
|
||||
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator"})
|
||||
@PostMapping("/detailsBeitreten")
|
||||
public String joinGroup(KeycloakAuthenticationToken token, Model model, @RequestParam("id") Long id) throws EventException {
|
||||
public String joinGroup(KeycloakAuthenticationToken token, Model model, @RequestParam("id") Long groupId) throws EventException {
|
||||
model.addAttribute("account", keyCloakService.createAccountFromPrincipal(token));
|
||||
Account account = keyCloakService.createAccountFromPrincipal(token);
|
||||
User user = new User(account.getName(), account.getGivenname(), account.getFamilyname(), account.getEmail());
|
||||
Group group = userService.getGroupById(id);
|
||||
Group group = userService.getGroupById(groupId);
|
||||
if (group.getMembers().contains(user)) {
|
||||
return "errorRenameLater"; //hier soll eigentlich auf die bereits beigetretene Gruppe weitergeleitet werden
|
||||
}
|
||||
controllerService.addUser(account, id);
|
||||
controllerService.addUser(account, groupId);
|
||||
return "redirect:/gruppen2/";
|
||||
}
|
||||
|
||||
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator"})
|
||||
@GetMapping("/detailsSearch")
|
||||
public String showGroupDetailsNoMember(KeycloakAuthenticationToken token, Model model, @RequestParam("id") Long id) throws EventException {
|
||||
public String showGroupDetailsNoMember(KeycloakAuthenticationToken token, Model model, @RequestParam("id") Long groupId) throws EventException {
|
||||
model.addAttribute("account", keyCloakService.createAccountFromPrincipal(token));
|
||||
Group group = userService.getGroupById(id);
|
||||
Group group = userService.getGroupById(groupId);
|
||||
if (group != null) {
|
||||
model.addAttribute("group", group);
|
||||
return "detailsNoMember";
|
||||
@ -200,18 +200,18 @@ public class Gruppen2Controller {
|
||||
|
||||
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator"})
|
||||
@PostMapping("/leaveGroup")
|
||||
public String pLeaveGroup(KeycloakAuthenticationToken token, @RequestParam("group_id") Long id) throws EventException {
|
||||
public String pLeaveGroup(KeycloakAuthenticationToken token, @RequestParam("group_id") Long groupId) throws EventException {
|
||||
Account account = keyCloakService.createAccountFromPrincipal(token);
|
||||
User user = new User(account.getName(), account.getGivenname(), account.getFamilyname(), account.getEmail());
|
||||
controllerService.deleteUser(user.getUser_id(), id);
|
||||
controllerService.deleteUser(user.getId(), groupId);
|
||||
return "redirect:/gruppen2/";
|
||||
}
|
||||
|
||||
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator)"})
|
||||
@GetMapping("/details/members/{id}")
|
||||
public String editMembers(Model model, KeycloakAuthenticationToken token, @PathVariable("id") Long id) throws EventException {
|
||||
public String editMembers(Model model, KeycloakAuthenticationToken token, @PathVariable("id") Long groupId) throws EventException {
|
||||
Account account = keyCloakService.createAccountFromPrincipal(token);
|
||||
Group group = userService.getGroupById(id);
|
||||
Group group = userService.getGroupById(groupId);
|
||||
if (group.getRoles().get(account.getName()) == Role.ADMIN) {
|
||||
model.addAttribute("account", account);
|
||||
model.addAttribute("members", group.getMembers());
|
||||
@ -225,17 +225,17 @@ public class Gruppen2Controller {
|
||||
|
||||
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator)"})
|
||||
@PostMapping("/details/members/changeRole")
|
||||
public String changeRole(KeycloakAuthenticationToken token, @RequestParam("group_id") Long group_id,
|
||||
@RequestParam("user_id") String user_id) throws EventException {
|
||||
controllerService.updateRole(user_id, group_id);
|
||||
return "redirect:/gruppen2/details/members/" + group_id;
|
||||
public String changeRole(KeycloakAuthenticationToken token, @RequestParam("group_id") Long groupId,
|
||||
@RequestParam("user_id") String userId) throws EventException {
|
||||
controllerService.updateRole(userId, groupId);
|
||||
return "redirect:/gruppen2/details/members/" + groupId;
|
||||
}
|
||||
|
||||
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator)"})
|
||||
@PostMapping("/details/members/deleteUser")
|
||||
public String deleteUser(KeycloakAuthenticationToken token, @RequestParam("group_id") Long group_id,
|
||||
@RequestParam("user_id") String user_id) throws EventException {
|
||||
controllerService.deleteUser(user_id, group_id);
|
||||
return "redirect:/gruppen2/details/members/" + group_id;
|
||||
public String deleteUser(KeycloakAuthenticationToken token, @RequestParam("group_id") Long groupId,
|
||||
@RequestParam("user_id") String userId) throws EventException {
|
||||
controllerService.deleteUser(userId, groupId);
|
||||
return "redirect:/gruppen2/details/members/" + groupId;
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,7 +9,7 @@ import lombok.Getter;
|
||||
@EqualsAndHashCode(exclude = {"givenname", "familyname", "email"})
|
||||
public class User {
|
||||
|
||||
private final String user_id;
|
||||
private final String id;
|
||||
private final String givenname;
|
||||
private final String familyname;
|
||||
private final String email;
|
||||
|
||||
@ -6,7 +6,7 @@ import mops.gruppen2.domain.Group;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Kombiniert den Status und die Gruppenliste zur ausgabe über die API
|
||||
* Kombiniert den Status und die Gruppenliste zur ausgabe über die API.
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
public class GroupRequestWrapper {
|
||||
|
||||
@ -4,6 +4,7 @@ import lombok.Value;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.relational.core.mapping.Table;
|
||||
|
||||
@SuppressWarnings("checkstyle:membername")
|
||||
@Table("invite")
|
||||
@Value
|
||||
public class InviteLinkDTO {
|
||||
|
||||
@ -21,21 +21,22 @@ public class AddUserEvent extends Event {
|
||||
private String familyname;
|
||||
private String email;
|
||||
|
||||
public AddUserEvent(Long group_id, String user_id, String givenname, String familyname, String email) {
|
||||
super(group_id, user_id);
|
||||
public AddUserEvent(Long groupId, String userId, String givenname, String familyname, String email) {
|
||||
super(groupId, userId);
|
||||
this.givenname = givenname;
|
||||
this.familyname = familyname;
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(Group group) throws EventException {
|
||||
User user = new User(this.user_id, this.givenname, this.familyname, this.email);
|
||||
User user = new User(this.userId, this.givenname, this.familyname, this.email);
|
||||
|
||||
if (group.getMembers().contains(user)) {
|
||||
throw new UserAlreadyExistsException("Der User existiert bereits");
|
||||
}
|
||||
|
||||
group.getMembers().add(user);
|
||||
group.getRoles().put(user_id, Role.MEMBER);
|
||||
group.getRoles().put(userId, Role.MEMBER);
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,15 +16,16 @@ public class CreateGroupEvent extends Event {
|
||||
private Long groupParent;
|
||||
private GroupType groupType;
|
||||
|
||||
public CreateGroupEvent(Long group_id, String user_id, Long parent, GroupType type, Visibility visibility) {
|
||||
super(group_id, user_id);
|
||||
public CreateGroupEvent(Long groupId, String userId, Long parent, GroupType type, Visibility visibility) {
|
||||
super(groupId, userId);
|
||||
this.groupParent = parent;
|
||||
this.groupType = type;
|
||||
this.groupVisibility = visibility;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(Group group) {
|
||||
group.setId(this.group_id);
|
||||
group.setId(this.groupId);
|
||||
group.setParent(this.groupParent);
|
||||
group.setType(this.groupType);
|
||||
group.setVisibility(this.groupVisibility);
|
||||
|
||||
@ -8,8 +8,8 @@ import mops.gruppen2.domain.Group;
|
||||
@NoArgsConstructor // For Jackson
|
||||
public class DeleteGroupEvent extends Event {
|
||||
|
||||
public DeleteGroupEvent(long group_id, String user_id) {
|
||||
super(group_id, user_id);
|
||||
public DeleteGroupEvent(Long groupId, String userId) {
|
||||
super(groupId, userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -14,15 +14,16 @@ import mops.gruppen2.domain.exception.UserNotFoundException;
|
||||
@NoArgsConstructor // For Jackson
|
||||
public class DeleteUserEvent extends Event {
|
||||
|
||||
public DeleteUserEvent(Long group_id, String user_id) {
|
||||
super(group_id, user_id);
|
||||
public DeleteUserEvent(Long groupId, String userId) {
|
||||
super(groupId, userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(Group group) throws EventException {
|
||||
for (User user : group.getMembers()) {
|
||||
if (user.getUser_id().equals(this.user_id)) {
|
||||
if (user.getId().equals(this.userId)) {
|
||||
group.getMembers().remove(user);
|
||||
group.getRoles().remove(user.getUser_id());
|
||||
group.getRoles().remove(user.getId());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,8 +27,8 @@ import mops.gruppen2.domain.exception.EventException;
|
||||
@AllArgsConstructor
|
||||
public class Event {
|
||||
|
||||
protected Long group_id;
|
||||
protected String user_id;
|
||||
protected Long groupId;
|
||||
protected String userId;
|
||||
|
||||
public void apply(Group group) throws EventException {}
|
||||
}
|
||||
|
||||
@ -15,11 +15,12 @@ public class UpdateGroupDescriptionEvent extends Event {
|
||||
|
||||
private String newGroupDescription;
|
||||
|
||||
public UpdateGroupDescriptionEvent(Long group_id, String user_id, String newGroupDescription) {
|
||||
super(group_id, user_id);
|
||||
public UpdateGroupDescriptionEvent(Long groupId, String userId, String newGroupDescription) {
|
||||
super(groupId, userId);
|
||||
this.newGroupDescription = newGroupDescription;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(Group group) {
|
||||
group.setDescription(this.newGroupDescription);
|
||||
}
|
||||
|
||||
@ -15,11 +15,12 @@ public class UpdateGroupTitleEvent extends Event {
|
||||
|
||||
private String newGroupTitle;
|
||||
|
||||
public UpdateGroupTitleEvent(Long group_id, String user_id, String newGroupTitle) {
|
||||
super(group_id, user_id);
|
||||
public UpdateGroupTitleEvent(Long groupId, String userId, String newGroupTitle) {
|
||||
super(groupId, userId);
|
||||
this.newGroupTitle = newGroupTitle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(Group group) {
|
||||
group.setTitle(this.newGroupTitle);
|
||||
}
|
||||
|
||||
@ -17,16 +17,17 @@ public class UpdateRoleEvent extends Event {
|
||||
|
||||
private Role newRole;
|
||||
|
||||
public UpdateRoleEvent(Long group_id, String user_id, Role newRole) {
|
||||
super(group_id, user_id);
|
||||
public UpdateRoleEvent(Long groupId, String userId, Role newRole) {
|
||||
super(groupId, userId);
|
||||
this.newRole = newRole;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(Group group) throws UserNotFoundException {
|
||||
if (!group.getRoles().containsKey(user_id)) {
|
||||
if (!group.getRoles().containsKey(userId)) {
|
||||
throw new UserNotFoundException("Der User wurde nicht gefunden");
|
||||
}
|
||||
group.getRoles().put(this.user_id, this.newRole);
|
||||
group.getRoles().put(this.userId, this.newRole);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -12,10 +12,10 @@ import java.util.List;
|
||||
public interface EventRepository extends CrudRepository<EventDTO, Long> {
|
||||
|
||||
@Query("select distinct group_id from event where user_id =:id")
|
||||
List<Long> findGroup_idsWhereUser_id(@Param("id") String user_id);
|
||||
List<Long> findGroup_idsWhereUser_id(@Param("id") String userId);
|
||||
|
||||
@Query("select * from event where group_id =:id")
|
||||
List<EventDTO> findEventDTOByGroup_id(@Param("id") Long group_id);
|
||||
List<EventDTO> findEventDTOByGroup_id(@Param("id") Long groupId);
|
||||
|
||||
//@Query("SELECT * FROM event WHERE event_id > ?#{[0]}")
|
||||
//Iterable<EventDTO> findNewEventSinceStatus(@Param("status") Long status);
|
||||
|
||||
@ -9,7 +9,7 @@ import java.util.List;
|
||||
@Service
|
||||
public class APIFormatterService {
|
||||
|
||||
static public GroupRequestWrapper wrap(Long status, List<Group> groupList) {
|
||||
public static GroupRequestWrapper wrap(Long status, List<Group> groupList) {
|
||||
return new GroupRequestWrapper(status, groupList);
|
||||
}
|
||||
}
|
||||
|
||||
@ -35,91 +35,90 @@ public class ControllerService {
|
||||
|
||||
public void createGroup(Account account, String title, String description, Boolean visibility) throws EventException {
|
||||
Visibility visibility1;
|
||||
Long group_id = eventService.checkGroup();
|
||||
Long groupId = eventService.checkGroup();
|
||||
|
||||
if (visibility) {
|
||||
visibility1 = Visibility.PUBLIC;
|
||||
} else {
|
||||
visibility1 = Visibility.PRIVATE;
|
||||
createInviteLink(group_id);
|
||||
createInviteLink(groupId);
|
||||
}
|
||||
|
||||
CreateGroupEvent createGroupEvent = new CreateGroupEvent(group_id, account.getName(), null, GroupType.SIMPLE, visibility1);
|
||||
CreateGroupEvent createGroupEvent = new CreateGroupEvent(groupId, account.getName(), null, GroupType.SIMPLE, visibility1);
|
||||
eventService.saveEvent(createGroupEvent);
|
||||
User user = new User(account.getName(), account.getGivenname(), account.getFamilyname(), account.getEmail());
|
||||
|
||||
addUser(account, group_id);
|
||||
updateTitle(account, group_id, title);
|
||||
updateDescription(account, group_id, description);
|
||||
updateRole(user.getUser_id(), group_id);
|
||||
addUser(account, groupId);
|
||||
updateTitle(account, groupId, title);
|
||||
updateDescription(account, groupId, description);
|
||||
updateRole(account.getName(), groupId);
|
||||
}
|
||||
|
||||
private void createInviteLink(Long group_id) {
|
||||
inviteLinkRepositoryService.saveInvite(group_id, UUID.randomUUID());
|
||||
private void createInviteLink(Long groupId) {
|
||||
inviteLinkRepositoryService.saveInvite(groupId, UUID.randomUUID());
|
||||
}
|
||||
|
||||
|
||||
public void addUser(Account account, Long group_id) {
|
||||
AddUserEvent addUserEvent = new AddUserEvent(group_id, account.getName(), account.getGivenname(), account.getFamilyname(), account.getEmail());
|
||||
public void addUser(Account account, Long groupId) {
|
||||
AddUserEvent addUserEvent = new AddUserEvent(groupId, account.getName(), account.getGivenname(), account.getFamilyname(), account.getEmail());
|
||||
eventService.saveEvent(addUserEvent);
|
||||
}
|
||||
|
||||
public void addUserList(List<User> users, Long group_id) {
|
||||
public void addUserList(List<User> users, Long groupId) {
|
||||
for (User user : users) {
|
||||
AddUserEvent addUserEvent = new AddUserEvent(group_id, user.getUser_id(), user.getGivenname(), user.getFamilyname(), user.getEmail());
|
||||
AddUserEvent addUserEvent = new AddUserEvent(groupId, user.getId(), user.getGivenname(), user.getFamilyname(), user.getEmail());
|
||||
eventService.saveEvent(addUserEvent);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateTitle(Account account, Long group_id, String title) {
|
||||
UpdateGroupTitleEvent updateGroupTitleEvent = new UpdateGroupTitleEvent(group_id, account.getName(), title);
|
||||
public void updateTitle(Account account, Long groupId, String title) {
|
||||
UpdateGroupTitleEvent updateGroupTitleEvent = new UpdateGroupTitleEvent(groupId, 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);
|
||||
public void updateDescription(Account account, Long groupId, String description) {
|
||||
UpdateGroupDescriptionEvent updateGroupDescriptionEvent = new UpdateGroupDescriptionEvent(groupId, account.getName(), description);
|
||||
eventService.saveEvent(updateGroupDescriptionEvent);
|
||||
}
|
||||
|
||||
public void updateRole(String user_id, Long group_id) throws EventException {
|
||||
public void updateRole(String userId, Long groupId) throws EventException {
|
||||
UpdateRoleEvent updateRoleEvent;
|
||||
Group group = userService.getGroupById(group_id);
|
||||
Group group = userService.getGroupById(groupId);
|
||||
User user = null;
|
||||
for (User member : group.getMembers()) {
|
||||
if (member.getUser_id().equals(user_id)) {
|
||||
if (member.getId().equals(userId)) {
|
||||
user = member;
|
||||
}
|
||||
}
|
||||
assert user != null;
|
||||
if (group.getRoles().get(user.getUser_id()) == Role.ADMIN) {
|
||||
updateRoleEvent = new UpdateRoleEvent(group_id, user.getUser_id(), Role.MEMBER);
|
||||
if (group.getRoles().get(user.getId()) == Role.ADMIN) {
|
||||
updateRoleEvent = new UpdateRoleEvent(groupId, user.getId(), Role.MEMBER);
|
||||
} else {
|
||||
updateRoleEvent = new UpdateRoleEvent(group_id, user.getUser_id(), Role.ADMIN);
|
||||
updateRoleEvent = new UpdateRoleEvent(groupId, user.getId(), Role.ADMIN);
|
||||
}
|
||||
eventService.saveEvent(updateRoleEvent);
|
||||
}
|
||||
|
||||
public void deleteUser(String user_id, Long group_id) throws EventException {
|
||||
Group group = userService.getGroupById(group_id);
|
||||
public void deleteUser(String userId, Long groupId) throws EventException {
|
||||
Group group = userService.getGroupById(groupId);
|
||||
User user = null;
|
||||
for (User member : group.getMembers()) {
|
||||
if (member.getUser_id().equals(user_id)) {
|
||||
if (member.getId().equals(userId)) {
|
||||
user = member;
|
||||
}
|
||||
}
|
||||
assert user != null;
|
||||
DeleteUserEvent deleteUserEvent = new DeleteUserEvent(group_id, user.getUser_id());
|
||||
DeleteUserEvent deleteUserEvent = new DeleteUserEvent(groupId, user.getId());
|
||||
eventService.saveEvent(deleteUserEvent);
|
||||
}
|
||||
|
||||
public void deleteGroupEvent(User user, Long group_id) {
|
||||
DeleteGroupEvent deleteGroupEvent = new DeleteGroupEvent(group_id, user.getUser_id());
|
||||
public void deleteGroupEvent(User user, Long groupId) {
|
||||
DeleteGroupEvent deleteGroupEvent = new DeleteGroupEvent(groupId, user.getId());
|
||||
eventService.saveEvent(deleteGroupEvent);
|
||||
}
|
||||
|
||||
public void createLecture(Account account, String title, String description, Boolean visibility, List<User> users) throws EventException {
|
||||
Visibility visibility1;
|
||||
Long group_id = eventService.checkGroup();
|
||||
Long groupId = eventService.checkGroup();
|
||||
|
||||
if (visibility) {
|
||||
visibility1 = Visibility.PUBLIC;
|
||||
@ -127,13 +126,13 @@ public class ControllerService {
|
||||
visibility1 = Visibility.PRIVATE;
|
||||
}
|
||||
|
||||
CreateGroupEvent createGroupEvent = new CreateGroupEvent(group_id, account.getName(), null, GroupType.LECTURE, visibility1);
|
||||
CreateGroupEvent createGroupEvent = new CreateGroupEvent(groupId, account.getName(), null, GroupType.LECTURE, visibility1);
|
||||
eventService.saveEvent(createGroupEvent);
|
||||
|
||||
addUser(account, group_id);
|
||||
updateTitle(account, group_id, title);
|
||||
updateDescription(account, group_id, description);
|
||||
updateRole(account.getName(), group_id);
|
||||
addUserList(users, group_id);
|
||||
addUser(account, groupId);
|
||||
updateTitle(account, groupId, title);
|
||||
updateDescription(account, groupId, description);
|
||||
updateRole(account.getName(), groupId);
|
||||
addUserList(users, groupId);
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,9 +23,9 @@ public class EventService {
|
||||
}
|
||||
|
||||
/**
|
||||
* sichert ein Event Objekt indem es ein EventDTO Objekt erzeugt
|
||||
* Erzeugt ein DTO aus einem Event und speicher es.
|
||||
*
|
||||
* @param event
|
||||
* @param event Event, welches gespeichert wird
|
||||
*/
|
||||
public void saveEvent(Event event) {
|
||||
EventDTO eventDTO = getDTO(event);
|
||||
@ -36,8 +36,8 @@ public class EventService {
|
||||
* Erzeugt aus einem Event Objekt ein EventDTO Objekt.
|
||||
* Ist die Gruppe öffentlich, dann wird die visibility auf true gesetzt.
|
||||
*
|
||||
* @param event
|
||||
* @return EventDTO
|
||||
* @param event Event, welches in DTO übersetzt wird
|
||||
* @return EventDTO Neues DTO
|
||||
*/
|
||||
public EventDTO getDTO(Event event) {
|
||||
boolean visibility = false;
|
||||
@ -52,14 +52,14 @@ public class EventService {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return new EventDTO(null, event.getGroup_id(), event.getUser_id(), payload, visibility);
|
||||
return new EventDTO(null, event.getGroupId(), event.getUserId(), payload, visibility);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gibt die nächst höhere groupID zurück die belegt werden kann.
|
||||
* Gibt 1 zurück, falls keine Gruppe vorhanden ist.
|
||||
*
|
||||
* @return Gibt Long zurück
|
||||
* @return Long GruppenId
|
||||
*/
|
||||
public Long checkGroup() {
|
||||
Long maxGroupID = eventStore.getMaxGroupID();
|
||||
@ -70,10 +70,10 @@ public class EventService {
|
||||
}
|
||||
|
||||
/**
|
||||
* Findet alle Events welche ab dem neuen Status hinzugekommen sind
|
||||
* Findet alle Events welche ab dem neuen Status hinzugekommen sind.
|
||||
*
|
||||
* @param status
|
||||
* @return Liste von Events
|
||||
* @param status Die Id des zuletzt gespeicherten Events
|
||||
* @return Liste von neueren Events
|
||||
*/
|
||||
public List<Event> getNewEvents(Long status) {
|
||||
List<Long> groupIdsThatChanged = eventStore.findNewEventSinceStatus(status);
|
||||
@ -83,9 +83,9 @@ public class EventService {
|
||||
}
|
||||
|
||||
/**
|
||||
* Erzeugt aus einer Liste von eventDTOs eine Liste von Events
|
||||
* Erzeugt aus einer Liste von eventDTOs eine Liste von Events.
|
||||
*
|
||||
* @param eventDTOS
|
||||
* @param eventDTOS Liste von DTOs
|
||||
* @return Liste von Events
|
||||
*/
|
||||
public List<Event> translateEventDTOs(Iterable<EventDTO> eventDTOS) {
|
||||
@ -102,12 +102,12 @@ public class EventService {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sichert eine Liste von Event Objekten mithilfe der Methode saveEvent(Event event)
|
||||
* Sichert eine Liste von Event Objekten mithilfe der Methode saveEvent(Event event).
|
||||
*
|
||||
* @param createGroupEvents Liste von Event Objekten
|
||||
* @param eventList Liste von Event Objekten
|
||||
*/
|
||||
public void saveEventList(List<Event> createGroupEvents) {
|
||||
for (Event event : createGroupEvents) {
|
||||
public void saveEventList(List<Event> eventList) {
|
||||
for (Event event : eventList) {
|
||||
saveEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
@ -28,13 +28,13 @@ public class GroupService {
|
||||
* Sucht in der DB alle Zeilen raus welche eine der Gruppen_ids hat.
|
||||
* Wandelt die Zeilen in Events um und gibt davon eine Liste zurück.
|
||||
*
|
||||
* @param group_ids
|
||||
* @return
|
||||
* @param groupIds Liste an IDs
|
||||
* @return Liste an Events
|
||||
*/
|
||||
public List<Event> getGroupEvents(List<Long> group_ids) {
|
||||
public List<Event> getGroupEvents(List<Long> groupIds) {
|
||||
List<EventDTO> eventDTOS = new ArrayList<>();
|
||||
for (Long group_id : group_ids) {
|
||||
eventDTOS.addAll(eventRepository.findEventDTOByGroup_id(group_id));
|
||||
for (Long groupId : groupIds) {
|
||||
eventDTOS.addAll(eventRepository.findEventDTOByGroup_id(groupId));
|
||||
}
|
||||
return eventService.translateEventDTOs(eventDTOS);
|
||||
}
|
||||
@ -43,67 +43,58 @@ public class GroupService {
|
||||
* Erzeugt eine neue Map wo Gruppen aus den Events erzeugt und den Gruppen_ids zugeordnet werden.
|
||||
* Die Gruppen werden als Liste zurückgegeben
|
||||
*
|
||||
* @param events
|
||||
* @return
|
||||
* @throws EventException
|
||||
* @param events Liste an Events
|
||||
* @return Liste an Projizierten Gruppen
|
||||
* @throws EventException Projektionsfehler
|
||||
*/
|
||||
public List<Group> projectEventList(List<Event> events) throws EventException {
|
||||
Map<Long, Group> groupMap = new HashMap<>();
|
||||
|
||||
for (Event event : events) {
|
||||
Group group = getOrCreateGroup(groupMap, event.getGroup_id());
|
||||
Group group = getOrCreateGroup(groupMap, event.getGroupId());
|
||||
event.apply(group);
|
||||
}
|
||||
|
||||
return new ArrayList<>(groupMap.values());
|
||||
}
|
||||
|
||||
/**
|
||||
* guckt in der Map anhand der Id nach ob die Gruppe schon in der Map vorhanden ist, wenn nicht wird eine neue
|
||||
* Gruppe erzeugt
|
||||
*
|
||||
* @param groups
|
||||
* @param group_id
|
||||
* @return
|
||||
*/
|
||||
private Group getOrCreateGroup(Map<Long, Group> groups, long group_id) {
|
||||
if (!groups.containsKey(group_id)) {
|
||||
groups.put(group_id, new Group());
|
||||
private Group getOrCreateGroup(Map<Long, Group> groups, long groupId) {
|
||||
if (!groups.containsKey(groupId)) {
|
||||
groups.put(groupId, new Group());
|
||||
}
|
||||
|
||||
return groups.get(group_id);
|
||||
return groups.get(groupId);
|
||||
}
|
||||
|
||||
private List<Long> removeUserGroups(List<Long> group_ids, List<Long> user_groups) {
|
||||
for (Long group_id : user_groups) {
|
||||
group_ids.remove(group_id);
|
||||
private List<Long> removeUserGroups(List<Long> groupIds, List<Long> userGroups) {
|
||||
for (Long groupId : userGroups) {
|
||||
groupIds.remove(groupId);
|
||||
}
|
||||
return group_ids;
|
||||
return groupIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* sucht alle Zeilen in der DB wo die Visibility true ist und entfernt alle Gruppen des Users.
|
||||
* Erstellt eine Liste aus Gruppen.
|
||||
* Sucht alle Zeilen in der DB mit visibility=true.
|
||||
* Erstellt eine Liste aus öffentlichen Gruppen (ohen bereits beigetretenen Gruppen).
|
||||
*
|
||||
* @return
|
||||
* @throws EventException
|
||||
* @return Liste von projizierten Gruppen
|
||||
* @throws EventException Projektionsfehler
|
||||
*/
|
||||
public List<Group> getAllGroupWithVisibilityPublic(String user_id) throws EventException {
|
||||
List<Long> group_ids = removeUserGroups(eventRepository.findGroup_idsWhereVisibility(Boolean.TRUE), eventRepository.findGroup_idsWhereUser_id(user_id));
|
||||
List<EventDTO> eventDTOS = eventRepository.findAllEventsOfGroups(group_ids);
|
||||
public List<Group> getAllGroupWithVisibilityPublic(String userId) throws EventException {
|
||||
List<Long> groupIds = removeUserGroups(eventRepository.findGroup_idsWhereVisibility(Boolean.TRUE), eventRepository.findGroup_idsWhereUser_id(userId));
|
||||
List<EventDTO> eventDTOS = eventRepository.findAllEventsOfGroups(groupIds);
|
||||
List<Event> events = eventService.translateEventDTOs(eventDTOS);
|
||||
List<Group> groups = projectEventList(events);
|
||||
return groups;
|
||||
return projectEventList(events);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Filtert alle öffentliche Gruppen nach dem suchbegriff und gibt diese als Liste von Gruppen zurück.
|
||||
* Groß und kleinschreibung wird beachtet.
|
||||
* Filtert alle öffentliche Gruppen nach dem Suchbegriff und gibt diese als Liste von Gruppen zurück.
|
||||
* Groß und Kleinschreibung wird nicht beachtet.
|
||||
*
|
||||
* @param search
|
||||
* @return
|
||||
* @throws EventException
|
||||
* @param search Der Suchstring
|
||||
* @return Liste von projizierten Gruppen
|
||||
* @throws EventException Projektionsfehler
|
||||
*/
|
||||
public List<Group> findGroupWith(String search, Account account) throws EventException {
|
||||
List<Group> groups = new ArrayList<>();
|
||||
|
||||
@ -19,8 +19,8 @@ public class InviteLinkRepositoryService {
|
||||
return inviteLinkRepository.findGroupIdByLink(link);
|
||||
}
|
||||
|
||||
public void saveInvite(Long group_id, UUID link) {
|
||||
inviteLinkRepository.save(new InviteLinkDTO(null, group_id, link.toString()));
|
||||
public void saveInvite(Long groupId, UUID link) {
|
||||
inviteLinkRepository.save(new InviteLinkDTO(null, groupId, link.toString()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -16,7 +16,7 @@ public class JsonService {
|
||||
*
|
||||
* @param event Java-Event-Repräsentation
|
||||
* @return JSON-Event-Payload als String
|
||||
* @throws JsonProcessingException
|
||||
* @throws JsonProcessingException Bei JSON Fehler
|
||||
*/
|
||||
|
||||
public String serializeEvent(Event event) throws JsonProcessingException {
|
||||
@ -29,7 +29,7 @@ public class JsonService {
|
||||
*
|
||||
* @param json JSON-Event-Payload als String
|
||||
* @return Java-Event-Repräsentation
|
||||
* @throws JsonProcessingException
|
||||
* @throws JsonProcessingException Bei JSON Fehler
|
||||
*/
|
||||
public Event deserializeEvent(String json) throws JsonProcessingException {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
@ -25,8 +25,8 @@ public class UserService {
|
||||
//Test nötig??
|
||||
|
||||
public List<Group> getUserGroups(User user) throws EventException {
|
||||
List<Long> group_ids = eventRepository.findGroup_idsWhereUser_id(user.getUser_id());
|
||||
List<Event> events = groupService.getGroupEvents(group_ids);
|
||||
List<Long> groupIds = eventRepository.findGroup_idsWhereUser_id(user.getId());
|
||||
List<Event> events = groupService.getGroupEvents(groupIds);
|
||||
List<Group> groups = groupService.projectEventList(events);
|
||||
List<Group> newGroups = new ArrayList<>();
|
||||
for (Group group : groups) {
|
||||
@ -37,10 +37,10 @@ public class UserService {
|
||||
return newGroups;
|
||||
}
|
||||
|
||||
public Group getGroupById(Long group_id) throws EventException {
|
||||
List<Long> group_ids = new ArrayList<>();
|
||||
group_ids.add(group_id);
|
||||
List<Event> events = groupService.getGroupEvents(group_ids);
|
||||
public Group getGroupById(Long groupId) throws EventException {
|
||||
List<Long> groupIds = new ArrayList<>();
|
||||
groupIds.add(groupId);
|
||||
List<Event> events = groupService.getGroupEvents(groupIds);
|
||||
return groupService.projectEventList(events).get(0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org"
|
||||
th:replace="~{mopslayout :: html(name='Gruppenbildung', headcontent=~{:: headcontent}, navigation=~{:: navigation}, bodycontent=~{:: bodycontent})}">
|
||||
<html lang="en"
|
||||
th:replace="~{mopslayout :: html(name='Gruppenbildung', headcontent=~{:: headcontent}, navigation=~{:: navigation}, bodycontent=~{:: bodycontent})}"
|
||||
xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Gruppendetails</title>
|
||||
@ -13,16 +14,16 @@
|
||||
<nav class="navigation navigation-secondary" is="mops-navigation" th:fragment="navigation">
|
||||
<ul>
|
||||
<li class="active">
|
||||
<a th:href="@{/gruppen2}" href="/">Gruppen</a>
|
||||
<a href="/" th:href="@{/gruppen2}">Gruppen</a>
|
||||
</li>
|
||||
<li>
|
||||
<a th:href="@{/gruppen2/createGroup}" href="/createGroup">Erstellen</a>
|
||||
<a href="/createGroup" th:href="@{/gruppen2/createGroup}">Erstellen</a>
|
||||
</li>
|
||||
<li>
|
||||
<a th:href="@{/gruppen2/findGroup}" href="/findGroup">Suche</a>
|
||||
<a href="/findGroup" th:href="@{/gruppen2/findGroup}">Suche</a>
|
||||
</li>
|
||||
<li th:if="${account.getRoles().contains('orga')}">
|
||||
<a th:href="@{/gruppen2/createLecture}" href="/createLecture">Veranstaltung</a>
|
||||
<a href="/createLecture" th:href="@{/gruppen2/createLecture}">Veranstaltung</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
@ -46,12 +47,12 @@
|
||||
<p style="overflow-wrap: break-word" th:text="${group.getDescription()}"></p>
|
||||
</div>
|
||||
<br>
|
||||
<div class="text-right btn-toolbar" style="float: right" role="toolbar">
|
||||
<div class="text-right btn-toolbar" role="toolbar" style="float: right">
|
||||
<button class="btn btn-primary"
|
||||
style="background: dodgerblue; border: none; margin: 5px">
|
||||
<a th:href="@{/gruppen2}" style="color: white">Zurück</a>
|
||||
<a style="color: white" th:href="@{/gruppen2}">Zurück</a>
|
||||
</button>
|
||||
<form method="post" action="/gruppen2/leaveGroup">
|
||||
<form action="/gruppen2/leaveGroup" method="post">
|
||||
<button class="btn btn-danger" style="border-style: none; margin: 5px"
|
||||
th:name="group_id" th:value="${group.getId()}"
|
||||
type="submit">Gruppe verlassen
|
||||
@ -62,7 +63,7 @@
|
||||
<div class="col-3" style="white-space: nowrap">
|
||||
<div style="display: inline-block; margin: 0">
|
||||
<h2>Mitglieder</h2>
|
||||
<div th:if='${group.getRoles().get(user.getUser_id()) == admin}'>
|
||||
<div th:if="${group.getRoles().get(user.getId()) == admin}">
|
||||
<form method="get"
|
||||
th:action="@{/gruppen2/details/members/{id}(id=${group.getId()})}">
|
||||
<button class="btn btn-secondary"
|
||||
|
||||
Reference in New Issue
Block a user