From da03d737042169cbc683f0809a5c8869ce23a2d7 Mon Sep 17 00:00:00 2001 From: Aleksandar Vidakovic Date: Fri, 25 Mar 2022 18:51:59 +0100 Subject: [PATCH] FINERACT-1547: Cleanup unnecessary credit bureau dependency in infrastructure core --- .../core/data/CommandProcessingResult.java | 9 +++---- .../data/CommandProcessingResultBuilder.java | 5 ++-- .../data/CreditBureauReportData.java | 27 +++++++++++++++++++ .../CreditReportWritePlatformServiceImpl.java | 7 ++++- 4 files changed, 39 insertions(+), 9 deletions(-) diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/data/CommandProcessingResult.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/data/CommandProcessingResult.java index d74131da8..dad68a568 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/data/CommandProcessingResult.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/data/CommandProcessingResult.java @@ -21,7 +21,6 @@ package org.apache.fineract.infrastructure.core.data; import java.io.Serializable; import java.util.HashMap; import java.util.Map; -import org.apache.fineract.infrastructure.creditbureau.data.CreditBureauReportData; /** * Represents the successful result of an REST API call that results in processing a command. @@ -38,7 +37,7 @@ public class CommandProcessingResult implements Serializable { private final Long subResourceId; private final String transactionId; private final Map changes; - private final CreditBureauReportData creditBureauReportData; + private final Map creditBureauReportData; @SuppressWarnings("unused") private final String resourceIdentifier; private final Long productId; @@ -55,7 +54,7 @@ public class CommandProcessingResult implements Serializable { public static CommandProcessingResult fromDetails(final Long commandId, final Long officeId, final Long groupId, final Long clientId, final Long loanId, final Long savingsId, final String resourceIdentifier, final Long entityId, final Long gsimId, - final Long glimId, final CreditBureauReportData creditBureauReportData, final String transactionId, + final Long glimId, final Map creditBureauReportData, final String transactionId, final Map changes, final Long productId, final Boolean rollbackTransaction, final Long subResourceId) { return new CommandProcessingResult(commandId, officeId, groupId, clientId, loanId, savingsId, resourceIdentifier, entityId, transactionId, changes, productId, gsimId, glimId, creditBureauReportData, rollbackTransaction, subResourceId); @@ -117,7 +116,7 @@ public class CommandProcessingResult implements Serializable { private CommandProcessingResult(final Long commandId, final Long officeId, final Long groupId, final Long clientId, final Long loanId, final Long savingsId, final String resourceIdentifier, final Long resourceId, final String transactionId, final Map changesOnly, final Long productId, final Long gsimId, final Long glimId, - final CreditBureauReportData creditBureauReportData, Boolean rollbackTransaction, final Long subResourceId) { + final Map creditBureauReportData, Boolean rollbackTransaction, final Long subResourceId) { this.commandId = commandId; this.officeId = officeId; this.groupId = groupId; @@ -200,7 +199,7 @@ public class CommandProcessingResult implements Serializable { return this.transactionId; } - public CreditBureauReportData getCreditReport() { + public Map getCreditReport() { return this.creditBureauReportData; } diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/data/CommandProcessingResultBuilder.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/data/CommandProcessingResultBuilder.java index 9b340f8b0..292081f17 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/data/CommandProcessingResultBuilder.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/data/CommandProcessingResultBuilder.java @@ -19,7 +19,6 @@ package org.apache.fineract.infrastructure.core.data; import java.util.Map; -import org.apache.fineract.infrastructure.creditbureau.data.CreditBureauReportData; /** * Represents the successful result of an REST API call that results in processing a command. @@ -39,7 +38,7 @@ public class CommandProcessingResultBuilder { private Long glimId; private String transactionId; private Map changes; - private CreditBureauReportData creditBureauReportData; + private Map creditBureauReportData; private Long productId; private boolean rollbackTransaction = false; @@ -119,7 +118,7 @@ public class CommandProcessingResultBuilder { return this; } - public CommandProcessingResultBuilder withCreditReport(final CreditBureauReportData withCreditReport) { + public CommandProcessingResultBuilder withCreditReport(final Map withCreditReport) { this.creditBureauReportData = withCreditReport; return this; } diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/data/CreditBureauReportData.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/data/CreditBureauReportData.java index 0ab3493da..a13054a13 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/data/CreditBureauReportData.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/data/CreditBureauReportData.java @@ -54,4 +54,31 @@ public final class CreditBureauReportData implements Serializable { this.closedAccounts = closedAccounts; } + public String getName() { + return name; + } + + public String getGender() { + return gender; + } + + public String getAddress() { + return address; + } + + public String getCreditScore() { + return creditScore; + } + + public String getBorrowerInfo() { + return borrowerInfo; + } + + public String[] getOpenAccounts() { + return openAccounts; + } + + public String[] getClosedAccounts() { + return closedAccounts; + } } diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/service/CreditReportWritePlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/service/CreditReportWritePlatformServiceImpl.java index 1cdd90e5e..b44c4ff3a 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/service/CreditReportWritePlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/service/CreditReportWritePlatformServiceImpl.java @@ -22,6 +22,7 @@ import java.io.File; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.Objects; import java.util.Optional; import javax.persistence.PersistenceException; @@ -103,7 +104,11 @@ public class CreditReportWritePlatformServiceImpl implements CreditReportWritePl CreditBureauReportData reportobj = this.thitsaWorksCreditBureauIntegrationWritePlatformService .getCreditReportFromThitsaWorks(command); - return new CommandProcessingResultBuilder().withCreditReport(reportobj).build(); + Map reportMap = Map.of("name", reportobj.getName(), "gender", reportobj.getGender(), "address", + reportobj.getAddress(), "creditScore", reportobj.getCreditScore(), "borrowerInfo", reportobj.getBorrowerInfo(), + "openAccounts", reportobj.getOpenAccounts(), "closedAccounts", reportobj.getClosedAccounts()); + + return new CommandProcessingResultBuilder().withCreditReport(reportMap).build(); } baseDataValidator.reset().failWithCode("creditBureau.has.not.been.Integrated");