oleksma commented on code in PR #4635:
URL: https://github.com/apache/fineract/pull/4635#discussion_r2071213134
##########
fineract-provider/src/main/java/org/apache/fineract/mix/handler/UpdateTaxonomyMappingCommandHandler.java:
##########
@@ -18,30 +18,25 @@
*/
package org.apache.fineract.mix.handler;
+import lombok.AllArgsConstructor;
+import org.apache.fineract.command.core.Command;
+import org.apache.fineract.command.core.CommandHandler;
import org.apache.fineract.commands.annotation.CommandType;
-import org.apache.fineract.commands.handler.NewCommandSourceHandler;
-import org.apache.fineract.infrastructure.core.api.JsonCommand;
-import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
+import org.apache.fineract.mix.data.MixTaxonomyMappingRequest;
+import org.apache.fineract.mix.data.MixTaxonomyMappingResponse;
import org.apache.fineract.mix.service.MixTaxonomyMappingWritePlatformService;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
@Service
@CommandType(entity = "XBRLMAPPING", action = "UPDATE")
-public class UpdateTaxonomyMappingCommandHandler implements
NewCommandSourceHandler {
+@AllArgsConstructor
+public class UpdateTaxonomyMappingCommandHandler implements
CommandHandler<MixTaxonomyMappingRequest, MixTaxonomyMappingResponse> {
private final MixTaxonomyMappingWritePlatformService writeTaxonomyService;
- @Autowired
- public UpdateTaxonomyMappingCommandHandler(final
MixTaxonomyMappingWritePlatformService writeTaxonomyService) {
- this.writeTaxonomyService = writeTaxonomyService;
- }
-
- @Transactional
@Override
- public CommandProcessingResult processCommand(final JsonCommand command) {
- return this.writeTaxonomyService.updateMapping(command.entityId(),
command);
+ public MixTaxonomyMappingResponse
handle(Command<MixTaxonomyMappingRequest> command) {
Review Comment:
Fixed
##########
fineract-provider/src/main/java/org/apache/fineract/mix/service/MixTaxonomyMappingWritePlatformServiceImpl.java:
##########
@@ -35,21 +36,23 @@ public class MixTaxonomyMappingWritePlatformServiceImpl
implements MixTaxonomyMa
@Transactional
@Override
- public CommandProcessingResult updateMapping(final Long mappingId, final
JsonCommand command) {
+ public MixTaxonomyMappingResponse
updateMapping(Command<MixTaxonomyMappingRequest> command) {
+ Long mappingId = ((MixTaxonomyCommand) command).getMappingId();
+
try {
MixTaxonomyMapping mapping =
this.mappingRepository.findById(mappingId).orElse(null);
if (mapping == null) {
- mapping = MixTaxonomyMapping.fromJson(command);
- } else {
- mapping.update(command);
+ mapping = new MixTaxonomyMapping();
}
+ mapping.setIdentifier(command.getPayload().getIdentifier());
+ mapping.setConfig(command.getPayload().getConfig());
+ mapping.setCurrency(command.getPayload().getCurrency());
- this.mappingRepository.saveAndFlush(mapping);
-
- return new
CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(mapping.getId()).build();
+ MixTaxonomyMapping result =
this.mappingRepository.saveAndFlush(mapping);
+ return new MixTaxonomyMappingResponse(result.getIdentifier(),
result.getConfig());
} catch (final JpaSystemException | DataIntegrityViolationException
dve) {
- return CommandProcessingResult.empty();
+ return new MixTaxonomyMappingResponse(null, null);
Review Comment:
Fixed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]