use fundId, fundName rather than fund object in loan product view

This commit is contained in:
John Woodlock
2012-07-13 19:58:33 +10:00
parent e26e4aca35
commit f6e99bc816
3 changed files with 35 additions and 36 deletions
@@ -32,8 +32,8 @@ import org.springframework.stereotype.Component;
@Scope("singleton")
public class LoanProductApiResource {
private String defaultFieldList = "principal,inArrearsTolerance,interestRatePerPeriod,annualInterestRate,repaymentFrequencyType,interestRateFrequencyType,amortizationType,interestType,interestCalculationPeriodType";
private String allowedFieldList = "currencyOptions,amortizationTypeOptions,interestTypeOptions,interestCalculationPeriodTypeOptions,repaymentFrequencyTypeOptions,interestRateFrequencyTypeOptions";
private String defaultFieldList = "principal,inArrearsTolerance,interestRatePerPeriod,annualInterestRate,repaymentFrequencyType,interestRateFrequencyType,amortizationType,interestType,interestCalculationPeriodType,fundId";
private String allowedFieldList = "currencyOptions,amortizationTypeOptions,interestTypeOptions,interestCalculationPeriodTypeOptions,repaymentFrequencyTypeOptions,interestRateFrequencyTypeOptions,fundOptions";
private String filterName = "myFilter";
@Autowired
@@ -15,13 +15,14 @@ public class LoanProductData implements Serializable {
private Long id;
private String name;
private String description;
private FundData fund;
private Long fundId;
private String fundName;
private MoneyData principal;
private MoneyData inArrearsTolerance;
private Integer numberOfRepayments;
private Integer numberOfRepayments;
private Integer repaymentEvery;
private BigDecimal interestRatePerPeriod = BigDecimal.ZERO;
private BigDecimal annualInterestRate = BigDecimal.ZERO;
@@ -31,10 +32,10 @@ public class LoanProductData implements Serializable {
private EnumOptionData amortizationType;
private EnumOptionData interestType;
private EnumOptionData interestCalculationPeriodType;
private DateTime createdOn;
private DateTime lastModifedOn;
private List<CurrencyData> currencyOptions = new ArrayList<CurrencyData>();
private Collection<FundData> fundOptions = new ArrayList<FundData>();
private List<EnumOptionData> amortizationTypeOptions = new ArrayList<EnumOptionData>();
@@ -42,8 +43,7 @@ public class LoanProductData implements Serializable {
private List<EnumOptionData> interestCalculationPeriodTypeOptions = new ArrayList<EnumOptionData>();
private List<EnumOptionData> repaymentFrequencyTypeOptions = new ArrayList<EnumOptionData>();
private List<EnumOptionData> interestRateFrequencyTypeOptions = new ArrayList<EnumOptionData>();
public LoanProductData() {
//
}
@@ -55,9 +55,9 @@ public class LoanProductData implements Serializable {
BigDecimal annualInterestRate,
EnumOptionData repaymentFrequencyType,
EnumOptionData interestRateFrequencyType,
EnumOptionData amortizationType,
EnumOptionData interestType,
EnumOptionData interestCalculationPeriodType, FundData fund) {
EnumOptionData amortizationType, EnumOptionData interestType,
EnumOptionData interestCalculationPeriodType, Long fundId,
String fundName) {
this.createdOn = createdOn;
this.lastModifedOn = lastModifedOn;
this.id = id;
@@ -74,7 +74,8 @@ public class LoanProductData implements Serializable {
this.amortizationType = amortizationType;
this.interestType = interestType;
this.interestCalculationPeriodType = interestCalculationPeriodType;
this.fund = fund;
this.fundId = fundId;
this.fundName = fundName;
}
public Long getId() {
@@ -100,13 +101,21 @@ public class LoanProductData implements Serializable {
public void setDescription(String description) {
this.description = description;
}
public FundData getFund() {
return fund;
public Long getFundId() {
return fundId;
}
public void setFund(FundData fund) {
this.fund = fund;
public void setFundId(Long fundId) {
this.fundId = fundId;
}
public String getFundName() {
return fundName;
}
public void setFundName(String fundName) {
this.fundName = fundName;
}
public MoneyData getPrincipal() {
@@ -240,7 +249,7 @@ public class LoanProductData implements Serializable {
public void setCurrencyOptions(List<CurrencyData> currencyOptions) {
this.currencyOptions = currencyOptions;
}
public Collection<FundData> getFundOptions() {
return fundOptions;
}
@@ -151,14 +151,14 @@ public class LoanProductReadPlatformServiceImpl implements
}
public String loanProductSchema() {
return "lp.id as id, lp.fund_id as fundId, lp.name as name, lp.description as description, lp.flexible_repayment_schedule as isFlexible, lp.interest_rebate as isInterestRebateAllowed, "
return "lp.id as id, lp.fund_id as fundId, f.name as fundName, lp.name as name, lp.description as description, lp.flexible_repayment_schedule as isFlexible, lp.interest_rebate as isInterestRebateAllowed, "
+ "lp.principal_amount as principal, lp.currency_code as currencyCode, lp.currency_digits as currencyDigits, "
+ "lp.nominal_interest_rate_per_period as interestRatePerPeriod, lp.interest_period_frequency_enum as interestRatePerPeriodFreq, "
+ "lp.annual_nominal_interest_rate as annualInterestRate, lp.interest_method_enum as interestMethod, lp.interest_calculated_in_period_enum as interestCalculationInPeriodMethod,"
+ "lp.repay_every as repaidEvery, lp.repayment_period_frequency_enum as repaymentPeriodFrequency, lp.number_of_repayments as numberOfRepayments, "
+ "lp.amortization_method_enum as amortizationMethod, lp.arrearstolerance_amount as tolerance, "
+ "lp.created_date as createdon, lp.lastmodified_date as modifiedon "
+ " from portfolio_product_loan lp";
+ " from portfolio_product_loan lp left join org_fund f on f.id = lp.fund_id";
}
@Override
@@ -169,8 +169,8 @@ public class LoanProductReadPlatformServiceImpl implements
String name = rs.getString("name");
String description = rs.getString("description");
Long fundId = rs.getLong("fundId");
FundData fund = findFundDataById(fundId, allFunds);
Long fundId = JdbcSupport.getLong(rs, "fundId");
String fundName = rs.getString("fundName");
String currencyCode = rs.getString("currencyCode");
Integer currencyDigits = JdbcSupport.getInteger(rs,
@@ -228,17 +228,7 @@ public class LoanProductReadPlatformServiceImpl implements
numberOfRepayments, repaymentEvery, interestRatePerPeriod,
annualInterestRate, repaymentFrequencyType,
interestRateFrequencyType, amortizationType, interestType,
interestCalculationPeriodType, fund);
}
private FundData findFundDataById(Long fundId, Collection<FundData> allFunds) {
FundData match = null;
for (FundData fundData : allFunds) {
if (fundData.getId().equals(fundId)) {
match = fundData;
}
}
return match;
interestCalculationPeriodType, fundId, fundName);
}
private CurrencyData findCurrencyByCode(String currencyCode, List<CurrencyData> allowedCurrencies) {