Upgrade to JDK 17
This commit is contained in:
committed by
Petri Tuomola
parent
84598709d1
commit
c81fc7f0f4
+2
-2
@@ -19,7 +19,6 @@
|
||||
package org.apache.fineract.batch.exception;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformDomainRuleException;
|
||||
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformResourceNotFoundException;
|
||||
import org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException;
|
||||
@@ -32,6 +31,7 @@ import org.apache.fineract.infrastructure.core.exceptionmapper.PlatformDomainRul
|
||||
import org.apache.fineract.infrastructure.core.exceptionmapper.PlatformInternalServerExceptionMapper;
|
||||
import org.apache.fineract.infrastructure.core.exceptionmapper.PlatformResourceNotFoundExceptionMapper;
|
||||
import org.apache.fineract.infrastructure.core.exceptionmapper.UnsupportedParameterExceptionMapper;
|
||||
import org.apache.fineract.infrastructure.core.serialization.GoogleGsonSerializerHelper;
|
||||
import org.apache.fineract.portfolio.loanaccount.exception.MultiDisbursementDataRequiredException;
|
||||
import org.apache.fineract.portfolio.loanproduct.exception.LinkedAccountRequiredException;
|
||||
import org.springframework.dao.NonTransientDataAccessException;
|
||||
@@ -49,7 +49,7 @@ import org.springframework.transaction.TransactionException;
|
||||
*/
|
||||
public class ErrorHandler extends RuntimeException {
|
||||
|
||||
private static Gson jsonHelper = new GsonBuilder().setPrettyPrinting().create();
|
||||
private static Gson jsonHelper = GoogleGsonSerializerHelper.createGsonBuilder(true).create();
|
||||
|
||||
/**
|
||||
* Sole Constructor
|
||||
|
||||
+3
-2
@@ -38,6 +38,7 @@ import org.apache.fineract.infrastructure.bulkimport.importhandler.helper.EnumOp
|
||||
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.serialization.GoogleGsonSerializerHelper;
|
||||
import org.apache.fineract.portfolio.calendar.data.CalendarData;
|
||||
import org.apache.fineract.portfolio.group.data.CenterData;
|
||||
import org.apache.fineract.portfolio.group.data.GroupGeneralData;
|
||||
@@ -229,7 +230,7 @@ public class CenterImportHandler implements ImportHandler {
|
||||
}
|
||||
|
||||
private CommandProcessingResult importCenter(int rowIndex, String dateFormat) {
|
||||
GsonBuilder gsonBuilder = new GsonBuilder();
|
||||
GsonBuilder gsonBuilder = GoogleGsonSerializerHelper.createGsonBuilder();
|
||||
gsonBuilder.registerTypeAdapter(LocalDate.class, new DateSerializer(dateFormat));
|
||||
Type groupCollectionType = new TypeToken<Collection<GroupGeneralData>>() {}.getType();
|
||||
gsonBuilder.registerTypeAdapter(groupCollectionType, new GroupIdSerializer());
|
||||
@@ -254,7 +255,7 @@ public class CenterImportHandler implements ImportHandler {
|
||||
private Integer importCenterMeeting(CommandProcessingResult result, int rowIndex, String dateFormat) {
|
||||
CalendarData calendarData = meetings.get(rowIndex);
|
||||
calendarData.setTitle("centers_" + result.getGroupId().toString() + "_CollectionMeeting");
|
||||
GsonBuilder gsonBuilder = new GsonBuilder();
|
||||
GsonBuilder gsonBuilder = GoogleGsonSerializerHelper.createGsonBuilder();
|
||||
gsonBuilder.registerTypeAdapter(LocalDate.class, new DateSerializer(dateFormat));
|
||||
gsonBuilder.registerTypeAdapter(EnumOptionData.class, new EnumOptionDataValueSerializer());
|
||||
|
||||
|
||||
+2
-1
@@ -46,6 +46,7 @@ import org.apache.fineract.infrastructure.bulkimport.importhandler.helper.EnumOp
|
||||
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.serialization.GoogleGsonSerializerHelper;
|
||||
import org.apache.fineract.organisation.monetary.data.CurrencyData;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.IndexedColors;
|
||||
@@ -148,7 +149,7 @@ public class ChartOfAccountsImportHandler implements ImportHandler {
|
||||
public Count importEntity(String dateFormat) {
|
||||
Sheet chartOfAccountsSheet = workbook.getSheet(TemplatePopulateImportConstants.CHART_OF_ACCOUNTS_SHEET_NAME);
|
||||
|
||||
GsonBuilder gsonBuilder = new GsonBuilder();
|
||||
GsonBuilder gsonBuilder = GoogleGsonSerializerHelper.createGsonBuilder();
|
||||
gsonBuilder.registerTypeAdapter(EnumOptionData.class, new EnumOptionDataIdSerializer());
|
||||
gsonBuilder.registerTypeAdapter(CodeValueData.class, new CodeValueDataIdSerializer());
|
||||
gsonBuilder.registerTypeAdapter(LocalDate.class, new DateSerializer(dateFormat));
|
||||
|
||||
+2
-1
@@ -35,6 +35,7 @@ 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.core.data.CommandProcessingResult;
|
||||
import org.apache.fineract.infrastructure.core.serialization.GoogleGsonSerializerHelper;
|
||||
import org.apache.fineract.portfolio.address.data.AddressData;
|
||||
import org.apache.fineract.portfolio.client.data.ClientData;
|
||||
import org.apache.fineract.portfolio.client.data.ClientNonPersonData;
|
||||
@@ -198,7 +199,7 @@ public class ClientEntityImportHandler implements ImportHandler {
|
||||
int errorCount = 0;
|
||||
String errorMessage = "";
|
||||
|
||||
GsonBuilder gsonBuilder = new GsonBuilder();
|
||||
GsonBuilder gsonBuilder = GoogleGsonSerializerHelper.createGsonBuilder();
|
||||
gsonBuilder.registerTypeAdapter(LocalDate.class, new DateSerializer(dateFormat));
|
||||
|
||||
for (ClientData client : clients) {
|
||||
|
||||
+2
-1
@@ -34,6 +34,7 @@ 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.core.serialization.GoogleGsonSerializerHelper;
|
||||
import org.apache.fineract.portfolio.address.data.AddressData;
|
||||
import org.apache.fineract.portfolio.client.data.ClientData;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
@@ -183,7 +184,7 @@ public class ClientPersonImportHandler implements ImportHandler {
|
||||
int successCount = 0;
|
||||
int errorCount = 0;
|
||||
String errorMessage = "";
|
||||
GsonBuilder gsonBuilder = new GsonBuilder();
|
||||
GsonBuilder gsonBuilder = GoogleGsonSerializerHelper.createGsonBuilder();
|
||||
gsonBuilder.registerTypeAdapter(LocalDate.class, new DateSerializer(dateFormat));
|
||||
for (ClientData client : clients) {
|
||||
try {
|
||||
|
||||
+5
-4
@@ -38,6 +38,7 @@ import org.apache.fineract.infrastructure.bulkimport.importhandler.helper.DateSe
|
||||
import org.apache.fineract.infrastructure.bulkimport.importhandler.helper.EnumOptionDataIdSerializer;
|
||||
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.apache.fineract.infrastructure.core.data.EnumOptionData;
|
||||
import org.apache.fineract.infrastructure.core.serialization.GoogleGsonSerializerHelper;
|
||||
import org.apache.fineract.portfolio.savings.data.ClosingOfSavingsAccounts;
|
||||
import org.apache.fineract.portfolio.savings.data.FixedDepositAccountData;
|
||||
import org.apache.fineract.portfolio.savings.data.SavingsAccountChargeData;
|
||||
@@ -344,7 +345,7 @@ public class FixedDepositImportHandler implements ImportHandler {
|
||||
|
||||
private int importSavingsClosing(Long savingsId, int i, String dateFormat) {
|
||||
if (closedOnDate.get(i) != null) {
|
||||
GsonBuilder gsonBuilder = new GsonBuilder();
|
||||
GsonBuilder gsonBuilder = GoogleGsonSerializerHelper.createGsonBuilder();
|
||||
gsonBuilder.registerTypeAdapter(LocalDate.class, new DateSerializer(dateFormat));
|
||||
String payload = gsonBuilder.create().toJson(closedOnDate.get(i));
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder() //
|
||||
@@ -357,7 +358,7 @@ public class FixedDepositImportHandler implements ImportHandler {
|
||||
}
|
||||
|
||||
private CommandProcessingResult importSavings(int i, String dateFormat) {
|
||||
GsonBuilder gsonBuilder = new GsonBuilder();
|
||||
GsonBuilder gsonBuilder = GoogleGsonSerializerHelper.createGsonBuilder();
|
||||
gsonBuilder.registerTypeAdapter(LocalDate.class, new DateSerializer(dateFormat));
|
||||
gsonBuilder.registerTypeAdapter(EnumOptionData.class, new EnumOptionDataIdSerializer());
|
||||
JsonObject savingsJsonob = gsonBuilder.create().toJsonTree(savings.get(i)).getAsJsonObject();
|
||||
@@ -382,7 +383,7 @@ public class FixedDepositImportHandler implements ImportHandler {
|
||||
|
||||
private int importSavingsApproval(Long savingsId, int i, String dateFormat) {
|
||||
if (approvalDates.get(i) != null) {
|
||||
GsonBuilder gsonBuilder = new GsonBuilder();
|
||||
GsonBuilder gsonBuilder = GoogleGsonSerializerHelper.createGsonBuilder();
|
||||
gsonBuilder.registerTypeAdapter(LocalDate.class, new DateSerializer(dateFormat));
|
||||
String payload = gsonBuilder.create().toJson(approvalDates.get(i));
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder() //
|
||||
@@ -396,7 +397,7 @@ public class FixedDepositImportHandler implements ImportHandler {
|
||||
|
||||
private int importSavingsActivation(Long savingsId, int i, String dateFormat) {
|
||||
if (activationDates.get(i) != null) {
|
||||
GsonBuilder gsonBuilder = new GsonBuilder();
|
||||
GsonBuilder gsonBuilder = GoogleGsonSerializerHelper.createGsonBuilder();
|
||||
gsonBuilder.registerTypeAdapter(LocalDate.class, new DateSerializer(dateFormat));
|
||||
String payload = gsonBuilder.create().toJson(activationDates.get(i));
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder() //
|
||||
|
||||
+2
-1
@@ -35,6 +35,7 @@ import org.apache.fineract.infrastructure.bulkimport.importhandler.ImportHandler
|
||||
import org.apache.fineract.infrastructure.bulkimport.importhandler.helper.DateSerializer;
|
||||
import org.apache.fineract.infrastructure.bulkimport.importhandler.helper.SavingsAccountTransactionEnumValueSerialiser;
|
||||
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.apache.fineract.infrastructure.core.serialization.GoogleGsonSerializerHelper;
|
||||
import org.apache.fineract.portfolio.savings.data.SavingsAccountTransactionData;
|
||||
import org.apache.fineract.portfolio.savings.data.SavingsAccountTransactionEnumData;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
@@ -119,7 +120,7 @@ public class FixedDepositTransactionImportHandler implements ImportHandler {
|
||||
int successCount = 0;
|
||||
int errorCount = 0;
|
||||
String errorMessage = "";
|
||||
GsonBuilder gsonBuilder = new GsonBuilder();
|
||||
GsonBuilder gsonBuilder = GoogleGsonSerializerHelper.createGsonBuilder();
|
||||
gsonBuilder.registerTypeAdapter(LocalDate.class, new DateSerializer(dateFormat));
|
||||
gsonBuilder.registerTypeAdapter(SavingsAccountTransactionEnumData.class, new SavingsAccountTransactionEnumValueSerialiser());
|
||||
|
||||
|
||||
+3
-2
@@ -38,6 +38,7 @@ import org.apache.fineract.infrastructure.bulkimport.importhandler.helper.DateSe
|
||||
import org.apache.fineract.infrastructure.bulkimport.importhandler.helper.EnumOptionDataValueSerializer;
|
||||
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.apache.fineract.infrastructure.core.data.EnumOptionData;
|
||||
import org.apache.fineract.infrastructure.core.serialization.GoogleGsonSerializerHelper;
|
||||
import org.apache.fineract.portfolio.calendar.data.CalendarData;
|
||||
import org.apache.fineract.portfolio.client.data.ClientData;
|
||||
import org.apache.fineract.portfolio.group.data.GroupGeneralData;
|
||||
@@ -233,7 +234,7 @@ public class GroupImportHandler implements ImportHandler {
|
||||
private Integer importGroupMeeting(CommandProcessingResult result, int rowIndex, String dateFormat) {
|
||||
CalendarData calendarData = meetings.get(rowIndex);
|
||||
calendarData.setTitle("group_" + result.getGroupId().toString() + "_CollectionMeeting");
|
||||
GsonBuilder gsonBuilder = new GsonBuilder();
|
||||
GsonBuilder gsonBuilder = GoogleGsonSerializerHelper.createGsonBuilder();
|
||||
gsonBuilder.registerTypeAdapter(LocalDate.class, new DateSerializer(dateFormat));
|
||||
gsonBuilder.registerTypeAdapter(EnumOptionData.class, new EnumOptionDataValueSerializer());
|
||||
|
||||
@@ -250,7 +251,7 @@ public class GroupImportHandler implements ImportHandler {
|
||||
}
|
||||
|
||||
private CommandProcessingResult importGroup(int rowIndex, String dateFormat) {
|
||||
GsonBuilder gsonBuilder = new GsonBuilder();
|
||||
GsonBuilder gsonBuilder = GoogleGsonSerializerHelper.createGsonBuilder();
|
||||
gsonBuilder.registerTypeAdapter(LocalDate.class, new DateSerializer(dateFormat));
|
||||
Type clientCollectionType = new TypeToken<Collection<ClientData>>() {}.getType();
|
||||
gsonBuilder.registerTypeAdapter(clientCollectionType, new ClientIdSerializer());
|
||||
|
||||
+2
-1
@@ -35,6 +35,7 @@ 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.core.data.CommandProcessingResult;
|
||||
import org.apache.fineract.infrastructure.core.serialization.GoogleGsonSerializerHelper;
|
||||
import org.apache.fineract.portfolio.loanaccount.guarantor.data.GuarantorData;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.IndexedColors;
|
||||
@@ -125,7 +126,7 @@ public class GuarantorImportHandler implements ImportHandler {
|
||||
int successCount = 0;
|
||||
int errorCount = 0;
|
||||
String errorMessage = "";
|
||||
GsonBuilder gsonBuilder = new GsonBuilder();
|
||||
GsonBuilder gsonBuilder = GoogleGsonSerializerHelper.createGsonBuilder();
|
||||
gsonBuilder.registerTypeAdapter(LocalDate.class, new DateSerializer(dateFormat));
|
||||
for (GuarantorData guarantor : guarantors) {
|
||||
try {
|
||||
|
||||
+2
-1
@@ -36,6 +36,7 @@ import org.apache.fineract.infrastructure.bulkimport.importhandler.ImportHandler
|
||||
import org.apache.fineract.infrastructure.bulkimport.importhandler.helper.CurrencyDateCodeSerializer;
|
||||
import org.apache.fineract.infrastructure.bulkimport.importhandler.helper.DateSerializer;
|
||||
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.apache.fineract.infrastructure.core.serialization.GoogleGsonSerializerHelper;
|
||||
import org.apache.fineract.organisation.monetary.data.CurrencyData;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.IndexedColors;
|
||||
@@ -197,7 +198,7 @@ public class JournalEntriesImportHandler implements ImportHandler {
|
||||
int successCount = 0;
|
||||
int errorCount = 0;
|
||||
String errorMessage = "";
|
||||
GsonBuilder gsonBuilder = new GsonBuilder();
|
||||
GsonBuilder gsonBuilder = GoogleGsonSerializerHelper.createGsonBuilder();
|
||||
gsonBuilder.registerTypeAdapter(LocalDate.class, new DateSerializer(dateFormat));
|
||||
gsonBuilder.registerTypeAdapter(CurrencyData.class, new CurrencyDateCodeSerializer());
|
||||
|
||||
|
||||
+5
-4
@@ -39,6 +39,7 @@ import org.apache.fineract.infrastructure.bulkimport.importhandler.helper.DateSe
|
||||
import org.apache.fineract.infrastructure.bulkimport.importhandler.helper.EnumOptionDataValueSerializer;
|
||||
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.apache.fineract.infrastructure.core.data.EnumOptionData;
|
||||
import org.apache.fineract.infrastructure.core.serialization.GoogleGsonSerializerHelper;
|
||||
import org.apache.fineract.portfolio.loanaccount.data.DisbursementData;
|
||||
import org.apache.fineract.portfolio.loanaccount.data.LoanAccountData;
|
||||
import org.apache.fineract.portfolio.loanaccount.data.LoanApprovalData;
|
||||
@@ -466,7 +467,7 @@ public class LoanImportHandler implements ImportHandler {
|
||||
}
|
||||
|
||||
private Integer importLoanRepayment(CommandProcessingResult result, int rowIndex, String dateFormat) {
|
||||
GsonBuilder gsonBuilder = new GsonBuilder();
|
||||
GsonBuilder gsonBuilder = GoogleGsonSerializerHelper.createGsonBuilder();
|
||||
gsonBuilder.registerTypeAdapter(LocalDate.class, new DateSerializer(dateFormat));
|
||||
JsonObject loanRepaymentJsonob = gsonBuilder.create().toJsonTree(loanRepayments.get(rowIndex)).getAsJsonObject();
|
||||
loanRepaymentJsonob.remove("manuallyReversed");
|
||||
@@ -486,7 +487,7 @@ public class LoanImportHandler implements ImportHandler {
|
||||
|
||||
DisbursementData disbusalData = disbursalDates.get(rowIndex);
|
||||
String linkAccountId = disbusalData.getLinkAccountId();
|
||||
GsonBuilder gsonBuilder = new GsonBuilder();
|
||||
GsonBuilder gsonBuilder = GoogleGsonSerializerHelper.createGsonBuilder();
|
||||
gsonBuilder.registerTypeAdapter(LocalDate.class, new DateSerializer(dateFormat));
|
||||
if (linkAccountId != null && !"".equals(linkAccountId)) {
|
||||
String payload = gsonBuilder.create().toJson(disbusalData);
|
||||
@@ -510,7 +511,7 @@ public class LoanImportHandler implements ImportHandler {
|
||||
|
||||
private Integer importLoanApproval(CommandProcessingResult result, int rowIndex, String dateFormat) {
|
||||
if (approvalDates.get(rowIndex) != null) {
|
||||
GsonBuilder gsonBuilder = new GsonBuilder();
|
||||
GsonBuilder gsonBuilder = GoogleGsonSerializerHelper.createGsonBuilder();
|
||||
gsonBuilder.registerTypeAdapter(LocalDate.class, new DateSerializer(dateFormat));
|
||||
String payload = gsonBuilder.create().toJson(approvalDates.get(rowIndex));
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder() //
|
||||
@@ -524,7 +525,7 @@ public class LoanImportHandler implements ImportHandler {
|
||||
}
|
||||
|
||||
private CommandProcessingResult importLoan(int rowIndex, String dateFormat) {
|
||||
GsonBuilder gsonBuilder = new GsonBuilder();
|
||||
GsonBuilder gsonBuilder = GoogleGsonSerializerHelper.createGsonBuilder();
|
||||
gsonBuilder.registerTypeAdapter(LocalDate.class, new DateSerializer(dateFormat));
|
||||
gsonBuilder.registerTypeAdapter(EnumOptionData.class, new EnumOptionDataValueSerializer());
|
||||
JsonObject loanJsonOb = gsonBuilder.create().toJsonTree(loans.get(rowIndex)).getAsJsonObject();
|
||||
|
||||
+2
-1
@@ -34,6 +34,7 @@ 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.core.serialization.GoogleGsonSerializerHelper;
|
||||
import org.apache.fineract.portfolio.loanaccount.data.LoanTransactionData;
|
||||
import org.apache.fineract.portfolio.loanaccount.service.LoanReadPlatformService;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
@@ -112,7 +113,7 @@ public class LoanRepaymentImportHandler implements ImportHandler {
|
||||
int successCount = 0;
|
||||
int errorCount = 0;
|
||||
String errorMessage = "";
|
||||
GsonBuilder gsonBuilder = new GsonBuilder();
|
||||
GsonBuilder gsonBuilder = GoogleGsonSerializerHelper.createGsonBuilder();
|
||||
gsonBuilder.registerTypeAdapter(LocalDate.class, new DateSerializer(dateFormat));
|
||||
|
||||
for (LoanTransactionData loanRepayment : loanRepayments) {
|
||||
|
||||
+2
-1
@@ -32,6 +32,7 @@ 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.core.data.CommandProcessingResult;
|
||||
import org.apache.fineract.infrastructure.core.serialization.GoogleGsonSerializerHelper;
|
||||
import org.apache.fineract.organisation.office.data.OfficeData;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.IndexedColors;
|
||||
@@ -88,7 +89,7 @@ public class OfficeImportHandler implements ImportHandler {
|
||||
|
||||
public Count importEntity(String dateFormat) {
|
||||
Sheet officeSheet = workbook.getSheet(TemplatePopulateImportConstants.OFFICE_SHEET_NAME);
|
||||
GsonBuilder gsonBuilder = new GsonBuilder();
|
||||
GsonBuilder gsonBuilder = GoogleGsonSerializerHelper.createGsonBuilder();
|
||||
gsonBuilder.registerTypeAdapter(LocalDate.class, new DateSerializer(dateFormat));
|
||||
|
||||
int successCount = 0;
|
||||
|
||||
+4
-3
@@ -36,6 +36,7 @@ import org.apache.fineract.infrastructure.bulkimport.importhandler.helper.DateSe
|
||||
import org.apache.fineract.infrastructure.bulkimport.importhandler.helper.EnumOptionDataIdSerializer;
|
||||
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.apache.fineract.infrastructure.core.data.EnumOptionData;
|
||||
import org.apache.fineract.infrastructure.core.serialization.GoogleGsonSerializerHelper;
|
||||
import org.apache.fineract.portfolio.savings.data.RecurringDepositAccountData;
|
||||
import org.apache.fineract.portfolio.savings.data.SavingsAccountChargeData;
|
||||
import org.apache.fineract.portfolio.savings.data.SavingsActivation;
|
||||
@@ -346,7 +347,7 @@ public class RecurringDepositImportHandler implements ImportHandler {
|
||||
|
||||
private int importSavingsActivation(Long savingsId, int i, String dateFormat) {
|
||||
if (activationDates.get(i) != null) {
|
||||
GsonBuilder gsonBuilder = new GsonBuilder();
|
||||
GsonBuilder gsonBuilder = GoogleGsonSerializerHelper.createGsonBuilder();
|
||||
gsonBuilder.registerTypeAdapter(LocalDate.class, new DateSerializer(dateFormat));
|
||||
String payload = gsonBuilder.create().toJson(activationDates.get(i));
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder() //
|
||||
@@ -360,7 +361,7 @@ public class RecurringDepositImportHandler implements ImportHandler {
|
||||
|
||||
private int importSavingsApproval(Long savingsId, int i, String dateFormat) {
|
||||
if (approvalDates.get(i) != null) {
|
||||
GsonBuilder gsonBuilder = new GsonBuilder();
|
||||
GsonBuilder gsonBuilder = GoogleGsonSerializerHelper.createGsonBuilder();
|
||||
gsonBuilder.registerTypeAdapter(LocalDate.class, new DateSerializer(dateFormat));
|
||||
String payload = gsonBuilder.create().toJson(approvalDates.get(i));
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder() //
|
||||
@@ -373,7 +374,7 @@ public class RecurringDepositImportHandler implements ImportHandler {
|
||||
}
|
||||
|
||||
private CommandProcessingResult importSavings(int i, String dateFormat) {
|
||||
GsonBuilder gsonBuilder = new GsonBuilder();
|
||||
GsonBuilder gsonBuilder = GoogleGsonSerializerHelper.createGsonBuilder();
|
||||
gsonBuilder.registerTypeAdapter(LocalDate.class, new DateSerializer(dateFormat));
|
||||
gsonBuilder.registerTypeAdapter(EnumOptionData.class, new EnumOptionDataIdSerializer());
|
||||
JsonObject savingsJsonob = gsonBuilder.create().toJsonTree(savings.get(i)).getAsJsonObject();
|
||||
|
||||
+2
-1
@@ -36,6 +36,7 @@ import org.apache.fineract.infrastructure.bulkimport.importhandler.helper.DateSe
|
||||
import org.apache.fineract.infrastructure.bulkimport.importhandler.helper.SavingsAccountTransactionEnumValueSerialiser;
|
||||
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformDomainRuleException;
|
||||
import org.apache.fineract.infrastructure.core.serialization.GoogleGsonSerializerHelper;
|
||||
import org.apache.fineract.portfolio.savings.data.SavingsAccountTransactionData;
|
||||
import org.apache.fineract.portfolio.savings.data.SavingsAccountTransactionEnumData;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
@@ -120,7 +121,7 @@ public class RecurringDepositTransactionImportHandler implements ImportHandler {
|
||||
int successCount = 0;
|
||||
int errorCount = 0;
|
||||
String errorMessage = "";
|
||||
GsonBuilder gsonBuilder = new GsonBuilder();
|
||||
GsonBuilder gsonBuilder = GoogleGsonSerializerHelper.createGsonBuilder();
|
||||
gsonBuilder.registerTypeAdapter(LocalDate.class, new DateSerializer(dateFormat));
|
||||
gsonBuilder.registerTypeAdapter(SavingsAccountTransactionEnumData.class, new SavingsAccountTransactionEnumValueSerialiser());
|
||||
|
||||
|
||||
+4
-3
@@ -37,6 +37,7 @@ import org.apache.fineract.infrastructure.bulkimport.importhandler.helper.DateSe
|
||||
import org.apache.fineract.infrastructure.bulkimport.importhandler.helper.EnumOptionDataIdSerializer;
|
||||
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.apache.fineract.infrastructure.core.data.EnumOptionData;
|
||||
import org.apache.fineract.infrastructure.core.serialization.GoogleGsonSerializerHelper;
|
||||
import org.apache.fineract.portfolio.savings.data.SavingsAccountChargeData;
|
||||
import org.apache.fineract.portfolio.savings.data.SavingsAccountData;
|
||||
import org.apache.fineract.portfolio.savings.data.SavingsActivation;
|
||||
@@ -341,7 +342,7 @@ public class SavingsImportHandler implements ImportHandler {
|
||||
|
||||
private int importSavingsActivation(Long savingsId, int i, String dateFormat) {
|
||||
if (activationDates.get(i) != null) {
|
||||
GsonBuilder gsonBuilder = new GsonBuilder();
|
||||
GsonBuilder gsonBuilder = GoogleGsonSerializerHelper.createGsonBuilder();
|
||||
gsonBuilder.registerTypeAdapter(LocalDate.class, new DateSerializer(dateFormat));
|
||||
String payload = gsonBuilder.create().toJson(activationDates.get(i));
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder() //
|
||||
@@ -355,7 +356,7 @@ public class SavingsImportHandler implements ImportHandler {
|
||||
|
||||
private int importSavingsApproval(Long savingsId, int i, String dateFormat) {
|
||||
if (approvalDates.get(i) != null) {
|
||||
GsonBuilder gsonBuilder = new GsonBuilder();
|
||||
GsonBuilder gsonBuilder = GoogleGsonSerializerHelper.createGsonBuilder();
|
||||
gsonBuilder.registerTypeAdapter(LocalDate.class, new DateSerializer(dateFormat));
|
||||
String payload = gsonBuilder.create().toJson(approvalDates.get(i));
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder() //
|
||||
@@ -368,7 +369,7 @@ public class SavingsImportHandler implements ImportHandler {
|
||||
}
|
||||
|
||||
private CommandProcessingResult importSavings(int i, String dateFormat) {
|
||||
GsonBuilder gsonBuilder = new GsonBuilder();
|
||||
GsonBuilder gsonBuilder = GoogleGsonSerializerHelper.createGsonBuilder();
|
||||
gsonBuilder.registerTypeAdapter(LocalDate.class, new DateSerializer(dateFormat));
|
||||
gsonBuilder.registerTypeAdapter(EnumOptionData.class, new EnumOptionDataIdSerializer());
|
||||
JsonObject savingsJsonob = gsonBuilder.create().toJsonTree(savings.get(i)).getAsJsonObject();
|
||||
|
||||
+2
-1
@@ -35,6 +35,7 @@ import org.apache.fineract.infrastructure.bulkimport.importhandler.ImportHandler
|
||||
import org.apache.fineract.infrastructure.bulkimport.importhandler.helper.DateSerializer;
|
||||
import org.apache.fineract.infrastructure.bulkimport.importhandler.helper.SavingsAccountTransactionEnumValueSerialiser;
|
||||
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.apache.fineract.infrastructure.core.serialization.GoogleGsonSerializerHelper;
|
||||
import org.apache.fineract.portfolio.savings.data.SavingsAccountTransactionData;
|
||||
import org.apache.fineract.portfolio.savings.data.SavingsAccountTransactionEnumData;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
@@ -119,7 +120,7 @@ public class SavingsTransactionImportHandler implements ImportHandler {
|
||||
int successCount = 0;
|
||||
int errorCount = 0;
|
||||
String errorMessage = "";
|
||||
GsonBuilder gsonBuilder = new GsonBuilder();
|
||||
GsonBuilder gsonBuilder = GoogleGsonSerializerHelper.createGsonBuilder();
|
||||
gsonBuilder.registerTypeAdapter(LocalDate.class, new DateSerializer(dateFormat));
|
||||
gsonBuilder.registerTypeAdapter(SavingsAccountTransactionEnumData.class, new SavingsAccountTransactionEnumValueSerialiser());
|
||||
|
||||
|
||||
+2
-1
@@ -33,6 +33,7 @@ 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.core.data.CommandProcessingResult;
|
||||
import org.apache.fineract.infrastructure.core.serialization.GoogleGsonSerializerHelper;
|
||||
import org.apache.fineract.portfolio.shareaccounts.data.ShareAccountChargeData;
|
||||
import org.apache.fineract.portfolio.shareaccounts.data.ShareAccountData;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
@@ -153,7 +154,7 @@ public class SharedAccountImportHandler implements ImportHandler {
|
||||
int successCount = 0;
|
||||
int errorCount = 0;
|
||||
String errorMessage = "";
|
||||
GsonBuilder gsonBuilder = new GsonBuilder();
|
||||
GsonBuilder gsonBuilder = GoogleGsonSerializerHelper.createGsonBuilder();
|
||||
gsonBuilder.registerTypeAdapter(LocalDate.class, new DateSerializer(dateFormat));
|
||||
|
||||
for (ShareAccountData shareAccountData : shareAccountDataList) {
|
||||
|
||||
+2
-1
@@ -32,6 +32,7 @@ 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.core.data.CommandProcessingResult;
|
||||
import org.apache.fineract.infrastructure.core.serialization.GoogleGsonSerializerHelper;
|
||||
import org.apache.fineract.organisation.staff.data.StaffData;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.IndexedColors;
|
||||
@@ -101,7 +102,7 @@ public class StaffImportHandler implements ImportHandler {
|
||||
int successCount = 0;
|
||||
int errorCount = 0;
|
||||
String errorMessage = "";
|
||||
GsonBuilder gsonBuilder = new GsonBuilder();
|
||||
GsonBuilder gsonBuilder = GoogleGsonSerializerHelper.createGsonBuilder();
|
||||
gsonBuilder.registerTypeAdapter(LocalDate.class, new DateSerializer(dateFormat));
|
||||
for (StaffData staff : staffList) {
|
||||
try {
|
||||
|
||||
+2
-1
@@ -31,6 +31,7 @@ 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.core.data.CommandProcessingResult;
|
||||
import org.apache.fineract.infrastructure.core.serialization.GoogleGsonSerializerHelper;
|
||||
import org.apache.fineract.useradministration.data.AppUserData;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.IndexedColors;
|
||||
@@ -113,7 +114,7 @@ public class UserImportHandler implements ImportHandler {
|
||||
int successCount = 0;
|
||||
int errorCount = 0;
|
||||
String errorMessage = "";
|
||||
GsonBuilder gsonBuilder = new GsonBuilder();
|
||||
GsonBuilder gsonBuilder = GoogleGsonSerializerHelper.createGsonBuilder();
|
||||
for (AppUserData user : users) {
|
||||
try {
|
||||
JsonObject userJsonob = gsonBuilder.create().toJsonTree(user).getAsJsonObject();
|
||||
|
||||
+2
-2
@@ -28,10 +28,10 @@ import java.time.LocalDate;
|
||||
import java.time.temporal.ChronoField;
|
||||
|
||||
/**
|
||||
* Serializer for Joda Time {@link LocalDate} that returns the date in array format to match previous Jackson
|
||||
* Serializer for Java Local Time {@link LocalDate} that returns the date in array format to match previous Jackson
|
||||
* functionality.
|
||||
*/
|
||||
public class JodaLocalDateAdapter implements JsonSerializer<LocalDate> {
|
||||
public class LocalDateAdapter implements JsonSerializer<LocalDate> {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unused")
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* 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.core.api;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
import java.lang.reflect.Type;
|
||||
import java.time.LocalTime;
|
||||
|
||||
/**
|
||||
* Serializer for Java Local Time {@link LocalTime} that returns the time in array format to match previous Jackson
|
||||
* functionality.
|
||||
*/
|
||||
public class LocalTimeAdapter implements JsonSerializer<LocalTime> {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unused")
|
||||
public JsonElement serialize(final LocalTime src, final Type typeOfSrc, final JsonSerializationContext context) {
|
||||
JsonArray array = null;
|
||||
if (src != null) {
|
||||
array = new JsonArray();
|
||||
array.add(new JsonPrimitive(src.getHour()));
|
||||
array.add(new JsonPrimitive(src.getMinute()));
|
||||
array.add(new JsonPrimitive(src.getSecond()));
|
||||
}
|
||||
return array;
|
||||
}
|
||||
}
|
||||
+19
-11
@@ -22,6 +22,7 @@ import com.google.gson.ExclusionStrategy;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalTime;
|
||||
import java.time.MonthDay;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.ArrayList;
|
||||
@@ -29,8 +30,9 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import org.apache.fineract.infrastructure.core.api.DateAdapter;
|
||||
import org.apache.fineract.infrastructure.core.api.JodaDateTimeAdapter;
|
||||
import org.apache.fineract.infrastructure.core.api.JodaLocalDateAdapter;
|
||||
import org.apache.fineract.infrastructure.core.api.JodaMonthDayAdapter;
|
||||
import org.apache.fineract.infrastructure.core.api.LocalDateAdapter;
|
||||
import org.apache.fineract.infrastructure.core.api.LocalTimeAdapter;
|
||||
import org.apache.fineract.infrastructure.core.api.ParameterListExclusionStrategy;
|
||||
import org.apache.fineract.infrastructure.core.api.ParameterListInclusionStrategy;
|
||||
import org.apache.fineract.infrastructure.core.exception.UnsupportedParameterException;
|
||||
@@ -42,15 +44,6 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
public final class GoogleGsonSerializerHelper {
|
||||
|
||||
public Gson createGsonBuilder(final boolean prettyPrint) {
|
||||
final GsonBuilder builder = new GsonBuilder();
|
||||
registerTypeAdapters(builder);
|
||||
if (prettyPrint) {
|
||||
builder.setPrettyPrinting();
|
||||
}
|
||||
return builder.create();
|
||||
}
|
||||
|
||||
public Gson createGsonBuilderForPartialResponseFiltering(final boolean prettyPrint, final Set<String> responseParameters) {
|
||||
final ExclusionStrategy strategy = new ParameterListInclusionStrategy(responseParameters);
|
||||
|
||||
@@ -99,9 +92,24 @@ public final class GoogleGsonSerializerHelper {
|
||||
return serializer.toJson(singleDataObject);
|
||||
}
|
||||
|
||||
public static GsonBuilder createGsonBuilder() {
|
||||
return createGsonBuilder(false);
|
||||
}
|
||||
|
||||
public static GsonBuilder createGsonBuilder(final boolean prettyPrint) {
|
||||
final GsonBuilder builder = new GsonBuilder();
|
||||
registerTypeAdapters(builder);
|
||||
if (prettyPrint) {
|
||||
builder.setPrettyPrinting();
|
||||
}
|
||||
return builder;
|
||||
}
|
||||
|
||||
public static void registerTypeAdapters(final GsonBuilder builder) {
|
||||
builder.registerTypeAdapter(java.util.Date.class, new DateAdapter());
|
||||
builder.registerTypeAdapter(LocalDate.class, new JodaLocalDateAdapter());
|
||||
builder.registerTypeAdapter(LocalDate.class, new LocalDateAdapter());
|
||||
// NOTE: was missing, necessary for GSON serialization with JDK 17's restrictive module access
|
||||
builder.registerTypeAdapter(LocalTime.class, new LocalTimeAdapter());
|
||||
builder.registerTypeAdapter(ZonedDateTime.class, new JodaDateTimeAdapter());
|
||||
builder.registerTypeAdapter(MonthDay.class, new JodaMonthDayAdapter());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user