FINERACT-1496: Formatting change
FINERACT-1496: Lazy relationship loading for Loan and it's corresponding LoanCollateralManagement entities and removed unnecessary data loads from ApplicationCurrency.
This commit is contained in:
committed by
Aleksandar Vidakovic
parent
6f4c75f83a
commit
1f6ff8ccad
-12
@@ -18,17 +18,12 @@
|
||||
*/
|
||||
package org.apache.fineract.organisation.monetary.domain;
|
||||
|
||||
import java.util.Collection;
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
|
||||
import org.apache.fineract.organisation.monetary.data.CurrencyData;
|
||||
import org.apache.fineract.organisation.office.domain.OrganisationCurrency;
|
||||
import org.apache.fineract.portfolio.collateralmanagement.domain.CollateralManagementDomain;
|
||||
|
||||
@Entity
|
||||
@Table(name = "m_currency")
|
||||
@@ -52,9 +47,6 @@ public class ApplicationCurrency extends AbstractPersistableCustom {
|
||||
@Column(name = "display_symbol", nullable = true, length = 10)
|
||||
private String displaySymbol;
|
||||
|
||||
@OneToMany(mappedBy = "currency", fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
private Collection<CollateralManagementDomain> collateralManagementData;
|
||||
|
||||
protected ApplicationCurrency() {
|
||||
this.code = null;
|
||||
this.name = null;
|
||||
@@ -103,10 +95,6 @@ public class ApplicationCurrency extends AbstractPersistableCustom {
|
||||
return this.displaySymbol;
|
||||
}
|
||||
|
||||
public Collection<CollateralManagementDomain> getCollateralManagementData() {
|
||||
return this.collateralManagementData;
|
||||
}
|
||||
|
||||
public CurrencyData toData() {
|
||||
return new CurrencyData(this.code, this.name, this.decimalPlaces, this.inMultiplesOf, this.displaySymbol, this.nameCode);
|
||||
}
|
||||
|
||||
+2
@@ -33,8 +33,10 @@ import org.apache.fineract.portfolio.loanaccount.domain.LoanRepository;
|
||||
import org.apache.fineract.portfolio.loanaccount.exception.LoanNotFoundException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
@Transactional(readOnly = true)
|
||||
public class LoanCollateralManagementReadPlatformServiceImpl implements LoanCollateralManagementReadPlatformService {
|
||||
|
||||
private final PlatformSecurityContext context;
|
||||
|
||||
+1
-1
@@ -316,7 +316,7 @@ public class Loan extends AbstractPersistableCustom {
|
||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "loan", orphanRemoval = true, fetch = FetchType.LAZY)
|
||||
private Set<LoanCollateral> collateral = null;
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "loan", orphanRemoval = true, fetch = FetchType.EAGER)
|
||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "loan", orphanRemoval = true, fetch = FetchType.LAZY)
|
||||
private Set<LoanCollateralManagement> loanCollateralManagements = new HashSet<>();
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "loan", orphanRemoval = true, fetch = FetchType.LAZY)
|
||||
|
||||
+25
@@ -5610,6 +5610,31 @@ public class ClientLoanIntegrationTest {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCollateralDataIsAvailableWhenRequested() {
|
||||
// given
|
||||
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
|
||||
Integer collateralId = CollateralManagementHelper.createCollateralProduct(this.requestSpec, this.responseSpec);
|
||||
List<HashMap> collaterals = new ArrayList<>();
|
||||
Integer clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientId);
|
||||
|
||||
Integer clientCollateralId = CollateralManagementHelper.createClientCollateral(this.requestSpec, this.responseSpec,
|
||||
String.valueOf(clientId), collateralId);
|
||||
addCollaterals(collaterals, clientCollateralId, BigDecimal.valueOf(1));
|
||||
|
||||
Integer loanProductId = createLoanProduct(false, NONE);
|
||||
|
||||
// when
|
||||
Integer loanId = applyForLoanApplication(clientId, loanProductId, null, null, "12,000.00", collaterals);
|
||||
|
||||
// then
|
||||
List<Integer> clientCollateralIds = (List<Integer>) loanTransactionHelper.getLoanDetail(this.requestSpec, this.responseSpec, loanId,
|
||||
"collateral.clientCollateralId");
|
||||
Integer clientCollateralIdResult = clientCollateralIds.get(0);
|
||||
assertEquals(clientCollateralId, clientCollateralIdResult);
|
||||
}
|
||||
|
||||
private void validateIfValuesAreNotOverridden(Integer loanID, Integer loanProductID) {
|
||||
String loanProductDetails = this.loanTransactionHelper.getLoanProductDetails(this.requestSpec, this.responseSpec, loanProductID);
|
||||
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID);
|
||||
|
||||
Reference in New Issue
Block a user