Currently scenario I have is Create an Organisation with an Office. Ideally I would like them to be split into two commands CreateOfficeCommand and AddOfficeCommand. How can I associated AddOfficeCommand to the same aggregate as CreateOfficeCommand. Shall I use aggregateId generation on the client side?
Something like this, ignore identifiedFactory
@RequestMapping(method= RequestMethod.POST)
@ResponseStatus(HttpStatus.CREATED)
public void post(@RequestBody @Valid CreateGroupRequest request) {
String identifier = identifierFactory.generateIdentifier();
CreateGroupCommand createGroupCommand = new CreateGroupCommand(identifier,
request.getName(),
request.getUrl(),
request.getNotes(),
request.getSortName(),
request.isInactive(),
request.getUserKey(),
request.getType());
this.commandGateway.send(createGroupCommand);
AddOfficeCommand addOfficeCommand = new AddOfficeCommand(request.getOffices());
this.commandGateway.send(addOfficeCommand);
}