You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fineract.apache.org by wkk91193 <gi...@git.apache.org> on 2017/10/03 12:58:05 UTC

[GitHub] fineract pull request #415: all modules populate & import

GitHub user wkk91193 opened a pull request:

    https://github.com/apache/fineract/pull/415

    all modules populate & import

    This commit comprises of all the backend changes related to Data import tool integration. The same structure has been conformed to, as of the  PR [office populate & Import](https://github.com/apache/fineract/pull/401)
    which can be used for sampling.Furthermore, The commit also includes integration tests for the main entitities Office,Loan,Savings,Client.
    The frontend changes are can be viewed [here](https://github.com/openMF/community-app/pull/2504).

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/wkk91193/incubator-fineract extend-mifos-data-import-tool-branch-all-modules

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/fineract/pull/415.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #415
    
----
commit 59fdbc08539d6a6eed9cd4ade99ea0449929989f
Author: Kumaranath Fernando <wk...@yahoo.com>
Date:   2017-09-04T06:48:52Z

    all modules populate & import# This is a combination of 5 commits.
    all modules populate and import
    
    async import,refactoring
    
    integration tests,Import document api
    
    improved error handling
    
    improved error handling-2

----


---

[GitHub] fineract pull request #415: Extend-mifos-data-import-tool-all-modules-popula...

Posted by avikganguly01 <gi...@git.apache.org>.
Github user avikganguly01 commented on a diff in the pull request:

    https://github.com/apache/fineract/pull/415#discussion_r143357965
  
    --- Diff: fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/bulkimport/importhandler/loan/LoanImportHandlerTest.java ---
    @@ -0,0 +1,195 @@
    +/**
    + * 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.integrationtests.bulkimport.importhandler.loan;
    +
    +import com.jayway.restassured.builder.RequestSpecBuilder;
    +import com.jayway.restassured.builder.ResponseSpecBuilder;
    +import com.jayway.restassured.specification.RequestSpecification;
    +import com.jayway.restassured.specification.ResponseSpecification;
    +import org.apache.fineract.infrastructure.bulkimport.constants.ClientEntityConstants;
    +import org.apache.fineract.infrastructure.bulkimport.constants.LoanConstants;
    +import org.apache.fineract.infrastructure.bulkimport.constants.TemplatePopulateImportConstants;
    +import org.apache.fineract.integrationtests.common.*;
    +import org.apache.fineract.integrationtests.common.funds.FundsResourceHandler;
    +import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper;
    +import org.apache.fineract.integrationtests.common.organisation.StaffHelper;
    +import org.apache.poi.hssf.usermodel.HSSFWorkbook;
    +import org.apache.poi.ss.usermodel.Row;
    +import org.apache.poi.ss.usermodel.Sheet;
    +import org.apache.poi.ss.usermodel.Workbook;
    +import org.junit.Assert;
    +import org.junit.Before;
    +import org.junit.Test;
    +
    +import javax.ws.rs.core.HttpHeaders;
    +import javax.ws.rs.core.MediaType;
    +import java.io.*;
    +import java.text.ParseException;
    +import java.text.SimpleDateFormat;
    +import java.util.Date;
    +
    +public class LoanImportHandlerTest {
    +    private ResponseSpecification responseSpec;
    +    private RequestSpecification requestSpec;
    +
    +    @Before
    +    public void setup() {
    +        Utils.initializeRESTAssured();
    +        this.requestSpec = new RequestSpecBuilder().build();
    +        this.requestSpec
    +                .header("Authorization",
    +                        "Basic "
    +                                + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
    +        this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200)
    +                .build();
    +    }
    +
    +    @Test
    +    public void testLoanImport() throws InterruptedException, IOException, ParseException {
    +        requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
    +        //in order to populate helper sheets
    +        OfficeHelper officeHelper=new OfficeHelper(requestSpec,responseSpec);
    +        Integer outcome_office_creation=officeHelper.createOffice("02 May 2000");
    +        Assert.assertNotNull("Could not create office" ,outcome_office_creation);
    +
    +        //in order to populate helper sheets
    +        ClientHelper clientHelper=new ClientHelper(requestSpec,responseSpec);
    +        Integer outcome_client_creation=clientHelper.createClient(requestSpec,responseSpec);
    +        Assert.assertNotNull("Could not create client" ,outcome_client_creation);
    +
    +        //in order to populate helper sheets
    +        GroupHelper groupHelper=new GroupHelper(requestSpec,responseSpec);
    +        Integer outcome_group_creation=groupHelper.createGroup(requestSpec,responseSpec,true);
    +        Assert.assertNotNull("Could not create group" ,outcome_group_creation);
    +
    +        //in order to populate helper sheets
    +        StaffHelper staffHelper=new StaffHelper();
    +        Integer outcome_staff_creation =staffHelper.createStaff(requestSpec,responseSpec);
    +        Assert.assertNotNull("Could not create staff",outcome_staff_creation);
    +
    +        LoanTransactionHelper loanTransactionHelper=new LoanTransactionHelper(requestSpec,responseSpec);
    +        String jsonLoanProduct="{\"currencyCode\":\"USD\",\"includeInBorrowerCycle\":\"false\"," +
    --- End diff --
    
    Use loan product test builder...avoid escaped string json


---

[GitHub] fineract pull request #415: Extend-mifos-data-import-tool-all-modules-popula...

Posted by avikganguly01 <gi...@git.apache.org>.
Github user avikganguly01 commented on a diff in the pull request:

    https://github.com/apache/fineract/pull/415#discussion_r143358027
  
    --- Diff: fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/bulkimport/importhandler/savings/SavingsImportHandlerTest.java ---
    @@ -0,0 +1,164 @@
    +/**
    + * 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.integrationtests.bulkimport.importhandler.savings;
    +
    +import com.jayway.restassured.builder.RequestSpecBuilder;
    +import com.jayway.restassured.builder.ResponseSpecBuilder;
    +import com.jayway.restassured.specification.RequestSpecification;
    +import com.jayway.restassured.specification.ResponseSpecification;
    +import org.apache.fineract.infrastructure.bulkimport.constants.LoanConstants;
    +import org.apache.fineract.infrastructure.bulkimport.constants.SavingsConstants;
    +import org.apache.fineract.infrastructure.bulkimport.constants.TemplatePopulateImportConstants;
    +import org.apache.fineract.integrationtests.common.ClientHelper;
    +import org.apache.fineract.integrationtests.common.GroupHelper;
    +import org.apache.fineract.integrationtests.common.OfficeHelper;
    +import org.apache.fineract.integrationtests.common.Utils;
    +import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper;
    +import org.apache.fineract.integrationtests.common.organisation.StaffHelper;
    +import org.apache.fineract.integrationtests.common.savings.SavingsAccountHelper;
    +import org.apache.fineract.integrationtests.common.savings.SavingsProductHelper;
    +import org.apache.fineract.template.domain.Template;
    +import org.apache.poi.hssf.usermodel.HSSFWorkbook;
    +import org.apache.poi.ss.usermodel.Row;
    +import org.apache.poi.ss.usermodel.Sheet;
    +import org.apache.poi.ss.usermodel.Workbook;
    +import org.junit.Assert;
    +import org.junit.Before;
    +import org.junit.Test;
    +
    +import javax.ws.rs.core.HttpHeaders;
    +import javax.ws.rs.core.MediaType;
    +import java.io.*;
    +import java.text.ParseException;
    +import java.text.SimpleDateFormat;
    +import java.util.Date;
    +
    +public class SavingsImportHandlerTest {
    +    private ResponseSpecification responseSpec;
    +    private RequestSpecification requestSpec;
    +
    +    @Before
    +    public void setup() {
    +        Utils.initializeRESTAssured();
    +        this.requestSpec = new RequestSpecBuilder().build();
    +        this.requestSpec
    +                .header("Authorization",
    +                        "Basic "
    +                                + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
    +        this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200)
    +                .build();
    +    }
    +
    +    @Test
    +    public void testSavingsImport() throws InterruptedException, IOException, ParseException {
    +
    +        requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
    +        //in order to populate helper sheets
    +        OfficeHelper officeHelper=new OfficeHelper(requestSpec,responseSpec);
    +        Integer outcome_office_creation=officeHelper.createOffice("02 May 2000");
    +        Assert.assertNotNull("Could not create office" ,outcome_office_creation);
    +
    +        //in order to populate helper sheets
    +        ClientHelper clientHelper=new ClientHelper(requestSpec,responseSpec);
    +        Integer outcome_client_creation=clientHelper.createClient(requestSpec,responseSpec);
    +        Assert.assertNotNull("Could not create client" ,outcome_client_creation);
    +
    +        //in order to populate helper sheets
    +        GroupHelper groupHelper=new GroupHelper(requestSpec,responseSpec);
    +        Integer outcome_group_creation=groupHelper.createGroup(requestSpec,responseSpec,true);
    +        Assert.assertNotNull("Could not create group" ,outcome_group_creation);
    +
    +        //in order to populate helper sheets
    +        StaffHelper staffHelper=new StaffHelper();
    +        Integer outcome_staff_creation =staffHelper.createStaff(requestSpec,responseSpec);
    +        Assert.assertNotNull("Could not create staff",outcome_staff_creation);
    +
    +        SavingsProductHelper savingsProductHelper=new SavingsProductHelper();
    +        String jsonSavingsProduct="{\"currencyCode\":\"USD\",\"digitsAfterDecimal\":2," +
    --- End diff --
    
    Use SavingsProductHelper


---

[GitHub] fineract pull request #415: Extend-mifos-data-import-tool-all-modules-popula...

Posted by avikganguly01 <gi...@git.apache.org>.
Github user avikganguly01 commented on a diff in the pull request:

    https://github.com/apache/fineract/pull/415#discussion_r143358796
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/importhandler/chartofaccounts/ChartOfAccountsImportHandler.java ---
    @@ -0,0 +1,185 @@
    +/**
    + * 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.bulkimport.importhandler.chartofaccounts;
    +
    +import com.google.gson.GsonBuilder;
    +import org.apache.fineract.accounting.glaccount.data.GLAccountData;
    +import org.apache.fineract.accounting.glaccount.domain.GLAccountType;
    +import org.apache.fineract.accounting.glaccount.domain.GLAccountUsage;
    +import org.apache.fineract.commands.domain.CommandWrapper;
    +import org.apache.fineract.commands.service.CommandWrapperBuilder;
    +import org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService;
    +import org.apache.fineract.infrastructure.bulkimport.constants.ChartOfAcountsConstants;
    +import org.apache.fineract.infrastructure.bulkimport.constants.TemplatePopulateImportConstants;
    +import org.apache.fineract.infrastructure.bulkimport.data.Count;
    +import org.apache.fineract.infrastructure.bulkimport.importhandler.ImportHandler;
    +import org.apache.fineract.infrastructure.bulkimport.importhandler.ImportHandlerUtils;
    +import org.apache.fineract.infrastructure.bulkimport.importhandler.helper.CodeValueDataIdSerializer;
    +import org.apache.fineract.infrastructure.bulkimport.importhandler.helper.EnumOptionDataIdSerializer;
    +import org.apache.fineract.infrastructure.codes.data.CodeValueData;
    +import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
    +import org.apache.fineract.infrastructure.core.data.EnumOptionData;
    +import org.apache.fineract.infrastructure.core.exception.*;
    +import org.apache.poi.ss.usermodel.*;
    +import org.springframework.beans.factory.annotation.Autowired;
    +import org.springframework.stereotype.Service;
    +
    +import java.util.ArrayList;
    +import java.util.List;
    +@Service
    +public class ChartOfAccountsImportHandler implements ImportHandler {
    +    private  List<GLAccountData> glAccounts;
    +    private  Workbook workbook;
    +
    +    private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService;
    +
    +    @Autowired
    +    public ChartOfAccountsImportHandler(final PortfolioCommandSourceWritePlatformService
    +            commandsSourceWritePlatformService) {
    +        this.commandsSourceWritePlatformService = commandsSourceWritePlatformService;
    +    }
    +
    +    @Override
    +    public Count process(Workbook workbook, String locale, String dateFormat) {
    +        this.glAccounts=new ArrayList<>();
    +        this.workbook=workbook;
    +        readExcelFile();
    +        return importEntity();
    +    }
    +
    +    public void readExcelFile() {
    +
    +        Sheet chartOfAccountsSheet=workbook.getSheet(TemplatePopulateImportConstants.CHART_OF_ACCOUNTS_SHEET_NAME);
    +        Integer noOfEntries= ImportHandlerUtils.getNumberOfRows(chartOfAccountsSheet,TemplatePopulateImportConstants.FIRST_COLUMN_INDEX);
    +        for (int rowIndex=1;rowIndex<=noOfEntries;rowIndex++){
    +            Row row;
    +                row=chartOfAccountsSheet.getRow(rowIndex);
    +                if (ImportHandlerUtils.isNotImported(row, ChartOfAcountsConstants.STATUS_COL)){
    +                    glAccounts.add(readGlAccounts(row));
    +                }
    +        }
    +    }
    +
    +    private GLAccountData readGlAccounts(Row row) {
    +        String accountType=ImportHandlerUtils.readAsString(ChartOfAcountsConstants.ACCOUNT_TYPE_COL,row);
    +        Long accountTypeId=null;
    +        EnumOptionData accountTypeEnum=null;
    +        if (accountType!=null && accountType.equalsIgnoreCase(GLAccountType.ASSET.toString())){
    +            accountTypeId=1L;
    +            accountTypeEnum=new EnumOptionData(accountTypeId,null,null);
    +        }else if(accountType!=null && accountType.equalsIgnoreCase(GLAccountType.LIABILITY.toString())){
    +            accountTypeId=2L;
    +            accountTypeEnum=new EnumOptionData(accountTypeId,null,null);
    +        }else if(accountType!=null && accountType.equalsIgnoreCase(GLAccountType.EQUITY.toString())){
    +            accountTypeId=3L;
    +            accountTypeEnum=new EnumOptionData(accountTypeId,null,null);
    +        }
    +        else if(accountType!=null && accountType.equalsIgnoreCase(GLAccountType.INCOME.toString())){
    +            accountTypeId=4L;
    +            accountTypeEnum=new EnumOptionData(accountTypeId,null,null);
    +        }else if(accountType!=null && accountType.equalsIgnoreCase(GLAccountType.EXPENSE.toString())){
    +            accountTypeId=5L;
    +            accountTypeEnum=new EnumOptionData(accountTypeId,null,null);
    +        }
    --- End diff --
    
    Move this code to GLAccountType new function fromString which will return the accountTypeEnum.


---

[GitHub] fineract issue #415: Extend-mifos-data-import-tool-all-modules-populate-&-im...

Posted by wkk91193 <gi...@git.apache.org>.
Github user wkk91193 commented on the issue:

    https://github.com/apache/fineract/pull/415
  
    @avikganguly01  Fixed those changes and ready for review!


---

[GitHub] fineract pull request #415: Extend-mifos-data-import-tool-all-modules-popula...

Posted by avikganguly01 <gi...@git.apache.org>.
Github user avikganguly01 commented on a diff in the pull request:

    https://github.com/apache/fineract/pull/415#discussion_r143358069
  
    --- Diff: fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/bulkimport/populator/loan/LoanWorkbookPopulatorTest.java ---
    @@ -0,0 +1,147 @@
    +/**
    + * 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.integrationtests.bulkimport.populator.loan;
    +
    +import com.jayway.restassured.builder.RequestSpecBuilder;
    +import com.jayway.restassured.builder.ResponseSpecBuilder;
    +import com.jayway.restassured.specification.RequestSpecification;
    +import com.jayway.restassured.specification.ResponseSpecification;
    +import org.apache.fineract.infrastructure.bulkimport.constants.TemplatePopulateImportConstants;
    +import org.apache.fineract.infrastructure.bulkimport.data.GlobalEntityType;
    +import org.apache.fineract.integrationtests.common.*;
    +import org.apache.fineract.integrationtests.common.funds.FundsResourceHandler;
    +import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper;
    +import org.apache.fineract.integrationtests.common.organisation.StaffHelper;
    +import org.apache.poi.ss.usermodel.Row;
    +import org.apache.poi.ss.usermodel.Sheet;
    +import org.apache.poi.ss.usermodel.Workbook;
    +import org.junit.Assert;
    +import org.junit.Before;
    +import org.junit.Test;
    +
    +import javax.ws.rs.core.HttpHeaders;
    +import javax.ws.rs.core.MediaType;
    +import java.io.IOException;
    +
    +public class LoanWorkbookPopulatorTest {
    +
    +    private ResponseSpecification responseSpec;
    +    private RequestSpecification requestSpec;
    +
    +    @Before
    +    public void setup(){
    +        Utils.initializeRESTAssured();
    +        this.requestSpec=new RequestSpecBuilder().build();
    +        this.requestSpec
    +                .header("Authorization",
    +                        "Basic "
    +                                + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
    +        this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200)
    +                .build();
    +    }
    +    @Test
    +    public void testLoanWorkbookPopulate() throws IOException {
    +        requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
    +        //in order to populate helper sheets
    +        OfficeHelper officeHelper=new OfficeHelper(requestSpec,responseSpec);
    +        Integer outcome_office_creation=officeHelper.createOffice("02 May 2000");
    +        Assert.assertNotNull("Could not create office" ,outcome_office_creation);
    +
    +        //in order to populate helper sheets
    +        ClientHelper clientHelper=new ClientHelper(requestSpec,responseSpec);
    +        Integer outcome_client_creation=clientHelper.createClient(requestSpec,responseSpec);
    +        Assert.assertNotNull("Could not create client" ,outcome_client_creation);
    +
    +        //in order to populate helper sheets
    +        GroupHelper groupHelper=new GroupHelper(requestSpec,responseSpec);
    +        Integer outcome_group_creation=groupHelper.createGroup(requestSpec,responseSpec,true);
    +        Assert.assertNotNull("Could not create group" ,outcome_group_creation);
    +
    +        //in order to populate helper sheets
    +        StaffHelper staffHelper=new StaffHelper();
    +        Integer outcome_staff_creation =staffHelper.createStaff(requestSpec,responseSpec);
    +        Assert.assertNotNull("Could not create staff",outcome_staff_creation);
    +
    +        LoanTransactionHelper loanTransactionHelper=new LoanTransactionHelper(requestSpec,responseSpec);
    +        String jsonLoanProduct="{\"currencyCode\":\"USD\",\"includeInBorrowerCycle\":\"false\"," +
    --- End diff --
    
    Use LoanProductTestBuilder


---

[GitHub] fineract pull request #415: Extend-mifos-data-import-tool-all-modules-popula...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/fineract/pull/415


---

[GitHub] fineract pull request #415: Extend-mifos-data-import-tool-all-modules-popula...

Posted by avikganguly01 <gi...@git.apache.org>.
Github user avikganguly01 commented on a diff in the pull request:

    https://github.com/apache/fineract/pull/415#discussion_r143358749
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/importhandler/center/CenterImportHandler.java ---
    @@ -0,0 +1,288 @@
    +/**
    + * 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.bulkimport.importhandler.center;
    +
    +import com.google.common.reflect.TypeToken;
    +import com.google.gson.GsonBuilder;
    +import org.apache.fineract.commands.domain.CommandWrapper;
    +import org.apache.fineract.commands.service.CommandWrapperBuilder;
    +import org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService;
    +import org.apache.fineract.infrastructure.bulkimport.constants.CenterConstants;
    +import org.apache.fineract.infrastructure.bulkimport.constants.TemplatePopulateImportConstants;
    +import org.apache.fineract.infrastructure.bulkimport.data.Count;
    +import org.apache.fineract.infrastructure.bulkimport.importhandler.ImportHandler;
    +import org.apache.fineract.infrastructure.bulkimport.importhandler.ImportHandlerUtils;
    +import org.apache.fineract.infrastructure.bulkimport.importhandler.helper.DateSerializer;
    +import org.apache.fineract.infrastructure.bulkimport.importhandler.helper.EnumOptionDataValueSerializer;
    +import org.apache.fineract.infrastructure.bulkimport.importhandler.helper.GroupIdSerializer;
    +import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
    +import org.apache.fineract.infrastructure.core.data.EnumOptionData;
    +import org.apache.fineract.infrastructure.core.exception.*;
    +import org.apache.fineract.portfolio.calendar.data.CalendarData;
    +import org.apache.fineract.portfolio.group.data.CenterData;
    +import org.apache.fineract.portfolio.group.data.GroupGeneralData;
    +import org.apache.poi.ss.usermodel.*;
    +import org.joda.time.LocalDate;
    +import org.springframework.beans.factory.annotation.Autowired;
    +import org.springframework.stereotype.Service;
    +
    +import java.lang.reflect.Type;
    +import java.util.ArrayList;
    +import java.util.Collection;
    +import java.util.List;
    +
    +@Service
    +public class CenterImportHandler implements ImportHandler {
    +
    +
    +    private List<CenterData> centers;
    +    private List<CalendarData> meetings;
    +    private List<String>statuses;
    +    private Workbook workbook;
    +
    +    private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService;
    +
    +    @Autowired
    +    public CenterImportHandler(final PortfolioCommandSourceWritePlatformService
    +            commandsSourceWritePlatformService) {
    +        this.commandsSourceWritePlatformService = commandsSourceWritePlatformService;
    +    }
    +
    +    @Override
    +    public Count process(Workbook workbook, String locale, String dateFormat) {
    +        this.centers=new ArrayList<>();
    +        this.meetings=new ArrayList<>();
    +        this.statuses=new ArrayList<>();
    +        this.workbook=workbook;
    +        readExcelFile(locale, dateFormat);
    +        return importEntity(dateFormat);
    +    }
    +
    +    public void readExcelFile(final String locale, final String dateFormat) {
    +
    +        Sheet centersSheet = workbook.getSheet(TemplatePopulateImportConstants.CENTER_SHEET_NAME);
    +        Integer noOfEntries = ImportHandlerUtils.getNumberOfRows(centersSheet, TemplatePopulateImportConstants.FIRST_COLUMN_INDEX);
    +        for (int rowIndex = 1; rowIndex <=noOfEntries; rowIndex++) {
    +            Row row;
    +                row = centersSheet.getRow(rowIndex);
    +                if(ImportHandlerUtils.isNotImported(row, CenterConstants.STATUS_COL)) {
    +                    centers.add(readCenter(row,locale,dateFormat));
    +                    meetings.add(readMeeting(row,locale,dateFormat));
    +                }
    +        }
    +    }
    +
    +    private CalendarData readMeeting(Row row,final String locale, final String dateFormat) {
    +        LocalDate meetingStartDate = ImportHandlerUtils.readAsDate(CenterConstants.MEETING_START_DATE_COL, row);
    +        Boolean isRepeating = ImportHandlerUtils.readAsBoolean(CenterConstants.IS_REPEATING_COL, row);
    +        String frequency = ImportHandlerUtils.readAsString(CenterConstants.FREQUENCY_COL, row);
    +        EnumOptionData frequencyEnum=new EnumOptionData(null,null,ImportHandlerUtils.getFrequencyId(frequency));
    +        Integer interval = ImportHandlerUtils.readAsInt(CenterConstants.INTERVAL_COL, row);
    +        String repeatsOnDay = ImportHandlerUtils.readAsString(CenterConstants.REPEATS_ON_DAY_COL, row);
    +        EnumOptionData repeatsOnDayEnum=new EnumOptionData(null,null,ImportHandlerUtils.getRepeatsOnDayId(repeatsOnDay));
    +        if(meetingStartDate==null)
    +            return null;
    +        else {
    +            if(repeatsOnDay==null)
    +                return CalendarData.importInstanceNoRepeatsOnDay(meetingStartDate, isRepeating,
    +                        frequencyEnum, interval, row.getRowNum(),locale,dateFormat);
    +            else
    +                return CalendarData.importInstanceWithRepeatsOnDay(meetingStartDate, isRepeating,
    +                        frequencyEnum, interval, repeatsOnDayEnum, row.getRowNum(),locale,dateFormat);
    +        }
    +    }
    +
    +    private CenterData readCenter(Row row,final String locale, final String dateFormat) {
    +        String status = ImportHandlerUtils.readAsString(CenterConstants.STATUS_COL, row);
    +        String officeName = ImportHandlerUtils.readAsString(CenterConstants.OFFICE_NAME_COL, row);
    +        Long officeId = ImportHandlerUtils.getIdByName(workbook.getSheet(TemplatePopulateImportConstants.OFFICE_SHEET_NAME), officeName);
    +        String staffName = ImportHandlerUtils.readAsString(CenterConstants.STAFF_NAME_COL, row);
    +        Long staffId = ImportHandlerUtils.getIdByName(workbook.getSheet(TemplatePopulateImportConstants.STAFF_SHEET_NAME), staffName);
    +
    +        String externalId = ImportHandlerUtils.readAsString(CenterConstants.EXTERNAL_ID_COL, row);
    +        Boolean active = ImportHandlerUtils.readAsBoolean(CenterConstants.ACTIVE_COL, row);
    +        LocalDate submittedOn=ImportHandlerUtils.readAsDate(CenterConstants.SUBMITTED_ON_DATE_COL,row);
    +        LocalDate activationDate = null;
    +        if (active){
    +            activationDate=ImportHandlerUtils.readAsDate(CenterConstants.ACTIVATION_DATE_COL, row);
    +        }else {
    +            activationDate=submittedOn;
    +        }
    +        String centerName = ImportHandlerUtils.readAsString(CenterConstants.CENTER_NAME_COL, row);
    +        if(centerName==null||centerName.equals("")) {
    +            throw new IllegalArgumentException("Name is blank");
    +        }
    +        List<GroupGeneralData> groupMembers = new ArrayList<GroupGeneralData>();
    +        for (int cellNo =CenterConstants. GROUP_NAMES_STARTING_COL; cellNo < CenterConstants.GROUP_NAMES_ENDING_COL; cellNo++) {
    +            String groupName = ImportHandlerUtils.readAsString(cellNo, row);
    +            if (groupName==null||groupName.equals(""))
    +                break;
    +            Long groupId = ImportHandlerUtils.getIdByName(workbook.getSheet(TemplatePopulateImportConstants.GROUP_SHEET_NAME), groupName);
    +            GroupGeneralData group = new GroupGeneralData(groupId);
    +            if (!containsGroupId(groupMembers,groupId)) {
    +                groupMembers.add(group);
    +            }
    +        }
    +
    +        statuses.add(status);
    +        return CenterData.importInstance(centerName,groupMembers,activationDate, active,submittedOn, externalId,
    +                officeId, staffId, row.getRowNum(),dateFormat,locale);
    +    }
    +
    +    private boolean containsGroupId(List<GroupGeneralData> groupMembers,Long groupId){
    +        for (GroupGeneralData group: groupMembers) {
    +            if (group.getId()==groupId){
    +                return true;
    +            }
    +        }
    +        return false;
    +    }
    +
    +    public Count importEntity(String dateFormat) {
    +        Sheet centerSheet = workbook.getSheet(TemplatePopulateImportConstants.CENTER_SHEET_NAME);
    +        int progressLevel = 0;
    +        String centerId = "";
    +        int successCount = 0;
    +        int errorCount = 0;
    +        String errorMessage = "";
    +        for (int i = 0; i < centers.size(); i++) {
    +            Row row = centerSheet.getRow(centers.get(i).getRowIndex());
    +            Cell errorReportCell = row.createCell(CenterConstants.FAILURE_COL);
    +            Cell statusCell = row.createCell(CenterConstants.STATUS_COL);
    +            CommandProcessingResult result = null;
    +            try {
    +                String status = statuses.get(i);
    +                progressLevel = getProgressLevel(status);
    +
    +                if (progressLevel == 0) {
    +                    result = importCenter(i, dateFormat);
    +                    centerId = result.getGroupId().toString();
    +                    progressLevel = 1;
    +                } else
    +                    centerId = ImportHandlerUtils.readAsInt(CenterConstants.CENTER_ID_COL, centerSheet.getRow(centers.get(i).getRowIndex())).toString();
    +
    +                if (meetings.get(i) != null)
    +                    progressLevel = importCenterMeeting(result, i, dateFormat);
    +                successCount++;
    +                statusCell.setCellValue(TemplatePopulateImportConstants.STATUS_CELL_IMPORTED);
    +                statusCell.setCellStyle(ImportHandlerUtils.getCellStyle(workbook, IndexedColors.LIGHT_GREEN));
    +            } catch (AbstractPlatformDomainRuleException e) {
    +                errorCount++;
    +                e.printStackTrace();
    +                errorMessage = e.getDefaultUserMessage();
    +                writeCenterErrorMessage(centerId,errorMessage,progressLevel,statusCell,errorReportCell,row);
    --- End diff --
    
    Move all the catch blocks to a functions in your Utils class and call it to get the error message. Call this function from all your import handler classes.


---