MIFOSX-97: move gaurantor under loan account for now.
This commit is contained in:
@@ -17,15 +17,15 @@ import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import org.mifosng.platform.api.commands.GuarantorCommand;
|
||||
import org.mifosng.platform.api.data.GuarantorData;
|
||||
import org.mifosng.platform.guarantor.GuarantorReadPlatformService;
|
||||
import org.mifosng.platform.guarantor.GuarantorWritePlatformService;
|
||||
import org.mifosplatform.infrastructure.core.api.ApiParameterHelper;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioApiDataConversionService;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioApiJsonSerializerService;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.portfolio.loanaccount.gaurantor.command.GuarantorCommand;
|
||||
import org.mifosplatform.portfolio.loanaccount.gaurantor.data.GuarantorData;
|
||||
import org.mifosplatform.portfolio.loanaccount.gaurantor.service.GuarantorReadPlatformService;
|
||||
import org.mifosplatform.portfolio.loanaccount.gaurantor.service.GuarantorWritePlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
-119
@@ -1,119 +0,0 @@
|
||||
package org.mifosng.platform.guarantor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.mifosng.platform.api.commands.GuarantorCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.ApiParameterError;
|
||||
import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder;
|
||||
import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException;
|
||||
|
||||
public class GuarantorCommandValidator {
|
||||
|
||||
private final GuarantorCommand command;
|
||||
|
||||
public GuarantorCommandValidator(GuarantorCommand command) {
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
public void validateForCreate() {
|
||||
|
||||
List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
|
||||
|
||||
DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(
|
||||
dataValidationErrors).resource("Guarantor");
|
||||
|
||||
// validate for existing Client
|
||||
if (command.isExternalGuarantor() == null
|
||||
|| command.isExternalGuarantor() == false) {
|
||||
baseDataValidator.reset().parameter("existingClientId")
|
||||
.value(command.getExistingClientId()).notNull()
|
||||
.integerGreaterThanZero();
|
||||
} else {
|
||||
// validate for an external guarantor
|
||||
baseDataValidator.reset().parameter("firstname")
|
||||
.value(command.getFirstname()).notBlank()
|
||||
.notExceedingLengthOf(50);
|
||||
baseDataValidator.reset().parameter("lastname")
|
||||
.value(command.getLastname()).notBlank()
|
||||
.notExceedingLengthOf(50);
|
||||
|
||||
validateNonMandatoryFieldsForMaxLength(baseDataValidator);
|
||||
}
|
||||
|
||||
if (!dataValidationErrors.isEmpty()) {
|
||||
throw new PlatformApiDataValidationException(
|
||||
"validation.msg.validation.errors.exist",
|
||||
"Validation errors exist.", dataValidationErrors);
|
||||
}
|
||||
}
|
||||
|
||||
public void validateForUpdate() {
|
||||
List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
|
||||
|
||||
DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(
|
||||
dataValidationErrors).resource("Guarantor");
|
||||
|
||||
// validate for existing Client
|
||||
if (command.isExternalGuarantor() == null
|
||||
|| command.isExternalGuarantor() == false) {
|
||||
baseDataValidator.reset().parameter("existingClientId")
|
||||
.value(command.getExistingClientId()).notNull()
|
||||
.integerGreaterThanZero();
|
||||
} else {
|
||||
// validate for an external guarantor
|
||||
baseDataValidator.reset().parameter("firstname")
|
||||
.value(command.getFirstname()).notBlank()
|
||||
.notExceedingLengthOf(50);
|
||||
baseDataValidator.reset().parameter("lastname")
|
||||
.value(command.getLastname()).notBlank()
|
||||
.notExceedingLengthOf(50);
|
||||
|
||||
validateNonMandatoryFieldsForMaxLength(baseDataValidator);
|
||||
}
|
||||
baseDataValidator.reset().anyOfNotNull(command.getExistingClientId(),
|
||||
command.getAddressLine1(), command.getAddressLine2(),
|
||||
command.getCity(), command.getComment(), command.getCountry(),
|
||||
command.getFirstname(), command.getHousePhoneNumber(),
|
||||
command.getLastname(), command.getMobileNumber(),
|
||||
command.getState(), command.getZip());
|
||||
|
||||
if (!dataValidationErrors.isEmpty()) {
|
||||
throw new PlatformApiDataValidationException(
|
||||
"validation.msg.validation.errors.exist",
|
||||
"Validation errors exist.", dataValidationErrors);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param baseDataValidator
|
||||
*/
|
||||
private void validateNonMandatoryFieldsForMaxLength(
|
||||
DataValidatorBuilder baseDataValidator) {
|
||||
// validate non mandatory fields for length
|
||||
baseDataValidator.reset().parameter("addressLine1")
|
||||
.value(command.getAddressLine1()).ignoreIfNull()
|
||||
.notExceedingLengthOf(50);
|
||||
baseDataValidator.reset().parameter("addressLine2")
|
||||
.value(command.getAddressLine2()).ignoreIfNull()
|
||||
.notExceedingLengthOf(50);
|
||||
baseDataValidator.reset().parameter("city").value(command.getCity())
|
||||
.ignoreIfNull().notExceedingLengthOf(50);
|
||||
baseDataValidator.reset().parameter("state").value(command.getState())
|
||||
.ignoreIfNull().notExceedingLengthOf(50);
|
||||
baseDataValidator.reset().parameter("zip").value(command.getZip())
|
||||
.ignoreIfNull().notExceedingLengthOf(50);
|
||||
baseDataValidator.reset().parameter("country")
|
||||
.value(command.getCountry()).ignoreIfNull()
|
||||
.notExceedingLengthOf(50);
|
||||
baseDataValidator.reset().parameter("mobileNumber")
|
||||
.value(command.getMobileNumber()).ignoreIfNull()
|
||||
.notExceedingLengthOf(20);
|
||||
baseDataValidator.reset().parameter("housePhoneNumber")
|
||||
.value(command.getHousePhoneNumber()).ignoreIfNull()
|
||||
.notExceedingLengthOf(20);
|
||||
baseDataValidator.reset().parameter("comment")
|
||||
.value(command.getComment()).ignoreIfNull()
|
||||
.notExceedingLengthOf(500);
|
||||
}
|
||||
}
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
package org.mifosng.platform.guarantor;
|
||||
|
||||
import org.mifosng.platform.api.data.GuarantorData;
|
||||
|
||||
public interface GuarantorReadPlatformService {
|
||||
|
||||
GuarantorData retrieveGuarantor(Long loanId);
|
||||
|
||||
boolean existsGuarantor(Long loanId);
|
||||
|
||||
GuarantorData getExternalGuarantor(Long loanId);
|
||||
|
||||
}
|
||||
-17
@@ -1,17 +0,0 @@
|
||||
package org.mifosng.platform.guarantor;
|
||||
|
||||
import org.mifosng.platform.api.commands.GuarantorCommand;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
||||
public interface GuarantorWritePlatformService {
|
||||
|
||||
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS','PORTFOLIO_MANAGEMENT_SUPER_USER')")
|
||||
void createGuarantor(final Long loanId, final GuarantorCommand command);
|
||||
|
||||
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS','PORTFOLIO_MANAGEMENT_SUPER_USER')")
|
||||
void updateGuarantor(final Long loanId, final GuarantorCommand command);
|
||||
|
||||
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS','PORTFOLIO_MANAGEMENT_SUPER_USER')")
|
||||
void removeGuarantor(final Long loanId);
|
||||
|
||||
}
|
||||
+1
-1
@@ -9,7 +9,6 @@ import org.mifosng.platform.api.data.DepositAccountData;
|
||||
import org.mifosng.platform.api.data.DepositProductData;
|
||||
import org.mifosng.platform.api.data.GroupAccountSummaryCollectionData;
|
||||
import org.mifosng.platform.api.data.GroupData;
|
||||
import org.mifosng.platform.api.data.GuarantorData;
|
||||
import org.mifosng.platform.api.data.SavingAccountData;
|
||||
import org.mifosng.platform.api.data.SavingProductData;
|
||||
import org.mifosplatform.commands.api.data.CommandSourceData;
|
||||
@@ -37,6 +36,7 @@ import org.mifosplatform.portfolio.fund.data.FundData;
|
||||
import org.mifosplatform.portfolio.loanaccount.data.LoanAccountData;
|
||||
import org.mifosplatform.portfolio.loanaccount.data.LoanChargeData;
|
||||
import org.mifosplatform.portfolio.loanaccount.data.LoanTransactionData;
|
||||
import org.mifosplatform.portfolio.loanaccount.gaurantor.data.GuarantorData;
|
||||
import org.mifosplatform.portfolio.loanaccount.loanschedule.data.LoanScheduleData;
|
||||
import org.mifosplatform.portfolio.loanproduct.data.LoanProductData;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
+1
-1
@@ -7,7 +7,6 @@ import org.mifosng.platform.api.commands.DepositProductCommand;
|
||||
import org.mifosng.platform.api.commands.DepositStateTransitionApprovalCommand;
|
||||
import org.mifosng.platform.api.commands.DepositStateTransitionCommand;
|
||||
import org.mifosng.platform.api.commands.GroupCommand;
|
||||
import org.mifosng.platform.api.commands.GuarantorCommand;
|
||||
import org.mifosng.platform.api.commands.SavingAccountCommand;
|
||||
import org.mifosng.platform.api.commands.SavingProductCommand;
|
||||
import org.mifosplatform.infrastructure.codes.command.CodeCommand;
|
||||
@@ -31,6 +30,7 @@ import org.mifosplatform.portfolio.loanaccount.command.LoanApplicationCommand;
|
||||
import org.mifosplatform.portfolio.loanaccount.command.LoanChargeCommand;
|
||||
import org.mifosplatform.portfolio.loanaccount.command.LoanStateTransitionCommand;
|
||||
import org.mifosplatform.portfolio.loanaccount.command.LoanTransactionCommand;
|
||||
import org.mifosplatform.portfolio.loanaccount.gaurantor.command.GuarantorCommand;
|
||||
import org.mifosplatform.portfolio.loanproduct.command.LoanProductCommand;
|
||||
|
||||
public interface PortfolioApiDataConversionService {
|
||||
|
||||
+1
-1
@@ -24,7 +24,6 @@ import org.mifosng.platform.api.commands.DepositProductCommand;
|
||||
import org.mifosng.platform.api.commands.DepositStateTransitionApprovalCommand;
|
||||
import org.mifosng.platform.api.commands.DepositStateTransitionCommand;
|
||||
import org.mifosng.platform.api.commands.GroupCommand;
|
||||
import org.mifosng.platform.api.commands.GuarantorCommand;
|
||||
import org.mifosng.platform.api.commands.SavingAccountCommand;
|
||||
import org.mifosng.platform.api.commands.SavingProductCommand;
|
||||
import org.mifosplatform.infrastructure.codes.command.CodeCommand;
|
||||
@@ -52,6 +51,7 @@ import org.mifosplatform.portfolio.loanaccount.command.LoanApplicationCommand;
|
||||
import org.mifosplatform.portfolio.loanaccount.command.LoanChargeCommand;
|
||||
import org.mifosplatform.portfolio.loanaccount.command.LoanStateTransitionCommand;
|
||||
import org.mifosplatform.portfolio.loanaccount.command.LoanTransactionCommand;
|
||||
import org.mifosplatform.portfolio.loanaccount.gaurantor.command.GuarantorCommand;
|
||||
import org.mifosplatform.portfolio.loanproduct.command.LoanProductCommand;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.format.number.NumberFormatter;
|
||||
|
||||
+1
-1
@@ -7,7 +7,6 @@ import org.mifosng.platform.api.data.DepositAccountData;
|
||||
import org.mifosng.platform.api.data.DepositProductData;
|
||||
import org.mifosng.platform.api.data.GroupAccountSummaryCollectionData;
|
||||
import org.mifosng.platform.api.data.GroupData;
|
||||
import org.mifosng.platform.api.data.GuarantorData;
|
||||
import org.mifosng.platform.api.data.SavingAccountData;
|
||||
import org.mifosng.platform.api.data.SavingProductData;
|
||||
import org.mifosplatform.commands.api.data.CommandSourceData;
|
||||
@@ -35,6 +34,7 @@ import org.mifosplatform.portfolio.fund.data.FundData;
|
||||
import org.mifosplatform.portfolio.loanaccount.data.LoanAccountData;
|
||||
import org.mifosplatform.portfolio.loanaccount.data.LoanChargeData;
|
||||
import org.mifosplatform.portfolio.loanaccount.data.LoanTransactionData;
|
||||
import org.mifosplatform.portfolio.loanaccount.gaurantor.data.GuarantorData;
|
||||
import org.mifosplatform.portfolio.loanaccount.loanschedule.data.LoanScheduleData;
|
||||
import org.mifosplatform.portfolio.loanproduct.data.LoanProductData;
|
||||
|
||||
|
||||
+2
-2
@@ -20,8 +20,6 @@ import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.mifosng.platform.api.data.GuarantorData;
|
||||
import org.mifosng.platform.guarantor.GuarantorReadPlatformService;
|
||||
import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformService;
|
||||
import org.mifosplatform.infrastructure.configuration.domain.MonetaryCurrency;
|
||||
import org.mifosplatform.infrastructure.configuration.domain.Money;
|
||||
@@ -56,6 +54,8 @@ import org.mifosplatform.portfolio.loanaccount.data.LoanBasicDetailsData;
|
||||
import org.mifosplatform.portfolio.loanaccount.data.LoanChargeData;
|
||||
import org.mifosplatform.portfolio.loanaccount.data.LoanPermissionData;
|
||||
import org.mifosplatform.portfolio.loanaccount.data.LoanTransactionData;
|
||||
import org.mifosplatform.portfolio.loanaccount.gaurantor.data.GuarantorData;
|
||||
import org.mifosplatform.portfolio.loanaccount.gaurantor.service.GuarantorReadPlatformService;
|
||||
import org.mifosplatform.portfolio.loanaccount.loanschedule.command.CalculateLoanScheduleCommand;
|
||||
import org.mifosplatform.portfolio.loanaccount.loanschedule.data.LoanScheduleData;
|
||||
import org.mifosplatform.portfolio.loanaccount.loanschedule.service.CalculationPlatformService;
|
||||
|
||||
+1
-1
@@ -4,12 +4,12 @@ import java.math.BigDecimal;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
import org.mifosng.platform.api.data.GuarantorData;
|
||||
import org.mifosplatform.infrastructure.configuration.data.CurrencyData;
|
||||
import org.mifosplatform.infrastructure.core.data.EnumOptionData;
|
||||
import org.mifosplatform.infrastructure.staff.data.StaffData;
|
||||
import org.mifosplatform.portfolio.charge.data.ChargeData;
|
||||
import org.mifosplatform.portfolio.fund.data.FundData;
|
||||
import org.mifosplatform.portfolio.loanaccount.gaurantor.data.GuarantorData;
|
||||
import org.mifosplatform.portfolio.loanaccount.loanschedule.data.LoanScheduleData;
|
||||
import org.mifosplatform.portfolio.loanproduct.data.LoanProductData;
|
||||
import org.mifosplatform.portfolio.loanproduct.data.TransactionProcessingStrategyData;
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
package org.mifosng.platform.api.commands;
|
||||
package org.mifosplatform.portfolio.loanaccount.gaurantor.command;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@@ -13,7 +13,7 @@ public class GuarantorCommand {
|
||||
private final Long existingClientId;
|
||||
|
||||
/*** Fields for external persons serving as guarantors ***/
|
||||
// FIXME - kw - what the details for collecting guarantors change? we are using datatable approach but fixing here?
|
||||
// FIXME - kw - what if the details for collecting guarantors change? we are using datatable approach but embedding a structure here?
|
||||
private final String firstname;
|
||||
private final String lastname;
|
||||
private final String addressLine1;
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
package org.mifosplatform.portfolio.loanaccount.gaurantor.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.data.ApiParameterError;
|
||||
import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder;
|
||||
import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException;
|
||||
|
||||
public class GuarantorCommandValidator {
|
||||
|
||||
private final GuarantorCommand command;
|
||||
|
||||
public GuarantorCommandValidator(GuarantorCommand command) {
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
public void validateForCreate() {
|
||||
|
||||
List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
|
||||
|
||||
DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("Guarantor");
|
||||
|
||||
// validate for existing Client
|
||||
if (command.isExternalGuarantor() == null || command.isExternalGuarantor() == false) {
|
||||
baseDataValidator.reset().parameter("existingClientId").value(command.getExistingClientId()).notNull().integerGreaterThanZero();
|
||||
} else {
|
||||
// validate for an external guarantor
|
||||
baseDataValidator.reset().parameter("firstname").value(command.getFirstname()).notBlank().notExceedingLengthOf(50);
|
||||
baseDataValidator.reset().parameter("lastname").value(command.getLastname()).notBlank().notExceedingLengthOf(50);
|
||||
|
||||
validateNonMandatoryFieldsForMaxLength(baseDataValidator);
|
||||
}
|
||||
|
||||
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist",
|
||||
"Validation errors exist.", dataValidationErrors); }
|
||||
}
|
||||
|
||||
public void validateForUpdate() {
|
||||
List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
|
||||
|
||||
DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("Guarantor");
|
||||
|
||||
// validate for existing Client
|
||||
if (command.isExternalGuarantor() == null || command.isExternalGuarantor() == false) {
|
||||
baseDataValidator.reset().parameter("existingClientId").value(command.getExistingClientId()).notNull().integerGreaterThanZero();
|
||||
} else {
|
||||
// validate for an external guarantor
|
||||
baseDataValidator.reset().parameter("firstname").value(command.getFirstname()).notBlank().notExceedingLengthOf(50);
|
||||
baseDataValidator.reset().parameter("lastname").value(command.getLastname()).notBlank().notExceedingLengthOf(50);
|
||||
|
||||
validateNonMandatoryFieldsForMaxLength(baseDataValidator);
|
||||
}
|
||||
baseDataValidator.reset().anyOfNotNull(command.getExistingClientId(), command.getAddressLine1(), command.getAddressLine2(),
|
||||
command.getCity(), command.getComment(), command.getCountry(), command.getFirstname(), command.getHousePhoneNumber(),
|
||||
command.getLastname(), command.getMobileNumber(), command.getState(), command.getZip());
|
||||
|
||||
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist",
|
||||
"Validation errors exist.", dataValidationErrors); }
|
||||
}
|
||||
|
||||
/**
|
||||
* @param baseDataValidator
|
||||
*/
|
||||
private void validateNonMandatoryFieldsForMaxLength(DataValidatorBuilder baseDataValidator) {
|
||||
// validate non mandatory fields for length
|
||||
baseDataValidator.reset().parameter("addressLine1").value(command.getAddressLine1()).ignoreIfNull().notExceedingLengthOf(50);
|
||||
baseDataValidator.reset().parameter("addressLine2").value(command.getAddressLine2()).ignoreIfNull().notExceedingLengthOf(50);
|
||||
baseDataValidator.reset().parameter("city").value(command.getCity()).ignoreIfNull().notExceedingLengthOf(50);
|
||||
baseDataValidator.reset().parameter("state").value(command.getState()).ignoreIfNull().notExceedingLengthOf(50);
|
||||
baseDataValidator.reset().parameter("zip").value(command.getZip()).ignoreIfNull().notExceedingLengthOf(50);
|
||||
baseDataValidator.reset().parameter("country").value(command.getCountry()).ignoreIfNull().notExceedingLengthOf(50);
|
||||
baseDataValidator.reset().parameter("mobileNumber").value(command.getMobileNumber()).ignoreIfNull().notExceedingLengthOf(20);
|
||||
baseDataValidator.reset().parameter("housePhoneNumber").value(command.getHousePhoneNumber()).ignoreIfNull()
|
||||
.notExceedingLengthOf(20);
|
||||
baseDataValidator.reset().parameter("comment").value(command.getComment()).ignoreIfNull().notExceedingLengthOf(500);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.mifosng.platform.api.data;
|
||||
package org.mifosplatform.portfolio.loanaccount.gaurantor.data;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.mifosng.platform.exceptions;
|
||||
package org.mifosplatform.portfolio.loanaccount.gaurantor.exception;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.exception.AbstractPlatformResourceNotFoundException;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.mifosng.platform.exceptions;
|
||||
package org.mifosplatform.portfolio.loanaccount.gaurantor.exception;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.exception.AbstractPlatformDomainRuleException;
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package org.mifosplatform.portfolio.loanaccount.gaurantor.service;
|
||||
|
||||
import org.mifosplatform.portfolio.loanaccount.gaurantor.data.GuarantorData;
|
||||
|
||||
public interface GuarantorReadPlatformService {
|
||||
|
||||
GuarantorData retrieveGuarantor(Long loanId);
|
||||
|
||||
boolean existsGuarantor(Long loanId);
|
||||
|
||||
GuarantorData getExternalGuarantor(Long loanId);
|
||||
|
||||
}
|
||||
+8
-7
@@ -1,17 +1,17 @@
|
||||
package org.mifosng.platform.guarantor;
|
||||
package org.mifosplatform.portfolio.loanaccount.gaurantor.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.mifosng.platform.api.data.GuarantorData;
|
||||
import org.mifosng.platform.exceptions.GuarantorNotFoundException;
|
||||
import org.mifosplatform.infrastructure.dataqueries.data.GenericResultsetData;
|
||||
import org.mifosplatform.infrastructure.dataqueries.service.ReadWriteNonCoreDataService;
|
||||
import org.mifosplatform.portfolio.client.domain.Client;
|
||||
import org.mifosplatform.portfolio.loanaccount.domain.Loan;
|
||||
import org.mifosplatform.portfolio.loanaccount.domain.LoanRepository;
|
||||
import org.mifosplatform.portfolio.loanaccount.exception.LoanNotFoundException;
|
||||
import org.mifosplatform.portfolio.loanaccount.gaurantor.data.GuarantorData;
|
||||
import org.mifosplatform.portfolio.loanaccount.gaurantor.exception.GuarantorNotFoundException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -20,7 +20,7 @@ public class GuarantorReadPlatformServiceImpl implements GuarantorReadPlatformSe
|
||||
|
||||
// Table for storing external Guarantor Details
|
||||
public static final String EXTERNAL_GUARANTOR_TABLE_NAME = "m_guarantor_external";
|
||||
|
||||
|
||||
private final LoanRepository loanRepository;
|
||||
private final ReadWriteNonCoreDataService readWriteNonCoreDataService;
|
||||
|
||||
@@ -61,8 +61,9 @@ public class GuarantorReadPlatformServiceImpl implements GuarantorReadPlatformSe
|
||||
}
|
||||
|
||||
private Loan retrieveLoanById(final Long loanId) {
|
||||
|
||||
// FIXME - KW - On the read side of services - we would prefer not to use the repository/ORM pattern
|
||||
|
||||
// FIXME - KW - On the read side of services - we would prefer not to
|
||||
// use the repository/ORM pattern
|
||||
Loan loan = loanRepository.findOne(loanId);
|
||||
if (loan == null) { throw new LoanNotFoundException(loanId); }
|
||||
return loan;
|
||||
@@ -70,7 +71,7 @@ public class GuarantorReadPlatformServiceImpl implements GuarantorReadPlatformSe
|
||||
|
||||
@Override
|
||||
public GuarantorData getExternalGuarantor(final Long loanId) {
|
||||
|
||||
|
||||
GenericResultsetData genericResultDataSet = readWriteNonCoreDataService.retrieveDataTableGenericResultSet(
|
||||
EXTERNAL_GUARANTOR_TABLE_NAME, loanId, null, null);
|
||||
if (genericResultDataSet.getData().size() == 1) {
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package org.mifosplatform.portfolio.loanaccount.gaurantor.service;
|
||||
|
||||
import org.mifosplatform.portfolio.loanaccount.gaurantor.command.GuarantorCommand;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
||||
public interface GuarantorWritePlatformService {
|
||||
|
||||
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS','PORTFOLIO_MANAGEMENT_SUPER_USER')")
|
||||
void createGuarantor(final Long loanId, final GuarantorCommand command);
|
||||
|
||||
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS','PORTFOLIO_MANAGEMENT_SUPER_USER')")
|
||||
void updateGuarantor(final Long loanId, final GuarantorCommand command);
|
||||
|
||||
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS','PORTFOLIO_MANAGEMENT_SUPER_USER')")
|
||||
void removeGuarantor(final Long loanId);
|
||||
|
||||
}
|
||||
+5
-4
@@ -1,4 +1,4 @@
|
||||
package org.mifosng.platform.guarantor;
|
||||
package org.mifosplatform.portfolio.loanaccount.gaurantor.service;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
@@ -8,8 +8,6 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.mifosng.platform.api.commands.GuarantorCommand;
|
||||
import org.mifosng.platform.exceptions.InvalidGuarantorException;
|
||||
import org.mifosplatform.infrastructure.core.data.ApiParameterError;
|
||||
import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException;
|
||||
import org.mifosplatform.infrastructure.dataqueries.service.ReadWriteNonCoreDataService;
|
||||
@@ -19,6 +17,9 @@ import org.mifosplatform.portfolio.client.exception.ClientNotFoundException;
|
||||
import org.mifosplatform.portfolio.loanaccount.domain.Loan;
|
||||
import org.mifosplatform.portfolio.loanaccount.domain.LoanRepository;
|
||||
import org.mifosplatform.portfolio.loanaccount.exception.LoanNotFoundException;
|
||||
import org.mifosplatform.portfolio.loanaccount.gaurantor.command.GuarantorCommand;
|
||||
import org.mifosplatform.portfolio.loanaccount.gaurantor.command.GuarantorCommandValidator;
|
||||
import org.mifosplatform.portfolio.loanaccount.gaurantor.exception.InvalidGuarantorException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -90,7 +91,7 @@ public class GuarantorWritePlatformServiceImpl implements GuarantorWritePlatform
|
||||
else {
|
||||
Set<String> modifiedParameters = command.getModifiedParameters();
|
||||
Map<String, String> modifiedParametersMap = new HashMap<String, String>();
|
||||
|
||||
|
||||
/***
|
||||
* TODO Vishwas: Check with JW/KW if using reflection here is a good
|
||||
* idea
|
||||
Reference in New Issue
Block a user