Skip to content

FINERACT-2302: Migrate collateral product to CommandDispatcher#5856

Open
avivijay19 wants to merge 1 commit into
apache:developfrom
avivijay19:FINERACT-2302
Open

FINERACT-2302: Migrate collateral product to CommandDispatcher#5856
avivijay19 wants to merge 1 commit into
apache:developfrom
avivijay19:FINERACT-2302

Conversation

@avivijay19
Copy link
Copy Markdown
Contributor

Migrates collateral product create/update/delete from the old CommandWrapper/PortfolioCommandSourceWritePlatformService pattern to the typed CommandDispatcher pipeline.

  • Add CollateralProductCreate/Update/Delete commands, request/response DTOs, and @component CommandHandler implementations (Resilience4j retry on each)
  • Switch CollateralManagementApiResource to dispatcher.dispatch(...) for create/update/delete
  • Remove old Create/Update/DeleteCollateralProductHandler and CollateralManagementWritePlatformServiceImpl
  • Rename CollateralManagementReadPlatformService/Impl → CollateralManagementReadService/Impl; add new CollateralManagementWriteService/Impl
  • Drop the now-unused CollateralManagementApiResourceSwagger (schemas live on the DTOs)
  • SecurityConfig: matchers for /collateral-management/*
  • application.properties: resilience4j retry instances for commandCollateralProductCreate/Update/Delete
  • Clean up CommandWrapperConstants / CommandWrapperBuilder entries

Jira: https://issues.apache.org/jira/browse/FINERACT-2302

@vidakovic vidakovic self-requested a review May 18, 2026 13:16
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)))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another one. See above.

private static final long serialVersionUID = 1L;

@Size(max = 200, message = "{org.apache.fineract.infrastructure.template.name.size}")
private String name;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No Jakarta Validation annotations?


private Integer id;
@Hidden
private Long collateralId;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be done with Jakarta Validation annotations!

}
}

private void validateForDeletion(final CollateralManagementDomain collateralManagementDomain, final Long collateralId) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try Jakarta Validation if possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants