First, let's implement all the Domain Commands: domain commands are all commands related to an Aggregate and generating events after the approval.
In Evento Framework every Domain Command implement the class com.evento.common.modeling.messaging.payload.DomainCommand and needs the getAggregateId() method implementation. Thath method returns the Unique Aggregate Identifier used to compute the Aggregate State of the Event Sourcing Pattern. Then you have to specify every single required information as a field.
Every single AggregateId in the System must be different you cannot use the same ID in different aggregate Types.
Usually, the Resource Identifier (in this case the TodoList Id) is used as an aggregate identifier, and, during the generation, a prefix to identify the aggregate type.
importcom.evento.common.documentation.Domain;importcom.evento.common.modeling.messaging.payload.DomainCommand;importlombok.AllArgsConstructor;importlombok.Getter;importlombok.NoArgsConstructor;importlombok.Setter;@Domain(name ="TodoList")@NoArgsConstructor@AllArgsConstructor@Getter@SetterpublicclassTodoListCreateCommandextendsDomainCommand {// The TodoList identifierprivateString identifier;// The TodoList NameprivateString name; @OverridepublicStringgetAggregateId() {return identifier; }}
importcom.evento.common.documentation.Domain;importcom.evento.common.modeling.messaging.payload.DomainCommand;importlombok.AllArgsConstructor;importlombok.Getter;importlombok.NoArgsConstructor;importlombok.Setter;@Domain(name ="TodoList")@NoArgsConstructor@AllArgsConstructor@Getter@SetterpublicclassTodoListDeleteCommandextendsDomainCommand {// Identifier of the TodoList to deleteprivateString identifier; @OverridepublicStringgetAggregateId() {return identifier; }}
importlombok.AllArgsConstructor;importlombok.Getter;importlombok.NoArgsConstructor;importlombok.Setter;importcom.evento.common.documentation.Domain;importcom.evento.common.modeling.messaging.payload.DomainCommand;@Domain(name ="TodoList")@NoArgsConstructor@AllArgsConstructor@Getter@SetterpublicclassTodoListAddTodoCommandextendsDomainCommand {// Identifier of the TodoList to updateprivateString identifier;// Identifier of the To-do to deleteprivateString todoIdentifier;// The To-do contentprivateString content; @OverridepublicStringgetAggregateId() {return identifier; }}
importcom.evento.common.documentation.Domain;importcom.evento.common.modeling.messaging.payload.DomainCommand;importlombok.AllArgsConstructor;importlombok.Getter;importlombok.NoArgsConstructor;importlombok.Setter;@Domain(name ="TodoList")@NoArgsConstructor@AllArgsConstructor@Getter@SetterpublicclassTodoListRemoveTodoCommandextendsDomainCommand {// Identifier of the TodoList to updateprivateString identifier;// Identifier of the To-do to removeprivateString todoIdentifier; @OverridepublicStringgetAggregateId() {return identifier; }}
importcom.evento.common.documentation.Domain;importcom.evento.common.modeling.messaging.payload.DomainCommand;importlombok.AllArgsConstructor;importlombok.Getter;importlombok.NoArgsConstructor;importlombok.Setter;@Domain(name ="TodoList")@NoArgsConstructor@AllArgsConstructor@Getter@SetterpublicclassTodoListCheckTodoCommandextendsDomainCommand {// Identifier of the TodoList to updateprivateString identifier;// Identifier of the To-do to checkprivateString todoIdentifier; @OverridepublicStringgetAggregateId() {return identifier; }}