My understanding of this is still a bit fuzzy, so sorry if I'm being confused. But, where should the repository method for adding a relationship belongs? For example, there's this domain logic:
|
public void addUser(User aUser) { |
|
this.assertArgumentNotNull(aUser, "User must not be null."); |
|
this.assertArgumentEquals(this.tenantId(), aUser.tenantId(), "Wrong tenant for this group."); |
|
this.assertArgumentTrue(aUser.isEnabled(), "User is not enabled."); |
|
|
|
if (this.groupMembers().add(aUser.toGroupMember()) && !this.isInternalGroup()) { |
|
DomainEventPublisher |
|
.instance() |
|
.publish(new GroupUserAdded( |
|
this.tenantId(), |
|
this.name(), |
|
aUser.username())); |
|
} |
|
} |
But it looks like the handler for the GroupUserAdded event is not implemented yet. But if you want to persist the fact that this user is added to the group (as a group member), where would you put that method?
Would it be in the GroupRepository or UserRepository? Or maybe a new repository (e.g. GroupMemberRepository)?
My understanding of this is still a bit fuzzy, so sorry if I'm being confused. But, where should the repository method for adding a relationship belongs? For example, there's this domain logic:
IDDD_Samples/iddd_identityaccess/src/main/java/com/saasovation/identityaccess/domain/model/identity/Group.java
Lines 58 to 71 in 9b27b11
But it looks like the handler for the
GroupUserAddedevent is not implemented yet. But if you want to persist the fact that this user is added to the group (as a group member), where would you put that method?Would it be in the
GroupRepositoryorUserRepository? Or maybe a new repository (e.g.GroupMemberRepository)?