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") @Scope("singleton")
public class LoanProductApiResource { public class LoanProductApiResource {
private String defaultFieldList = "principal,inArrearsTolerance,interestRatePerPeriod,annualInterestRate,repaymentFrequencyType,interestRateFrequencyType,amortizationType,interestType,interestCalculationPeriodType"; private String defaultFieldList = "principal,inArrearsTolerance,interestRatePerPeriod,annualInterestRate,repaymentFrequencyType,interestRateFrequencyType,amortizationType,interestType,interestCalculationPeriodType,fundId";
private String allowedFieldList = "currencyOptions,amortizationTypeOptions,interestTypeOptions,interestCalculationPeriodTypeOptions,repaymentFrequencyTypeOptions,interestRateFrequencyTypeOptions"; private String allowedFieldList = "currencyOptions,amortizationTypeOptions,interestTypeOptions,interestCalculationPeriodTypeOptions,repaymentFrequencyTypeOptions,interestRateFrequencyTypeOptions,fundOptions";
private String filterName = "myFilter"; private String filterName = "myFilter";
@Autowired @Autowired
@@ -15,13 +15,14 @@ public class LoanProductData implements Serializable {
private Long id; private Long id;
private String name; private String name;
private String description; private String description;
private FundData fund; private Long fundId;
private String fundName;
private MoneyData principal; private MoneyData principal;
private MoneyData inArrearsTolerance; private MoneyData inArrearsTolerance;
private Integer numberOfRepayments; private Integer numberOfRepayments;
private Integer repaymentEvery; private Integer repaymentEvery;
private BigDecimal interestRatePerPeriod = BigDecimal.ZERO; private BigDecimal interestRatePerPeriod = BigDecimal.ZERO;
private BigDecimal annualInterestRate = BigDecimal.ZERO; private BigDecimal annualInterestRate = BigDecimal.ZERO;
@@ -31,10 +32,10 @@ public class LoanProductData implements Serializable {
private EnumOptionData amortizationType; private EnumOptionData amortizationType;
private EnumOptionData interestType; private EnumOptionData interestType;
private EnumOptionData interestCalculationPeriodType; private EnumOptionData interestCalculationPeriodType;
private DateTime createdOn; private DateTime createdOn;
private DateTime lastModifedOn; private DateTime lastModifedOn;
private List<CurrencyData> currencyOptions = new ArrayList<CurrencyData>(); private List<CurrencyData> currencyOptions = new ArrayList<CurrencyData>();
private Collection<FundData> fundOptions = new ArrayList<FundData>(); private Collection<FundData> fundOptions = new ArrayList<FundData>();
private List<EnumOptionData> amortizationTypeOptions = new ArrayList<EnumOptionData>(); 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> interestCalculationPeriodTypeOptions = new ArrayList<EnumOptionData>();
private List<EnumOptionData> repaymentFrequencyTypeOptions = new ArrayList<EnumOptionData>(); private List<EnumOptionData> repaymentFrequencyTypeOptions = new ArrayList<EnumOptionData>();
private List<EnumOptionData> interestRateFrequencyTypeOptions = new ArrayList<EnumOptionData>(); private List<EnumOptionData> interestRateFrequencyTypeOptions = new ArrayList<EnumOptionData>();
public LoanProductData() { public LoanProductData() {
// //
} }
@@ -55,9 +55,9 @@ public class LoanProductData implements Serializable {
BigDecimal annualInterestRate, BigDecimal annualInterestRate,
EnumOptionData repaymentFrequencyType, EnumOptionData repaymentFrequencyType,
EnumOptionData interestRateFrequencyType, EnumOptionData interestRateFrequencyType,
EnumOptionData amortizationType, EnumOptionData amortizationType, EnumOptionData interestType,
EnumOptionData interestType, EnumOptionData interestCalculationPeriodType, Long fundId,
EnumOptionData interestCalculationPeriodType, FundData fund) { String fundName) {
this.createdOn = createdOn; this.createdOn = createdOn;
this.lastModifedOn = lastModifedOn; this.lastModifedOn = lastModifedOn;
this.id = id; this.id = id;
@@ -74,7 +74,8 @@ public class LoanProductData implements Serializable {
this.amortizationType = amortizationType; this.amortizationType = amortizationType;
this.interestType = interestType; this.interestType = interestType;
this.interestCalculationPeriodType = interestCalculationPeriodType; this.interestCalculationPeriodType = interestCalculationPeriodType;
this.fund = fund; this.fundId = fundId;
this.fundName = fundName;
} }
public Long getId() { public Long getId() {
@@ -100,13 +101,21 @@ public class LoanProductData implements Serializable {
public void setDescription(String description) { public void setDescription(String description) {
this.description = description; this.description = description;
} }
public FundData getFund() { public Long getFundId() {
return fund; return fundId;
} }
public void setFund(FundData fund) { public void setFundId(Long fundId) {
this.fund = fund; this.fundId = fundId;
}
public String getFundName() {
return fundName;
}
public void setFundName(String fundName) {
this.fundName = fundName;
} }
public MoneyData getPrincipal() { public MoneyData getPrincipal() {
@@ -240,7 +249,7 @@ public class LoanProductData implements Serializable {
public void setCurrencyOptions(List<CurrencyData> currencyOptions) { public void setCurrencyOptions(List<CurrencyData> currencyOptions) {
this.currencyOptions = currencyOptions; this.currencyOptions = currencyOptions;
} }
public Collection<FundData> getFundOptions() { public Collection<FundData> getFundOptions() {
return fundOptions; return fundOptions;
} }
@@ -151,14 +151,14 @@ public class LoanProductReadPlatformServiceImpl implements
} }
public String loanProductSchema() { 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.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.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.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.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.amortization_method_enum as amortizationMethod, lp.arrearstolerance_amount as tolerance, "
+ "lp.created_date as createdon, lp.lastmodified_date as modifiedon " + "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 @Override
@@ -169,8 +169,8 @@ public class LoanProductReadPlatformServiceImpl implements
String name = rs.getString("name"); String name = rs.getString("name");
String description = rs.getString("description"); String description = rs.getString("description");
Long fundId = rs.getLong("fundId"); Long fundId = JdbcSupport.getLong(rs, "fundId");
FundData fund = findFundDataById(fundId, allFunds); String fundName = rs.getString("fundName");
String currencyCode = rs.getString("currencyCode"); String currencyCode = rs.getString("currencyCode");
Integer currencyDigits = JdbcSupport.getInteger(rs, Integer currencyDigits = JdbcSupport.getInteger(rs,
@@ -228,17 +228,7 @@ public class LoanProductReadPlatformServiceImpl implements
numberOfRepayments, repaymentEvery, interestRatePerPeriod, numberOfRepayments, repaymentEvery, interestRatePerPeriod,
annualInterestRate, repaymentFrequencyType, annualInterestRate, repaymentFrequencyType,
interestRateFrequencyType, amortizationType, interestType, interestRateFrequencyType, amortizationType, interestType,
interestCalculationPeriodType, fund); interestCalculationPeriodType, fundId, fundName);
}
private FundData findFundDataById(Long fundId, Collection<FundData> allFunds) {
FundData match = null;
for (FundData fundData : allFunds) {
if (fundData.getId().equals(fundId)) {
match = fundData;
}
}
return match;
} }
private CurrencyData findCurrencyByCode(String currencyCode, List<CurrencyData> allowedCurrencies) { private CurrencyData findCurrencyByCode(String currencyCode, List<CurrencyData> allowedCurrencies) {