-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adds support for rich 'aggregate' modeling (working)
- Loading branch information
Showing
10 changed files
with
58 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 39 additions & 1 deletion
40
...nerator/src/main/java/core/implementation/partials/jpa/aggregates-commands-methodBody.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,39 @@ | ||
// aggregates commands | ||
{{{logMethodCall method}}} | ||
{{~#if (eq (size aggregateCommandsForMethod.aggregatesCommandsForMethod) 1)}} | ||
{{~assign 'aggregateCommand' aggregateCommandsForMethod.aggregatesCommandsForMethod.0}} | ||
{{~#if method.paramId}} | ||
var {{asInstanceName aggregateCommand.aggregate.className}} = {{aggregateCommand.entity.instanceName}}Repository.find{{aggregateCommand.aggregate.className}}ById({{method.paramId}}).orElseThrow(); | ||
{{~else}} | ||
var {{asInstanceName aggregateCommand.aggregate.className}} = new {{aggregateCommand.aggregate.className}}(); | ||
{{~/if}} | ||
{{asInstanceName aggregateCommand.aggregate.className}}.{{aggregateCommand.command.name}}({{#if method.parameter}}input{{/if}}); | ||
persistAndEmitEvents({{asInstanceName aggregateCommand.aggregate.className}}); | ||
{{~#if method.returnType}} | ||
{{~#if (eq aggregateCommand.aggregate.className method.returnType)}} | ||
return {{asInstanceName aggregateCommand.aggregate.className}}; | ||
{{~else if (eq aggregateCommand.aggregate.aggregateRoot method.returnType)}} | ||
return {{asInstanceName aggregateCommand.aggregate.className}}.getRootEntity(); | ||
{{~else}} | ||
return {{asInstanceName service.name}}Mapper.as{{returnType}}({{asInstanceName aggregateCommand.aggregate.className}}.getRootEntity()); | ||
{{~/if}} | ||
{{~/if}} | ||
{{~else}} | ||
{{~#each aggregateCommandsForMethod.aggregatesCommandsForMethod as |aggregateCommand| }} | ||
{{~#if method.paramId}} | ||
var {{asInstanceName aggregate.className}} = {{entity.instanceName}}Repository.find{{aggregate.className}}ById({{method.paramId}}).orElseThrow(); | ||
{{~else}} | ||
var {{asInstanceName aggregate.className}} = new {{aggregate.className}}(); | ||
{{~/if}} | ||
{{asInstanceName aggregate.className}}.{{command.name}}({{#if method.parameter}}input{{/if}}); | ||
persistAndEmitEvents({{asInstanceName aggregate.className}}); | ||
{{~/each}} | ||
{{~#if method.returnType}} | ||
{{~#if (eq aggregate.className method.returnType)}} | ||
return {{asInstanceName aggregate.className}}; | ||
{{~else if (eq aggregate.aggregateRoot method.returnType)}} | ||
return {{asInstanceName aggregate.className}}.getRootEntity(); | ||
{{~else}} | ||
return null; | ||
{{~/if}} | ||
{{~/if}} | ||
{{~/if}} |
5 changes: 5 additions & 0 deletions
5
...ltGenerator/src/main/java/core/implementation/partials/jpa/aggregates-void-methodBody.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,6 @@ | ||
{{{logMethodCall method}}} | ||
// void | ||
{{~#if method.returnType}} | ||
return null; | ||
{{~/if}} | ||
|
2 changes: 1 addition & 1 deletion
2
...aultGenerator/src/main/java/core/implementation/partials/jpa/entities-crud-methodBody.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ApplicationDefaultGenerator/src/main/java/core/implementation/partials/jpa/methodBody.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
{{assign 'aggregateCommandsForMethod' (findAggregateCommandsForMethod method)}} | ||
{{~assign 'aggregateCommandsForMethod' (findAggregateCommandsForMethod method)}} | ||
{{~> (partial aggregateCommandsForMethod.templateFile)}} |
3 changes: 2 additions & 1 deletion
3
...tor/src/main/java/core/implementation/partials/mongodb/aggregates-commands-methodBody.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...icationDefaultGenerator/src/main/java/core/implementation/partials/mongodb/methodBody.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
{{assign 'aggregateCommandsForMethod' (findAggregateCommandsForMethod method)}} | ||
{{~assign 'aggregateCommandsForMethod' (findAggregateCommandsForMethod method)}} | ||
{{~> (partial aggregateCommandsForMethod.templateFile)}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters