muss ich neu machen
This commit is contained in:
@ -10,6 +10,8 @@ import mops.gruppen2.domain.exception.UserAlreadyExistsException;
|
||||
import mops.gruppen2.domain.model.group.Group;
|
||||
import mops.gruppen2.domain.model.group.User;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Fügt einen einzelnen Nutzer einer Gruppe hinzu.
|
||||
*/
|
||||
@ -21,8 +23,8 @@ public class AddMemberEvent extends Event {
|
||||
@JsonProperty("user")
|
||||
User user;
|
||||
|
||||
public AddMemberEvent(Group group, String exec, String target, User user) throws IdMismatchException {
|
||||
super(group.getId(), exec, target);
|
||||
public AddMemberEvent(UUID groupId, String exec, String target, User user) throws IdMismatchException {
|
||||
super(groupId, exec, target);
|
||||
this.user = user;
|
||||
|
||||
if (!target.equals(user.getId())) {
|
||||
|
||||
@ -6,13 +6,15 @@ import lombok.extern.log4j.Log4j2;
|
||||
import mops.gruppen2.domain.exception.NoAccessException;
|
||||
import mops.gruppen2.domain.model.group.Group;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Log4j2
|
||||
@Value
|
||||
@AllArgsConstructor
|
||||
public class DestroyGroupEvent extends Event {
|
||||
|
||||
public DestroyGroupEvent(Group group, String exec) {
|
||||
super(group.getId(), exec, null);
|
||||
public DestroyGroupEvent(UUID groupId, String exec) {
|
||||
super(groupId, exec, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -7,6 +7,8 @@ import mops.gruppen2.domain.exception.LastAdminException;
|
||||
import mops.gruppen2.domain.exception.UserNotFoundException;
|
||||
import mops.gruppen2.domain.model.group.Group;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Entfernt ein einzelnes Mitglied einer Gruppe.
|
||||
*/
|
||||
@ -15,8 +17,8 @@ import mops.gruppen2.domain.model.group.Group;
|
||||
@AllArgsConstructor
|
||||
public class KickMemberEvent extends Event {
|
||||
|
||||
public KickMemberEvent(Group group, String exec, String target) {
|
||||
super(group.getId(), exec, target);
|
||||
public KickMemberEvent(UUID groupId, String exec, String target) {
|
||||
super(groupId, exec, target);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -9,6 +9,7 @@ import mops.gruppen2.domain.model.group.Group;
|
||||
import mops.gruppen2.domain.model.group.wrapper.Description;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Ändert nur die Gruppenbeschreibung.
|
||||
@ -21,8 +22,8 @@ public class SetDescriptionEvent extends Event {
|
||||
@JsonProperty("desc")
|
||||
Description description;
|
||||
|
||||
public SetDescriptionEvent(Group group, String exec, @Valid Description description) {
|
||||
super(group.getId(), exec, null);
|
||||
public SetDescriptionEvent(UUID groupId, String exec, @Valid Description description) {
|
||||
super(groupId, exec, null);
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
|
||||
@ -9,6 +9,7 @@ import mops.gruppen2.domain.model.group.Group;
|
||||
import mops.gruppen2.domain.model.group.wrapper.Link;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.UUID;
|
||||
|
||||
@Log4j2
|
||||
@Value
|
||||
@ -18,8 +19,8 @@ public class SetInviteLinkEvent extends Event {
|
||||
@JsonProperty("link")
|
||||
Link link;
|
||||
|
||||
public SetInviteLinkEvent(Group group, String exec, @Valid Link link) {
|
||||
super(group.getId(), exec, null);
|
||||
public SetInviteLinkEvent(UUID groupId, String exec, @Valid Link link) {
|
||||
super(groupId, exec, null);
|
||||
this.link = link;
|
||||
}
|
||||
|
||||
|
||||
@ -10,6 +10,7 @@ import mops.gruppen2.domain.model.group.Group;
|
||||
import mops.gruppen2.domain.model.group.wrapper.Limit;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.UUID;
|
||||
|
||||
@Log4j2
|
||||
@Value
|
||||
@ -19,8 +20,8 @@ public class SetLimitEvent extends Event {
|
||||
@JsonProperty("limit")
|
||||
Limit limit;
|
||||
|
||||
public SetLimitEvent(Group group, String exec, @Valid Limit limit) {
|
||||
super(group.getId(), exec, null);
|
||||
public SetLimitEvent(UUID groupId, String exec, @Valid Limit limit) {
|
||||
super(groupId, exec, null);
|
||||
this.limit = limit;
|
||||
}
|
||||
|
||||
|
||||
@ -9,6 +9,7 @@ import mops.gruppen2.domain.model.group.Group;
|
||||
import mops.gruppen2.domain.model.group.wrapper.Parent;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.UUID;
|
||||
|
||||
@Log4j2
|
||||
@Value
|
||||
@ -18,8 +19,8 @@ public class SetParentEvent extends Event {
|
||||
@JsonProperty("parent")
|
||||
Parent parent;
|
||||
|
||||
public SetParentEvent(Group group, String exec, @Valid Parent parent) {
|
||||
super(group.getId(), exec, null);
|
||||
public SetParentEvent(UUID groupId, String exec, @Valid Parent parent) {
|
||||
super(groupId, exec, null);
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
|
||||
@ -9,6 +9,7 @@ import mops.gruppen2.domain.model.group.Group;
|
||||
import mops.gruppen2.domain.model.group.wrapper.Title;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Ändert nur den Gruppentitel.
|
||||
@ -21,8 +22,8 @@ public class SetTitleEvent extends Event {
|
||||
@JsonProperty("title")
|
||||
Title title;
|
||||
|
||||
public SetTitleEvent(Group group, String exec, @Valid Title title) {
|
||||
super(group.getId(), exec, null);
|
||||
public SetTitleEvent(UUID groupId, String exec, @Valid Title title) {
|
||||
super(groupId, exec, null);
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
|
||||
@ -9,6 +9,7 @@ import mops.gruppen2.domain.model.group.Group;
|
||||
import mops.gruppen2.domain.model.group.Type;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.UUID;
|
||||
|
||||
@Log4j2
|
||||
@Value
|
||||
@ -18,8 +19,8 @@ public class SetTypeEvent extends Event {
|
||||
@JsonProperty("type")
|
||||
Type type;
|
||||
|
||||
public SetTypeEvent(Group group, String exec, @Valid Type type) {
|
||||
super(group.getId(), exec, null);
|
||||
public SetTypeEvent(UUID groupId, String exec, @Valid Type type) {
|
||||
super(groupId, exec, null);
|
||||
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@ -9,6 +9,8 @@ import mops.gruppen2.domain.exception.UserNotFoundException;
|
||||
import mops.gruppen2.domain.model.group.Group;
|
||||
import mops.gruppen2.domain.model.group.Role;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Aktualisiert die Gruppenrolle eines Teilnehmers.
|
||||
*/
|
||||
@ -20,8 +22,8 @@ public class UpdateRoleEvent extends Event {
|
||||
@JsonProperty("role")
|
||||
Role role;
|
||||
|
||||
public UpdateRoleEvent(Group group, String exec, String target, Role role) {
|
||||
super(group.getId(), exec, target);
|
||||
public UpdateRoleEvent(UUID groupId, String exec, String target, Role role) {
|
||||
super(groupId, exec, target);
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
|
||||
@ -161,7 +161,7 @@ public class GroupService {
|
||||
* Prüft, ob der Nutzer schon Mitglied ist und ob Gruppe voll ist.
|
||||
*/
|
||||
public void addMember(Group group, String exec, String target, User user) {
|
||||
applyAndSave(group, new AddMemberEvent(group, exec, target, user));
|
||||
applyAndSave(group, new AddMemberEvent(group.getId(), exec, target, user));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -169,7 +169,7 @@ public class GroupService {
|
||||
* Prüft, ob der Nutzer Mitglied ist und ob er der letzte Admin ist.
|
||||
*/
|
||||
public void kickMember(Group group, String exec, String target) {
|
||||
applyAndSave(group, new KickMemberEvent(group, exec, target));
|
||||
applyAndSave(group, new KickMemberEvent(group.getId(), exec, target));
|
||||
|
||||
if (ValidationHelper.checkIfGroupEmpty(group)) {
|
||||
deleteGroup(group, exec);
|
||||
@ -185,7 +185,7 @@ public class GroupService {
|
||||
return;
|
||||
}
|
||||
|
||||
applyAndSave(group, new DestroyGroupEvent(group, exec));
|
||||
applyAndSave(group, new DestroyGroupEvent(group.getId(), exec));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -198,7 +198,7 @@ public class GroupService {
|
||||
return;
|
||||
}
|
||||
|
||||
applyAndSave(group, new SetTitleEvent(group, exec, title));
|
||||
applyAndSave(group, new SetTitleEvent(group.getId(), exec, title));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -211,7 +211,7 @@ public class GroupService {
|
||||
return;
|
||||
}
|
||||
|
||||
applyAndSave(group, new SetDescriptionEvent(group, exec, description));
|
||||
applyAndSave(group, new SetDescriptionEvent(group.getId(), exec, description));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -224,7 +224,7 @@ public class GroupService {
|
||||
return;
|
||||
}
|
||||
|
||||
applyAndSave(group, new UpdateRoleEvent(group, exec, target, role));
|
||||
applyAndSave(group, new UpdateRoleEvent(group.getId(), exec, target, role));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -237,7 +237,7 @@ public class GroupService {
|
||||
return;
|
||||
}
|
||||
|
||||
applyAndSave(group, new SetLimitEvent(group, exec, userLimit));
|
||||
applyAndSave(group, new SetLimitEvent(group.getId(), exec, userLimit));
|
||||
}
|
||||
|
||||
public void setParent(Group group, String exec, Parent parent) {
|
||||
@ -245,7 +245,7 @@ public class GroupService {
|
||||
return;
|
||||
}
|
||||
|
||||
applyAndSave(group, new SetParentEvent(group, exec, parent));
|
||||
applyAndSave(group, new SetParentEvent(group.getId(), exec, parent));
|
||||
}
|
||||
|
||||
public void setLink(Group group, String exec, Link link) {
|
||||
@ -253,7 +253,7 @@ public class GroupService {
|
||||
return;
|
||||
}
|
||||
|
||||
applyAndSave(group, new SetInviteLinkEvent(group, exec, link));
|
||||
applyAndSave(group, new SetInviteLinkEvent(group.getId(), exec, link));
|
||||
}
|
||||
|
||||
private void setType(Group group, String exec, Type type) {
|
||||
@ -261,7 +261,7 @@ public class GroupService {
|
||||
return;
|
||||
}
|
||||
|
||||
applyAndSave(group, new SetTypeEvent(group, exec, type));
|
||||
applyAndSave(group, new SetTypeEvent(group.getId(), exec, type));
|
||||
}
|
||||
|
||||
private void applyAndSave(Group group, Event event) throws EventException {
|
||||
|
||||
@ -62,7 +62,7 @@ public class ProjectionService {
|
||||
*
|
||||
* @throws EventException Projektionsfehler
|
||||
*/
|
||||
private static List<Group> projectGroupsByEvents(List<Event> events) throws EventException {
|
||||
public static List<Group> projectGroupsByEvents(List<Event> events) throws EventException {
|
||||
Map<UUID, Group> groupMap = new HashMap<>();
|
||||
|
||||
events.forEach(event -> event.apply(getOrCreateGroup(groupMap, event.getGroupid())));
|
||||
|
||||
Reference in New Issue
Block a user