FINERACT-2302: Migrate collateral product to CommandDispatcher#5856
FINERACT-2302: Migrate collateral product to CommandDispatcher#5856avivijay19 wants to merge 1 commit into
Conversation
| final CommandWrapper commandWrapper = new CommandWrapperBuilder().createCollateral() | ||
| .withJson(apiJsonSerializerService.serialize(collateralManagementProductRequest)).build(); | ||
| return this.commandsSourceWritePlatformService.logCommandSource(commandWrapper); | ||
| @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = CollateralProductCreateResponse.class))) |
There was a problem hiding this comment.
Not needed, you missed this one.
| BigDecimal pctToBase = jsonCommand.bigDecimalValueOfParameterNamedDefaultToNullIfZero("pctToBase"); | ||
| String unitType = jsonCommand.stringValueOfParameterNamed("unitType"); | ||
| String name = jsonCommand.stringValueOfParameterNamed("name"); | ||
| public static CollateralManagementDomain createNew(final String name, final String quality, final BigDecimal basePrice, |
There was a problem hiding this comment.
No, use Lombok builder please... these "replacements" for constructors have no added value and just create boilerplate code.
| } | ||
|
|
||
| public Map<String, Object> update(final JsonCommand command, final ApplicationCurrency applicationCurrency) { | ||
| public Map<String, Object> update(final String name, final String quality, final String unitType, final BigDecimal basePrice, |
There was a problem hiding this comment.
I am pretty sure this function is called only in one place. We should not add it to the entity, but move it to the service function where this is called. Then we can leave the entity class simple and not overload it with business logic. Note: I'm also convinced that the "changes" attributes (same in other packages) are rarely if at all used; but ok, let's leave them to avoid surprises. Anyway, stuff like this should be in the business logic service.
| @RequestBody(required = true, content = @Content(schema = @Schema(implementation = CollateralProductRequest.class))) | ||
| @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = CollateralManagementApiResourceSwagger.PutCollateralProductResponse.class))) | ||
| public CommandProcessingResult updateCollateral( | ||
| @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = CollateralProductUpdateResponse.class))) |
There was a problem hiding this comment.
You misse this. Not needed, we have types now. Remove the swagger @apiresponse annotation please. See earlier comment. Please make sure that you didn't miss any of these.
| @Operation(summary = "Delete a Collateral", description = "Delete Collateral") | ||
| @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = CollateralManagementApiResourceSwagger.DeleteCollateralProductResponse.class))) | ||
| public CommandProcessingResult deleteCollateral( | ||
| @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = CollateralProductDeleteResponse.class))) |
| private static final long serialVersionUID = 1L; | ||
|
|
||
| @Size(max = 200, message = "{org.apache.fineract.infrastructure.template.name.size}") | ||
| private String name; |
There was a problem hiding this comment.
No Jakarta Validation annotations?
|
|
||
| private Integer id; | ||
| @Hidden | ||
| private Long collateralId; |
There was a problem hiding this comment.
No Jakarta Validation? Why is this one hidden? Please check the other request classes for validation annotations!
| return CollateralProductDeleteResponse.builder().resourceId(request.getCollateralId()).build(); | ||
| } | ||
|
|
||
| private void validateForCreation(final CollateralProductCreateRequest request) { |
There was a problem hiding this comment.
This can be done with Jakarta Validation annotations!
| } | ||
| } | ||
|
|
||
| private void validateForDeletion(final CollateralManagementDomain collateralManagementDomain, final Long collateralId) { |
There was a problem hiding this comment.
Try Jakarta Validation if possible.
Migrates collateral product create/update/delete from the old CommandWrapper/PortfolioCommandSourceWritePlatformService pattern to the typed CommandDispatcher pipeline.
Jira: https://issues.apache.org/jira/browse/FINERACT-2302