nikpawar89 commented on a change in pull request #1235:
URL: https://github.com/apache/fineract/pull/1235#discussion_r512404952



##########
File path: 
fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/service/CreditReportWritePlatformServiceImpl.java
##########
@@ -0,0 +1,234 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.fineract.infrastructure.creditbureau.service;
+
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
+import java.io.File;
+import java.util.NoSuchElementException;
+import javax.persistence.PersistenceException;
+import org.apache.commons.lang3.exception.ExceptionUtils;
+import org.apache.fineract.infrastructure.core.api.JsonCommand;
+import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
+import 
org.apache.fineract.infrastructure.core.data.CommandProcessingResultBuilder;
+import 
org.apache.fineract.infrastructure.core.exception.PlatformDataIntegrityException;
+import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper;
+import org.apache.fineract.infrastructure.core.service.RoutingDataSource;
+import org.apache.fineract.infrastructure.creditbureau.data.CreditBureaNames;
+import org.apache.fineract.infrastructure.creditbureau.data.CreditReportData;
+import org.apache.fineract.infrastructure.creditbureau.domain.CreditBureau;
+import 
org.apache.fineract.infrastructure.creditbureau.domain.CreditBureauConfiguration;
+import 
org.apache.fineract.infrastructure.creditbureau.domain.CreditBureauConfigurationRepositoryWrapper;
+import 
org.apache.fineract.infrastructure.creditbureau.domain.CreditBureauLoanProductMappingRepository;
+import 
org.apache.fineract.infrastructure.creditbureau.domain.CreditBureauRepository;
+import 
org.apache.fineract.infrastructure.creditbureau.domain.TokenRepositoryWrapper;
+import 
org.apache.fineract.infrastructure.creditbureau.serialization.CreditBureauTokenCommandFromApiJsonDeserializer;
+import 
org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.dao.DataIntegrityViolationException;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+@Service
+public class CreditReportWritePlatformServiceImpl implements 
CreditReportWritePlatformService {
+
+    private final JdbcTemplate jdbcTemplate;
+    private final PlatformSecurityContext context;
+    private final FromJsonHelper fromApiJsonHelper;
+    private final TokenRepositoryWrapper tokenRepository;
+    private final CreditBureauConfigurationRepositoryWrapper 
configDataRepository;
+    private final CreditBureauTokenCommandFromApiJsonDeserializer 
fromApiJsonDeserializer;
+    private final CreditBureauLoanProductMappingRepository 
loanProductMappingRepository;
+    private final CreditBureauRepository creditBureauRepository;
+    private final ThitsaWorksCreditBureauIntegrationWritePlatformService 
thitsaWorksCreditBureauIntegrationWritePlatformService;
+
+    @Autowired
+    public CreditReportWritePlatformServiceImpl(final PlatformSecurityContext 
context, final RoutingDataSource dataSource,
+            final FromJsonHelper fromApiJsonHelper, final 
TokenRepositoryWrapper tokenRepository,
+            final CreditBureauConfigurationRepositoryWrapper 
configDataRepository,
+            final CreditBureauTokenCommandFromApiJsonDeserializer 
fromApiJsonDeserializer,
+            final CreditBureauLoanProductMappingRepository 
loanProductMappingRepository,
+            final CreditBureauRepository creditBureauRepository,
+            final ThitsaWorksCreditBureauIntegrationWritePlatformService 
thitsaWorksCreditBureauIntegrationWritePlatformService) {
+        this.context = context;
+        this.jdbcTemplate = new JdbcTemplate(dataSource);
+        this.tokenRepository = tokenRepository;
+        this.configDataRepository = configDataRepository;
+        this.fromApiJsonHelper = fromApiJsonHelper;
+        this.fromApiJsonDeserializer = fromApiJsonDeserializer;
+        this.loanProductMappingRepository = loanProductMappingRepository;
+        this.creditBureauRepository = creditBureauRepository;
+        this.thitsaWorksCreditBureauIntegrationWritePlatformService = 
thitsaWorksCreditBureauIntegrationWritePlatformService;
+    }
+
+    private static final Logger LOG = 
LoggerFactory.getLogger(CreditReportWritePlatformServiceImpl.class);
+
+    @SuppressWarnings({ "CatchAndPrintStackTrace", "DefaultCharset" })
+    @Override
+    @Transactional
+    public CommandProcessingResult getCreditReport(JsonCommand command) {
+
+        try {
+            this.context.authenticatedUser();
+
+            String creditBureauID = 
command.stringValueOfParameterNamed("creditBureauID");
+
+            String creditBureauName = getCreditBureau(creditBureauID);
+
+            CreditReportData reportobj = null;
+
+            if 
(creditBureauName.equals(CreditBureaNames.THITSAWORKS.toString())) {
+                reportobj = 
this.thitsaWorksCreditBureauIntegrationWritePlatformService.getCreditReportFromThitsaWorks(command);

Review comment:
       I think, if string does not match you should let client know,




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to