formatting and rename of patch files.

This commit is contained in:
Keith Woodlock
2013-02-05 20:53:44 +00:00
parent 58ee1847e3
commit 0bb4fd282b
4 changed files with 72 additions and 84 deletions
@@ -0,0 +1,6 @@
UPDATE m_product_loan SET name = CONCAT(id,'-',name);
-- concating unique value to make sure column does not contain any duplicate value
ALTER TABLE m_product_loan
ADD CONSTRAINT unq_name UNIQUE (name);
@@ -1,3 +0,0 @@
UPDATE m_product_loan SET name = CONCAT(id,'-',name); -- concating unique value to make sure column does not contain any duplicate value
ALTER TABLE m_product_loan
ADD CONSTRAINT unq_name UNIQUE (name);
@@ -75,28 +75,21 @@ public class LoanProductWritePlatformServiceJpaRepositoryImpl implements LoanPro
// associating fund with loan product at creation is optional for // associating fund with loan product at creation is optional for
// now. // now.
final Fund fund = findFundByIdIfProvided(command final Fund fund = findFundByIdIfProvided(command.longValueOfParameterNamed("fundId"));
.longValueOfParameterNamed("fundId"));
final Long transactionProcessingStrategyId = command final Long transactionProcessingStrategyId = command.longValueOfParameterNamed("transactionProcessingStrategyId");
.longValueOfParameterNamed("transactionProcessingStrategyId");
final LoanTransactionProcessingStrategy loanTransactionProcessingStrategy = findStrategyByIdIfProvided(transactionProcessingStrategyId); final LoanTransactionProcessingStrategy loanTransactionProcessingStrategy = findStrategyByIdIfProvided(transactionProcessingStrategyId);
final String currencyCode = command final String currencyCode = command.stringValueOfParameterNamed("currencyCode");
.stringValueOfParameterNamed("currencyCode"); final Set<Charge> charges = this.assembleSetOfCharges(command, currencyCode);
final Set<Charge> charges = this.assembleSetOfCharges(command,
currencyCode);
final LoanProduct loanproduct = LoanProduct.assembleFromJson(fund, final LoanProduct loanproduct = LoanProduct.assembleFromJson(fund, loanTransactionProcessingStrategy, charges, command,
loanTransactionProcessingStrategy, charges, command,
this.aprCalculator); this.aprCalculator);
this.loanProductRepository.save(loanproduct); this.loanProductRepository.save(loanproduct);
// save accounting mappings // save accounting mappings
accountMappingWritePlatformService accountMappingWritePlatformService.createLoanProductToGLAccountMapping(loanproduct.getId(), command);
.createLoanProductToGLAccountMapping(loanproduct.getId(),
command);
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) // .withCommandId(command.commandId()) //
@@ -138,14 +131,10 @@ public class LoanProductWritePlatformServiceJpaRepositoryImpl implements LoanPro
this.fromApiJsonDeserializer.validateForUpdate(command.json()); this.fromApiJsonDeserializer.validateForUpdate(command.json());
final LoanProduct product = this.loanProductRepository final LoanProduct product = this.loanProductRepository.findOne(loanProductId);
.findOne(loanProductId); if (product == null) { throw new LoanProductNotFoundException(loanProductId); }
if (product == null) {
throw new LoanProductNotFoundException(loanProductId);
}
final Map<String, Object> changes = product.update(command, final Map<String, Object> changes = product.update(command, this.aprCalculator);
this.aprCalculator);
// associating fund with loan product at creation is optional for // associating fund with loan product at creation is optional for
// now. // now.
@@ -156,25 +145,20 @@ public class LoanProductWritePlatformServiceJpaRepositoryImpl implements LoanPro
} }
if (changes.containsKey("transactionProcessingStrategyId")) { if (changes.containsKey("transactionProcessingStrategyId")) {
final Long transactionProcessingStrategyId = (Long) changes final Long transactionProcessingStrategyId = (Long) changes.get("transactionProcessingStrategyId");
.get("transactionProcessingStrategyId");
final LoanTransactionProcessingStrategy loanTransactionProcessingStrategy = findStrategyByIdIfProvided(transactionProcessingStrategyId); final LoanTransactionProcessingStrategy loanTransactionProcessingStrategy = findStrategyByIdIfProvided(transactionProcessingStrategyId);
product.update(loanTransactionProcessingStrategy); product.update(loanTransactionProcessingStrategy);
} }
if (changes.containsKey("charges")) { if (changes.containsKey("charges")) {
final Set<Charge> charges = this.assembleSetOfCharges(command, final Set<Charge> charges = this.assembleSetOfCharges(command, product.getCurrency().getCode());
product.getCurrency().getCode());
product.update(charges); product.update(charges);
} }
// accounting related changes // accounting related changes
boolean accountingTypeChanged = changes boolean accountingTypeChanged = changes.containsKey("accountingType");
.containsKey("accountingType");
if (accountingTypeChanged) { if (accountingTypeChanged) {
accountMappingWritePlatformService accountMappingWritePlatformService.updateLoanProductToGLAccountMapping(product.getId(), command, accountingTypeChanged);
.updateLoanProductToGLAccountMapping(product.getId(),
command, accountingTypeChanged);
} }
if (!changes.isEmpty()) { if (!changes.isEmpty()) {
@@ -222,6 +206,7 @@ public class LoanProductWritePlatformServiceJpaRepositoryImpl implements LoanPro
return charges; return charges;
} }
/* /*
* Guaranteed to throw an exception no matter what the data integrity issue * Guaranteed to throw an exception no matter what the data integrity issue
* is. * is.