corrected type while fethcing data from metadata

This commit is contained in:
pramod
2016-02-16 12:21:30 +05:30
parent a13a80794f
commit b5dc6b2b5b
2 changed files with 79 additions and 62 deletions
@@ -68,21 +68,9 @@ public final class ResultsetColumnHeaderData {
this.columnValues = columnValues; this.columnValues = columnValues;
this.columnCode = columnCode; this.columnCode = columnCode;
if("NEWDECIMAL".equalsIgnoreCase(this.columnType)) { // Refer org.drizzle.jdbc.internal.mysql.MySQLType.java
this.columnType = "DECIMAL" ; adjustColumnTypes();
//Refer org.drizzle.jdbc.internal.mysql.MySQLType.java
}
if("CLOB".equalsIgnoreCase(this.columnType)) {
this.columnType = "varchar" ;
//Drizzle is returning some of the String data a CLOB
}
if("LONGLONG".equalsIgnoreCase(this.columnType) || "LONG".equalsIgnoreCase(this.columnType)) {
this.columnType = "bigint" ;
//Refer org.drizzle.jdbc.internal.mysql.MySQLType.java
}
String displayType = null; String displayType = null;
if (this.columnCode == null) { if (this.columnCode == null) {
if (isString()) { if (isString()) {
@@ -97,7 +85,7 @@ public final class ResultsetColumnHeaderData {
displayType = "DECIMAL"; displayType = "DECIMAL";
} else if (isAnyText()) { } else if (isAnyText()) {
displayType = "TEXT"; displayType = "TEXT";
} else if(isBit()) { } else if (isBit()) {
displayType = "BOOLEAN"; displayType = "BOOLEAN";
} else { } else {
throw new PlatformDataIntegrityException("error.msg.invalid.lookup.type", "Invalid Lookup Type:" + this.columnType throw new PlatformDataIntegrityException("error.msg.invalid.lookup.type", "Invalid Lookup Type:" + this.columnType
@@ -118,6 +106,33 @@ public final class ResultsetColumnHeaderData {
this.columnDisplayType = displayType; this.columnDisplayType = displayType;
} }
private void adjustColumnTypes() {
switch (this.columnType) {
case "NEWDECIMAL":
this.columnType = "DECIMAL";
break;
case "CLOB":
case "ENUM":
case "SET":
this.columnType = "varchar";
break;
case "LONGLONG":
this.columnType = "bigint";
break;
case "SHORT":
this.columnType = "smallint";
break;
case "TINY":
this.columnType = "tinyint";
break;
case "INT24":
this.columnType = "int";
break;
default:
break;
}
}
public boolean isNamed(final String columnName) { public boolean isNamed(final String columnName) {
return this.columnName.equalsIgnoreCase(columnName); return this.columnName.equalsIgnoreCase(columnName);
} }
@@ -144,7 +159,7 @@ public final class ResultsetColumnHeaderData {
private boolean isDecimal() { private boolean isDecimal() {
return "decimal".equalsIgnoreCase(this.columnType) || "NEWDECIMAL".equalsIgnoreCase(this.columnType); return "decimal".equalsIgnoreCase(this.columnType) || "NEWDECIMAL".equalsIgnoreCase(this.columnType);
//Refer org.drizzle.jdbc.internal.mysql.MySQLType.java // Refer org.drizzle.jdbc.internal.mysql.MySQLType.java
} }
private boolean isDate() { private boolean isDate() {
@@ -190,10 +205,10 @@ public final class ResultsetColumnHeaderData {
private boolean isBigInt() { private boolean isBigInt() {
return "bigint".equalsIgnoreCase(this.columnType); return "bigint".equalsIgnoreCase(this.columnType);
} }
private boolean isLong() { private boolean isLong() {
return "LONG".equalsIgnoreCase(this.columnType) || "LONGLONG".equalsIgnoreCase(this.columnType); return "LONG".equalsIgnoreCase(this.columnType) || "LONGLONG".equalsIgnoreCase(this.columnType);
//Refer org.drizzle.jdbc.internal.mysql.MySQLType.java // Refer org.drizzle.jdbc.internal.mysql.MySQLType.java
} }
private boolean isBit() { private boolean isBit() {
@@ -1599,11 +1599,11 @@ public class Loan extends AbstractPersistable<Long> {
BigDecimal chargeAmt = BigDecimal.ZERO; BigDecimal chargeAmt = BigDecimal.ZERO;
BigDecimal totalChargeAmt = BigDecimal.ZERO; BigDecimal totalChargeAmt = BigDecimal.ZERO;
if (loanCharge.getChargeCalculation().isPercentageBased()) { if (loanCharge.getChargeCalculation().isPercentageBased()) {
if (loanCharge.isOverdueInstallmentCharge()) { if (loanCharge.isOverdueInstallmentCharge()) {
amount = calculateOverdueAmountPercentageAppliedTo(loanCharge, penaltyWaitPeriod); amount = calculateOverdueAmountPercentageAppliedTo(loanCharge, penaltyWaitPeriod);
} else { } else {
amount = calculateAmountPercentageAppliedTo(loanCharge); amount = calculateAmountPercentageAppliedTo(loanCharge);
} }
chargeAmt = loanCharge.getPercentage(); chargeAmt = loanCharge.getPercentage();
if (loanCharge.isInstalmentFee()) { if (loanCharge.isInstalmentFee()) {
totalChargeAmt = calculatePerInstallmentChargeAmount(loanCharge); totalChargeAmt = calculatePerInstallmentChargeAmount(loanCharge);
@@ -2337,7 +2337,8 @@ public class Loan extends AbstractPersistable<Long> {
} }
public void regenerateScheduleOnDisbursement(final ScheduleGeneratorDTO scheduleGeneratorDTO, final boolean recalculateSchedule, public void regenerateScheduleOnDisbursement(final ScheduleGeneratorDTO scheduleGeneratorDTO, final boolean recalculateSchedule,
final LocalDate actualDisbursementDate, BigDecimal emiAmount, final AppUser currentUser, LocalDate nextPossibleRepaymentDate, Date rescheduledRepaymentDate) { final LocalDate actualDisbursementDate, BigDecimal emiAmount, final AppUser currentUser, LocalDate nextPossibleRepaymentDate,
Date rescheduledRepaymentDate) {
boolean isEmiAmountChanged = false; boolean isEmiAmountChanged = false;
if ((this.loanProduct.isMultiDisburseLoan() || this.loanProduct.canDefineInstallmentAmount()) && emiAmount != null if ((this.loanProduct.isMultiDisburseLoan() || this.loanProduct.canDefineInstallmentAmount()) && emiAmount != null
&& emiAmount.compareTo(retriveLastEmiAmount()) != 0) { && emiAmount.compareTo(retriveLastEmiAmount()) != 0) {
@@ -2352,11 +2353,12 @@ public class Loan extends AbstractPersistable<Long> {
} }
isEmiAmountChanged = true; isEmiAmountChanged = true;
} }
if(rescheduledRepaymentDate != null && this.loanProduct.isMultiDisburseLoan()){ if (rescheduledRepaymentDate != null && this.loanProduct.isMultiDisburseLoan()) {
final boolean isSpecificToInstallment = false; final boolean isSpecificToInstallment = false;
LoanTermVariations loanVariationTerms = new LoanTermVariations(LoanTermVariationType.DUE_DATE.getValue(), LoanTermVariations loanVariationTerms = new LoanTermVariations(LoanTermVariationType.DUE_DATE.getValue(),
nextPossibleRepaymentDate.toDate(), emiAmount, rescheduledRepaymentDate, isSpecificToInstallment, this, LoanStatus.ACTIVE.getValue()); nextPossibleRepaymentDate.toDate(), emiAmount, rescheduledRepaymentDate, isSpecificToInstallment, this,
this.loanTermVariations.add(loanVariationTerms); LoanStatus.ACTIVE.getValue());
this.loanTermVariations.add(loanVariationTerms);
} }
if (isRepaymentScheduleRegenerationRequiredForDisbursement(actualDisbursementDate) || recalculateSchedule || isEmiAmountChanged) { if (isRepaymentScheduleRegenerationRequiredForDisbursement(actualDisbursementDate) || recalculateSchedule || isEmiAmountChanged) {
@@ -4771,7 +4773,7 @@ public class Loan extends AbstractPersistable<Long> {
} }
public ChangedTransactionDetail updateDisbursementDateAndAmountForTranche(final LoanDisbursementDetails disbursementDetails, public ChangedTransactionDetail updateDisbursementDateAndAmountForTranche(final LoanDisbursementDetails disbursementDetails,
final JsonCommand command,final Map<String, Object> actualChanges, final ScheduleGeneratorDTO scheduleGeneratorDTO, final JsonCommand command, final Map<String, Object> actualChanges, final ScheduleGeneratorDTO scheduleGeneratorDTO,
final AppUser currentUser) { final AppUser currentUser) {
final Locale locale = command.extractLocale(); final Locale locale = command.extractLocale();
validateAccountStatus(LoanEvent.LOAN_EDIT_MULTI_DISBURSE_DATE); validateAccountStatus(LoanEvent.LOAN_EDIT_MULTI_DISBURSE_DATE);
@@ -4965,8 +4967,8 @@ public class Loan extends AbstractPersistable<Long> {
for (LoanTransaction loanTransaction : allNonContraTransactionsPostDisbursement) { for (LoanTransaction loanTransaction : allNonContraTransactionsPostDisbursement) {
copyTransactions.add(LoanTransaction.copyTransactionProperties(loanTransaction)); copyTransactions.add(LoanTransaction.copyTransactionProperties(loanTransaction));
} }
loanRepaymentScheduleTransactionProcessor.handleTransaction(getDisbursementDate(), copyTransactions, loanRepaymentScheduleTransactionProcessor.handleTransaction(getDisbursementDate(), copyTransactions, getCurrency(),
getCurrency(), this.repaymentScheduleInstallments, charges()); this.repaymentScheduleInstallments, charges());
updateLoanSummaryDerivedFields(); updateLoanSummaryDerivedFields();
} }
@@ -5551,11 +5553,11 @@ public class Loan extends AbstractPersistable<Long> {
actualDisbursementDate = lastTransactionDate; actualDisbursementDate = lastTransactionDate;
updateLoanToLastDisbursalState(actualDisbursementDate); updateLoanToLastDisbursalState(actualDisbursementDate);
for (Iterator<LoanTermVariations> iterator = this.loanTermVariations.iterator(); iterator.hasNext();) { for (Iterator<LoanTermVariations> iterator = this.loanTermVariations.iterator(); iterator.hasNext();) {
LoanTermVariations loanTermVariations = iterator.next(); LoanTermVariations loanTermVariations = iterator.next();
if (loanTermVariations.fetchDateValue().isAfter(actualDisbursementDate)) { if (loanTermVariations.fetchDateValue().isAfter(actualDisbursementDate)) {
iterator.remove(); iterator.remove();
} }
} }
reverseExistingTransactionsTillLastDisbursal(actualDisbursementDate); reverseExistingTransactionsTillLastDisbursal(actualDisbursementDate);
loan.recalculateScheduleFromLastTransaction(scheduleGeneratorDTO, existingTransactionIds, existingReversedTransactionIds, loan.recalculateScheduleFromLastTransaction(scheduleGeneratorDTO, existingTransactionIds, existingReversedTransactionIds,
currentUser); currentUser);
@@ -5638,11 +5640,11 @@ public class Loan extends AbstractPersistable<Long> {
} }
public int fetchNumberOfInstallmensAfterExceptions() { public int fetchNumberOfInstallmensAfterExceptions() {
if(this.repaymentScheduleInstallments.size() > 0){ if (this.repaymentScheduleInstallments.size() > 0) {
int numberOfInstallments = 0; int numberOfInstallments = 0;
for (final LoanRepaymentScheduleInstallment installment : this.repaymentScheduleInstallments) { for (final LoanRepaymentScheduleInstallment installment : this.repaymentScheduleInstallments) {
if(!installment.isRecalculatedInterestComponent()){ if (!installment.isRecalculatedInterestComponent()) {
numberOfInstallments++; numberOfInstallments++;
} }
} }
return numberOfInstallments; return numberOfInstallments;
@@ -5653,27 +5655,27 @@ public class Loan extends AbstractPersistable<Long> {
public void setExpectedFirstRepaymentOnDate(Date expectedFirstRepaymentOnDate) { public void setExpectedFirstRepaymentOnDate(Date expectedFirstRepaymentOnDate) {
this.expectedFirstRepaymentOnDate = expectedFirstRepaymentOnDate; this.expectedFirstRepaymentOnDate = expectedFirstRepaymentOnDate;
} }
/* /*
* get the next repayment date for rescheduling at the time of disbursement * get the next repayment date for rescheduling at the time of disbursement
*/ */
public LocalDate getNextPossibleRepaymentDateForRescheduling(){ public LocalDate getNextPossibleRepaymentDateForRescheduling() {
Set<LoanDisbursementDetails> loanDisbursementDetails = this.disbursementDetails; Set<LoanDisbursementDetails> loanDisbursementDetails = this.disbursementDetails;
LocalDate nextRepaymentDate = new LocalDate(); LocalDate nextRepaymentDate = new LocalDate();
for(LoanDisbursementDetails loanDisbursementDetail : loanDisbursementDetails){ for (LoanDisbursementDetails loanDisbursementDetail : loanDisbursementDetails) {
if(loanDisbursementDetail.actualDisbursementDate() == null){ if (loanDisbursementDetail.actualDisbursementDate() == null) {
for (final LoanRepaymentScheduleInstallment installment : this.repaymentScheduleInstallments) { for (final LoanRepaymentScheduleInstallment installment : this.repaymentScheduleInstallments) {
if (installment.getDueDate().isEqual(loanDisbursementDetail.expectedDisbursementDateAsLocalDate()) || if (installment.getDueDate().isEqual(loanDisbursementDetail.expectedDisbursementDateAsLocalDate())
installment.getDueDate().isAfter(loanDisbursementDetail.expectedDisbursementDateAsLocalDate()) || installment.getDueDate().isAfter(loanDisbursementDetail.expectedDisbursementDateAsLocalDate())
&& installment.isNotFullyPaidOff()) { && installment.isNotFullyPaidOff()) {
nextRepaymentDate = installment.getDueDate(); nextRepaymentDate = installment.getDueDate();
break; break;
} }
} }
break; break;
} }
} }
return nextRepaymentDate; return nextRepaymentDate;
} }
} }