merge release 1.10.1 to develop branch
This commit is contained in:
+1
-1
@@ -76,7 +76,7 @@ public class GLClosuresApiResource {
|
||||
|
||||
this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermission);
|
||||
final List<GLClosureData> glClosureDatas = this.glClosureReadPlatformService.retrieveAllGLClosures(officeId);
|
||||
|
||||
|
||||
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
return this.apiJsonSerializerService.serialize(settings, glClosureDatas, RESPONSE_DATA_PARAMETERS);
|
||||
}
|
||||
|
||||
+7
-6
@@ -50,20 +50,21 @@ public class AccountingDropdownReadPlatformServiceImpl implements AccountingDrop
|
||||
|
||||
@Override
|
||||
public Map<String, List<GLAccountData>> retrieveAccountMappingOptionsForLoanProducts() {
|
||||
Map<String, List<GLAccountData>> accountOptions = new HashMap<String, List<GLAccountData>>();
|
||||
List<GLAccountData> assetAccountOptions = accountReadPlatformService.retrieveAllEnabledDetailGLAccounts(GLAccountType.ASSET);
|
||||
final Map<String, List<GLAccountData>> accountOptions = new HashMap<String, List<GLAccountData>>();
|
||||
List<GLAccountData> assetAccountOptions = this.accountReadPlatformService.retrieveAllEnabledDetailGLAccounts(GLAccountType.ASSET);
|
||||
if (assetAccountOptions.isEmpty()) {
|
||||
assetAccountOptions = null;
|
||||
}
|
||||
accountOptions.put("assetAccountOptions", assetAccountOptions);
|
||||
|
||||
List<GLAccountData> incomeAccountOptions = accountReadPlatformService.retrieveAllEnabledDetailGLAccounts(GLAccountType.INCOME);
|
||||
List<GLAccountData> incomeAccountOptions = this.accountReadPlatformService.retrieveAllEnabledDetailGLAccounts(GLAccountType.INCOME);
|
||||
if (incomeAccountOptions.isEmpty()) {
|
||||
incomeAccountOptions = null;
|
||||
}
|
||||
accountOptions.put("incomeAccountOptions", incomeAccountOptions);
|
||||
|
||||
List<GLAccountData> expenseAccountOptions = accountReadPlatformService.retrieveAllEnabledDetailGLAccounts(GLAccountType.EXPENSE);
|
||||
List<GLAccountData> expenseAccountOptions = this.accountReadPlatformService
|
||||
.retrieveAllEnabledDetailGLAccounts(GLAccountType.EXPENSE);
|
||||
if (expenseAccountOptions.isEmpty()) {
|
||||
expenseAccountOptions = null;
|
||||
}
|
||||
@@ -73,8 +74,8 @@ public class AccountingDropdownReadPlatformServiceImpl implements AccountingDrop
|
||||
|
||||
@Override
|
||||
public Map<String, List<GLAccountData>> retrieveAccountMappingOptionsForSavingsProducts() {
|
||||
Map<String, List<GLAccountData>> accountOptions = retrieveAccountMappingOptionsForLoanProducts();
|
||||
List<GLAccountData> liabilityAccountOptions = accountReadPlatformService
|
||||
final Map<String, List<GLAccountData>> accountOptions = retrieveAccountMappingOptionsForLoanProducts();
|
||||
List<GLAccountData> liabilityAccountOptions = this.accountReadPlatformService
|
||||
.retrieveAllEnabledDetailGLAccounts(GLAccountType.LIABILITY);
|
||||
if (liabilityAccountOptions.isEmpty()) {
|
||||
liabilityAccountOptions = null;
|
||||
|
||||
+1
-1
@@ -85,7 +85,7 @@ public class AccountingEnumerations {
|
||||
}
|
||||
|
||||
public static EnumOptionData accountingRuleType(final AccountingRuleType type) {
|
||||
EnumOptionData optionData = new EnumOptionData(type.getValue().longValue(), type.getCode(), type.toString());
|
||||
final EnumOptionData optionData = new EnumOptionData(type.getValue().longValue(), type.getCode(), type.toString());
|
||||
return optionData;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -19,13 +19,13 @@ public enum AccountingRuleType {
|
||||
|
||||
private static final Map<Integer, AccountingRuleType> intToEnumMap = new HashMap<Integer, AccountingRuleType>();
|
||||
static {
|
||||
for (AccountingRuleType type : AccountingRuleType.values()) {
|
||||
for (final AccountingRuleType type : AccountingRuleType.values()) {
|
||||
intToEnumMap.put(type.value, type);
|
||||
}
|
||||
}
|
||||
|
||||
public static AccountingRuleType fromInt(final Integer ruleTypeValue) {
|
||||
AccountingRuleType type = intToEnumMap.get(ruleTypeValue);
|
||||
final AccountingRuleType type = intToEnumMap.get(ruleTypeValue);
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
+5
-3
@@ -71,8 +71,9 @@ public class GLAccountCommand {
|
||||
|
||||
baseDataValidator.reset().parameter(GLAccountJsonInputParams.MANUAL_ENTRIES_ALLOWED.getValue()).value(this.manualEntriesAllowed)
|
||||
.notBlank();
|
||||
|
||||
baseDataValidator.reset().parameter(GLAccountJsonInputParams.TAGID.getValue()).value(this.tagId).ignoreIfNull().longGreaterThanZero();
|
||||
|
||||
baseDataValidator.reset().parameter(GLAccountJsonInputParams.TAGID.getValue()).value(this.tagId).ignoreIfNull()
|
||||
.longGreaterThanZero();
|
||||
|
||||
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist",
|
||||
"Validation errors exist.", dataValidationErrors); }
|
||||
@@ -106,7 +107,8 @@ public class GLAccountCommand {
|
||||
|
||||
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist",
|
||||
"Validation errors exist.", dataValidationErrors); }
|
||||
baseDataValidator.reset().parameter(GLAccountJsonInputParams.TAGID.getValue()).value(this.tagId).ignoreIfNull().longGreaterThanZero();
|
||||
baseDataValidator.reset().parameter(GLAccountJsonInputParams.TAGID.getValue()).value(this.tagId).ignoreIfNull()
|
||||
.longGreaterThanZero();
|
||||
}
|
||||
|
||||
public boolean isHeaderAccount() {
|
||||
|
||||
+6
-6
@@ -83,7 +83,7 @@ public class GLAccount extends AbstractPersistable<Long> {
|
||||
this.tagId = tagId;
|
||||
}
|
||||
|
||||
public static GLAccount fromJson(final GLAccount parent, final JsonCommand command, CodeValue glAccountTagType) {
|
||||
public static GLAccount fromJson(final GLAccount parent, final JsonCommand command, final CodeValue glAccountTagType) {
|
||||
final String name = command.stringValueOfParameterNamed(GLAccountJsonInputParams.NAME.getValue());
|
||||
final String glCode = command.stringValueOfParameterNamed(GLAccountJsonInputParams.GL_CODE.getValue());
|
||||
final boolean disabled = command.booleanPrimitiveValueOfParameterNamed(GLAccountJsonInputParams.DISABLED.getValue());
|
||||
@@ -211,8 +211,8 @@ public class GLAccount extends AbstractPersistable<Long> {
|
||||
|
||||
public void generateHierarchy() {
|
||||
|
||||
if (parent != null) {
|
||||
this.hierarchy = this.parent.hierarchyOf(this.getId());
|
||||
if (this.parent != null) {
|
||||
this.hierarchy = this.parent.hierarchyOf(getId());
|
||||
} else {
|
||||
this.hierarchy = ".";
|
||||
}
|
||||
@@ -226,12 +226,12 @@ public class GLAccount extends AbstractPersistable<Long> {
|
||||
return GLAccountUsage.DETAIL.getValue().equals(this.usage);
|
||||
}
|
||||
|
||||
public void updateTagId(CodeValue tagID) {
|
||||
public void updateTagId(final CodeValue tagID) {
|
||||
this.tagId = tagID;
|
||||
}
|
||||
|
||||
public void updateParentAccount(GLAccount parentAccount) {
|
||||
public void updateParentAccount(final GLAccount parentAccount) {
|
||||
this.parent = parentAccount;
|
||||
this.generateHierarchy();
|
||||
generateHierarchy();
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -58,7 +58,7 @@ public final class GLAccountCommandFromApiJsonDeserializer extends AbstractFromA
|
||||
final Integer usage = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(GLAccountJsonInputParams.USAGE.getValue(), element);
|
||||
final String description = this.fromApiJsonHelper.extractStringNamed(GLAccountJsonInputParams.DESCRIPTION.getValue(), element);
|
||||
final Long tagId = this.fromApiJsonHelper.extractLongNamed(GLAccountJsonInputParams.TAGID.getValue(), element);
|
||||
|
||||
|
||||
return new GLAccountCommand(id, name, parentId, glCode, disabled, manualEntriesAllowed, type, usage, description, tagId);
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -75,7 +75,7 @@ public class GLAccountWritePlatformServiceJpaRepositoryImpl implements GLAccount
|
||||
CodeValue glAccountTagType = null;
|
||||
final Long tagId = command.longValueOfParameterNamed(GLAccountJsonInputParams.TAGID.getValue());
|
||||
final Long type = command.longValueOfParameterNamed(GLAccountJsonInputParams.TYPE.getValue());
|
||||
GLAccountType accountType = GLAccountType.fromInt(type.intValue());
|
||||
final GLAccountType accountType = GLAccountType.fromInt(type.intValue());
|
||||
|
||||
if (tagId != null) {
|
||||
glAccountTagType = retrieveTagId(tagId, accountType);
|
||||
@@ -113,7 +113,7 @@ public class GLAccountWritePlatformServiceJpaRepositoryImpl implements GLAccount
|
||||
|
||||
// is the new parent valid
|
||||
if (changesOnly.containsKey(GLAccountJsonInputParams.PARENT_ID.getValue())) {
|
||||
GLAccount parentAccount = validateParentGLAccount(parentId);
|
||||
final GLAccount parentAccount = validateParentGLAccount(parentId);
|
||||
glAccount.updateParentAccount(parentAccount);
|
||||
}
|
||||
|
||||
@@ -203,7 +203,7 @@ public class GLAccountWritePlatformServiceJpaRepositoryImpl implements GLAccount
|
||||
"Unknown data integrity issue with resource GL Account: " + realCause.getMessage());
|
||||
}
|
||||
|
||||
private CodeValue retrieveTagId(Long tagId, GLAccountType accountType) {
|
||||
private CodeValue retrieveTagId(final Long tagId, final GLAccountType accountType) {
|
||||
CodeValue glAccountTagType = null;
|
||||
if (accountType.isAssetType()) {
|
||||
glAccountTagType = this.codeValueRepositoryWrapper.findOneByCodeNameAndIdWithNotFoundDetection(
|
||||
|
||||
+3
-3
@@ -26,9 +26,9 @@ public class DateParam {
|
||||
this.dateAsString = dateStr;
|
||||
}
|
||||
|
||||
public Date getDate(String parameterName,String dateFormat, String localeAsString) {
|
||||
Locale locale = JsonParserHelper.localeFromString(localeAsString);
|
||||
LocalDate localDate = JsonParserHelper.convertFrom(dateAsString, parameterName, dateFormat, locale);
|
||||
public Date getDate(final String parameterName, final String dateFormat, final String localeAsString) {
|
||||
final Locale locale = JsonParserHelper.localeFromString(localeAsString);
|
||||
final LocalDate localDate = JsonParserHelper.convertFrom(this.dateAsString, parameterName, dateFormat, locale);
|
||||
return localDate.toDate();
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -94,9 +94,9 @@ public class JournalEntriesApiResource {
|
||||
|
||||
final SearchParameters searchParameters = SearchParameters.forJournalEntries(officeId, offset, limit, orderBy, sortOrder);
|
||||
|
||||
Page<JournalEntryData> glJournalEntries = this.journalEntryReadPlatformService.retrieveAll(searchParameters, glAccountId,
|
||||
final Page<JournalEntryData> glJournalEntries = this.journalEntryReadPlatformService.retrieveAll(searchParameters, glAccountId,
|
||||
onlyManualEntries, fromDate, toDate, transactionId);
|
||||
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
return this.apiJsonSerializerService.serialize(settings, glJournalEntries, RESPONSE_DATA_PARAMETERS);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ public class ChargePaymentDTO {
|
||||
private final BigDecimal amount;
|
||||
private final Long loanChargeId;
|
||||
|
||||
public ChargePaymentDTO(Long chargeId, Long loanChargeId, BigDecimal amount) {
|
||||
public ChargePaymentDTO(final Long chargeId, final Long loanChargeId, final BigDecimal amount) {
|
||||
this.chargeId = chargeId;
|
||||
this.amount = amount;
|
||||
this.loanChargeId = loanChargeId;
|
||||
|
||||
+2
-1
@@ -63,7 +63,8 @@ public class JournalEntryData {
|
||||
final Long glAccountId, final String glAccountCode, final EnumOptionData glAccountClassification,
|
||||
final LocalDate transactionDate, final EnumOptionData entryType, final BigDecimal amount, final String transactionId,
|
||||
final Boolean manualEntry, final EnumOptionData entityType, final Long entityId, final Long createdByUserId,
|
||||
final LocalDate createdDate, final String createdByUserName, final String comments, final Boolean reversed, final String referenceNumber) {
|
||||
final LocalDate createdDate, final String createdByUserName, final String comments, final Boolean reversed,
|
||||
final String referenceNumber) {
|
||||
this.id = id;
|
||||
this.officeId = officeId;
|
||||
this.officeName = officeName;
|
||||
|
||||
+1
-1
@@ -82,7 +82,7 @@ public class LoanDTO {
|
||||
return this.currencyCode;
|
||||
}
|
||||
|
||||
public void setCurrencyCode(String currencyCode) {
|
||||
public void setCurrencyCode(final String currencyCode) {
|
||||
this.currencyCode = currencyCode;
|
||||
}
|
||||
|
||||
|
||||
+7
-7
@@ -33,7 +33,7 @@ public class SavingsDTO {
|
||||
return this.savingsId;
|
||||
}
|
||||
|
||||
public void setSavingsId(Long savingsId) {
|
||||
public void setSavingsId(final Long savingsId) {
|
||||
this.savingsId = savingsId;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class SavingsDTO {
|
||||
return this.savingsProductId;
|
||||
}
|
||||
|
||||
public void setSavingsProductId(Long savingsProductId) {
|
||||
public void setSavingsProductId(final Long savingsProductId) {
|
||||
this.savingsProductId = savingsProductId;
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public class SavingsDTO {
|
||||
return this.officeId;
|
||||
}
|
||||
|
||||
public void setOfficeId(Long officeId) {
|
||||
public void setOfficeId(final Long officeId) {
|
||||
this.officeId = officeId;
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public class SavingsDTO {
|
||||
return this.cashBasedAccountingEnabled;
|
||||
}
|
||||
|
||||
public void setCashBasedAccountingEnabled(boolean cashBasedAccountingEnabled) {
|
||||
public void setCashBasedAccountingEnabled(final boolean cashBasedAccountingEnabled) {
|
||||
this.cashBasedAccountingEnabled = cashBasedAccountingEnabled;
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ public class SavingsDTO {
|
||||
return this.accrualBasedAccountingEnabled;
|
||||
}
|
||||
|
||||
public void setAccrualBasedAccountingEnabled(boolean accrualBasedAccountingEnabled) {
|
||||
public void setAccrualBasedAccountingEnabled(final boolean accrualBasedAccountingEnabled) {
|
||||
this.accrualBasedAccountingEnabled = accrualBasedAccountingEnabled;
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public class SavingsDTO {
|
||||
return this.newSavingsTransactions;
|
||||
}
|
||||
|
||||
public void setNewSavingsTransactions(List<SavingsTransactionDTO> newSavingsTransactions) {
|
||||
public void setNewSavingsTransactions(final List<SavingsTransactionDTO> newSavingsTransactions) {
|
||||
this.newSavingsTransactions = newSavingsTransactions;
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ public class SavingsDTO {
|
||||
return this.currencyCode;
|
||||
}
|
||||
|
||||
public void setCurrencyCode(String currencyCode) {
|
||||
public void setCurrencyCode(final String currencyCode) {
|
||||
this.currencyCode = currencyCode;
|
||||
}
|
||||
|
||||
|
||||
+1
-2
@@ -16,8 +16,7 @@ public class JournalEntryInvalidException extends AbstractPlatformDomainRuleExce
|
||||
|
||||
/*** enum of reasons for invalid Journal Entry **/
|
||||
public static enum GL_JOURNAL_ENTRY_INVALID_REASON {
|
||||
FUTURE_DATE, ACCOUNTING_CLOSED, NO_DEBITS_OR_CREDITS, DEBIT_CREDIT_SUM_MISMATCH_WITH_AMOUNT, DEBIT_CREDIT_SUM_MISMATCH, DEBIT_CREDIT_ACCOUNT_OR_AMOUNT_EMPTY, GL_ACCOUNT_DISABLED, GL_ACCOUNT_MANUAL_ENTRIES_NOT_PERMITTED,
|
||||
INVALID_DEBIT_OR_CREDIT_ACCOUNTS;
|
||||
FUTURE_DATE, ACCOUNTING_CLOSED, NO_DEBITS_OR_CREDITS, DEBIT_CREDIT_SUM_MISMATCH_WITH_AMOUNT, DEBIT_CREDIT_SUM_MISMATCH, DEBIT_CREDIT_ACCOUNT_OR_AMOUNT_EMPTY, GL_ACCOUNT_DISABLED, GL_ACCOUNT_MANUAL_ENTRIES_NOT_PERMITTED, INVALID_DEBIT_OR_CREDIT_ACCOUNTS;
|
||||
|
||||
public String errorMessage() {
|
||||
if (name().toString().equalsIgnoreCase("FUTURE_DATE")) {
|
||||
|
||||
+5
-5
@@ -13,10 +13,10 @@ import org.springframework.stereotype.Component;
|
||||
@Component
|
||||
public class AccountingProcessorForLoanFactory {
|
||||
|
||||
private ApplicationContext applicationContext;
|
||||
private final ApplicationContext applicationContext;
|
||||
|
||||
@Autowired
|
||||
public AccountingProcessorForLoanFactory(ApplicationContext applicationContext) {
|
||||
public AccountingProcessorForLoanFactory(final ApplicationContext applicationContext) {
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
@@ -25,12 +25,12 @@ public class AccountingProcessorForLoanFactory {
|
||||
AccountingProcessorForLoan accountingProcessorForLoan = null;
|
||||
|
||||
if (loanDTO.isCashBasedAccountingEnabled()) {
|
||||
accountingProcessorForLoan = applicationContext
|
||||
.getBean("cashBasedAccountingProcessorForLoan", AccountingProcessorForLoan.class);
|
||||
accountingProcessorForLoan = this.applicationContext.getBean("cashBasedAccountingProcessorForLoan",
|
||||
AccountingProcessorForLoan.class);
|
||||
}
|
||||
|
||||
else if (loanDTO.isAccrualBasedAccountingEnabled()) {
|
||||
accountingProcessorForLoan = applicationContext.getBean("accrualBasedAccountingProcessorForLoan",
|
||||
accountingProcessorForLoan = this.applicationContext.getBean("accrualBasedAccountingProcessorForLoan",
|
||||
AccountingProcessorForLoan.class);
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -13,10 +13,10 @@ import org.springframework.stereotype.Component;
|
||||
@Component
|
||||
public class AccountingProcessorForSavingsFactory {
|
||||
|
||||
private ApplicationContext applicationContext;
|
||||
private final ApplicationContext applicationContext;
|
||||
|
||||
@Autowired
|
||||
public AccountingProcessorForSavingsFactory(ApplicationContext applicationContext) {
|
||||
public AccountingProcessorForSavingsFactory(final ApplicationContext applicationContext) {
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public class AccountingProcessorForSavingsFactory {
|
||||
AccountingProcessorForSavings accountingProcessorForSavings = null;
|
||||
|
||||
if (savingsDTO.isCashBasedAccountingEnabled()) {
|
||||
accountingProcessorForSavings = applicationContext.getBean("cashBasedAccountingProcessorForSavings",
|
||||
accountingProcessorForSavings = this.applicationContext.getBean("cashBasedAccountingProcessorForSavings",
|
||||
AccountingProcessorForSavings.class);
|
||||
}
|
||||
|
||||
|
||||
+26
-26
@@ -84,8 +84,8 @@ public class AccountingProcessorHelper {
|
||||
final boolean reversed = (Boolean) map.get("reversed");
|
||||
final Long paymentTypeId = (Long) map.get("paymentTypeId");
|
||||
|
||||
List<ChargePaymentDTO> feePayments = new ArrayList<ChargePaymentDTO>();
|
||||
List<ChargePaymentDTO> penaltyPayments = new ArrayList<ChargePaymentDTO>();
|
||||
final List<ChargePaymentDTO> feePayments = new ArrayList<ChargePaymentDTO>();
|
||||
final List<ChargePaymentDTO> penaltyPayments = new ArrayList<ChargePaymentDTO>();
|
||||
// extract charge payment details (if exists)
|
||||
if (map.containsKey("loanChargesPaid")) {
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -95,7 +95,7 @@ public class AccountingProcessorHelper {
|
||||
final Long loanChargeId = (Long) loanChargePaid.get("chargeId");
|
||||
final boolean isPenalty = (Boolean) loanChargePaid.get("isPenalty");
|
||||
final BigDecimal chargeAmountPaid = (BigDecimal) loanChargePaid.get("amount");
|
||||
ChargePaymentDTO chargePaymentDTO = new ChargePaymentDTO(chargeId, loanChargeId, chargeAmountPaid);
|
||||
final ChargePaymentDTO chargePaymentDTO = new ChargePaymentDTO(chargeId, loanChargeId, chargeAmountPaid);
|
||||
if (isPenalty) {
|
||||
penaltyPayments.add(chargePaymentDTO);
|
||||
} else {
|
||||
@@ -254,7 +254,7 @@ public class AccountingProcessorHelper {
|
||||
public void createCreditJournalEntryOrReversalForLoan(final Office office, final String currencyCode,
|
||||
final CASH_ACCOUNTS_FOR_LOAN accountMappingType, final Long loanProductId, final Long paymentTypeId, final Long loanId,
|
||||
final String transactionId, final Date transactionDate, final BigDecimal amount, final Boolean isReversal) {
|
||||
int accountMappingTypeId = accountMappingType.getValue();
|
||||
final int accountMappingTypeId = accountMappingType.getValue();
|
||||
createCreditJournalEntryOrReversalForLoan(office, currencyCode, accountMappingTypeId, loanProductId, paymentTypeId, loanId,
|
||||
transactionId, transactionDate, amount, isReversal);
|
||||
}
|
||||
@@ -262,7 +262,7 @@ public class AccountingProcessorHelper {
|
||||
public void createCreditJournalEntryOrReversalForLoan(final Office office, final String currencyCode,
|
||||
final ACCRUAL_ACCOUNTS_FOR_LOAN accountMappingType, final Long loanProductId, final Long paymentTypeId, final Long loanId,
|
||||
final String transactionId, final Date transactionDate, final BigDecimal amount, final Boolean isReversal) {
|
||||
int accountMappingTypeId = accountMappingType.getValue();
|
||||
final int accountMappingTypeId = accountMappingType.getValue();
|
||||
createCreditJournalEntryOrReversalForLoan(office, currencyCode, accountMappingTypeId, loanProductId, paymentTypeId, loanId,
|
||||
transactionId, transactionDate, amount, isReversal);
|
||||
}
|
||||
@@ -270,7 +270,7 @@ public class AccountingProcessorHelper {
|
||||
public void createDebitJournalEntryOrReversalForLoan(final Office office, final String currencyCode,
|
||||
final CASH_ACCOUNTS_FOR_LOAN accountMappingType, final Long loanProductId, final Long paymentTypeId, final Long loanId,
|
||||
final String transactionId, final Date transactionDate, final BigDecimal amount, final Boolean isReversal) {
|
||||
int accountMappingTypeId = accountMappingType.getValue();
|
||||
final int accountMappingTypeId = accountMappingType.getValue();
|
||||
createDebitJournalEntryOrReversalForLoan(office, currencyCode, accountMappingTypeId, loanProductId, paymentTypeId, loanId,
|
||||
transactionId, transactionDate, amount, isReversal);
|
||||
}
|
||||
@@ -278,7 +278,7 @@ public class AccountingProcessorHelper {
|
||||
public void createDebitJournalEntryOrReversalForLoan(final Office office, final String currencyCode,
|
||||
final ACCRUAL_ACCOUNTS_FOR_LOAN accountMappingType, final Long loanProductId, final Long paymentTypeId, final Long loanId,
|
||||
final String transactionId, final Date transactionDate, final BigDecimal amount, final Boolean isReversal) {
|
||||
int accountMappingTypeId = accountMappingType.getValue();
|
||||
final int accountMappingTypeId = accountMappingType.getValue();
|
||||
createDebitJournalEntryOrReversalForLoan(office, currencyCode, accountMappingTypeId, loanProductId, paymentTypeId, loanId,
|
||||
transactionId, transactionDate, amount, isReversal);
|
||||
}
|
||||
@@ -298,19 +298,19 @@ public class AccountingProcessorHelper {
|
||||
}
|
||||
}
|
||||
|
||||
public GLClosure getLatestClosureByBranch(long officeId) {
|
||||
public GLClosure getLatestClosureByBranch(final long officeId) {
|
||||
return this.closureRepository.getLatestGLClosureByBranch(officeId);
|
||||
}
|
||||
|
||||
public Office getOfficeById(long officeId) {
|
||||
public Office getOfficeById(final long officeId) {
|
||||
return this.officeRepository.findOne(officeId);
|
||||
}
|
||||
|
||||
private void createJournalEntriesForLoan(final Office office, final String currencyCode, final int accountTypeToDebitId,
|
||||
final int accountTypeToCreditId, final Long loanProductId, final Long paymentTypeId, final Long loanId,
|
||||
final String transactionId, final Date transactionDate, final BigDecimal amount) {
|
||||
GLAccount debitAccount = getLinkedGLAccountForLoanProduct(loanProductId, accountTypeToDebitId, paymentTypeId);
|
||||
GLAccount creditAccount = getLinkedGLAccountForLoanProduct(loanProductId, accountTypeToCreditId, paymentTypeId);
|
||||
final GLAccount debitAccount = getLinkedGLAccountForLoanProduct(loanProductId, accountTypeToDebitId, paymentTypeId);
|
||||
final GLAccount creditAccount = getLinkedGLAccountForLoanProduct(loanProductId, accountTypeToCreditId, paymentTypeId);
|
||||
createDebitJournalEntryForLoan(office, currencyCode, debitAccount, loanId, transactionId, transactionDate, amount);
|
||||
createCreditJournalEntryForLoan(office, currencyCode, creditAccount, loanId, transactionId, transactionDate, amount);
|
||||
}
|
||||
@@ -318,8 +318,8 @@ public class AccountingProcessorHelper {
|
||||
private void createJournalEntriesForSavings(final Office office, final String currencyCode, final int accountTypeToDebitId,
|
||||
final int accountTypeToCreditId, final Long savingsProductId, final Long paymentTypeId, final Long savingsId,
|
||||
final String transactionId, final Date transactionDate, final BigDecimal amount) {
|
||||
GLAccount debitAccount = getLinkedGLAccountForSavingsProduct(savingsProductId, accountTypeToDebitId, paymentTypeId);
|
||||
GLAccount creditAccount = getLinkedGLAccountForSavingsProduct(savingsProductId, accountTypeToCreditId, paymentTypeId);
|
||||
final GLAccount debitAccount = getLinkedGLAccountForSavingsProduct(savingsProductId, accountTypeToDebitId, paymentTypeId);
|
||||
final GLAccount creditAccount = getLinkedGLAccountForSavingsProduct(savingsProductId, accountTypeToCreditId, paymentTypeId);
|
||||
createDebitJournalEntryForSavings(office, currencyCode, debitAccount, savingsId, transactionId, transactionDate, amount);
|
||||
createCreditJournalEntryForSavings(office, currencyCode, creditAccount, savingsId, transactionId, transactionDate, amount);
|
||||
}
|
||||
@@ -327,7 +327,7 @@ public class AccountingProcessorHelper {
|
||||
private void createDebitJournalEntryOrReversalForLoan(final Office office, final String currencyCode, final int accountMappingTypeId,
|
||||
final Long loanProductId, final Long paymentTypeId, final Long loanId, final String transactionId, final Date transactionDate,
|
||||
final BigDecimal amount, final Boolean isReversal) {
|
||||
GLAccount account = getLinkedGLAccountForLoanProduct(loanProductId, accountMappingTypeId, paymentTypeId);
|
||||
final GLAccount account = getLinkedGLAccountForLoanProduct(loanProductId, accountMappingTypeId, paymentTypeId);
|
||||
if (isReversal) {
|
||||
createCreditJournalEntryForLoan(office, currencyCode, account, loanId, transactionId, transactionDate, amount);
|
||||
} else {
|
||||
@@ -343,25 +343,25 @@ public class AccountingProcessorHelper {
|
||||
* Map to track each account and the net credit to be made for a
|
||||
* particular account
|
||||
***/
|
||||
Map<GLAccount, BigDecimal> creditDetailsMap = new LinkedHashMap<GLAccount, BigDecimal>();
|
||||
for (ChargePaymentDTO chargePaymentDTO : chargePaymentDTOs) {
|
||||
Long chargeId = chargePaymentDTO.getChargeId();
|
||||
GLAccount chargeSpecificAccount = getLinkedGLAccountForLoanCharges(loanProductId, accountMappingTypeId, chargeId);
|
||||
final Map<GLAccount, BigDecimal> creditDetailsMap = new LinkedHashMap<GLAccount, BigDecimal>();
|
||||
for (final ChargePaymentDTO chargePaymentDTO : chargePaymentDTOs) {
|
||||
final Long chargeId = chargePaymentDTO.getChargeId();
|
||||
final GLAccount chargeSpecificAccount = getLinkedGLAccountForLoanCharges(loanProductId, accountMappingTypeId, chargeId);
|
||||
BigDecimal chargeSpecificAmount = chargePaymentDTO.getAmount();
|
||||
|
||||
// adjust net credit amount if the account is already present in the
|
||||
// map
|
||||
if (creditDetailsMap.containsKey(chargeSpecificAccount)) {
|
||||
BigDecimal existingAmount = creditDetailsMap.get(chargeSpecificAccount);
|
||||
final BigDecimal existingAmount = creditDetailsMap.get(chargeSpecificAccount);
|
||||
chargeSpecificAmount = chargeSpecificAmount.add(existingAmount);
|
||||
}
|
||||
creditDetailsMap.put(chargeSpecificAccount, chargeSpecificAmount);
|
||||
}
|
||||
|
||||
BigDecimal totalCreditedAmount = BigDecimal.ZERO;
|
||||
for (Map.Entry<GLAccount, BigDecimal> entry : creditDetailsMap.entrySet()) {
|
||||
GLAccount account = entry.getKey();
|
||||
BigDecimal amount = entry.getValue();
|
||||
for (final Map.Entry<GLAccount, BigDecimal> entry : creditDetailsMap.entrySet()) {
|
||||
final GLAccount account = entry.getKey();
|
||||
final BigDecimal amount = entry.getValue();
|
||||
totalCreditedAmount = totalCreditedAmount.add(amount);
|
||||
if (isReversal) {
|
||||
createDebitJournalEntryForLoan(office, currencyCode, account, loanId, transactionId, transactionDate, amount);
|
||||
@@ -381,7 +381,7 @@ public class AccountingProcessorHelper {
|
||||
private void createCreditJournalEntryOrReversalForLoan(final Office office, final String currencyCode, final int accountMappingTypeId,
|
||||
final Long loanProductId, final Long paymentTypeId, final Long loanId, final String transactionId, final Date transactionDate,
|
||||
final BigDecimal amount, final Boolean isReversal) {
|
||||
GLAccount account = getLinkedGLAccountForLoanProduct(loanProductId, accountMappingTypeId, paymentTypeId);
|
||||
final GLAccount account = getLinkedGLAccountForLoanProduct(loanProductId, accountMappingTypeId, paymentTypeId);
|
||||
if (isReversal) {
|
||||
createDebitJournalEntryForLoan(office, currencyCode, account, loanId, transactionId, transactionDate, amount);
|
||||
} else {
|
||||
@@ -430,7 +430,7 @@ public class AccountingProcessorHelper {
|
||||
* both cash and accrual accounts
|
||||
***/
|
||||
if (accountMappingTypeId == CASH_ACCOUNTS_FOR_LOAN.FUND_SOURCE.getValue()) {
|
||||
ProductToGLAccountMapping paymentChannelSpecificAccountMapping = this.accountMappingRepository
|
||||
final ProductToGLAccountMapping paymentChannelSpecificAccountMapping = this.accountMappingRepository
|
||||
.findByProductIdAndProductTypeAndFinancialAccountTypeAndPaymentTypeId(loanProductId,
|
||||
PortfolioProductType.LOAN.getValue(), accountMappingTypeId, paymentTypeId);
|
||||
if (paymentChannelSpecificAccountMapping != null) {
|
||||
@@ -454,7 +454,7 @@ public class AccountingProcessorHelper {
|
||||
// Vishwas TODO: remove this condition as it should always be true
|
||||
if (accountMappingTypeId == CASH_ACCOUNTS_FOR_LOAN.INCOME_FROM_FEES.getValue()
|
||||
|| accountMappingTypeId == CASH_ACCOUNTS_FOR_LOAN.INCOME_FROM_PENALTIES.getValue()) {
|
||||
ProductToGLAccountMapping chargeSpecificIncomeAccountMapping = this.accountMappingRepository
|
||||
final ProductToGLAccountMapping chargeSpecificIncomeAccountMapping = this.accountMappingRepository
|
||||
.findByProductIdAndProductTypeAndFinancialAccountTypeAndChargeId(loanProductId, PortfolioProductType.LOAN.getValue(),
|
||||
accountMappingTypeId, chargeId);
|
||||
if (chargeSpecificIncomeAccountMapping != null) {
|
||||
@@ -474,7 +474,7 @@ public class AccountingProcessorHelper {
|
||||
* both cash and accrual accounts
|
||||
***/
|
||||
if (accountMappingTypeId == CASH_ACCOUNTS_FOR_LOAN.FUND_SOURCE.getValue()) {
|
||||
ProductToGLAccountMapping paymentChannelSpecificAccountMapping = this.accountMappingRepository
|
||||
final ProductToGLAccountMapping paymentChannelSpecificAccountMapping = this.accountMappingRepository
|
||||
.findByProductIdAndProductTypeAndFinancialAccountTypeAndPaymentTypeId(savingsProductId,
|
||||
PortfolioProductType.SAVING.getValue(), accountMappingTypeId, paymentTypeId);
|
||||
if (paymentChannelSpecificAccountMapping != null) {
|
||||
|
||||
+19
-18
@@ -32,7 +32,7 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
|
||||
final Office office = this.helper.getOfficeById(loanDTO.getOfficeId());
|
||||
for (final LoanTransactionDTO loanTransactionDTO : loanDTO.getNewLoanTransactions()) {
|
||||
final Date transactionDate = loanTransactionDTO.getTransactionDate();
|
||||
helper.checkForBranchClosures(latestGLClosure, transactionDate);
|
||||
this.helper.checkForBranchClosures(latestGLClosure, transactionDate);
|
||||
|
||||
/** Handle Disbursements **/
|
||||
if (loanTransactionDTO.getTransactionType().isDisbursement()) {
|
||||
@@ -54,7 +54,8 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
|
||||
* Repayments and Repayments at disbursement
|
||||
***/
|
||||
else if (loanTransactionDTO.getTransactionType().isRepayment()
|
||||
|| loanTransactionDTO.getTransactionType().isRepaymentAtDisbursement() || loanTransactionDTO.getTransactionType().isChargePayment()) {
|
||||
|| loanTransactionDTO.getTransactionType().isRepaymentAtDisbursement()
|
||||
|| loanTransactionDTO.getTransactionType().isChargePayment()) {
|
||||
createJournalEntriesForRepaymentsAndWriteOffs(loanDTO, loanTransactionDTO, office, false, loanTransactionDTO
|
||||
.getTransactionType().isRepaymentAtDisbursement() || loanTransactionDTO.getTransactionType().isChargePayment());
|
||||
}
|
||||
@@ -91,7 +92,7 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
|
||||
|
||||
// create journal entries for the disbursement (or disbursement
|
||||
// reversal)
|
||||
helper.createAccrualBasedJournalEntriesAndReversalsForLoan(office, currencyCode, ACCRUAL_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO,
|
||||
this.helper.createAccrualBasedJournalEntriesAndReversalsForLoan(office, currencyCode, ACCRUAL_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO,
|
||||
ACCRUAL_ACCOUNTS_FOR_LOAN.FUND_SOURCE, loanProductId, paymentTypeId, loanId, transactionId, transactionDate,
|
||||
disbursalAmount, isReversed);
|
||||
|
||||
@@ -122,9 +123,9 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
|
||||
|
||||
// create journal entries for recognising interest (or reversal)
|
||||
if (amount != null && !(amount.compareTo(BigDecimal.ZERO) == 0)) {
|
||||
helper.createAccrualBasedJournalEntriesAndReversalsForLoan(office, currencyCode, ACCRUAL_ACCOUNTS_FOR_LOAN.INTEREST_RECEIVABLE,
|
||||
ACCRUAL_ACCOUNTS_FOR_LOAN.INTEREST_ON_LOANS, loanProductId, paymentTypeId, loanId, transactionId, transactionDate,
|
||||
amount, isReversed);
|
||||
this.helper.createAccrualBasedJournalEntriesAndReversalsForLoan(office, currencyCode,
|
||||
ACCRUAL_ACCOUNTS_FOR_LOAN.INTEREST_RECEIVABLE, ACCRUAL_ACCOUNTS_FOR_LOAN.INTEREST_ON_LOANS, loanProductId,
|
||||
paymentTypeId, loanId, transactionId, transactionDate, amount, isReversed);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,14 +192,14 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
|
||||
// handle principal payment or writeOff (and reversals)
|
||||
if (principalAmount != null && !(principalAmount.compareTo(BigDecimal.ZERO) == 0)) {
|
||||
totalDebitAmount = totalDebitAmount.add(principalAmount);
|
||||
helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, ACCRUAL_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO, loanProductId,
|
||||
paymentTypeId, loanId, transactionId, transactionDate, principalAmount, isReversal);
|
||||
this.helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, ACCRUAL_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO,
|
||||
loanProductId, paymentTypeId, loanId, transactionId, transactionDate, principalAmount, isReversal);
|
||||
}
|
||||
|
||||
// handle interest payment of writeOff (and reversals)
|
||||
if (interestAmount != null && !(interestAmount.compareTo(BigDecimal.ZERO) == 0)) {
|
||||
totalDebitAmount = totalDebitAmount.add(interestAmount);
|
||||
helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, ACCRUAL_ACCOUNTS_FOR_LOAN.INTEREST_RECEIVABLE,
|
||||
this.helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, ACCRUAL_ACCOUNTS_FOR_LOAN.INTEREST_RECEIVABLE,
|
||||
loanProductId, paymentTypeId, loanId, transactionId, transactionDate, interestAmount, isReversal);
|
||||
}
|
||||
|
||||
@@ -212,14 +213,14 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
|
||||
feeAccountToCredit = ACCRUAL_ACCOUNTS_FOR_LOAN.INCOME_FROM_FEES;
|
||||
}
|
||||
|
||||
helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, feeAccountToCredit, loanProductId, paymentTypeId,
|
||||
this.helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, feeAccountToCredit, loanProductId, paymentTypeId,
|
||||
loanId, transactionId, transactionDate, feesAmount, isReversal);
|
||||
}
|
||||
|
||||
// handle penalties payment of writeOff (and reversals)
|
||||
if (penaltiesAmount != null && !(penaltiesAmount.compareTo(BigDecimal.ZERO) == 0)) {
|
||||
totalDebitAmount = totalDebitAmount.add(penaltiesAmount);
|
||||
helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, ACCRUAL_ACCOUNTS_FOR_LOAN.PENALTIES_RECEIVABLE,
|
||||
this.helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, ACCRUAL_ACCOUNTS_FOR_LOAN.PENALTIES_RECEIVABLE,
|
||||
loanProductId, paymentTypeId, loanId, transactionId, transactionDate, penaltiesAmount, isReversal);
|
||||
}
|
||||
|
||||
@@ -228,11 +229,11 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
|
||||
* reversals)
|
||||
***/
|
||||
if (writeOff) {
|
||||
helper.createDebitJournalEntryOrReversalForLoan(office, currencyCode, ACCRUAL_ACCOUNTS_FOR_LOAN.LOSSES_WRITTEN_OFF,
|
||||
this.helper.createDebitJournalEntryOrReversalForLoan(office, currencyCode, ACCRUAL_ACCOUNTS_FOR_LOAN.LOSSES_WRITTEN_OFF,
|
||||
loanProductId, paymentTypeId, loanId, transactionId, transactionDate, totalDebitAmount, isReversal);
|
||||
} else {
|
||||
helper.createDebitJournalEntryOrReversalForLoan(office, currencyCode, ACCRUAL_ACCOUNTS_FOR_LOAN.FUND_SOURCE, loanProductId,
|
||||
paymentTypeId, loanId, transactionId, transactionDate, totalDebitAmount, isReversal);
|
||||
this.helper.createDebitJournalEntryOrReversalForLoan(office, currencyCode, ACCRUAL_ACCOUNTS_FOR_LOAN.FUND_SOURCE,
|
||||
loanProductId, paymentTypeId, loanId, transactionId, transactionDate, totalDebitAmount, isReversal);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -269,13 +270,13 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
|
||||
|
||||
// create journal entries for the fees application (or reversal)
|
||||
if (feesAmount != null && !(feesAmount.compareTo(BigDecimal.ZERO) == 0)) {
|
||||
helper.createAccrualBasedJournalEntriesAndReversalsForLoan(office, currencyCode, ACCRUAL_ACCOUNTS_FOR_LOAN.FEES_RECEIVABLE,
|
||||
ACCRUAL_ACCOUNTS_FOR_LOAN.INCOME_FROM_FEES, loanProductId, paymentTypeId, loanId, transactionId, transactionDate,
|
||||
feesAmount, isReversed);
|
||||
this.helper.createAccrualBasedJournalEntriesAndReversalsForLoan(office, currencyCode,
|
||||
ACCRUAL_ACCOUNTS_FOR_LOAN.FEES_RECEIVABLE, ACCRUAL_ACCOUNTS_FOR_LOAN.INCOME_FROM_FEES, loanProductId, paymentTypeId,
|
||||
loanId, transactionId, transactionDate, feesAmount, isReversed);
|
||||
}
|
||||
// create journal entries for the penalties application (or reversal)
|
||||
else if (penaltiesAmount != null && !(penaltiesAmount.compareTo(BigDecimal.ZERO) == 0)) {
|
||||
helper.createAccrualBasedJournalEntriesAndReversalsForLoan(office, currencyCode,
|
||||
this.helper.createAccrualBasedJournalEntriesAndReversalsForLoan(office, currencyCode,
|
||||
ACCRUAL_ACCOUNTS_FOR_LOAN.PENALTIES_RECEIVABLE, ACCRUAL_ACCOUNTS_FOR_LOAN.INCOME_FROM_PENALTIES, loanProductId,
|
||||
paymentTypeId, loanId, transactionId, transactionDate, penaltiesAmount, isReversed);
|
||||
}
|
||||
|
||||
+16
-16
@@ -27,7 +27,7 @@ public class CashBasedAccountingProcessorForLoan implements AccountingProcessorF
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createJournalEntriesForLoan(LoanDTO loanDTO) {
|
||||
public void createJournalEntriesForLoan(final LoanDTO loanDTO) {
|
||||
final GLClosure latestGLClosure = this.helper.getLatestClosureByBranch(loanDTO.getOfficeId());
|
||||
// final Office office =
|
||||
// this.helper.getOfficeById(loanDTO.getOfficeId());
|
||||
@@ -40,7 +40,7 @@ public class CashBasedAccountingProcessorForLoan implements AccountingProcessorF
|
||||
final Long paymentTypeId = loanTransactionDTO.getPaymentTypeId();
|
||||
final Long loanId = loanDTO.getLoanId();
|
||||
|
||||
helper.checkForBranchClosures(latestGLClosure, transactionDate);
|
||||
this.helper.checkForBranchClosures(latestGLClosure, transactionDate);
|
||||
|
||||
/** Handle Disbursements and reversals of disbursements **/
|
||||
if (loanTransactionDTO.getTransactionType().isDisbursement()) {
|
||||
@@ -51,7 +51,7 @@ public class CashBasedAccountingProcessorForLoan implements AccountingProcessorF
|
||||
* Repayments and Repayments at disbursement
|
||||
***/
|
||||
else if (loanTransactionDTO.getTransactionType().isRepayment()
|
||||
|| loanTransactionDTO.getTransactionType().isRepaymentAtDisbursement()
|
||||
|| loanTransactionDTO.getTransactionType().isRepaymentAtDisbursement()
|
||||
|| loanTransactionDTO.getTransactionType().isChargePayment()) {
|
||||
createJournalEntriesForRepayments(loanDTO, loanTransactionDTO, office);
|
||||
}
|
||||
@@ -62,9 +62,9 @@ public class CashBasedAccountingProcessorForLoan implements AccountingProcessorF
|
||||
**/
|
||||
else if (loanTransactionDTO.getTransactionType().isWriteOff() && !loanTransactionDTO.isReversed()) {
|
||||
final BigDecimal principalAmount = loanTransactionDTO.getPrincipal();
|
||||
helper.createCashBasedJournalEntriesAndReversalsForLoan(office, currencyCode, CASH_ACCOUNTS_FOR_LOAN.LOSSES_WRITTEN_OFF,
|
||||
CASH_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO, loanProductId, paymentTypeId, loanId, transactionId, transactionDate,
|
||||
principalAmount, false);
|
||||
this.helper.createCashBasedJournalEntriesAndReversalsForLoan(office, currencyCode,
|
||||
CASH_ACCOUNTS_FOR_LOAN.LOSSES_WRITTEN_OFF, CASH_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO, loanProductId, paymentTypeId,
|
||||
loanId, transactionId, transactionDate, principalAmount, false);
|
||||
} else if (loanTransactionDTO.getTransactionType().isInitiateTransfer()
|
||||
|| loanTransactionDTO.getTransactionType().isApproveTransfer()
|
||||
|| loanTransactionDTO.getTransactionType().isWithdrawTransfer()) {
|
||||
@@ -98,7 +98,7 @@ public class CashBasedAccountingProcessorForLoan implements AccountingProcessorF
|
||||
final boolean isReversal = loanTransactionDTO.isReversed();
|
||||
final Long paymentTypeId = loanTransactionDTO.getPaymentTypeId();
|
||||
|
||||
helper.createCashBasedJournalEntriesAndReversalsForLoan(office, currencyCode, CASH_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO,
|
||||
this.helper.createCashBasedJournalEntriesAndReversalsForLoan(office, currencyCode, CASH_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO,
|
||||
CASH_ACCOUNTS_FOR_LOAN.FUND_SOURCE, loanProductId, paymentTypeId, loanId, transactionId, transactionDate, disbursalAmount,
|
||||
isReversal);
|
||||
}
|
||||
@@ -132,32 +132,32 @@ public class CashBasedAccountingProcessorForLoan implements AccountingProcessorF
|
||||
|
||||
if (principalAmount != null && !(principalAmount.compareTo(BigDecimal.ZERO) == 0)) {
|
||||
totalDebitAmount = totalDebitAmount.add(principalAmount);
|
||||
helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, CASH_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO, loanProductId,
|
||||
paymentTypeId, loanId, transactionId, transactionDate, principalAmount, isReversal);
|
||||
this.helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, CASH_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO,
|
||||
loanProductId, paymentTypeId, loanId, transactionId, transactionDate, principalAmount, isReversal);
|
||||
}
|
||||
|
||||
if (interestAmount != null && !(interestAmount.compareTo(BigDecimal.ZERO) == 0)) {
|
||||
totalDebitAmount = totalDebitAmount.add(interestAmount);
|
||||
helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, CASH_ACCOUNTS_FOR_LOAN.INTEREST_ON_LOANS, loanProductId,
|
||||
paymentTypeId, loanId, transactionId, transactionDate, interestAmount, isReversal);
|
||||
this.helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, CASH_ACCOUNTS_FOR_LOAN.INTEREST_ON_LOANS,
|
||||
loanProductId, paymentTypeId, loanId, transactionId, transactionDate, interestAmount, isReversal);
|
||||
}
|
||||
|
||||
if (feesAmount != null && !(feesAmount.compareTo(BigDecimal.ZERO) == 0)) {
|
||||
totalDebitAmount = totalDebitAmount.add(feesAmount);
|
||||
helper.createCreditJournalEntryOrReversalForLoanCharges(office, currencyCode,
|
||||
this.helper.createCreditJournalEntryOrReversalForLoanCharges(office, currencyCode,
|
||||
CASH_ACCOUNTS_FOR_LOAN.INCOME_FROM_FEES.getValue(), loanProductId, loanId, transactionId, transactionDate, feesAmount,
|
||||
isReversal, loanTransactionDTO.getFeePayments());
|
||||
}
|
||||
|
||||
if (penaltiesAmount != null && !(penaltiesAmount.compareTo(BigDecimal.ZERO) == 0)) {
|
||||
totalDebitAmount = totalDebitAmount.add(penaltiesAmount);
|
||||
helper.createCreditJournalEntryOrReversalForLoanCharges(office, currencyCode,
|
||||
this.helper.createCreditJournalEntryOrReversalForLoanCharges(office, currencyCode,
|
||||
CASH_ACCOUNTS_FOR_LOAN.INCOME_FROM_PENALTIES.getValue(), loanProductId, loanId, transactionId, transactionDate,
|
||||
penaltiesAmount, isReversal, loanTransactionDTO.getPenaltyPayments());
|
||||
}
|
||||
|
||||
/*** create a single debit entry (or reversal) for the entire amount **/
|
||||
helper.createDebitJournalEntryOrReversalForLoan(office, currencyCode, CASH_ACCOUNTS_FOR_LOAN.FUND_SOURCE, loanProductId,
|
||||
this.helper.createDebitJournalEntryOrReversalForLoan(office, currencyCode, CASH_ACCOUNTS_FOR_LOAN.FUND_SOURCE, loanProductId,
|
||||
paymentTypeId, loanId, transactionId, transactionDate, totalDebitAmount, isReversal);
|
||||
}
|
||||
|
||||
@@ -188,12 +188,12 @@ public class CashBasedAccountingProcessorForLoan implements AccountingProcessorF
|
||||
// final Long paymentTypeId = loanTransactionDTO.getPaymentTypeId();
|
||||
|
||||
if (loanTransactionDTO.getTransactionType().isInitiateTransfer()) {
|
||||
helper.createCashBasedJournalEntriesAndReversalsForLoan(office, currencyCode, CASH_ACCOUNTS_FOR_LOAN.TRANSFERS_SUSPENSE,
|
||||
this.helper.createCashBasedJournalEntriesAndReversalsForLoan(office, currencyCode, CASH_ACCOUNTS_FOR_LOAN.TRANSFERS_SUSPENSE,
|
||||
CASH_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO, loanProductId, null, loanId, transactionId, transactionDate, principalAmount,
|
||||
isReversal);
|
||||
} else if (loanTransactionDTO.getTransactionType().isApproveTransfer()
|
||||
|| loanTransactionDTO.getTransactionType().isWithdrawTransfer()) {
|
||||
helper.createCashBasedJournalEntriesAndReversalsForLoan(office, currencyCode, CASH_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO,
|
||||
this.helper.createCashBasedJournalEntriesAndReversalsForLoan(office, currencyCode, CASH_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO,
|
||||
CASH_ACCOUNTS_FOR_LOAN.TRANSFERS_SUSPENSE, loanProductId, null, loanId, transactionId, transactionDate,
|
||||
principalAmount, isReversal);
|
||||
}
|
||||
|
||||
+14
-14
@@ -27,7 +27,7 @@ public class CashBasedAccountingProcessorForSavings implements AccountingProcess
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createJournalEntriesForSavings(SavingsDTO savingsDTO) {
|
||||
public void createJournalEntriesForSavings(final SavingsDTO savingsDTO) {
|
||||
final GLClosure latestGLClosure = this.helper.getLatestClosureByBranch(savingsDTO.getOfficeId());
|
||||
final Long savingsProductId = savingsDTO.getSavingsProductId();
|
||||
final Long savingsId = savingsDTO.getSavingsId();
|
||||
@@ -40,20 +40,20 @@ public class CashBasedAccountingProcessorForSavings implements AccountingProcess
|
||||
final boolean isReversal = savingsTransactionDTO.isReversed();
|
||||
final BigDecimal amount = savingsTransactionDTO.getAmount();
|
||||
|
||||
helper.checkForBranchClosures(latestGLClosure, transactionDate);
|
||||
this.helper.checkForBranchClosures(latestGLClosure, transactionDate);
|
||||
|
||||
/** Handle Deposits and reversals of deposits **/
|
||||
if (savingsTransactionDTO.getTransactionType().isDeposit()) {
|
||||
helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_REFERENCE, CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL, savingsProductId,
|
||||
paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
||||
}
|
||||
|
||||
/** Handle withdrawals and reversals of withdrawals **/
|
||||
else if (savingsTransactionDTO.getTransactionType().isWithdrawal()) {
|
||||
helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode, CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL,
|
||||
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_REFERENCE, savingsProductId, paymentTypeId, savingsId, transactionId,
|
||||
transactionDate, amount, isReversal);
|
||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL, CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_REFERENCE, savingsProductId,
|
||||
paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,29 +61,29 @@ public class CashBasedAccountingProcessorForSavings implements AccountingProcess
|
||||
* Applications
|
||||
**/
|
||||
else if (savingsTransactionDTO.getTransactionType().isInterestPosting()) {
|
||||
helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||
CASH_ACCOUNTS_FOR_SAVINGS.INTEREST_ON_SAVINGS, CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL, savingsProductId,
|
||||
paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
||||
}
|
||||
|
||||
/** Handle Fees Deductions and reversals of Fees Deductions **/
|
||||
else if (savingsTransactionDTO.getTransactionType().isFeeDeduction()) {
|
||||
helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode, CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL,
|
||||
CASH_ACCOUNTS_FOR_SAVINGS.INCOME_FROM_FEES, savingsProductId, paymentTypeId, savingsId, transactionId,
|
||||
transactionDate, amount, isReversal);
|
||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL, CASH_ACCOUNTS_FOR_SAVINGS.INCOME_FROM_FEES, savingsProductId,
|
||||
paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
||||
}
|
||||
|
||||
/** Handle Transfers proposal **/
|
||||
else if (savingsTransactionDTO.getTransactionType().isInitiateTransfer()) {
|
||||
helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode, CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL,
|
||||
CASH_ACCOUNTS_FOR_SAVINGS.TRANSFERS_SUSPENSE, savingsProductId, paymentTypeId, savingsId, transactionId,
|
||||
transactionDate, amount, isReversal);
|
||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL, CASH_ACCOUNTS_FOR_SAVINGS.TRANSFERS_SUSPENSE, savingsProductId,
|
||||
paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
||||
}
|
||||
|
||||
/** Handle Transfer Withdrawal or Acceptance **/
|
||||
else if (savingsTransactionDTO.getTransactionType().isWithdrawTransfer()
|
||||
|| savingsTransactionDTO.getTransactionType().isApproveTransfer()) {
|
||||
helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||
CASH_ACCOUNTS_FOR_SAVINGS.TRANSFERS_SUSPENSE, CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL, savingsProductId,
|
||||
paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
||||
}
|
||||
|
||||
+2
-2
@@ -100,9 +100,9 @@ public class JournalEntryReadPlatformServiceImpl implements JournalEntryReadPlat
|
||||
public Page<JournalEntryData> retrieveAll(final SearchParameters searchParameters, final Long glAccountId,
|
||||
final Boolean onlyManualEntries, final Date fromDate, final Date toDate, final String transactionId) {
|
||||
|
||||
StringBuilder sqlBuilder = new StringBuilder(200);
|
||||
final StringBuilder sqlBuilder = new StringBuilder(200);
|
||||
sqlBuilder.append("select SQL_CALC_FOUND_ROWS ");
|
||||
sqlBuilder.append(journalEntryMapper.schema());
|
||||
sqlBuilder.append(this.journalEntryMapper.schema());
|
||||
|
||||
final Object[] objectArray = new Object[5];
|
||||
int arrayPos = 0;
|
||||
|
||||
+3
-2
@@ -172,14 +172,15 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
|
||||
}
|
||||
}
|
||||
|
||||
private void validateDebitOrCreditArrayForExistingGLAccount(GLAccount glaccount, SingleDebitOrCreditEntryCommand[] creditOrDebits) {
|
||||
private void validateDebitOrCreditArrayForExistingGLAccount(final GLAccount glaccount,
|
||||
final SingleDebitOrCreditEntryCommand[] creditOrDebits) {
|
||||
/**
|
||||
* If a glaccount is assigned for a rule the credits or debits array
|
||||
* should have only one entry and it must be same as existing account
|
||||
*/
|
||||
if (creditOrDebits.length != 1) { throw new JournalEntryInvalidException(
|
||||
GL_JOURNAL_ENTRY_INVALID_REASON.INVALID_DEBIT_OR_CREDIT_ACCOUNTS, null, null, null); }
|
||||
for (SingleDebitOrCreditEntryCommand creditOrDebit : creditOrDebits) {
|
||||
for (final SingleDebitOrCreditEntryCommand creditOrDebit : creditOrDebits) {
|
||||
if (!glaccount.getId().equals(creditOrDebit.getGlAccountId())) { throw new JournalEntryInvalidException(
|
||||
GL_JOURNAL_ENTRY_INVALID_REASON.INVALID_DEBIT_OR_CREDIT_ACCOUNTS, null, null, null); }
|
||||
}
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ public class ChargeToGLAccountMapper {
|
||||
@SuppressWarnings("unused")
|
||||
private final long incomeAccountId;
|
||||
|
||||
public ChargeToGLAccountMapper(long chargeId, long incomeAccountId) {
|
||||
public ChargeToGLAccountMapper(final long chargeId, final long incomeAccountId) {
|
||||
this.chargeId = chargeId;
|
||||
this.incomeAccountId = incomeAccountId;
|
||||
}
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ public class PaymentTypeToGLAccountMapper {
|
||||
@SuppressWarnings("unused")
|
||||
private final long fundSourceAccountId;
|
||||
|
||||
public PaymentTypeToGLAccountMapper(long paymentTypeId, long fundSourceAccountId) {
|
||||
public PaymentTypeToGLAccountMapper(final long paymentTypeId, final long fundSourceAccountId) {
|
||||
this.paymentTypeId = paymentTypeId;
|
||||
this.fundSourceAccountId = fundSourceAccountId;
|
||||
}
|
||||
|
||||
+2
-2
@@ -113,7 +113,7 @@ public class ProductToGLAccountMapping extends AbstractPersistable<Long> {
|
||||
return this.paymentType;
|
||||
}
|
||||
|
||||
public void setPaymentType(CodeValue paymentType) {
|
||||
public void setPaymentType(final CodeValue paymentType) {
|
||||
this.paymentType = paymentType;
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ public class ProductToGLAccountMapping extends AbstractPersistable<Long> {
|
||||
return this.charge;
|
||||
}
|
||||
|
||||
public void setCharge(Charge charge) {
|
||||
public void setCharge(final Charge charge) {
|
||||
this.charge = charge;
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -151,28 +151,28 @@ public final class ProductToGLAccountMappingFromApiJsonDeserializer {
|
||||
|
||||
if (isCashBasedAccounting(accountingRuleType)) {
|
||||
|
||||
final Long savingsControlAccountId = fromApiJsonHelper.extractLongNamed(
|
||||
final Long savingsControlAccountId = this.fromApiJsonHelper.extractLongNamed(
|
||||
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.SAVINGS_CONTROL.getValue(), element);
|
||||
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.SAVINGS_CONTROL.getValue())
|
||||
.value(savingsControlAccountId).notNull().integerGreaterThanZero();
|
||||
|
||||
final Long savingsReferenceAccountId = fromApiJsonHelper.extractLongNamed(
|
||||
final Long savingsReferenceAccountId = this.fromApiJsonHelper.extractLongNamed(
|
||||
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.SAVINGS_REFERENCE.getValue(), element);
|
||||
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.SAVINGS_REFERENCE.getValue())
|
||||
.value(savingsReferenceAccountId).notNull().integerGreaterThanZero();
|
||||
|
||||
final Long transfersInSuspenseAccountId = fromApiJsonHelper.extractLongNamed(
|
||||
final Long transfersInSuspenseAccountId = this.fromApiJsonHelper.extractLongNamed(
|
||||
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.TRANSFERS_SUSPENSE.getValue(), element);
|
||||
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.TRANSFERS_SUSPENSE.getValue())
|
||||
.value(transfersInSuspenseAccountId).notNull().integerGreaterThanZero();
|
||||
|
||||
final Long interestOnSavingsAccountId = fromApiJsonHelper.extractLongNamed(
|
||||
final Long interestOnSavingsAccountId = this.fromApiJsonHelper.extractLongNamed(
|
||||
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INTEREST_ON_SAVINGS.getValue(), element);
|
||||
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INTEREST_ON_SAVINGS.getValue())
|
||||
.value(interestOnSavingsAccountId).notNull().integerGreaterThanZero();
|
||||
|
||||
final Long incomeFromFeeId = fromApiJsonHelper.extractLongNamed(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue(),
|
||||
element);
|
||||
final Long incomeFromFeeId = this.fromApiJsonHelper.extractLongNamed(
|
||||
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue(), element);
|
||||
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue()).value(incomeFromFeeId)
|
||||
.notNull().integerGreaterThanZero();
|
||||
|
||||
|
||||
+35
-35
@@ -97,8 +97,8 @@ public class ProductToGLAccountMappingHelper {
|
||||
* @param changes
|
||||
*/
|
||||
public void savePaymentChannelToFundSourceMappings(final JsonCommand command, final JsonElement element, final Long productId,
|
||||
Map<String, Object> changes, final PortfolioProductType portfolioProductType) {
|
||||
JsonArray paymentChannelMappingArray = fromApiJsonHelper.extractJsonArrayNamed(
|
||||
final Map<String, Object> changes, final PortfolioProductType portfolioProductType) {
|
||||
final JsonArray paymentChannelMappingArray = this.fromApiJsonHelper.extractJsonArrayNamed(
|
||||
LOAN_PRODUCT_ACCOUNTING_PARAMS.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue(), element);
|
||||
if (paymentChannelMappingArray != null) {
|
||||
if (changes != null) {
|
||||
@@ -124,7 +124,7 @@ public class ProductToGLAccountMappingHelper {
|
||||
* @param changes
|
||||
*/
|
||||
public void saveChargesToIncomeAccountMappings(final JsonCommand command, final JsonElement element, final Long productId,
|
||||
Map<String, Object> changes, final PortfolioProductType portfolioProductType, final boolean isPenalty) {
|
||||
final Map<String, Object> changes, final PortfolioProductType portfolioProductType, final boolean isPenalty) {
|
||||
String arrayName;
|
||||
if (isPenalty) {
|
||||
arrayName = LOAN_PRODUCT_ACCOUNTING_PARAMS.PENALTY_INCOME_ACCOUNT_MAPPING.getValue();
|
||||
@@ -132,7 +132,7 @@ public class ProductToGLAccountMappingHelper {
|
||||
arrayName = LOAN_PRODUCT_ACCOUNTING_PARAMS.FEE_INCOME_ACCOUNT_MAPPING.getValue();
|
||||
}
|
||||
|
||||
JsonArray chargeToIncomeAccountMappingArray = fromApiJsonHelper.extractJsonArrayNamed(arrayName, element);
|
||||
final JsonArray chargeToIncomeAccountMappingArray = this.fromApiJsonHelper.extractJsonArrayNamed(arrayName, element);
|
||||
if (chargeToIncomeAccountMappingArray != null) {
|
||||
if (changes != null) {
|
||||
changes.put(LOAN_PRODUCT_ACCOUNTING_PARAMS.FEE_INCOME_ACCOUNT_MAPPING.getValue(),
|
||||
@@ -154,33 +154,33 @@ public class ProductToGLAccountMappingHelper {
|
||||
* @param changes
|
||||
*/
|
||||
public void updateChargeToIncomeAccountMappings(final JsonCommand command, final JsonElement element, final Long productId,
|
||||
Map<String, Object> changes, final PortfolioProductType portfolioProductType, boolean isPenalty) {
|
||||
final Map<String, Object> changes, final PortfolioProductType portfolioProductType, final boolean isPenalty) {
|
||||
// find all existing payment Channel to Fund source Mappings
|
||||
List<ProductToGLAccountMapping> existingChargeToIncomeAccountMappings;
|
||||
String arrayFragmentName;
|
||||
|
||||
if (isPenalty) {
|
||||
existingChargeToIncomeAccountMappings = accountMappingRepository.findAllPenaltyToIncomeAccountMappings(productId,
|
||||
existingChargeToIncomeAccountMappings = this.accountMappingRepository.findAllPenaltyToIncomeAccountMappings(productId,
|
||||
portfolioProductType.getValue());
|
||||
arrayFragmentName = LOAN_PRODUCT_ACCOUNTING_PARAMS.PENALTY_INCOME_ACCOUNT_MAPPING.getValue();
|
||||
} else {
|
||||
existingChargeToIncomeAccountMappings = accountMappingRepository.findAllFeeToIncomeAccountMappings(productId,
|
||||
existingChargeToIncomeAccountMappings = this.accountMappingRepository.findAllFeeToIncomeAccountMappings(productId,
|
||||
portfolioProductType.getValue());
|
||||
arrayFragmentName = LOAN_PRODUCT_ACCOUNTING_PARAMS.FEE_INCOME_ACCOUNT_MAPPING.getValue();
|
||||
}
|
||||
|
||||
JsonArray chargeToIncomeAccountMappingArray = fromApiJsonHelper.extractJsonArrayNamed(arrayFragmentName, element);
|
||||
final JsonArray chargeToIncomeAccountMappingArray = this.fromApiJsonHelper.extractJsonArrayNamed(arrayFragmentName, element);
|
||||
/**
|
||||
* Variable stores a map representation of charges (key) and their
|
||||
* associated income Id's (value) extracted from the passed in
|
||||
* Jsoncommand
|
||||
**/
|
||||
Map<Long, Long> inputChargeToIncomeAccountMap = new HashMap<Long, Long>();
|
||||
final Map<Long, Long> inputChargeToIncomeAccountMap = new HashMap<Long, Long>();
|
||||
/***
|
||||
* Variable stores all charges which have already been mapped to Income
|
||||
* Accounts in the system
|
||||
**/
|
||||
Set<Long> existingCharges = new HashSet<Long>();
|
||||
final Set<Long> existingCharges = new HashSet<Long>();
|
||||
if (chargeToIncomeAccountMappingArray != null) {
|
||||
if (changes != null) {
|
||||
changes.put(arrayFragmentName, command.jsonFragment(arrayFragmentName));
|
||||
@@ -195,7 +195,7 @@ public class ProductToGLAccountMappingHelper {
|
||||
|
||||
// If input map is empty, delete all existing mappings
|
||||
if (inputChargeToIncomeAccountMap.size() == 0) {
|
||||
accountMappingRepository.deleteInBatch(existingChargeToIncomeAccountMappings);
|
||||
this.accountMappingRepository.deleteInBatch(existingChargeToIncomeAccountMappings);
|
||||
}/**
|
||||
* Else, <br/>
|
||||
* update existing mappings OR <br/>
|
||||
@@ -206,30 +206,30 @@ public class ProductToGLAccountMappingHelper {
|
||||
*
|
||||
**/
|
||||
else {
|
||||
for (ProductToGLAccountMapping chargeToIncomeAccountMapping : existingChargeToIncomeAccountMappings) {
|
||||
Long currentCharge = chargeToIncomeAccountMapping.getCharge().getId();
|
||||
for (final ProductToGLAccountMapping chargeToIncomeAccountMapping : existingChargeToIncomeAccountMappings) {
|
||||
final Long currentCharge = chargeToIncomeAccountMapping.getCharge().getId();
|
||||
existingCharges.add(currentCharge);
|
||||
// update existing mappings (if required)
|
||||
if (inputChargeToIncomeAccountMap.containsKey(currentCharge)) {
|
||||
Long newGLAccountId = inputChargeToIncomeAccountMap.get(currentCharge);
|
||||
final Long newGLAccountId = inputChargeToIncomeAccountMap.get(currentCharge);
|
||||
if (newGLAccountId != chargeToIncomeAccountMapping.getGlAccount().getId()) {
|
||||
final GLAccount glAccount = getAccountByIdAndType(LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_ACCOUNT_ID.getValue(),
|
||||
GLAccountType.INCOME, newGLAccountId);
|
||||
chargeToIncomeAccountMapping.setGlAccount(glAccount);
|
||||
accountMappingRepository.save(chargeToIncomeAccountMapping);
|
||||
this.accountMappingRepository.save(chargeToIncomeAccountMapping);
|
||||
}
|
||||
}// deleted payment type
|
||||
else {
|
||||
accountMappingRepository.delete(chargeToIncomeAccountMapping);
|
||||
this.accountMappingRepository.delete(chargeToIncomeAccountMapping);
|
||||
}
|
||||
}
|
||||
// create new mappings
|
||||
Set<Long> incomingCharges = inputChargeToIncomeAccountMap.keySet();
|
||||
final Set<Long> incomingCharges = inputChargeToIncomeAccountMap.keySet();
|
||||
incomingCharges.removeAll(existingCharges);
|
||||
// incomingPaymentTypes now only contains the newly added
|
||||
// payment Type mappings
|
||||
for (Long newCharge : incomingCharges) {
|
||||
Long newGLAccountId = inputChargeToIncomeAccountMap.get(newCharge);
|
||||
for (final Long newCharge : incomingCharges) {
|
||||
final Long newGLAccountId = inputChargeToIncomeAccountMap.get(newCharge);
|
||||
saveChargeToFundSourceMapping(productId, newCharge, newGLAccountId, portfolioProductType, isPenalty);
|
||||
}
|
||||
}
|
||||
@@ -243,22 +243,22 @@ public class ProductToGLAccountMappingHelper {
|
||||
* @param changes
|
||||
*/
|
||||
public void updatePaymentChannelToFundSourceMappings(final JsonCommand command, final JsonElement element, final Long productId,
|
||||
Map<String, Object> changes, final PortfolioProductType portfolioProductType) {
|
||||
final Map<String, Object> changes, final PortfolioProductType portfolioProductType) {
|
||||
// find all existing payment Channel to Fund source Mappings
|
||||
List<ProductToGLAccountMapping> existingPaymentChannelToFundSourceMappings = accountMappingRepository
|
||||
final List<ProductToGLAccountMapping> existingPaymentChannelToFundSourceMappings = this.accountMappingRepository
|
||||
.findAllPaymentTypeToFundSourceMappings(productId, portfolioProductType.getValue());
|
||||
JsonArray paymentChannelMappingArray = fromApiJsonHelper.extractJsonArrayNamed(
|
||||
final JsonArray paymentChannelMappingArray = this.fromApiJsonHelper.extractJsonArrayNamed(
|
||||
LOAN_PRODUCT_ACCOUNTING_PARAMS.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue(), element);
|
||||
/**
|
||||
* Variable stores a map representation of Payment channels (key) and
|
||||
* their fund sources (value) extracted from the passed in Jsoncommand
|
||||
**/
|
||||
Map<Long, Long> inputPaymentChannelFundSourceMap = new HashMap<Long, Long>();
|
||||
final Map<Long, Long> inputPaymentChannelFundSourceMap = new HashMap<Long, Long>();
|
||||
/***
|
||||
* Variable stores all payment types which have already been mapped to
|
||||
* Fund Sources in the system
|
||||
**/
|
||||
Set<Long> existingPaymentTypes = new HashSet<Long>();
|
||||
final Set<Long> existingPaymentTypes = new HashSet<Long>();
|
||||
if (paymentChannelMappingArray != null) {
|
||||
if (changes != null) {
|
||||
changes.put(LOAN_PRODUCT_ACCOUNTING_PARAMS.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue(),
|
||||
@@ -274,7 +274,7 @@ public class ProductToGLAccountMappingHelper {
|
||||
|
||||
// If input map is empty, delete all existing mappings
|
||||
if (inputPaymentChannelFundSourceMap.size() == 0) {
|
||||
accountMappingRepository.deleteInBatch(existingPaymentChannelToFundSourceMappings);
|
||||
this.accountMappingRepository.deleteInBatch(existingPaymentChannelToFundSourceMappings);
|
||||
}/**
|
||||
* Else, <br/>
|
||||
* update existing mappings OR <br/>
|
||||
@@ -285,30 +285,30 @@ public class ProductToGLAccountMappingHelper {
|
||||
*
|
||||
**/
|
||||
else {
|
||||
for (ProductToGLAccountMapping existingPaymentChannelToFundSourceMapping : existingPaymentChannelToFundSourceMappings) {
|
||||
Long currentPaymentChannelId = existingPaymentChannelToFundSourceMapping.getPaymentType().getId();
|
||||
for (final ProductToGLAccountMapping existingPaymentChannelToFundSourceMapping : existingPaymentChannelToFundSourceMappings) {
|
||||
final Long currentPaymentChannelId = existingPaymentChannelToFundSourceMapping.getPaymentType().getId();
|
||||
existingPaymentTypes.add(currentPaymentChannelId);
|
||||
// update existing mappings (if required)
|
||||
if (inputPaymentChannelFundSourceMap.containsKey(currentPaymentChannelId)) {
|
||||
Long newGLAccountId = inputPaymentChannelFundSourceMap.get(currentPaymentChannelId);
|
||||
final Long newGLAccountId = inputPaymentChannelFundSourceMap.get(currentPaymentChannelId);
|
||||
if (newGLAccountId != existingPaymentChannelToFundSourceMapping.getGlAccount().getId()) {
|
||||
final GLAccount glAccount = getAccountByIdAndType(LOAN_PRODUCT_ACCOUNTING_PARAMS.FUND_SOURCE.getValue(),
|
||||
GLAccountType.ASSET, newGLAccountId);
|
||||
existingPaymentChannelToFundSourceMapping.setGlAccount(glAccount);
|
||||
accountMappingRepository.save(existingPaymentChannelToFundSourceMapping);
|
||||
this.accountMappingRepository.save(existingPaymentChannelToFundSourceMapping);
|
||||
}
|
||||
}// deleted payment type
|
||||
else {
|
||||
accountMappingRepository.delete(existingPaymentChannelToFundSourceMapping);
|
||||
this.accountMappingRepository.delete(existingPaymentChannelToFundSourceMapping);
|
||||
}
|
||||
}
|
||||
// create new mappings
|
||||
Set<Long> incomingPaymentTypes = inputPaymentChannelFundSourceMap.keySet();
|
||||
final Set<Long> incomingPaymentTypes = inputPaymentChannelFundSourceMap.keySet();
|
||||
incomingPaymentTypes.removeAll(existingPaymentTypes);
|
||||
// incomingPaymentTypes now only contains the newly added
|
||||
// payment Type mappings
|
||||
for (Long newPaymentType : incomingPaymentTypes) {
|
||||
Long newGLAccountId = inputPaymentChannelFundSourceMap.get(newPaymentType);
|
||||
for (final Long newPaymentType : incomingPaymentTypes) {
|
||||
final Long newGLAccountId = inputPaymentChannelFundSourceMap.get(newPaymentType);
|
||||
savePaymentChannelToFundSourceMapping(productId, newPaymentType, newGLAccountId, portfolioProductType);
|
||||
}
|
||||
}
|
||||
@@ -321,7 +321,7 @@ public class ProductToGLAccountMappingHelper {
|
||||
*/
|
||||
private void savePaymentChannelToFundSourceMapping(final Long productId, final Long paymentTypeId,
|
||||
final Long paymentTypeSpecificFundAccountId, final PortfolioProductType portfolioProductType) {
|
||||
CodeValue paymentType = codeValueRepositoryWrapper.findOneByCodeNameAndIdWithNotFoundDetection(
|
||||
final CodeValue paymentType = this.codeValueRepositoryWrapper.findOneByCodeNameAndIdWithNotFoundDetection(
|
||||
PaymentDetailConstants.paymentTypeCodeName, paymentTypeId);
|
||||
final GLAccount glAccount = getAccountByIdAndType(LOAN_PRODUCT_ACCOUNTING_PARAMS.FUND_SOURCE.getValue(), GLAccountType.ASSET,
|
||||
paymentTypeSpecificFundAccountId);
|
||||
@@ -336,7 +336,7 @@ public class ProductToGLAccountMappingHelper {
|
||||
*/
|
||||
private void saveChargeToFundSourceMapping(final Long productId, final Long chargeId, final Long incomeAccountId,
|
||||
final PortfolioProductType portfolioProductType, final boolean isPenalty) {
|
||||
Charge charge = chargeRepositoryWrapper.findOneWithNotFoundDetection(chargeId);
|
||||
final Charge charge = this.chargeRepositoryWrapper.findOneWithNotFoundDetection(chargeId);
|
||||
|
||||
// TODO Vishwas: Need to validate if given charge is fee or Penalty
|
||||
// based on input condition
|
||||
|
||||
+11
-11
@@ -145,7 +145,7 @@ public class ProductToGLAccountMappingReadPlatformServiceImpl implements Product
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> fetchAccountMappingDetailsForSavingsProduct(Long savingsProductId, Integer accountingType) {
|
||||
public Map<String, Object> fetchAccountMappingDetailsForSavingsProduct(final Long savingsProductId, final Integer accountingType) {
|
||||
final Map<String, Object> accountMappingDetails = new LinkedHashMap<String, Object>(8);
|
||||
|
||||
final ProductToGLAccountMappingMapper rm = new ProductToGLAccountMappingMapper();
|
||||
@@ -180,12 +180,12 @@ public class ProductToGLAccountMappingReadPlatformServiceImpl implements Product
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PaymentTypeToGLAccountMapper> fetchPaymentTypeToFundSourceMappingsForLoanProduct(Long loanProductId) {
|
||||
public List<PaymentTypeToGLAccountMapper> fetchPaymentTypeToFundSourceMappingsForLoanProduct(final Long loanProductId) {
|
||||
return fetchPaymentTypeToFundSourceMappings(PortfolioProductType.LOAN, loanProductId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PaymentTypeToGLAccountMapper> fetchPaymentTypeToFundSourceMappingsForSavingsProduct(Long savingsProductId) {
|
||||
public List<PaymentTypeToGLAccountMapper> fetchPaymentTypeToFundSourceMappingsForSavingsProduct(final Long savingsProductId) {
|
||||
return fetchPaymentTypeToFundSourceMappings(PortfolioProductType.SAVING, savingsProductId);
|
||||
}
|
||||
|
||||
@@ -194,8 +194,8 @@ public class ProductToGLAccountMappingReadPlatformServiceImpl implements Product
|
||||
* @param paymentTypeToGLAccountMappers
|
||||
* @return
|
||||
*/
|
||||
private List<PaymentTypeToGLAccountMapper> fetchPaymentTypeToFundSourceMappings(PortfolioProductType portfolioProductType,
|
||||
Long loanProductId) {
|
||||
private List<PaymentTypeToGLAccountMapper> fetchPaymentTypeToFundSourceMappings(final PortfolioProductType portfolioProductType,
|
||||
final Long loanProductId) {
|
||||
final ProductToGLAccountMappingMapper rm = new ProductToGLAccountMappingMapper();
|
||||
final String sql = "select " + rm.schema() + " and product_id = ? and payment_type is not null";
|
||||
|
||||
@@ -209,24 +209,24 @@ public class ProductToGLAccountMappingReadPlatformServiceImpl implements Product
|
||||
}
|
||||
final Long glAccountId = (Long) productToGLAccountMap.get("glAccountId");
|
||||
final Long paymentTypeId = (Long) productToGLAccountMap.get("paymentTypeId");
|
||||
PaymentTypeToGLAccountMapper paymentTypeToGLAccountMapper = new PaymentTypeToGLAccountMapper(paymentTypeId, glAccountId);
|
||||
final PaymentTypeToGLAccountMapper paymentTypeToGLAccountMapper = new PaymentTypeToGLAccountMapper(paymentTypeId, glAccountId);
|
||||
paymentTypeToGLAccountMappers.add(paymentTypeToGLAccountMapper);
|
||||
}
|
||||
return paymentTypeToGLAccountMappers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ChargeToGLAccountMapper> fetchFeeToIncomeAccountMappingsForLoanProduct(Long loanProductId) {
|
||||
public List<ChargeToGLAccountMapper> fetchFeeToIncomeAccountMappingsForLoanProduct(final Long loanProductId) {
|
||||
return fetchChargeToIncomeAccountMappings(PortfolioProductType.LOAN, loanProductId, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ChargeToGLAccountMapper> fetchPenaltyToIncomeAccountMappingsForLoanProduct(Long loanProductId) {
|
||||
public List<ChargeToGLAccountMapper> fetchPenaltyToIncomeAccountMappingsForLoanProduct(final Long loanProductId) {
|
||||
return fetchChargeToIncomeAccountMappings(PortfolioProductType.LOAN, loanProductId, true);
|
||||
}
|
||||
|
||||
private List<ChargeToGLAccountMapper> fetchChargeToIncomeAccountMappings(PortfolioProductType portfolioProductType, Long loanProductId,
|
||||
boolean penalty) {
|
||||
private List<ChargeToGLAccountMapper> fetchChargeToIncomeAccountMappings(final PortfolioProductType portfolioProductType,
|
||||
final Long loanProductId, final boolean penalty) {
|
||||
final ProductToGLAccountMappingMapper rm = new ProductToGLAccountMappingMapper();
|
||||
String sql = "select " + rm.schema() + " and product_id = ? and mapping.charge_id is not null and charge.is_penalty=";
|
||||
if (penalty) {
|
||||
@@ -244,7 +244,7 @@ public class ProductToGLAccountMappingReadPlatformServiceImpl implements Product
|
||||
}
|
||||
final Long glAccountId = (Long) chargeToIncomeAccountMap.get("glAccountId");
|
||||
final Long chargeId = (Long) chargeToIncomeAccountMap.get("chargeId");
|
||||
ChargeToGLAccountMapper chargeToGLAccountMapper = new ChargeToGLAccountMapper(chargeId, glAccountId);
|
||||
final ChargeToGLAccountMapper chargeToGLAccountMapper = new ChargeToGLAccountMapper(chargeId, glAccountId);
|
||||
chargeToGLAccountMappers.add(chargeToGLAccountMapper);
|
||||
}
|
||||
return chargeToGLAccountMappers;
|
||||
|
||||
+43
-42
@@ -37,8 +37,8 @@ public class ProductToGLAccountMappingWritePlatformServiceImpl implements Produc
|
||||
@Autowired
|
||||
public ProductToGLAccountMappingWritePlatformServiceImpl(final FromJsonHelper fromApiJsonHelper,
|
||||
final ProductToGLAccountMappingFromApiJsonDeserializer deserializer,
|
||||
LoanProductToGLAccountMappingHelper loanProductToGLAccountMappingHelper,
|
||||
SavingsProductToGLAccountMappingHelper savingsProductToGLAccountMappingHelper) {
|
||||
final LoanProductToGLAccountMappingHelper loanProductToGLAccountMappingHelper,
|
||||
final SavingsProductToGLAccountMappingHelper savingsProductToGLAccountMappingHelper) {
|
||||
this.fromApiJsonHelper = fromApiJsonHelper;
|
||||
this.deserializer = deserializer;
|
||||
this.loanProductToGLAccountMappingHelper = loanProductToGLAccountMappingHelper;
|
||||
@@ -57,84 +57,84 @@ public class ProductToGLAccountMappingWritePlatformServiceImpl implements Produc
|
||||
break;
|
||||
case CASH_BASED:
|
||||
// asset
|
||||
loanProductToGLAccountMappingHelper
|
||||
this.loanProductToGLAccountMappingHelper
|
||||
.saveLoanToAssetAccountMapping(element, LOAN_PRODUCT_ACCOUNTING_PARAMS.FUND_SOURCE.getValue(), loanProductId,
|
||||
CASH_ACCOUNTS_FOR_LOAN.FUND_SOURCE.getValue());
|
||||
loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element,
|
||||
this.loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element,
|
||||
LOAN_PRODUCT_ACCOUNTING_PARAMS.LOAN_PORTFOLIO.getValue(), loanProductId,
|
||||
CASH_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO.getValue());
|
||||
loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element,
|
||||
this.loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element,
|
||||
LOAN_PRODUCT_ACCOUNTING_PARAMS.TRANSFERS_SUSPENSE.getValue(), loanProductId,
|
||||
CASH_ACCOUNTS_FOR_LOAN.TRANSFERS_SUSPENSE.getValue());
|
||||
|
||||
// income
|
||||
loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element,
|
||||
this.loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element,
|
||||
LOAN_PRODUCT_ACCOUNTING_PARAMS.INTEREST_ON_LOANS.getValue(), loanProductId,
|
||||
CASH_ACCOUNTS_FOR_LOAN.INTEREST_ON_LOANS.getValue());
|
||||
loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element,
|
||||
this.loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element,
|
||||
LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue(), loanProductId,
|
||||
CASH_ACCOUNTS_FOR_LOAN.INCOME_FROM_FEES.getValue());
|
||||
loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element,
|
||||
this.loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element,
|
||||
LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_PENALTIES.getValue(), loanProductId,
|
||||
CASH_ACCOUNTS_FOR_LOAN.INCOME_FROM_PENALTIES.getValue());
|
||||
|
||||
// expenses
|
||||
loanProductToGLAccountMappingHelper.saveLoanToExpenseAccountMapping(element,
|
||||
this.loanProductToGLAccountMappingHelper.saveLoanToExpenseAccountMapping(element,
|
||||
LOAN_PRODUCT_ACCOUNTING_PARAMS.LOSSES_WRITTEN_OFF.getValue(), loanProductId,
|
||||
CASH_ACCOUNTS_FOR_LOAN.LOSSES_WRITTEN_OFF.getValue());
|
||||
|
||||
// advanced accounting mappings
|
||||
loanProductToGLAccountMappingHelper.savePaymentChannelToFundSourceMappings(command, element, loanProductId, null);
|
||||
loanProductToGLAccountMappingHelper.saveChargesToIncomeAccountMappings(command, element, loanProductId, null);
|
||||
this.loanProductToGLAccountMappingHelper.savePaymentChannelToFundSourceMappings(command, element, loanProductId, null);
|
||||
this.loanProductToGLAccountMappingHelper.saveChargesToIncomeAccountMappings(command, element, loanProductId, null);
|
||||
break;
|
||||
case ACCRUAL_BASED:
|
||||
|
||||
// assets (including receivables)
|
||||
loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element,
|
||||
this.loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element,
|
||||
LOAN_PRODUCT_ACCOUNTING_PARAMS.FUND_SOURCE.getValue(), loanProductId,
|
||||
ACCRUAL_ACCOUNTS_FOR_LOAN.FUND_SOURCE.getValue());
|
||||
loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element,
|
||||
this.loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element,
|
||||
LOAN_PRODUCT_ACCOUNTING_PARAMS.LOAN_PORTFOLIO.getValue(), loanProductId,
|
||||
ACCRUAL_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO.getValue());
|
||||
loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element,
|
||||
this.loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element,
|
||||
LOAN_PRODUCT_ACCOUNTING_PARAMS.TRANSFERS_SUSPENSE.getValue(), loanProductId,
|
||||
ACCRUAL_ACCOUNTS_FOR_LOAN.TRANSFERS_SUSPENSE.getValue());
|
||||
loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element,
|
||||
this.loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element,
|
||||
LOAN_PRODUCT_ACCOUNTING_PARAMS.INTEREST_RECEIVABLE.getValue(), loanProductId,
|
||||
ACCRUAL_ACCOUNTS_FOR_LOAN.INTEREST_RECEIVABLE.getValue());
|
||||
loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element,
|
||||
this.loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element,
|
||||
LOAN_PRODUCT_ACCOUNTING_PARAMS.FEES_RECEIVABLE.getValue(), loanProductId,
|
||||
ACCRUAL_ACCOUNTS_FOR_LOAN.FEES_RECEIVABLE.getValue());
|
||||
loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element,
|
||||
this.loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element,
|
||||
LOAN_PRODUCT_ACCOUNTING_PARAMS.PENALTIES_RECEIVABLE.getValue(), loanProductId,
|
||||
ACCRUAL_ACCOUNTS_FOR_LOAN.PENALTIES_RECEIVABLE.getValue());
|
||||
|
||||
// income
|
||||
loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element,
|
||||
this.loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element,
|
||||
LOAN_PRODUCT_ACCOUNTING_PARAMS.INTEREST_ON_LOANS.getValue(), loanProductId,
|
||||
ACCRUAL_ACCOUNTS_FOR_LOAN.INTEREST_ON_LOANS.getValue());
|
||||
loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element,
|
||||
this.loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element,
|
||||
LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue(), loanProductId,
|
||||
ACCRUAL_ACCOUNTS_FOR_LOAN.INCOME_FROM_FEES.getValue());
|
||||
loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element,
|
||||
this.loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element,
|
||||
LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_PENALTIES.getValue(), loanProductId,
|
||||
ACCRUAL_ACCOUNTS_FOR_LOAN.INCOME_FROM_PENALTIES.getValue());
|
||||
|
||||
// expenses
|
||||
loanProductToGLAccountMappingHelper.saveLoanToExpenseAccountMapping(element,
|
||||
this.loanProductToGLAccountMappingHelper.saveLoanToExpenseAccountMapping(element,
|
||||
LOAN_PRODUCT_ACCOUNTING_PARAMS.LOSSES_WRITTEN_OFF.getValue(), loanProductId,
|
||||
ACCRUAL_ACCOUNTS_FOR_LOAN.LOSSES_WRITTEN_OFF.getValue());
|
||||
|
||||
// advanced accounting mappings
|
||||
loanProductToGLAccountMappingHelper.savePaymentChannelToFundSourceMappings(command, element, loanProductId, null);
|
||||
loanProductToGLAccountMappingHelper.saveChargesToIncomeAccountMappings(command, element, loanProductId, null);
|
||||
this.loanProductToGLAccountMappingHelper.savePaymentChannelToFundSourceMappings(command, element, loanProductId, null);
|
||||
this.loanProductToGLAccountMappingHelper.saveChargesToIncomeAccountMappings(command, element, loanProductId, null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void createSavingProductToGLAccountMapping(Long savingProductId, JsonCommand command) {
|
||||
public void createSavingProductToGLAccountMapping(final Long savingProductId, final JsonCommand command) {
|
||||
final JsonElement element = this.fromApiJsonHelper.parse(command.json());
|
||||
final Integer accountingRuleTypeId = this.fromApiJsonHelper.extractIntegerNamed(accountingRuleParamName, element,
|
||||
Locale.getDefault());
|
||||
@@ -145,30 +145,30 @@ public class ProductToGLAccountMappingWritePlatformServiceImpl implements Produc
|
||||
break;
|
||||
case CASH_BASED:
|
||||
// asset
|
||||
savingsProductToGLAccountMappingHelper.saveSavingsToAssetAccountMapping(element,
|
||||
this.savingsProductToGLAccountMappingHelper.saveSavingsToAssetAccountMapping(element,
|
||||
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.SAVINGS_REFERENCE.getValue(), savingProductId,
|
||||
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_REFERENCE.getValue());
|
||||
|
||||
// income
|
||||
savingsProductToGLAccountMappingHelper.saveSavingsToIncomeAccountMapping(element,
|
||||
this.savingsProductToGLAccountMappingHelper.saveSavingsToIncomeAccountMapping(element,
|
||||
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue(), savingProductId,
|
||||
CASH_ACCOUNTS_FOR_SAVINGS.INCOME_FROM_FEES.getValue());
|
||||
|
||||
// expenses
|
||||
savingsProductToGLAccountMappingHelper.saveSavingsToExpenseAccountMapping(element,
|
||||
this.savingsProductToGLAccountMappingHelper.saveSavingsToExpenseAccountMapping(element,
|
||||
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INTEREST_ON_SAVINGS.getValue(), savingProductId,
|
||||
CASH_ACCOUNTS_FOR_SAVINGS.INTEREST_ON_SAVINGS.getValue());
|
||||
|
||||
// liability
|
||||
savingsProductToGLAccountMappingHelper.saveSavingsToLiabilityAccountMapping(element,
|
||||
this.savingsProductToGLAccountMappingHelper.saveSavingsToLiabilityAccountMapping(element,
|
||||
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.SAVINGS_CONTROL.getValue(), savingProductId,
|
||||
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL.getValue());
|
||||
savingsProductToGLAccountMappingHelper.saveSavingsToLiabilityAccountMapping(element,
|
||||
this.savingsProductToGLAccountMappingHelper.saveSavingsToLiabilityAccountMapping(element,
|
||||
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.TRANSFERS_SUSPENSE.getValue(), savingProductId,
|
||||
CASH_ACCOUNTS_FOR_SAVINGS.TRANSFERS_SUSPENSE.getValue());
|
||||
|
||||
// advanced accounting mappings
|
||||
savingsProductToGLAccountMappingHelper.savePaymentChannelToFundSourceMappings(command, element, savingProductId, null);
|
||||
this.savingsProductToGLAccountMappingHelper.savePaymentChannelToFundSourceMappings(command, element, savingProductId, null);
|
||||
break;
|
||||
/*** Do not have accrual based accounting for now ***/
|
||||
case ACCRUAL_BASED:
|
||||
@@ -195,23 +195,23 @@ public class ProductToGLAccountMappingWritePlatformServiceImpl implements Produc
|
||||
***/
|
||||
if (accountingRuleChanged) {
|
||||
this.deserializer.validateForLoanProductCreate(command.json());
|
||||
loanProductToGLAccountMappingHelper.deleteLoanProductToGLAccountMapping(loanProductId);
|
||||
this.loanProductToGLAccountMappingHelper.deleteLoanProductToGLAccountMapping(loanProductId);
|
||||
createLoanProductToGLAccountMapping(loanProductId, command);
|
||||
changes = loanProductToGLAccountMappingHelper.populateChangesForNewLoanProductToGLAccountMappingCreation(element,
|
||||
changes = this.loanProductToGLAccountMappingHelper.populateChangesForNewLoanProductToGLAccountMappingCreation(element,
|
||||
accountingRuleType);
|
||||
}/*** else examine and update individual changes ***/
|
||||
else {
|
||||
loanProductToGLAccountMappingHelper.handleChangesToLoanProductToGLAccountMappings(loanProductId, changes, element,
|
||||
this.loanProductToGLAccountMappingHelper.handleChangesToLoanProductToGLAccountMappings(loanProductId, changes, element,
|
||||
accountingRuleType);
|
||||
loanProductToGLAccountMappingHelper.updatePaymentChannelToFundSourceMappings(command, element, loanProductId, changes);
|
||||
loanProductToGLAccountMappingHelper.updateChargesToIncomeAccountMappings(command, element, loanProductId, changes);
|
||||
this.loanProductToGLAccountMappingHelper.updatePaymentChannelToFundSourceMappings(command, element, loanProductId, changes);
|
||||
this.loanProductToGLAccountMappingHelper.updateChargesToIncomeAccountMappings(command, element, loanProductId, changes);
|
||||
}
|
||||
return changes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> updateSavingsProductToGLAccountMapping(Long savingsProductId, JsonCommand command,
|
||||
boolean accountingRuleChanged, int accountingRuleTypeId) {
|
||||
public Map<String, Object> updateSavingsProductToGLAccountMapping(final Long savingsProductId, final JsonCommand command,
|
||||
final boolean accountingRuleChanged, final int accountingRuleTypeId) {
|
||||
/***
|
||||
* Variable tracks all accounting mapping properties that have been
|
||||
* updated
|
||||
@@ -226,15 +226,16 @@ public class ProductToGLAccountMappingWritePlatformServiceImpl implements Produc
|
||||
***/
|
||||
if (accountingRuleChanged) {
|
||||
this.deserializer.validateForSavingsProductCreate(command.json());
|
||||
savingsProductToGLAccountMappingHelper.deleteSavingsProductToGLAccountMapping(savingsProductId);
|
||||
this.savingsProductToGLAccountMappingHelper.deleteSavingsProductToGLAccountMapping(savingsProductId);
|
||||
createSavingProductToGLAccountMapping(savingsProductId, command);
|
||||
changes = savingsProductToGLAccountMappingHelper.populateChangesForNewSavingsProductToGLAccountMappingCreation(element,
|
||||
changes = this.savingsProductToGLAccountMappingHelper.populateChangesForNewSavingsProductToGLAccountMappingCreation(element,
|
||||
accountingRuleType);
|
||||
}/*** else examine and update individual changes ***/
|
||||
else {
|
||||
savingsProductToGLAccountMappingHelper.handleChangesToSavingsProductToGLAccountMappings(savingsProductId, changes, element,
|
||||
accountingRuleType);
|
||||
savingsProductToGLAccountMappingHelper.updatePaymentChannelToFundSourceMappings(command, element, savingsProductId, changes);
|
||||
this.savingsProductToGLAccountMappingHelper.handleChangesToSavingsProductToGLAccountMappings(savingsProductId, changes,
|
||||
element, accountingRuleType);
|
||||
this.savingsProductToGLAccountMappingHelper.updatePaymentChannelToFundSourceMappings(command, element, savingsProductId,
|
||||
changes);
|
||||
}
|
||||
return changes;
|
||||
}
|
||||
|
||||
+5
-5
@@ -28,9 +28,9 @@ import com.google.gson.JsonElement;
|
||||
public class SavingsProductToGLAccountMappingHelper extends ProductToGLAccountMappingHelper {
|
||||
|
||||
@Autowired
|
||||
public SavingsProductToGLAccountMappingHelper(GLAccountRepository glAccountRepository,
|
||||
ProductToGLAccountMappingRepository glAccountMappingRepository, FromJsonHelper fromApiJsonHelper,
|
||||
CodeValueRepositoryWrapper codeValueRepositoryWrapper, ChargeRepositoryWrapper chargeRepositoryWrapper) {
|
||||
public SavingsProductToGLAccountMappingHelper(final GLAccountRepository glAccountRepository,
|
||||
final ProductToGLAccountMappingRepository glAccountMappingRepository, final FromJsonHelper fromApiJsonHelper,
|
||||
final CodeValueRepositoryWrapper codeValueRepositoryWrapper, final ChargeRepositoryWrapper chargeRepositoryWrapper) {
|
||||
super(glAccountRepository, glAccountMappingRepository, fromApiJsonHelper, codeValueRepositoryWrapper, chargeRepositoryWrapper);
|
||||
}
|
||||
|
||||
@@ -85,12 +85,12 @@ public class SavingsProductToGLAccountMappingHelper extends ProductToGLAccountMa
|
||||
/*** Abstractions for payments channel related to savings products ***/
|
||||
|
||||
public void savePaymentChannelToFundSourceMappings(final JsonCommand command, final JsonElement element, final Long productId,
|
||||
Map<String, Object> changes) {
|
||||
final Map<String, Object> changes) {
|
||||
savePaymentChannelToFundSourceMappings(command, element, productId, changes, PortfolioProductType.SAVING);
|
||||
}
|
||||
|
||||
public void updatePaymentChannelToFundSourceMappings(final JsonCommand command, final JsonElement element, final Long productId,
|
||||
Map<String, Object> changes) {
|
||||
final Map<String, Object> changes) {
|
||||
updatePaymentChannelToFundSourceMappings(command, element, productId, changes, PortfolioProductType.SAVING);
|
||||
}
|
||||
|
||||
|
||||
+17
-11
@@ -107,22 +107,24 @@ public class AccountingRuleApiResource {
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String retrieveAllAccountingRules(@Context final UriInfo uriInfo) {
|
||||
|
||||
final AppUser currentUser = context.authenticatedUser();
|
||||
|
||||
final AppUser currentUser = this.context.authenticatedUser();
|
||||
currentUser.validateHasReadPermission(this.resourceNameForPermission);
|
||||
|
||||
|
||||
final String hierarchy = currentUser.getOffice().getHierarchy();
|
||||
final String hierarchySearchString = hierarchy + "%";
|
||||
|
||||
|
||||
final Set<String> associationParameters = ApiParameterHelper.extractAssociationsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
boolean isAssociationParametersExists = false;
|
||||
if (!associationParameters.isEmpty()) {
|
||||
if (associationParameters.contains("all")) {
|
||||
isAssociationParametersExists = true; // If true, retrieve additional fields for journal entry form.
|
||||
isAssociationParametersExists = true; // If true, retrieve
|
||||
// additional fields for
|
||||
// journal entry form.
|
||||
}
|
||||
}
|
||||
final List<AccountingRuleData> accountingRuleDatas = this.accountingRuleReadPlatformService.retrieveAllAccountingRules(hierarchySearchString,
|
||||
isAssociationParametersExists);
|
||||
final List<AccountingRuleData> accountingRuleDatas = this.accountingRuleReadPlatformService.retrieveAllAccountingRules(
|
||||
hierarchySearchString, isAssociationParametersExists);
|
||||
|
||||
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
return this.apiJsonSerializerService.serialize(settings, accountingRuleDatas, RESPONSE_DATA_PARAMETERS);
|
||||
@@ -189,10 +191,14 @@ public class AccountingRuleApiResource {
|
||||
final Collection<CodeValueData> allowedTagOptions = this.codeValueReadPlatformService
|
||||
.retrieveCodeValuesByCode(AccountingConstants.ASSESTS_TAG_OPTION_CODE_NAME);
|
||||
|
||||
allowedTagOptions.addAll(this.codeValueReadPlatformService.retrieveCodeValuesByCode(AccountingConstants.LIABILITIES_TAG_OPTION_CODE_NAME));
|
||||
allowedTagOptions.addAll(this.codeValueReadPlatformService.retrieveCodeValuesByCode(AccountingConstants.EQUITY_TAG_OPTION_CODE_NAME));
|
||||
allowedTagOptions.addAll(this.codeValueReadPlatformService.retrieveCodeValuesByCode(AccountingConstants.INCOME_TAG_OPTION_CODE_NAME));
|
||||
allowedTagOptions.addAll(this.codeValueReadPlatformService.retrieveCodeValuesByCode(AccountingConstants.EXPENSES_TAG_OPTION_CODE_NAME));
|
||||
allowedTagOptions.addAll(this.codeValueReadPlatformService
|
||||
.retrieveCodeValuesByCode(AccountingConstants.LIABILITIES_TAG_OPTION_CODE_NAME));
|
||||
allowedTagOptions.addAll(this.codeValueReadPlatformService
|
||||
.retrieveCodeValuesByCode(AccountingConstants.EQUITY_TAG_OPTION_CODE_NAME));
|
||||
allowedTagOptions.addAll(this.codeValueReadPlatformService
|
||||
.retrieveCodeValuesByCode(AccountingConstants.INCOME_TAG_OPTION_CODE_NAME));
|
||||
allowedTagOptions.addAll(this.codeValueReadPlatformService
|
||||
.retrieveCodeValuesByCode(AccountingConstants.EXPENSES_TAG_OPTION_CODE_NAME));
|
||||
|
||||
if (accountingRuleData == null) {
|
||||
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ public class AccountingTagRuleData {
|
||||
}
|
||||
|
||||
public CodeValueData getTag() {
|
||||
return tag;
|
||||
return this.tag;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -13,10 +13,10 @@ import org.mifosplatform.infrastructure.core.exception.AbstractPlatformDomainRul
|
||||
*/
|
||||
public class AccountingRuleDuplicateException extends AbstractPlatformDomainRuleException {
|
||||
|
||||
public AccountingRuleDuplicateException(String name) {
|
||||
public AccountingRuleDuplicateException(final String name) {
|
||||
super("error.msg.accounting.rule.duplicate", "An accounting rule with the name " + name + " already exists" + name);
|
||||
}
|
||||
|
||||
|
||||
public AccountingRuleDuplicateException() {
|
||||
super("error.msg.accounting.rule.tag.duplicate", "The accounting rule already have the tags which you defined");
|
||||
}
|
||||
|
||||
+2
-1
@@ -141,7 +141,8 @@ public class AccountingRuleReadPlatformServiceImpl implements AccountingRuleRead
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AccountingRuleData> retrieveAllAccountingRules(final String hierarchySearchString, final boolean isAssociationParametersExists) {
|
||||
public List<AccountingRuleData> retrieveAllAccountingRules(final String hierarchySearchString,
|
||||
final boolean isAssociationParametersExists) {
|
||||
final AccountingRuleDataExtractor resultSetExtractor = new AccountingRuleDataExtractor(this.jdbcTemplate,
|
||||
this.glAccountReadPlatformService, isAssociationParametersExists);
|
||||
Object[] arguments = new Object[] {};
|
||||
|
||||
+1
-1
@@ -112,7 +112,7 @@ public class AccountingRuleWritePlatformServiceJpaRepositoryImpl implements Acco
|
||||
// get the GL Accounts or tags to Debit and Credit
|
||||
final String[] debitTags = command.arrayValueOfParameterNamed(AccountingRuleJsonInputParams.DEBIT_ACCOUNT_TAGS.getValue());
|
||||
final String[] creditTags = command.arrayValueOfParameterNamed(AccountingRuleJsonInputParams.CREDIT_ACCOUNT_TAGS.getValue());
|
||||
final Set<String> incomingDebitTags = debitTags == null ? new HashSet<String>(): new HashSet<String>(Arrays.asList(debitTags));
|
||||
final Set<String> incomingDebitTags = debitTags == null ? new HashSet<String>() : new HashSet<String>(Arrays.asList(debitTags));
|
||||
final Set<String> incomingCreditTags = creditTags == null ? new HashSet<String>() : new HashSet<String>(Arrays.asList(creditTags));
|
||||
final Long accountToDebitId = command.longValueOfParameterNamed(AccountingRuleJsonInputParams.ACCOUNT_TO_DEBIT.getValue());
|
||||
final Long accountToCreditId = command.longValueOfParameterNamed(AccountingRuleJsonInputParams.ACCOUNT_TO_CREDIT.getValue());
|
||||
|
||||
+8
-8
@@ -74,17 +74,17 @@ public class AuditsApiResource {
|
||||
@QueryParam("groupId") final Integer groupId, @QueryParam("clientId") final Integer clientId,
|
||||
@QueryParam("loanid") final Integer loanId, @QueryParam("savingsAccountId") final Integer savingsAccountId) {
|
||||
|
||||
context.authenticatedUser().validateHasReadPermission(resourceNameForPermissions);
|
||||
this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions);
|
||||
|
||||
final String extraCriteria = getExtraCriteria(actionName, entityName, resourceId, makerId, makerDateTimeFrom, makerDateTimeTo,
|
||||
checkerId, checkerDateTimeFrom, checkerDateTimeTo, processingResult, officeId, groupId, clientId, loanId, savingsAccountId);
|
||||
|
||||
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
|
||||
final Collection<AuditData> auditEntries = this.auditReadPlatformService.retrieveAuditEntries(extraCriteria,
|
||||
settings.isIncludeJson());
|
||||
|
||||
return this.toApiJsonSerializer.serialize(settings, auditEntries, RESPONSE_DATA_PARAMETERS);
|
||||
return this.toApiJsonSerializer.serialize(settings, auditEntries, this.RESPONSE_DATA_PARAMETERS);
|
||||
}
|
||||
|
||||
@GET
|
||||
@@ -93,12 +93,12 @@ public class AuditsApiResource {
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String retrieveAuditEntry(@PathParam("auditId") final Long auditId, @Context final UriInfo uriInfo) {
|
||||
|
||||
context.authenticatedUser().validateHasReadPermission(resourceNameForPermissions);
|
||||
this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions);
|
||||
|
||||
final AuditData auditEntry = this.auditReadPlatformService.retrieveAuditEntry(auditId);
|
||||
|
||||
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
return this.toApiJsonSerializer.serialize(settings, auditEntry, RESPONSE_DATA_PARAMETERS);
|
||||
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
return this.toApiJsonSerializer.serialize(settings, auditEntry, this.RESPONSE_DATA_PARAMETERS);
|
||||
}
|
||||
|
||||
@GET
|
||||
@@ -107,9 +107,9 @@ public class AuditsApiResource {
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String retrieveAuditSearchTemplate(@Context final UriInfo uriInfo) {
|
||||
|
||||
context.authenticatedUser().validateHasReadPermission(resourceNameForPermissions);
|
||||
this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions);
|
||||
|
||||
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
|
||||
final AuditSearchData auditSearchData = this.auditReadPlatformService.retrieveSearchTemplate("audit");
|
||||
|
||||
|
||||
+3
-3
@@ -77,12 +77,12 @@ public class MakercheckersApiResource {
|
||||
final String extraCriteria = getExtraCriteria(actionName, entityName, resourceId, makerId, makerDateTimeFrom, makerDateTimeTo,
|
||||
officeId, groupId, clientId, loanId, savingsAccountId);
|
||||
|
||||
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
|
||||
final Collection<AuditData> entries = this.readPlatformService.retrieveAllEntriesToBeChecked(extraCriteria,
|
||||
settings.isIncludeJson());
|
||||
|
||||
return this.toApiJsonSerializerAudit.serialize(settings, entries, RESPONSE_DATA_PARAMETERS);
|
||||
return this.toApiJsonSerializerAudit.serialize(settings, entries, this.RESPONSE_DATA_PARAMETERS);
|
||||
}
|
||||
|
||||
@GET
|
||||
@@ -91,7 +91,7 @@ public class MakercheckersApiResource {
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String retrieveAuditSearchTemplate(@Context final UriInfo uriInfo) {
|
||||
|
||||
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
|
||||
final AuditSearchData auditSearchData = this.readPlatformService.retrieveSearchTemplate("makerchecker");
|
||||
|
||||
|
||||
+2
-2
@@ -21,11 +21,11 @@ public enum CommandProcessingResultType {
|
||||
}
|
||||
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
return this.code;
|
||||
}
|
||||
|
||||
public static CommandProcessingResultType fromInt(final Integer typeValue) {
|
||||
|
||||
+120
-133
@@ -25,175 +25,162 @@ import org.springframework.data.jpa.domain.AbstractPersistable;
|
||||
@Table(name = "m_portfolio_command_source")
|
||||
public class CommandSource extends AbstractPersistable<Long> {
|
||||
|
||||
@Column(name = "action_name", nullable = true, length = 100)
|
||||
private String actionName;
|
||||
@Column(name = "action_name", nullable = true, length = 100)
|
||||
private String actionName;
|
||||
|
||||
@Column(name = "entity_name", nullable = true, length = 100)
|
||||
private String entityName;
|
||||
@Column(name = "entity_name", nullable = true, length = 100)
|
||||
private String entityName;
|
||||
|
||||
@Column(name = "office_id")
|
||||
private Long officeId;
|
||||
@Column(name = "office_id")
|
||||
private Long officeId;
|
||||
|
||||
@Column(name = "group_id")
|
||||
private Long groupId;
|
||||
@Column(name = "group_id")
|
||||
private Long groupId;
|
||||
|
||||
@Column(name = "client_id")
|
||||
private Long clientId;
|
||||
@Column(name = "client_id")
|
||||
private Long clientId;
|
||||
|
||||
@Column(name = "loan_id")
|
||||
private Long loanId;
|
||||
@Column(name = "loan_id")
|
||||
private Long loanId;
|
||||
|
||||
@Column(name = "savings_account_id")
|
||||
private Long savingsId;
|
||||
@Column(name = "savings_account_id")
|
||||
private Long savingsId;
|
||||
|
||||
@Column(name = "api_get_url", length = 100)
|
||||
private String resourceGetUrl;
|
||||
@Column(name = "api_get_url", length = 100)
|
||||
private String resourceGetUrl;
|
||||
|
||||
@Column(name = "resource_id")
|
||||
private Long resourceId;
|
||||
@Column(name = "resource_id")
|
||||
private Long resourceId;
|
||||
|
||||
@Column(name = "subresource_id")
|
||||
private Long subresourceId;
|
||||
@Column(name = "subresource_id")
|
||||
private Long subresourceId;
|
||||
|
||||
@Column(name = "command_as_json", length = 1000)
|
||||
private String commandAsJson;
|
||||
@Column(name = "command_as_json", length = 1000)
|
||||
private String commandAsJson;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "maker_id", nullable = false)
|
||||
private AppUser maker;
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "maker_id", nullable = false)
|
||||
private AppUser maker;
|
||||
|
||||
@Column(name = "made_on_date", nullable = false)
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date madeOnDate;
|
||||
@Column(name = "made_on_date", nullable = false)
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date madeOnDate;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "checker_id", nullable = true)
|
||||
private AppUser checker;
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "checker_id", nullable = true)
|
||||
private AppUser checker;
|
||||
|
||||
@Column(name = "checked_on_date", nullable = true)
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date checkedOnDate;
|
||||
@Column(name = "checked_on_date", nullable = true)
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date checkedOnDate;
|
||||
|
||||
@Column(name = "processing_result_enum", nullable = false)
|
||||
private Integer processingResult;
|
||||
@Column(name = "processing_result_enum", nullable = false)
|
||||
private Integer processingResult;
|
||||
|
||||
@Column(name = "product_id")
|
||||
private Long productId;
|
||||
@Column(name = "product_id")
|
||||
private Long productId;
|
||||
|
||||
public static CommandSource fullEntryFrom(final CommandWrapper wrapper,
|
||||
final JsonCommand command, final AppUser maker) {
|
||||
return new CommandSource(wrapper.actionName(), wrapper.entityName(),
|
||||
wrapper.getHref(), command.entityId(), command.subentityId(),
|
||||
command.json(), maker, DateTime.now());
|
||||
}
|
||||
public static CommandSource fullEntryFrom(final CommandWrapper wrapper, final JsonCommand command, final AppUser maker) {
|
||||
return new CommandSource(wrapper.actionName(), wrapper.entityName(), wrapper.getHref(), command.entityId(), command.subentityId(),
|
||||
command.json(), maker, DateTime.now());
|
||||
}
|
||||
|
||||
protected CommandSource() {
|
||||
//
|
||||
}
|
||||
protected CommandSource() {
|
||||
//
|
||||
}
|
||||
|
||||
private CommandSource(final String actionName, final String entityName,
|
||||
final String href, final Long resourceId, final Long subresourceId,
|
||||
final String commandSerializedAsJson, final AppUser maker,
|
||||
final DateTime madeOnDateTime) {
|
||||
this.actionName = actionName;
|
||||
this.entityName = entityName;
|
||||
this.resourceGetUrl = href;
|
||||
this.resourceId = resourceId;
|
||||
this.subresourceId = subresourceId;
|
||||
this.commandAsJson = commandSerializedAsJson;
|
||||
this.maker = maker;
|
||||
this.madeOnDate = madeOnDateTime.toDate();
|
||||
this.processingResult = CommandProcessingResultType.PROCESSED
|
||||
.getValue();
|
||||
}
|
||||
private CommandSource(final String actionName, final String entityName, final String href, final Long resourceId,
|
||||
final Long subresourceId, final String commandSerializedAsJson, final AppUser maker, final DateTime madeOnDateTime) {
|
||||
this.actionName = actionName;
|
||||
this.entityName = entityName;
|
||||
this.resourceGetUrl = href;
|
||||
this.resourceId = resourceId;
|
||||
this.subresourceId = subresourceId;
|
||||
this.commandAsJson = commandSerializedAsJson;
|
||||
this.maker = maker;
|
||||
this.madeOnDate = madeOnDateTime.toDate();
|
||||
this.processingResult = CommandProcessingResultType.PROCESSED.getValue();
|
||||
}
|
||||
|
||||
public void markAsChecked(final AppUser checker,
|
||||
final DateTime checkedOnDate) {
|
||||
this.checker = checker;
|
||||
this.checkedOnDate = checkedOnDate.toDate();
|
||||
this.processingResult = CommandProcessingResultType.PROCESSED
|
||||
.getValue();
|
||||
}
|
||||
public void markAsChecked(final AppUser checker, final DateTime checkedOnDate) {
|
||||
this.checker = checker;
|
||||
this.checkedOnDate = checkedOnDate.toDate();
|
||||
this.processingResult = CommandProcessingResultType.PROCESSED.getValue();
|
||||
}
|
||||
|
||||
public void updateResourceId(final Long resourceId) {
|
||||
this.resourceId = resourceId;
|
||||
}
|
||||
public void updateResourceId(final Long resourceId) {
|
||||
this.resourceId = resourceId;
|
||||
}
|
||||
|
||||
public void updateSubresourceId(final Long subresourceId) {
|
||||
this.subresourceId = subresourceId;
|
||||
}
|
||||
public void updateSubresourceId(final Long subresourceId) {
|
||||
this.subresourceId = subresourceId;
|
||||
}
|
||||
|
||||
public void updateJsonTo(final String json) {
|
||||
this.commandAsJson = json;
|
||||
}
|
||||
public void updateJsonTo(final String json) {
|
||||
this.commandAsJson = json;
|
||||
}
|
||||
|
||||
public Long resourceId() {
|
||||
return this.resourceId;
|
||||
}
|
||||
public Long resourceId() {
|
||||
return this.resourceId;
|
||||
}
|
||||
|
||||
public Long subresourceId() {
|
||||
return this.subresourceId;
|
||||
}
|
||||
public Long subresourceId() {
|
||||
return this.subresourceId;
|
||||
}
|
||||
|
||||
public boolean hasJson() {
|
||||
return StringUtils.isNotBlank(this.commandAsJson);
|
||||
}
|
||||
public boolean hasJson() {
|
||||
return StringUtils.isNotBlank(this.commandAsJson);
|
||||
}
|
||||
|
||||
public String json() {
|
||||
return this.commandAsJson;
|
||||
}
|
||||
public String json() {
|
||||
return this.commandAsJson;
|
||||
}
|
||||
|
||||
public String getActionName() {
|
||||
return this.actionName;
|
||||
}
|
||||
public String getActionName() {
|
||||
return this.actionName;
|
||||
}
|
||||
|
||||
public String getEntityName() {
|
||||
return this.entityName;
|
||||
}
|
||||
public String getEntityName() {
|
||||
return this.entityName;
|
||||
}
|
||||
|
||||
public String getPermissionCode() {
|
||||
return this.actionName + "_" + this.entityName;
|
||||
}
|
||||
public String getPermissionCode() {
|
||||
return this.actionName + "_" + this.entityName;
|
||||
}
|
||||
|
||||
public Long getResourceId() {
|
||||
return this.resourceId;
|
||||
}
|
||||
public Long getResourceId() {
|
||||
return this.resourceId;
|
||||
}
|
||||
|
||||
public Long getSubresourceId() {
|
||||
return this.subresourceId;
|
||||
}
|
||||
public Long getSubresourceId() {
|
||||
return this.subresourceId;
|
||||
}
|
||||
|
||||
public void markAsAwaitingApproval() {
|
||||
this.processingResult = CommandProcessingResultType.AWAITING_APPROVAL
|
||||
.getValue();
|
||||
}
|
||||
public void markAsAwaitingApproval() {
|
||||
this.processingResult = CommandProcessingResultType.AWAITING_APPROVAL.getValue();
|
||||
}
|
||||
|
||||
public boolean isMarkedAsAwaitingApproval() {
|
||||
if (this.processingResult
|
||||
.equals(CommandProcessingResultType.AWAITING_APPROVAL
|
||||
.getValue())) {
|
||||
return true;
|
||||
}
|
||||
public boolean isMarkedAsAwaitingApproval() {
|
||||
if (this.processingResult.equals(CommandProcessingResultType.AWAITING_APPROVAL.getValue())) { return true; }
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void updateForAudit(final Long officeId, final Long groupId,
|
||||
final Long clientId, final Long loanId, final Long savingsId,
|
||||
final Long productId) {
|
||||
this.officeId = officeId;
|
||||
this.groupId = groupId;
|
||||
this.clientId = clientId;
|
||||
this.loanId = loanId;
|
||||
this.savingsId = savingsId;
|
||||
this.productId = productId;
|
||||
}
|
||||
public void updateForAudit(final Long officeId, final Long groupId, final Long clientId, final Long loanId, final Long savingsId,
|
||||
final Long productId) {
|
||||
this.officeId = officeId;
|
||||
this.groupId = groupId;
|
||||
this.clientId = clientId;
|
||||
this.loanId = loanId;
|
||||
this.savingsId = savingsId;
|
||||
this.productId = productId;
|
||||
}
|
||||
|
||||
public String getResourceGetUrl() {
|
||||
return this.resourceGetUrl;
|
||||
}
|
||||
public String getResourceGetUrl() {
|
||||
return this.resourceGetUrl;
|
||||
}
|
||||
|
||||
public Long getProductId() {
|
||||
return this.productId;
|
||||
}
|
||||
public Long getProductId() {
|
||||
return this.productId;
|
||||
}
|
||||
}
|
||||
+6
-6
@@ -185,8 +185,8 @@ public class CommandWrapper {
|
||||
|
||||
public boolean isUpdate() {
|
||||
// permissions resource has special update which involves no resource.
|
||||
return isPermissionResource() && isUpdateOperation() || isCurrencyResource() && isUpdateOperation() || isCacheResource() && isUpdateOperation()
|
||||
|| isUpdateOperation() && this.entityId != null;
|
||||
return isPermissionResource() && isUpdateOperation() || isCurrencyResource() && isUpdateOperation() || isCacheResource()
|
||||
&& isUpdateOperation() || isUpdateOperation() && this.entityId != null;
|
||||
}
|
||||
|
||||
public boolean isUpdateOperation() {
|
||||
@@ -445,7 +445,7 @@ public class CommandWrapper {
|
||||
public boolean isSavingsAccountResource() {
|
||||
return this.entityName.equalsIgnoreCase("SAVINGSACCOUNT");
|
||||
}
|
||||
|
||||
|
||||
public boolean isRejectionOfSavingsAccountApplication() {
|
||||
return this.actionName.equalsIgnoreCase("REJECT") && this.entityName.equalsIgnoreCase("SAVINGSACCOUNT");
|
||||
}
|
||||
@@ -501,7 +501,7 @@ public class CommandWrapper {
|
||||
public boolean isSavingsAccountChargeResource() {
|
||||
return this.entityName.equalsIgnoreCase("SAVINGSACCOUNTCHARGE");
|
||||
}
|
||||
|
||||
|
||||
public boolean isAddSavingsAccountCharge() {
|
||||
return this.actionName.equalsIgnoreCase("CREATE") && this.entityName.equalsIgnoreCase("SAVINGSACCOUNTCHARGE");
|
||||
}
|
||||
@@ -517,11 +517,11 @@ public class CommandWrapper {
|
||||
public boolean isWaiveSavingsAccountCharge() {
|
||||
return this.actionName.equalsIgnoreCase("WAIVE") && this.entityName.equalsIgnoreCase("SAVINGSACCOUNTCHARGE");
|
||||
}
|
||||
|
||||
|
||||
public boolean isPaySavingsAccountCharge() {
|
||||
return this.actionName.equalsIgnoreCase("PAY") && this.entityName.equalsIgnoreCase("SAVINGSACCOUNTCHARGE");
|
||||
}
|
||||
|
||||
|
||||
public boolean isCalendarResource() {
|
||||
return this.entityName.equalsIgnoreCase("CALENDAR");
|
||||
}
|
||||
|
||||
+1
-1
@@ -18,6 +18,6 @@ public class UnsupportedCommandException extends RuntimeException {
|
||||
}
|
||||
|
||||
public String getUnsupportedCommandName() {
|
||||
return unsupportedCommandName;
|
||||
return this.unsupportedCommandName;
|
||||
}
|
||||
}
|
||||
+37
-32
@@ -79,7 +79,9 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService {
|
||||
public String schema(final boolean includeJson, final String hierarchy) {
|
||||
|
||||
String commandAsJsonString = "";
|
||||
if (includeJson) commandAsJsonString = ", aud.command_as_json as commandAsJson ";
|
||||
if (includeJson) {
|
||||
commandAsJsonString = ", aud.command_as_json as commandAsJson ";
|
||||
}
|
||||
|
||||
String partSql = " aud.id as id, aud.action_name as actionName, aud.entity_name as entityName,"
|
||||
+ " aud.resource_id as resourceId, aud.subresource_id as subresourceId,"
|
||||
@@ -120,16 +122,16 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService {
|
||||
// commandAsJson might not be on the select list of columns
|
||||
try {
|
||||
commandAsJson = rs.getString("commandAsJson");
|
||||
} catch (SQLException e) {
|
||||
} catch (final SQLException e) {
|
||||
commandAsJson = null;
|
||||
}
|
||||
|
||||
String officeName = rs.getString("officeName");
|
||||
String groupLevelName = rs.getString("groupLevelName");
|
||||
String groupName = rs.getString("groupName");
|
||||
String clientName = rs.getString("clientName");
|
||||
String loanAccountNo = rs.getString("loanAccountNo");
|
||||
String savingsAccountNo = rs.getString("savingsAccountNo");
|
||||
final String officeName = rs.getString("officeName");
|
||||
final String groupLevelName = rs.getString("groupLevelName");
|
||||
final String groupName = rs.getString("groupName");
|
||||
final String clientName = rs.getString("clientName");
|
||||
final String loanAccountNo = rs.getString("loanAccountNo");
|
||||
final String savingsAccountNo = rs.getString("savingsAccountNo");
|
||||
|
||||
return new AuditData(id, actionName, entityName, resourceId, subresourceId, maker, madeOnDate, checker, checkedOnDate,
|
||||
processingResult, commandAsJson, officeName, groupLevelName, groupName, clientName, loanAccountNo, savingsAccountNo);
|
||||
@@ -140,7 +142,9 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService {
|
||||
public Collection<AuditData> retrieveAuditEntries(final String extraCriteria, final boolean includeJson) {
|
||||
|
||||
String updatedExtraCriteria = "";
|
||||
if (StringUtils.isNotBlank(extraCriteria)) updatedExtraCriteria = " where (" + extraCriteria + ")";
|
||||
if (StringUtils.isNotBlank(extraCriteria)) {
|
||||
updatedExtraCriteria = " where (" + extraCriteria + ")";
|
||||
}
|
||||
|
||||
updatedExtraCriteria += " order by aud.id DESC";
|
||||
return retrieveEntries("audit", updatedExtraCriteria, includeJson);
|
||||
@@ -150,10 +154,11 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService {
|
||||
public Collection<AuditData> retrieveAllEntriesToBeChecked(final String extraCriteria, final boolean includeJson) {
|
||||
|
||||
String updatedExtraCriteria = "";
|
||||
if (StringUtils.isNotBlank(extraCriteria))
|
||||
if (StringUtils.isNotBlank(extraCriteria)) {
|
||||
updatedExtraCriteria = " where (" + extraCriteria + ")" + " and aud.processing_result_enum = 2";
|
||||
else
|
||||
} else {
|
||||
updatedExtraCriteria = " where aud.processing_result_enum = 2";
|
||||
}
|
||||
|
||||
updatedExtraCriteria += " order by aud.id";
|
||||
|
||||
@@ -165,8 +170,8 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService {
|
||||
if (!(useType.equals("audit") || useType.equals("makerchecker"))) { throw new PlatformDataIntegrityException(
|
||||
"error.msg.invalid.auditSearchTemplate.useType", "Invalid Audit Search Template UseType: " + useType); }
|
||||
|
||||
AppUser currentUser = context.authenticatedUser();
|
||||
String hierarchy = currentUser.getOffice().getHierarchy();
|
||||
final AppUser currentUser = this.context.authenticatedUser();
|
||||
final String hierarchy = currentUser.getOffice().getHierarchy();
|
||||
|
||||
final AuditMapper rm = new AuditMapper();
|
||||
String sql = "select " + rm.schema(includeJson, hierarchy);
|
||||
@@ -194,7 +199,7 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService {
|
||||
@Override
|
||||
public AuditData retrieveAuditEntry(final Long auditId) {
|
||||
|
||||
final AppUser currentUser = context.authenticatedUser();
|
||||
final AppUser currentUser = this.context.authenticatedUser();
|
||||
final String hierarchy = currentUser.getOffice().getHierarchy();
|
||||
|
||||
final AuditMapper rm = new AuditMapper();
|
||||
@@ -220,10 +225,10 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService {
|
||||
commandAsJsonMap.remove("officeId");
|
||||
|
||||
Long officeId = null;
|
||||
String officeIdStr = auditObject.get("officeId").getAsString();
|
||||
final String officeIdStr = auditObject.get("officeId").getAsString();
|
||||
if (StringUtils.isNotBlank(officeIdStr)) {
|
||||
officeId = Long.valueOf(officeIdStr);
|
||||
OfficeData office = this.officeReadPlatformService.retrieveOffice(officeId);
|
||||
final OfficeData office = this.officeReadPlatformService.retrieveOffice(officeId);
|
||||
commandAsJsonMap.put("officeName", office.name());
|
||||
} else {
|
||||
commandAsJsonMap.put("officeName", "");
|
||||
@@ -234,10 +239,10 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService {
|
||||
commandAsJsonMap.remove("clientId");
|
||||
|
||||
Long clientId = null;
|
||||
String clientIdStr = auditObject.get("clientId").getAsString();
|
||||
final String clientIdStr = auditObject.get("clientId").getAsString();
|
||||
if (StringUtils.isNotBlank(clientIdStr)) {
|
||||
clientId = Long.valueOf(clientIdStr);
|
||||
ClientData client = this.clientReadPlatformService.retrieveOne(clientId);
|
||||
final ClientData client = this.clientReadPlatformService.retrieveOne(clientId);
|
||||
commandAsJsonMap.put("clientName", client.displayName());
|
||||
} else {
|
||||
commandAsJsonMap.put("clientName", "");
|
||||
@@ -248,10 +253,10 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService {
|
||||
commandAsJsonMap.remove("productId");
|
||||
|
||||
Long productId = null;
|
||||
String productIdStr = auditObject.get("productId").getAsString();
|
||||
final String productIdStr = auditObject.get("productId").getAsString();
|
||||
if (StringUtils.isNotBlank(productIdStr)) {
|
||||
productId = Long.valueOf(productIdStr);
|
||||
LoanProductData loanProduct = this.loanProductReadPlatformService.retrieveLoanProduct(productId);
|
||||
final LoanProductData loanProduct = this.loanProductReadPlatformService.retrieveLoanProduct(productId);
|
||||
commandAsJsonMap.put("productName", loanProduct.getName());
|
||||
} else {
|
||||
commandAsJsonMap.put("productName", "");
|
||||
@@ -262,10 +267,10 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService {
|
||||
commandAsJsonMap.remove("loanOfficerId");
|
||||
|
||||
Long loanOfficerId = null;
|
||||
String loanOfficerIdStr = auditObject.get("loanOfficerId").getAsString();
|
||||
final String loanOfficerIdStr = auditObject.get("loanOfficerId").getAsString();
|
||||
if (StringUtils.isNotBlank(loanOfficerIdStr)) {
|
||||
loanOfficerId = Long.valueOf(loanOfficerIdStr);
|
||||
StaffData officer = this.staffReadPlatformService.retrieveStaff(loanOfficerId);
|
||||
final StaffData officer = this.staffReadPlatformService.retrieveStaff(loanOfficerId);
|
||||
commandAsJsonMap.put("loanOfficerName", officer.getDisplayName());
|
||||
} else {
|
||||
commandAsJsonMap.put("loanOfficerName", "");
|
||||
@@ -275,7 +280,7 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService {
|
||||
final String[] enumTypes = { "loanTermFrequencyType", "repaymentFrequencyType", "amortizationType", "interestType",
|
||||
"interestCalculationPeriodType", "interestRateFrequencyType" };
|
||||
|
||||
for (String typeName : enumTypes) {
|
||||
for (final String typeName : enumTypes) {
|
||||
if (commandAsJsonMap.containsKey(typeName)) {
|
||||
commandAsJsonMap.remove(typeName);
|
||||
|
||||
@@ -301,25 +306,25 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService {
|
||||
if (!(useType.equals("audit") || useType.equals("makerchecker"))) { throw new PlatformDataIntegrityException(
|
||||
"error.msg.invalid.auditSearchTemplate.useType", "Invalid Audit Search Template UseType: " + useType); }
|
||||
|
||||
AppUser currentUser = context.authenticatedUser();
|
||||
final AppUser currentUser = this.context.authenticatedUser();
|
||||
|
||||
final Collection<AppUserData> appUsers = appUserReadPlatformService.retrieveSearchTemplate();
|
||||
final Collection<AppUserData> appUsers = this.appUserReadPlatformService.retrieveSearchTemplate();
|
||||
|
||||
String sql = " SELECT distinct(action_name) as actionName FROM m_permission p ";
|
||||
sql += makercheckerCapabilityOnly(useType, currentUser);
|
||||
sql += " order by if(action_name in ('CREATE', 'DELETE', 'UPDATE'), action_name, 'ZZZ'), action_name";
|
||||
ActionNamesMapper mapper = new ActionNamesMapper();
|
||||
List<String> actionNames = this.jdbcTemplate.query(sql, mapper, new Object[] {});
|
||||
final ActionNamesMapper mapper = new ActionNamesMapper();
|
||||
final List<String> actionNames = this.jdbcTemplate.query(sql, mapper, new Object[] {});
|
||||
|
||||
sql = " select distinct(entity_name) as entityName from m_permission p ";
|
||||
sql += makercheckerCapabilityOnly(useType, currentUser);
|
||||
sql += " order by if(grouping = 'datatable', 'ZZZ', entity_name), entity_name";
|
||||
EntityNamesMapper mapper2 = new EntityNamesMapper();
|
||||
List<String> entityNames = this.jdbcTemplate.query(sql, mapper2, new Object[] {});
|
||||
final EntityNamesMapper mapper2 = new EntityNamesMapper();
|
||||
final List<String> entityNames = this.jdbcTemplate.query(sql, mapper2, new Object[] {});
|
||||
|
||||
Collection<ProcessingResultLookup> processingResults = null;
|
||||
if (useType.equals("audit")) {
|
||||
ProcessingResultsMapper mapper3 = new ProcessingResultsMapper();
|
||||
final ProcessingResultsMapper mapper3 = new ProcessingResultsMapper();
|
||||
processingResults = this.jdbcTemplate.query(mapper3.schema(), mapper3, new Object[] {});
|
||||
}
|
||||
|
||||
@@ -370,8 +375,8 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService {
|
||||
|
||||
@Override
|
||||
public ProcessingResultLookup mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException {
|
||||
Long id = JdbcSupport.getLong(rs, "id");
|
||||
String processingResult = rs.getString("processingResult");
|
||||
final Long id = JdbcSupport.getLong(rs, "id");
|
||||
final String processingResult = rs.getString("processingResult");
|
||||
|
||||
return new ProcessingResultLookup(id, processingResult);
|
||||
}
|
||||
|
||||
+7
-8
@@ -490,20 +490,20 @@ public class CommandWrapperBuilder {
|
||||
this.href = "/loans/" + loanId + "/charges/" + loanChargeId;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public CommandWrapperBuilder payLoanCharge(final Long loanId, final Long loanChargeId) {
|
||||
this.actionName = "PAY";
|
||||
this.entityName = "LOANCHARGE";
|
||||
this.entityId = loanChargeId;
|
||||
this.loanId = loanId;
|
||||
if(loanChargeId == null){
|
||||
if (loanChargeId == null) {
|
||||
this.href = "/loans/" + loanId;
|
||||
}else{
|
||||
this.href = "/loans/" + loanId + "/charges/" + loanChargeId;
|
||||
} else {
|
||||
this.href = "/loans/" + loanId + "/charges/" + loanChargeId;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public CommandWrapperBuilder deleteLoanCharge(final Long loanId, final Long loanChargeId) {
|
||||
this.actionName = "DELETE";
|
||||
this.entityName = "LOANCHARGE";
|
||||
@@ -866,7 +866,6 @@ public class CommandWrapperBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public CommandWrapperBuilder createAccountTransfer() {
|
||||
this.actionName = "CREATE";
|
||||
this.entityName = "ACCOUNTTRANSFER";
|
||||
@@ -941,7 +940,7 @@ public class CommandWrapperBuilder {
|
||||
this.href = "/savingsaccounts/" + accountId + "?command=applyAnnualFees";
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public CommandWrapperBuilder createSavingsAccountCharge(final Long savingsAccountId) {
|
||||
this.actionName = "CREATE";
|
||||
this.entityName = "SAVINGSACCOUNTCHARGE";
|
||||
@@ -978,7 +977,7 @@ public class CommandWrapperBuilder {
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public CommandWrapperBuilder deleteSavingsAccountCharge(final Long savingsAccountId, final Long savingsAccountChargeId) {
|
||||
this.actionName = "DELETE";
|
||||
this.entityName = "SAVINGSACCOUNTCHARGE";
|
||||
|
||||
+6
-6
@@ -47,7 +47,7 @@ public class PortfolioCommandSourceWritePlatformServiceImpl implements Portfolio
|
||||
|
||||
boolean isApprovedByChecker = false;
|
||||
// check if is update of own account details
|
||||
if (wrapper.isUpdateOfOwnUserDetails(context.authenticatedUser().getId())) {
|
||||
if (wrapper.isUpdateOfOwnUserDetails(this.context.authenticatedUser().getId())) {
|
||||
// then allow this operation to proceed.
|
||||
// maker checker doesnt mean anything here.
|
||||
isApprovedByChecker = true; // set to true in case permissions have
|
||||
@@ -56,7 +56,7 @@ public class PortfolioCommandSourceWritePlatformServiceImpl implements Portfolio
|
||||
} else {
|
||||
// if not user changing their own details - check user has
|
||||
// permission to perform specific task.
|
||||
context.authenticatedUser().validateHasPermissionTo(wrapper.getTaskPermissionName());
|
||||
this.context.authenticatedUser().validateHasPermissionTo(wrapper.getTaskPermissionName());
|
||||
}
|
||||
validateIsUpdateAllowed();
|
||||
|
||||
@@ -70,7 +70,7 @@ public class PortfolioCommandSourceWritePlatformServiceImpl implements Portfolio
|
||||
wrapper.getTransactionId(), wrapper.getHref(), wrapper.getProductId());
|
||||
|
||||
result = this.processAndLogCommandService.processAndLogCommand(wrapper, command, isApprovedByChecker);
|
||||
} catch (RollbackTransactionAsCommandIsNotApprovedByCheckerException e) {
|
||||
} catch (final RollbackTransactionAsCommandIsNotApprovedByCheckerException e) {
|
||||
|
||||
result = this.processAndLogCommandService.logCommand(e.getCommandSourceResult());
|
||||
}
|
||||
@@ -81,7 +81,7 @@ public class PortfolioCommandSourceWritePlatformServiceImpl implements Portfolio
|
||||
@Override
|
||||
public CommandProcessingResult approveEntry(final Long makerCheckerId) {
|
||||
|
||||
CommandSource commandSourceInput = validateMakerCheckerTransaction(makerCheckerId);
|
||||
final CommandSource commandSourceInput = validateMakerCheckerTransaction(makerCheckerId);
|
||||
validateIsUpdateAllowed();
|
||||
|
||||
final CommandWrapper wrapper = CommandWrapper.fromExistingCommand(makerCheckerId, commandSourceInput.getActionName(),
|
||||
@@ -115,13 +115,13 @@ public class PortfolioCommandSourceWritePlatformServiceImpl implements Portfolio
|
||||
if (commandSourceInput == null) { throw new CommandNotFoundException(makerCheckerId); }
|
||||
if (!(commandSourceInput.isMarkedAsAwaitingApproval())) { throw new CommandNotAwaitingApprovalException(makerCheckerId); }
|
||||
|
||||
context.authenticatedUser().validateHasCheckerPermissionTo(commandSourceInput.getPermissionCode());
|
||||
this.context.authenticatedUser().validateHasCheckerPermissionTo(commandSourceInput.getPermissionCode());
|
||||
|
||||
return commandSourceInput;
|
||||
}
|
||||
|
||||
private boolean validateIsUpdateAllowed() {
|
||||
return schedulerJobRunnerReadService.isUpdatesAllowed();
|
||||
return this.schedulerJobRunnerReadService.isUpdatesAllowed();
|
||||
|
||||
}
|
||||
}
|
||||
+6
-7
@@ -111,8 +111,7 @@ public class SynchronousCommandProcessingService implements CommandProcessingSer
|
||||
} else {
|
||||
throw new UnsupportedCommandException(wrapper.commandName());
|
||||
}
|
||||
}
|
||||
else if (wrapper.isConfigurationResource()) {
|
||||
} else if (wrapper.isConfigurationResource()) {
|
||||
handler = this.applicationContext.getBean("updateGlobalConfigurationCommandHandler", NewCommandSourceHandler.class);
|
||||
} else if (wrapper.isDatatableResource()) {
|
||||
if (wrapper.isCreateDatatable()) {
|
||||
@@ -442,7 +441,7 @@ public class SynchronousCommandProcessingService implements CommandProcessingSer
|
||||
handler = this.applicationContext.getBean("paySavingsAccountChargeCommandHandler", NewCommandSourceHandler.class);
|
||||
} else {
|
||||
throw new UnsupportedCommandException(wrapper.commandName());
|
||||
}
|
||||
}
|
||||
} else if (wrapper.isCalendarResource()) {
|
||||
if (wrapper.isCreate()) {
|
||||
handler = this.applicationContext.getBean("createCalendarCommandHandler", NewCommandSourceHandler.class);
|
||||
@@ -476,7 +475,7 @@ public class SynchronousCommandProcessingService implements CommandProcessingSer
|
||||
handler = this.applicationContext.getBean("unassignRoleCommandHandler", NewCommandSourceHandler.class);
|
||||
} else if (wrapper.isUpdateGroupRole()) {
|
||||
handler = this.applicationContext.getBean("updateGroupRoleCommandHandler", NewCommandSourceHandler.class);
|
||||
} else if (wrapper.isAssignStaff()) {
|
||||
} else if (wrapper.isAssignStaff()) {
|
||||
handler = this.applicationContext.getBean("assignGroupStaffCommandHandler", NewCommandSourceHandler.class);
|
||||
} else if (wrapper.isTransferClientsBetweenGroups()) {
|
||||
handler = this.applicationContext.getBean("transferClientsBetweenGroupsCommandHandler", NewCommandSourceHandler.class);
|
||||
@@ -534,9 +533,9 @@ public class SynchronousCommandProcessingService implements CommandProcessingSer
|
||||
}
|
||||
|
||||
} else if (wrapper.isXBRLMappingResource()) {
|
||||
if (wrapper.isUpdate()) {
|
||||
handler = this.applicationContext.getBean("updateTaxonomyMappingCommandHandler", NewCommandSourceHandler.class);
|
||||
} else {
|
||||
if (wrapper.isUpdate()) {
|
||||
handler = this.applicationContext.getBean("updateTaxonomyMappingCommandHandler", NewCommandSourceHandler.class);
|
||||
} else {
|
||||
throw new UnsupportedCommandException(wrapper.commandName());
|
||||
}
|
||||
} else if (wrapper.isHolidayResource()) {
|
||||
|
||||
Vendored
+3
-3
@@ -15,8 +15,7 @@ public class CacheEnumerations {
|
||||
}
|
||||
|
||||
public static EnumOptionData cacheType(final CacheType cacheType) {
|
||||
EnumOptionData optionData = new EnumOptionData(CacheType.INVALID.getValue().longValue(), CacheType.INVALID.getCode(),
|
||||
"Invalid");
|
||||
EnumOptionData optionData = new EnumOptionData(CacheType.INVALID.getValue().longValue(), CacheType.INVALID.getCode(), "Invalid");
|
||||
switch (cacheType) {
|
||||
case INVALID:
|
||||
optionData = new EnumOptionData(CacheType.INVALID.getValue().longValue(), CacheType.INVALID.getCode(), "Invalid");
|
||||
@@ -25,7 +24,8 @@ public class CacheEnumerations {
|
||||
optionData = new EnumOptionData(CacheType.NO_CACHE.getValue().longValue(), CacheType.NO_CACHE.getCode(), "No cache");
|
||||
break;
|
||||
case SINGLE_NODE:
|
||||
optionData = new EnumOptionData(CacheType.SINGLE_NODE.getValue().longValue(), CacheType.SINGLE_NODE.getCode(), "Single node");
|
||||
optionData = new EnumOptionData(CacheType.SINGLE_NODE.getValue().longValue(), CacheType.SINGLE_NODE.getCode(),
|
||||
"Single node");
|
||||
break;
|
||||
case MULTI_NODE:
|
||||
optionData = new EnumOptionData(CacheType.MULTI_NODE.getValue().longValue(), CacheType.MULTI_NODE.getCode(), "Multi node");
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ public class CacheWritePlatformServiceJpaRepositoryImpl implements CacheWritePla
|
||||
final Map<String, Object> changes = this.cacheService.switchToCache(ehCacheEnabled, toCacheType);
|
||||
|
||||
if (!changes.isEmpty()) {
|
||||
this.configurationDomainService.updateCache(toCacheType);
|
||||
this.configurationDomainService.updateCache(toCacheType);
|
||||
}
|
||||
|
||||
return changes;
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ import org.springframework.stereotype.Component;
|
||||
/**
|
||||
* At present this implementation of {@link CacheManager} just delegates to the
|
||||
* real {@link CacheManager} to use.
|
||||
*
|
||||
*
|
||||
* By default it is {@link NoOpCacheManager} but we can change that by checking
|
||||
* some persisted configuration in the database on startup and allow user to
|
||||
* switch implementation through UI/API
|
||||
|
||||
+3
-2
@@ -11,7 +11,8 @@ import java.util.Set;
|
||||
public class CodeConstants {
|
||||
|
||||
/***
|
||||
* Enum of all parameters passed in while creating/updating a code and code value
|
||||
* Enum of all parameters passed in while creating/updating a code and code
|
||||
* value
|
||||
***/
|
||||
public static enum CODEVALUE_JSON_INPUT_PARAMS {
|
||||
CODEVALUE_ID("id"), NAME("name"), POSITION("position");
|
||||
@@ -24,7 +25,7 @@ public class CodeConstants {
|
||||
|
||||
private static final Set<String> values = new HashSet<String>();
|
||||
static {
|
||||
for (CODEVALUE_JSON_INPUT_PARAMS type : CODEVALUE_JSON_INPUT_PARAMS.values()) {
|
||||
for (final CODEVALUE_JSON_INPUT_PARAMS type : CODEVALUE_JSON_INPUT_PARAMS.values()) {
|
||||
values.add(type.value);
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -77,7 +77,7 @@ public class CodeValuesApiResource {
|
||||
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
return this.toApiJsonSerializer.serialize(settings, codeValues, this.RESPONSE_DATA_PARAMETERS);
|
||||
}
|
||||
|
||||
|
||||
@GET
|
||||
@Path("{codeValueId}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@@ -112,7 +112,8 @@ public class CodeValuesApiResource {
|
||||
public String updateCodeValue(@PathParam("codeId") final Long codeId, @PathParam("codeValueId") final Long codeValueId,
|
||||
final String apiRequestBodyAsJson) {
|
||||
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder().updateCodeValue(codeId, codeValueId).withJson(apiRequestBodyAsJson).build();
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder().updateCodeValue(codeId, codeValueId)
|
||||
.withJson(apiRequestBodyAsJson).build();
|
||||
|
||||
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
|
||||
|
||||
+5
-5
@@ -69,12 +69,12 @@ public class CodesApiResource {
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String retrieveCodes(@Context final UriInfo uriInfo) {
|
||||
|
||||
context.authenticatedUser().validateHasReadPermission(resourceNameForPermissions);
|
||||
this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions);
|
||||
|
||||
final Collection<CodeData> codes = this.readPlatformService.retrieveAllCodes();
|
||||
|
||||
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
return this.toApiJsonSerializer.serialize(settings, codes, RESPONSE_DATA_PARAMETERS);
|
||||
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
return this.toApiJsonSerializer.serialize(settings, codes, this.RESPONSE_DATA_PARAMETERS);
|
||||
}
|
||||
|
||||
@POST
|
||||
@@ -97,8 +97,8 @@ public class CodesApiResource {
|
||||
|
||||
final CodeData code = this.readPlatformService.retrieveCode(codeId);
|
||||
|
||||
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
return this.toApiJsonSerializer.serialize(settings, code, RESPONSE_DATA_PARAMETERS);
|
||||
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
return this.toApiJsonSerializer.serialize(settings, code, this.RESPONSE_DATA_PARAMETERS);
|
||||
}
|
||||
|
||||
@PUT
|
||||
|
||||
+2
-2
@@ -27,8 +27,8 @@ public class CodeData implements Serializable {
|
||||
this.name = name;
|
||||
this.systemDefined = systemDefined;
|
||||
}
|
||||
|
||||
public Long getCodeId(){
|
||||
|
||||
public Long getCodeId() {
|
||||
return this.id;
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -10,7 +10,7 @@ import java.io.Serializable;
|
||||
/**
|
||||
* Immutable data object represent code-value data in system.
|
||||
*/
|
||||
public class CodeValueData implements Serializable{
|
||||
public class CodeValueData implements Serializable {
|
||||
|
||||
private final Long id;
|
||||
|
||||
@@ -35,6 +35,6 @@ public class CodeValueData implements Serializable{
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -59,7 +59,7 @@ public class Code extends AbstractPersistable<Long> {
|
||||
|
||||
public Map<String, Object> update(final JsonCommand command) {
|
||||
|
||||
if (systemDefined) { throw new SystemDefinedCodeCannotBeChangedException(); }
|
||||
if (this.systemDefined) { throw new SystemDefinedCodeCannotBeChangedException(); }
|
||||
|
||||
final Map<String, Object> actualChanges = new LinkedHashMap<String, Object>(1);
|
||||
|
||||
|
||||
+52
-64
@@ -22,85 +22,73 @@ import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.springframework.data.jpa.domain.AbstractPersistable;
|
||||
|
||||
@Entity
|
||||
@Table(name = "m_code_value", uniqueConstraints = { @UniqueConstraint(columnNames = {
|
||||
"code_id", "code_value" }, name = "code_value_duplicate") })
|
||||
@Table(name = "m_code_value", uniqueConstraints = { @UniqueConstraint(columnNames = { "code_id", "code_value" }, name = "code_value_duplicate") })
|
||||
public class CodeValue extends AbstractPersistable<Long> {
|
||||
|
||||
@Column(name = "code_value", length = 100)
|
||||
private String label;
|
||||
@Column(name = "code_value", length = 100)
|
||||
private String label;
|
||||
|
||||
@Column(name = "order_position")
|
||||
private int position;
|
||||
@Column(name = "order_position")
|
||||
private int position;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "code_id", nullable = false)
|
||||
private Code code;
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "code_id", nullable = false)
|
||||
private Code code;
|
||||
|
||||
public static CodeValue createNew(final Code code, final String label,
|
||||
final int position) {
|
||||
return new CodeValue(code, label, position);
|
||||
}
|
||||
public static CodeValue createNew(final Code code, final String label, final int position) {
|
||||
return new CodeValue(code, label, position);
|
||||
}
|
||||
|
||||
protected CodeValue() {
|
||||
//
|
||||
}
|
||||
protected CodeValue() {
|
||||
//
|
||||
}
|
||||
|
||||
private CodeValue(final Code code, final String label, final int position) {
|
||||
this.code = code;
|
||||
this.label = StringUtils.defaultIfEmpty(label, null);
|
||||
this.position = position;
|
||||
}
|
||||
private CodeValue(final Code code, final String label, final int position) {
|
||||
this.code = code;
|
||||
this.label = StringUtils.defaultIfEmpty(label, null);
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
public String label() {
|
||||
return this.label;
|
||||
}
|
||||
public String label() {
|
||||
return this.label;
|
||||
}
|
||||
|
||||
public int position() {
|
||||
return this.position;
|
||||
}
|
||||
public int position() {
|
||||
return this.position;
|
||||
}
|
||||
|
||||
public static CodeValue fromJson(final Code code, final JsonCommand command) {
|
||||
public static CodeValue fromJson(final Code code, final JsonCommand command) {
|
||||
|
||||
final String label = command
|
||||
.stringValueOfParameterNamed(CODEVALUE_JSON_INPUT_PARAMS.NAME
|
||||
.getValue());
|
||||
Integer position = command
|
||||
.integerValueSansLocaleOfParameterNamed(CODEVALUE_JSON_INPUT_PARAMS.POSITION
|
||||
.getValue());
|
||||
if (position == null) {
|
||||
position = new Integer(0);
|
||||
}
|
||||
return new CodeValue(code, label, position.intValue());
|
||||
}
|
||||
final String label = command.stringValueOfParameterNamed(CODEVALUE_JSON_INPUT_PARAMS.NAME.getValue());
|
||||
Integer position = command.integerValueSansLocaleOfParameterNamed(CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue());
|
||||
if (position == null) {
|
||||
position = new Integer(0);
|
||||
}
|
||||
return new CodeValue(code, label, position.intValue());
|
||||
}
|
||||
|
||||
public Map<String, Object> update(final JsonCommand command) {
|
||||
public Map<String, Object> update(final JsonCommand command) {
|
||||
|
||||
final Map<String, Object> actualChanges = new LinkedHashMap<String, Object>(
|
||||
2);
|
||||
final Map<String, Object> actualChanges = new LinkedHashMap<String, Object>(2);
|
||||
|
||||
final String labelParamName = CODEVALUE_JSON_INPUT_PARAMS.NAME
|
||||
.getValue();
|
||||
if (command.isChangeInStringParameterNamed(labelParamName, this.label)) {
|
||||
final String newValue = command
|
||||
.stringValueOfParameterNamed(labelParamName);
|
||||
actualChanges.put(labelParamName, newValue);
|
||||
this.label = StringUtils.defaultIfEmpty(newValue, null);
|
||||
}
|
||||
final String labelParamName = CODEVALUE_JSON_INPUT_PARAMS.NAME.getValue();
|
||||
if (command.isChangeInStringParameterNamed(labelParamName, this.label)) {
|
||||
final String newValue = command.stringValueOfParameterNamed(labelParamName);
|
||||
actualChanges.put(labelParamName, newValue);
|
||||
this.label = StringUtils.defaultIfEmpty(newValue, null);
|
||||
}
|
||||
|
||||
final String positionParamName = CODEVALUE_JSON_INPUT_PARAMS.POSITION
|
||||
.getValue();
|
||||
if (command.isChangeInIntegerSansLocaleParameterNamed(
|
||||
positionParamName, this.position)) {
|
||||
final Integer newValue = command
|
||||
.integerValueSansLocaleOfParameterNamed(positionParamName);
|
||||
actualChanges.put(positionParamName, newValue);
|
||||
this.position = newValue.intValue();
|
||||
}
|
||||
final String positionParamName = CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue();
|
||||
if (command.isChangeInIntegerSansLocaleParameterNamed(positionParamName, this.position)) {
|
||||
final Integer newValue = command.integerValueSansLocaleOfParameterNamed(positionParamName);
|
||||
actualChanges.put(positionParamName, newValue);
|
||||
this.position = newValue.intValue();
|
||||
}
|
||||
|
||||
return actualChanges;
|
||||
}
|
||||
return actualChanges;
|
||||
}
|
||||
|
||||
public CodeValueData toData() {
|
||||
return CodeValueData.instance(getId(), this.label, this.position);
|
||||
}
|
||||
public CodeValueData toData() {
|
||||
return CodeValueData.instance(getId(), this.label, this.position);
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -8,7 +8,8 @@ package org.mifosplatform.infrastructure.codes.exception;
|
||||
import org.mifosplatform.infrastructure.core.exception.AbstractPlatformDomainRuleException;
|
||||
|
||||
/**
|
||||
* A {@link AbstractPlatformDomainRuleException} thrown when someone attempts to update or delete a system defined code.
|
||||
* A {@link AbstractPlatformDomainRuleException} thrown when someone attempts to
|
||||
* update or delete a system defined code.
|
||||
*/
|
||||
public class SystemDefinedCodeCannotBeChangedException extends AbstractPlatformDomainRuleException {
|
||||
|
||||
|
||||
+7
-7
@@ -46,14 +46,14 @@ public final class CodeCommandFromApiJsonDeserializer {
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
|
||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, supportedParameters);
|
||||
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, this.supportedParameters);
|
||||
|
||||
final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
|
||||
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("code");
|
||||
|
||||
final JsonElement element = fromApiJsonHelper.parse(json);
|
||||
final JsonElement element = this.fromApiJsonHelper.parse(json);
|
||||
|
||||
final String name = fromApiJsonHelper.extractStringNamed("name", element);
|
||||
final String name = this.fromApiJsonHelper.extractStringNamed("name", element);
|
||||
baseDataValidator.reset().parameter("name").value(name).notBlank().notExceedingLengthOf(100);
|
||||
|
||||
throwExceptionIfValidationWarningsExist(dataValidationErrors);
|
||||
@@ -63,14 +63,14 @@ public final class CodeCommandFromApiJsonDeserializer {
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
|
||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, supportedParameters);
|
||||
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, this.supportedParameters);
|
||||
|
||||
final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
|
||||
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("code");
|
||||
|
||||
final JsonElement element = fromApiJsonHelper.parse(json);
|
||||
if (fromApiJsonHelper.parameterExists("name", element)) {
|
||||
final String name = fromApiJsonHelper.extractStringNamed("name", element);
|
||||
final JsonElement element = this.fromApiJsonHelper.parse(json);
|
||||
if (this.fromApiJsonHelper.parameterExists("name", element)) {
|
||||
final String name = this.fromApiJsonHelper.extractStringNamed("name", element);
|
||||
baseDataValidator.reset().parameter("name").value(name).notBlank().notExceedingLengthOf(100);
|
||||
}
|
||||
|
||||
|
||||
+4
-6
@@ -56,9 +56,8 @@ public final class CodeValueCommandFromApiJsonDeserializer {
|
||||
baseDataValidator.reset().parameter(CODEVALUE_JSON_INPUT_PARAMS.NAME.getValue()).value(name).notBlank().notExceedingLengthOf(100);
|
||||
|
||||
if (this.fromApiJsonHelper.parameterExists(CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue(), element)) {
|
||||
//Validate input value is a valid Integer
|
||||
this.fromApiJsonHelper.extractIntegerSansLocaleNamed(CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue(),
|
||||
element);
|
||||
// Validate input value is a valid Integer
|
||||
this.fromApiJsonHelper.extractIntegerSansLocaleNamed(CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue(), element);
|
||||
}
|
||||
|
||||
throwExceptionIfValidationWarningsExist(dataValidationErrors);
|
||||
@@ -82,9 +81,8 @@ public final class CodeValueCommandFromApiJsonDeserializer {
|
||||
}
|
||||
|
||||
if (this.fromApiJsonHelper.parameterExists(CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue(), element)) {
|
||||
//Validate input value is a valid Integer
|
||||
this.fromApiJsonHelper.extractIntegerSansLocaleNamed(CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue(),
|
||||
element);
|
||||
// Validate input value is a valid Integer
|
||||
this.fromApiJsonHelper.extractIntegerSansLocaleNamed(CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue(), element);
|
||||
}
|
||||
|
||||
throwExceptionIfValidationWarningsExist(dataValidationErrors);
|
||||
|
||||
+1
-1
@@ -14,6 +14,6 @@ public interface CodeReadPlatformService {
|
||||
Collection<CodeData> retrieveAllCodes();
|
||||
|
||||
CodeData retrieveCode(Long codeId);
|
||||
|
||||
|
||||
CodeData retriveCode(String codeName);
|
||||
}
|
||||
|
||||
+6
-6
@@ -52,7 +52,7 @@ public class CodeReadPlatformServiceImpl implements CodeReadPlatformService {
|
||||
@Override
|
||||
@Cacheable(value = "codes", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat('CD')")
|
||||
public Collection<CodeData> retrieveAllCodes() {
|
||||
context.authenticatedUser();
|
||||
this.context.authenticatedUser();
|
||||
|
||||
final CodeMapper rm = new CodeMapper();
|
||||
final String sql = "select " + rm.schema() + " order by c.code_name";
|
||||
@@ -63,27 +63,27 @@ public class CodeReadPlatformServiceImpl implements CodeReadPlatformService {
|
||||
@Override
|
||||
public CodeData retrieveCode(final Long codeId) {
|
||||
try {
|
||||
context.authenticatedUser();
|
||||
this.context.authenticatedUser();
|
||||
|
||||
final CodeMapper rm = new CodeMapper();
|
||||
final String sql = "select " + rm.schema() + " where c.id = ?";
|
||||
|
||||
return this.jdbcTemplate.queryForObject(sql, rm, new Object[] { codeId });
|
||||
} catch (EmptyResultDataAccessException e) {
|
||||
} catch (final EmptyResultDataAccessException e) {
|
||||
throw new CodeNotFoundException(codeId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodeData retriveCode(String codeName) {
|
||||
public CodeData retriveCode(final String codeName) {
|
||||
try {
|
||||
context.authenticatedUser();
|
||||
this.context.authenticatedUser();
|
||||
|
||||
final CodeMapper rm = new CodeMapper();
|
||||
final String sql = "select " + rm.schema() + " where c.code_name = ?";
|
||||
|
||||
return this.jdbcTemplate.queryForObject(sql, rm, new Object[] { codeName });
|
||||
} catch (EmptyResultDataAccessException e) {
|
||||
} catch (final EmptyResultDataAccessException e) {
|
||||
throw new CodeNotFoundException(codeName);
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -51,7 +51,7 @@ public class CodeValueReadPlatformServiceImpl implements CodeValueReadPlatformSe
|
||||
@Override
|
||||
public Collection<CodeValueData> retrieveCodeValuesByCode(final String code) {
|
||||
|
||||
context.authenticatedUser();
|
||||
this.context.authenticatedUser();
|
||||
|
||||
final CodeValueDataMapper rm = new CodeValueDataMapper();
|
||||
final String sql = "select " + rm.schema() + "where c.code_name like ? order by position";
|
||||
@@ -61,9 +61,9 @@ public class CodeValueReadPlatformServiceImpl implements CodeValueReadPlatformSe
|
||||
|
||||
@Override
|
||||
@Cacheable(value = "code_values", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat(#codeId+'cv')")
|
||||
public Collection<CodeValueData> retrieveAllCodeValues(Long codeId) {
|
||||
public Collection<CodeValueData> retrieveAllCodeValues(final Long codeId) {
|
||||
|
||||
context.authenticatedUser();
|
||||
this.context.authenticatedUser();
|
||||
|
||||
final CodeValueDataMapper rm = new CodeValueDataMapper();
|
||||
final String sql = "select " + rm.schema() + "where cv.code_id = ? order by position";
|
||||
@@ -72,9 +72,9 @@ public class CodeValueReadPlatformServiceImpl implements CodeValueReadPlatformSe
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodeValueData retrieveCodeValue(Long codeValueId) {
|
||||
public CodeValueData retrieveCodeValue(final Long codeValueId) {
|
||||
|
||||
context.authenticatedUser();
|
||||
this.context.authenticatedUser();
|
||||
|
||||
final CodeValueDataMapper rm = new CodeValueDataMapper();
|
||||
final String sql = "select " + rm.schema() + "where cv.id = ? order by position";
|
||||
|
||||
+4
-4
@@ -68,7 +68,7 @@ public class CodeValueWritePlatformServiceJpaRepositoryImpl implements CodeValue
|
||||
.withCommandId(command.commandId()) //
|
||||
.withEntityId(codeValue.getId()) //
|
||||
.build();
|
||||
} catch (DataIntegrityViolationException dve) {
|
||||
} catch (final DataIntegrityViolationException dve) {
|
||||
handleCodeValueDataIntegrityIssues(command, dve);
|
||||
return new CommandProcessingResultBuilder() //
|
||||
.withCommandId(command.commandId()) //
|
||||
@@ -115,7 +115,7 @@ public class CodeValueWritePlatformServiceJpaRepositoryImpl implements CodeValue
|
||||
.withEntityId(codeValueId) //
|
||||
.with(changes) //
|
||||
.build();
|
||||
} catch (DataIntegrityViolationException dve) {
|
||||
} catch (final DataIntegrityViolationException dve) {
|
||||
handleCodeValueDataIntegrityIssues(command, dve);
|
||||
return new CommandProcessingResultBuilder() //
|
||||
.withCommandId(command.commandId()) //
|
||||
@@ -137,7 +137,7 @@ public class CodeValueWritePlatformServiceJpaRepositoryImpl implements CodeValue
|
||||
|
||||
final CodeValue codeValueToDelete = this.codeValueRepositoryWrapper.findOneWithNotFoundDetection(codeValueId);
|
||||
|
||||
boolean removed = code.remove(codeValueToDelete);
|
||||
final boolean removed = code.remove(codeValueToDelete);
|
||||
if (removed) {
|
||||
this.codeRepository.saveAndFlush(code);
|
||||
}
|
||||
@@ -145,7 +145,7 @@ public class CodeValueWritePlatformServiceJpaRepositoryImpl implements CodeValue
|
||||
return new CommandProcessingResultBuilder() //
|
||||
.withEntityId(codeValueId) //
|
||||
.build();
|
||||
} catch (DataIntegrityViolationException dve) {
|
||||
} catch (final DataIntegrityViolationException dve) {
|
||||
logger.error(dve.getMessage(), dve);
|
||||
throw new PlatformDataIntegrityException("error.msg.code.value.unknown.data.integrity.issue",
|
||||
"Unknown data integrity issue with resource: " + dve.getMostSpecificCause().getMessage());
|
||||
|
||||
+7
-7
@@ -48,7 +48,7 @@ public class CodeWritePlatformServiceJpaRepositoryImpl implements CodeWritePlatf
|
||||
public CommandProcessingResult createCode(final JsonCommand command) {
|
||||
|
||||
try {
|
||||
context.authenticatedUser();
|
||||
this.context.authenticatedUser();
|
||||
|
||||
this.fromApiJsonDeserializer.validateForCreate(command.json());
|
||||
|
||||
@@ -56,7 +56,7 @@ public class CodeWritePlatformServiceJpaRepositoryImpl implements CodeWritePlatf
|
||||
this.codeRepository.save(code);
|
||||
|
||||
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(code.getId()).build();
|
||||
} catch (DataIntegrityViolationException dve) {
|
||||
} catch (final DataIntegrityViolationException dve) {
|
||||
handleCodeDataIntegrityIssues(command, dve);
|
||||
return CommandProcessingResult.empty();
|
||||
}
|
||||
@@ -68,7 +68,7 @@ public class CodeWritePlatformServiceJpaRepositoryImpl implements CodeWritePlatf
|
||||
public CommandProcessingResult updateCode(final Long codeId, final JsonCommand command) {
|
||||
|
||||
try {
|
||||
context.authenticatedUser();
|
||||
this.context.authenticatedUser();
|
||||
|
||||
this.fromApiJsonDeserializer.validateForUpdate(command.json());
|
||||
|
||||
@@ -84,7 +84,7 @@ public class CodeWritePlatformServiceJpaRepositoryImpl implements CodeWritePlatf
|
||||
.withEntityId(codeId) //
|
||||
.with(changes) //
|
||||
.build();
|
||||
} catch (DataIntegrityViolationException dve) {
|
||||
} catch (final DataIntegrityViolationException dve) {
|
||||
handleCodeDataIntegrityIssues(command, dve);
|
||||
return null;
|
||||
}
|
||||
@@ -95,7 +95,7 @@ public class CodeWritePlatformServiceJpaRepositoryImpl implements CodeWritePlatf
|
||||
@CacheEvict(value = "codes", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat('cv')")
|
||||
public CommandProcessingResult deleteCode(final Long codeId) {
|
||||
|
||||
context.authenticatedUser();
|
||||
this.context.authenticatedUser();
|
||||
|
||||
final Code code = retrieveCodeBy(codeId);
|
||||
if (code.isSystemDefined()) { throw new SystemDefinedCodeCannotBeChangedException(); }
|
||||
@@ -103,7 +103,7 @@ public class CodeWritePlatformServiceJpaRepositoryImpl implements CodeWritePlatf
|
||||
try {
|
||||
this.codeRepository.delete(code);
|
||||
this.codeRepository.flush();
|
||||
} catch (DataIntegrityViolationException e) {
|
||||
} catch (final DataIntegrityViolationException e) {
|
||||
throw new PlatformDataIntegrityException("error.msg.cund.unknown.data.integrity.issue",
|
||||
"Unknown data integrity issue with resource: " + e.getMostSpecificCause());
|
||||
}
|
||||
@@ -121,7 +121,7 @@ public class CodeWritePlatformServiceJpaRepositoryImpl implements CodeWritePlatf
|
||||
* is.
|
||||
*/
|
||||
private void handleCodeDataIntegrityIssues(final JsonCommand command, final DataIntegrityViolationException dve) {
|
||||
Throwable realCause = dve.getMostSpecificCause();
|
||||
final Throwable realCause = dve.getMostSpecificCause();
|
||||
if (realCause.getMessage().contains("code_name")) {
|
||||
final String name = command.stringValueOfParameterNamed("name");
|
||||
throw new PlatformDataIntegrityException("error.msg.code.duplicate.name", "A code with name '" + name + "' already exists",
|
||||
|
||||
+5
-5
@@ -68,12 +68,12 @@ public class GlobalConfigurationApiResource {
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String retrieveConfiguration(@Context final UriInfo uriInfo) {
|
||||
|
||||
context.authenticatedUser().validateHasReadPermission(resourceNameForPermissions);
|
||||
this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions);
|
||||
|
||||
final GlobalConfigurationData configurationData = this.readPlatformService.retrieveGlobalConfiguration();
|
||||
|
||||
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
return this.toApiJsonSerializer.serialize(settings, configurationData, RESPONSE_DATA_PARAMETERS);
|
||||
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
return this.toApiJsonSerializer.serialize(settings, configurationData, this.RESPONSE_DATA_PARAMETERS);
|
||||
}
|
||||
|
||||
@PUT
|
||||
@@ -81,9 +81,9 @@ public class GlobalConfigurationApiResource {
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String updateConfiguration(@Context final UriInfo uriInfo) {
|
||||
|
||||
Map<String, String> configurationParameters = ApiParameterHelper.asMap(uriInfo.getQueryParameters());
|
||||
final Map<String, String> configurationParameters = ApiParameterHelper.asMap(uriInfo.getQueryParameters());
|
||||
|
||||
Map<String, Object> globalConfiguration = new HashMap<String, Object>();
|
||||
final Map<String, Object> globalConfiguration = new HashMap<String, Object>();
|
||||
globalConfiguration.put("globalConfiguration", configurationParameters);
|
||||
|
||||
final String apiRequestJson = this.toApiJsonSerializer.serialize(globalConfiguration);
|
||||
|
||||
+2
-2
@@ -11,9 +11,9 @@ package org.mifosplatform.infrastructure.configuration.data;
|
||||
public class GlobalConfigurationPropertyData {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private String name;
|
||||
private final String name;
|
||||
@SuppressWarnings("unused")
|
||||
private boolean enabled;
|
||||
private final boolean enabled;
|
||||
|
||||
public GlobalConfigurationPropertyData(final String name, final boolean enabled) {
|
||||
this.name = name;
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ public class S3CredentialsData {
|
||||
private final String accessKey;
|
||||
private final String secretKey;
|
||||
|
||||
public S3CredentialsData(String bucketName, String accessKey, String secretKey) {
|
||||
public S3CredentialsData(final String bucketName, final String accessKey, final String secretKey) {
|
||||
this.bucketName = bucketName;
|
||||
this.accessKey = accessKey;
|
||||
this.secretKey = secretKey;
|
||||
|
||||
+8
@@ -10,12 +10,20 @@ import org.mifosplatform.infrastructure.cache.domain.CacheType;
|
||||
public interface ConfigurationDomainService {
|
||||
|
||||
boolean isMakerCheckerEnabledForTask(String taskPermissionCode);
|
||||
|
||||
boolean isAmazonS3Enabled();
|
||||
|
||||
boolean isRescheduleFutureRepaymentsEnabled();
|
||||
|
||||
boolean isRescheduleRepaymentsOnHolidaysEnabled();
|
||||
|
||||
boolean allowTransactionsOnHolidayEnabled();
|
||||
|
||||
boolean allowTransactionsOnNonWorkingDayEnabled();
|
||||
|
||||
boolean isConstraintApproachEnabledForDatatables();
|
||||
|
||||
boolean isEhcacheEnabled();
|
||||
|
||||
void updateCache(CacheType cacheType);
|
||||
}
|
||||
+12
-8
@@ -7,8 +7,8 @@ package org.mifosplatform.infrastructure.configuration.domain;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.mifosplatform.infrastructure.cache.domain.CacheType;
|
||||
import org.mifosplatform.infrastructure.cache.domain.PlatformCacheRepository;
|
||||
import org.mifosplatform.infrastructure.cache.domain.PlatformCache;
|
||||
import org.mifosplatform.infrastructure.cache.domain.PlatformCacheRepository;
|
||||
import org.mifosplatform.infrastructure.configuration.exception.GlobalConfigurationPropertyNotFoundException;
|
||||
import org.mifosplatform.useradministration.domain.Permission;
|
||||
import org.mifosplatform.useradministration.domain.PermissionRepository;
|
||||
@@ -26,8 +26,7 @@ public class ConfigurationDomainServiceJpa implements ConfigurationDomainService
|
||||
|
||||
@Autowired
|
||||
public ConfigurationDomainServiceJpa(final PermissionRepository permissionRepository,
|
||||
final GlobalConfigurationRepository globalConfigurationRepository,
|
||||
final PlatformCacheRepository cacheTypeRepository) {
|
||||
final GlobalConfigurationRepository globalConfigurationRepository, final PlatformCacheRepository cacheTypeRepository) {
|
||||
this.permissionRepository = permissionRepository;
|
||||
this.globalConfigurationRepository = globalConfigurationRepository;
|
||||
this.cacheTypeRepository = cacheTypeRepository;
|
||||
@@ -48,20 +47,24 @@ public class ConfigurationDomainServiceJpa implements ConfigurationDomainService
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAmazonS3Enabled(){
|
||||
public boolean isAmazonS3Enabled() {
|
||||
return this.globalConfigurationRepository.findOneByName("amazon-S3").isEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRescheduleFutureRepaymentsEnabled() {
|
||||
final String rescheduleRepaymentsConfigurationProperty = "reschedule-future-repayments";
|
||||
final GlobalConfigurationProperty property = this.globalConfigurationRepository.findOneByName(rescheduleRepaymentsConfigurationProperty);
|
||||
final GlobalConfigurationProperty property = this.globalConfigurationRepository
|
||||
.findOneByName(rescheduleRepaymentsConfigurationProperty);
|
||||
if (property == null) { throw new GlobalConfigurationPropertyNotFoundException(rescheduleRepaymentsConfigurationProperty); }
|
||||
return property.isEnabled();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.mifosplatform.infrastructure.configuration.domain.ConfigurationDomainService#isHolidaysEnabled()
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.mifosplatform.infrastructure.configuration.domain.
|
||||
* ConfigurationDomainService#isHolidaysEnabled()
|
||||
*/
|
||||
@Override
|
||||
public boolean isRescheduleRepaymentsOnHolidaysEnabled() {
|
||||
@@ -82,7 +85,8 @@ public class ConfigurationDomainServiceJpa implements ConfigurationDomainService
|
||||
@Override
|
||||
public boolean allowTransactionsOnNonWorkingDayEnabled() {
|
||||
final String allowTransactionsOnNonWorkingDayProperty = "allow-transactions-on-non_workingday";
|
||||
final GlobalConfigurationProperty property = this.globalConfigurationRepository.findOneByName(allowTransactionsOnNonWorkingDayProperty);
|
||||
final GlobalConfigurationProperty property = this.globalConfigurationRepository
|
||||
.findOneByName(allowTransactionsOnNonWorkingDayProperty);
|
||||
if (property == null) { throw new GlobalConfigurationPropertyNotFoundException(allowTransactionsOnNonWorkingDayProperty); }
|
||||
return property.isEnabled();
|
||||
}
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ public class GlobalConfigurationProperty extends AbstractPersistable<Long> {
|
||||
this.name = name;
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
|
||||
public boolean isEnabled() {
|
||||
return this.enabled;
|
||||
}
|
||||
|
||||
+2
-2
@@ -47,8 +47,8 @@ public final class GlobalConfigurationCommandFromApiJsonDeserializer extends
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
|
||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, supportedParameters);
|
||||
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, this.supportedParameters);
|
||||
|
||||
return fromApiJsonHelper.fromJson(json, UpdateGlobalConfigurationCommand.class);
|
||||
return this.fromApiJsonHelper.fromJson(json, UpdateGlobalConfigurationCommand.class);
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -30,16 +30,16 @@ public class ConfigurationReadPlatformServiceImpl implements ConfigurationReadPl
|
||||
this.context = context;
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
|
||||
rm = new GlobalConfigurationRowMapper();
|
||||
this.rm = new GlobalConfigurationRowMapper();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GlobalConfigurationData retrieveGlobalConfiguration() {
|
||||
|
||||
context.authenticatedUser();
|
||||
this.context.authenticatedUser();
|
||||
|
||||
final String sql = "SELECT c.name, c.enabled FROM c_configuration c order by c.id";
|
||||
final List<GlobalConfigurationPropertyData> globalConfiguration = this.jdbcTemplate.query(sql, rm, new Object[] {});
|
||||
final List<GlobalConfigurationPropertyData> globalConfiguration = this.jdbcTemplate.query(sql, this.rm, new Object[] {});
|
||||
|
||||
return new GlobalConfigurationData(globalConfiguration);
|
||||
}
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ public class ExternalServicesReadPlatformServiceImpl implements ExternalServices
|
||||
private static final class S3CredentialsDataExtractor implements ResultSetExtractor<S3CredentialsData> {
|
||||
|
||||
@Override
|
||||
public S3CredentialsData extractData(ResultSet rs) throws SQLException, DataAccessException {
|
||||
public S3CredentialsData extractData(final ResultSet rs) throws SQLException, DataAccessException {
|
||||
String accessKey = null;
|
||||
String bucketName = null;
|
||||
String secretKey = null;
|
||||
|
||||
+14
-13
@@ -30,7 +30,8 @@ public class GlobalConfigurationWritePlatformServiceJpaRepositoryImpl implements
|
||||
|
||||
@Autowired
|
||||
public GlobalConfigurationWritePlatformServiceJpaRepositoryImpl(final PlatformSecurityContext context,
|
||||
final GlobalConfigurationRepository codeRepository, final GlobalConfigurationCommandFromApiJsonDeserializer fromApiJsonDeserializer) {
|
||||
final GlobalConfigurationRepository codeRepository,
|
||||
final GlobalConfigurationCommandFromApiJsonDeserializer fromApiJsonDeserializer) {
|
||||
this.context = context;
|
||||
this.repository = codeRepository;
|
||||
this.fromApiJsonDeserializer = fromApiJsonDeserializer;
|
||||
@@ -40,30 +41,30 @@ public class GlobalConfigurationWritePlatformServiceJpaRepositoryImpl implements
|
||||
@Override
|
||||
public CommandProcessingResult update(final JsonCommand command) {
|
||||
|
||||
context.authenticatedUser();
|
||||
|
||||
this.context.authenticatedUser();
|
||||
|
||||
final UpdateGlobalConfigurationCommand configurationCommand = this.fromApiJsonDeserializer.commandFromApiJson(command.json());
|
||||
|
||||
|
||||
final Map<String, Boolean> params = configurationCommand.getGlobalConfiguration();
|
||||
|
||||
|
||||
final Map<String, Object> changes = new LinkedHashMap<String, Object>(params.size());
|
||||
final Map<String, Boolean> propertiesMap = new LinkedHashMap<String, Boolean>(1);
|
||||
for (String propertyName : params.keySet()) {
|
||||
for (final String propertyName : params.keySet()) {
|
||||
final GlobalConfigurationProperty property = retrieveBy(propertyName);
|
||||
|
||||
Boolean value = params.get(propertyName);
|
||||
boolean updated = property.updateTo(value);
|
||||
|
||||
|
||||
final Boolean value = params.get(propertyName);
|
||||
final boolean updated = property.updateTo(value);
|
||||
|
||||
if (updated) {
|
||||
propertiesMap.put(propertyName, value);
|
||||
propertiesMap.put(propertyName, value);
|
||||
this.repository.save(property);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!propertiesMap.isEmpty()) {
|
||||
changes.put("globalConfiguration", propertiesMap);
|
||||
}
|
||||
|
||||
|
||||
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).with(changes).build();
|
||||
}
|
||||
|
||||
|
||||
+16
-16
@@ -58,7 +58,7 @@ public class ApiParameterHelper {
|
||||
public static boolean prettyPrint(final MultivaluedMap<String, String> queryParams) {
|
||||
boolean prettyPrint = false;
|
||||
if (queryParams.getFirst("pretty") != null) {
|
||||
String prettyPrintValue = queryParams.getFirst("pretty");
|
||||
final String prettyPrintValue = queryParams.getFirst("pretty");
|
||||
prettyPrint = "true".equalsIgnoreCase(prettyPrintValue);
|
||||
}
|
||||
return prettyPrint;
|
||||
@@ -67,7 +67,7 @@ public class ApiParameterHelper {
|
||||
public static Locale extractLocale(final MultivaluedMap<String, String> queryParams) {
|
||||
Locale locale = null;
|
||||
if (queryParams.getFirst("locale") != null) {
|
||||
String localeAsString = queryParams.getFirst("locale");
|
||||
final String localeAsString = queryParams.getFirst("locale");
|
||||
locale = JsonParserHelper.localeFromString(localeAsString);
|
||||
}
|
||||
return locale;
|
||||
@@ -76,7 +76,7 @@ public class ApiParameterHelper {
|
||||
public static boolean exportCsv(final MultivaluedMap<String, String> queryParams) {
|
||||
boolean exportCsv = false;
|
||||
if (queryParams.getFirst("exportCSV") != null) {
|
||||
String exportCsvValue = queryParams.getFirst("exportCSV");
|
||||
final String exportCsvValue = queryParams.getFirst("exportCSV");
|
||||
exportCsv = "true".equalsIgnoreCase(exportCsvValue);
|
||||
}
|
||||
return exportCsv;
|
||||
@@ -85,7 +85,7 @@ public class ApiParameterHelper {
|
||||
public static boolean exportPdf(final MultivaluedMap<String, String> queryParams) {
|
||||
boolean exportPDF = false;
|
||||
if (queryParams.getFirst("exportPDF") != null) {
|
||||
String exportPdfValue = queryParams.getFirst("exportPDF");
|
||||
final String exportPdfValue = queryParams.getFirst("exportPDF");
|
||||
exportPDF = "true".equalsIgnoreCase(exportPdfValue);
|
||||
}
|
||||
return exportPDF;
|
||||
@@ -94,7 +94,7 @@ public class ApiParameterHelper {
|
||||
public static boolean parameterType(final MultivaluedMap<String, String> queryParams) {
|
||||
boolean parameterType = false;
|
||||
if (queryParams.getFirst("parameterType") != null) {
|
||||
String parameterTypeValue = queryParams.getFirst("parameterType");
|
||||
final String parameterTypeValue = queryParams.getFirst("parameterType");
|
||||
parameterType = "true".equalsIgnoreCase(parameterTypeValue);
|
||||
}
|
||||
return parameterType;
|
||||
@@ -103,7 +103,7 @@ public class ApiParameterHelper {
|
||||
public static boolean template(final MultivaluedMap<String, String> queryParams) {
|
||||
boolean template = false;
|
||||
if (queryParams.getFirst("template") != null) {
|
||||
String prettyPrintValue = queryParams.getFirst("template");
|
||||
final String prettyPrintValue = queryParams.getFirst("template");
|
||||
template = "true".equalsIgnoreCase(prettyPrintValue);
|
||||
}
|
||||
return template;
|
||||
@@ -112,7 +112,7 @@ public class ApiParameterHelper {
|
||||
public static boolean makerCheckerable(final MultivaluedMap<String, String> queryParams) {
|
||||
boolean makerCheckerable = false;
|
||||
if (queryParams.getFirst("makerCheckerable") != null) {
|
||||
String prettyPrintValue = queryParams.getFirst("makerCheckerable");
|
||||
final String prettyPrintValue = queryParams.getFirst("makerCheckerable");
|
||||
makerCheckerable = "true".equalsIgnoreCase(prettyPrintValue);
|
||||
}
|
||||
return makerCheckerable;
|
||||
@@ -121,7 +121,7 @@ public class ApiParameterHelper {
|
||||
public static boolean includeJson(final MultivaluedMap<String, String> queryParams) {
|
||||
boolean includeJson = false;
|
||||
if (queryParams.getFirst("includeJson") != null) {
|
||||
String includeJsonValue = queryParams.getFirst("includeJson");
|
||||
final String includeJsonValue = queryParams.getFirst("includeJson");
|
||||
includeJson = "true".equalsIgnoreCase(includeJsonValue);
|
||||
}
|
||||
return includeJson;
|
||||
@@ -130,28 +130,28 @@ public class ApiParameterHelper {
|
||||
public static boolean genericResultSet(final MultivaluedMap<String, String> queryParams) {
|
||||
boolean genericResultSet = false;
|
||||
if (queryParams.getFirst("genericResultSet") != null) {
|
||||
String genericResultSetValue = queryParams.getFirst("genericResultSet");
|
||||
final String genericResultSetValue = queryParams.getFirst("genericResultSet");
|
||||
genericResultSet = "true".equalsIgnoreCase(genericResultSetValue);
|
||||
}
|
||||
return genericResultSet;
|
||||
}
|
||||
|
||||
public static boolean genericResultSetPassed(MultivaluedMap<String, String> queryParams) {
|
||||
public static boolean genericResultSetPassed(final MultivaluedMap<String, String> queryParams) {
|
||||
return queryParams.getFirst("genericResultSet") != null;
|
||||
}
|
||||
|
||||
public static String sqlEncodeString(String str) {
|
||||
String singleQuote = "'";
|
||||
String twoSingleQuotes = "''";
|
||||
public static String sqlEncodeString(final String str) {
|
||||
final String singleQuote = "'";
|
||||
final String twoSingleQuotes = "''";
|
||||
return singleQuote + StringUtils.replace(str, singleQuote, twoSingleQuotes, -1) + singleQuote;
|
||||
}
|
||||
|
||||
public static Map<String, String> asMap(MultivaluedMap<String, String> queryParameters) {
|
||||
public static Map<String, String> asMap(final MultivaluedMap<String, String> queryParameters) {
|
||||
|
||||
final Map<String, String> map = new HashMap<String, String>(queryParameters.size());
|
||||
|
||||
for (String parameterName : queryParameters.keySet()) {
|
||||
List<String> values = queryParameters.get(parameterName);
|
||||
for (final String parameterName : queryParameters.keySet()) {
|
||||
final List<String> values = queryParameters.get(parameterName);
|
||||
map.put(parameterName, values.get(0));
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ public class ApiRequestParameterHelper {
|
||||
public ApiRequestJsonSerializationSettings process(final MultivaluedMap<String, String> queryParameters,
|
||||
final Set<String> mandatoryResponseParameters) {
|
||||
|
||||
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(queryParameters);
|
||||
final Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(queryParameters);
|
||||
if (!responseParameters.isEmpty()) {
|
||||
responseParameters.addAll(mandatoryResponseParameters);
|
||||
}
|
||||
|
||||
+3
-2
@@ -26,7 +26,7 @@ import com.google.gson.JsonElement;
|
||||
|
||||
/**
|
||||
* Immutable representation of a command.
|
||||
*
|
||||
*
|
||||
* Wraps the provided JSON with convenience functions for extracting parameter
|
||||
* values and checking for changes against an existing value.
|
||||
*/
|
||||
@@ -68,7 +68,8 @@ public final class JsonCommand {
|
||||
public JsonCommand(final Long commandId, final String jsonCommand, final JsonElement parsedCommand,
|
||||
final FromJsonHelper fromApiJsonHelper, final String entityName, final Long resourceId, final Long subresourceId,
|
||||
final Long groupId, final Long clientId, final Long loanId, final Long savingsId, final Long codeId,
|
||||
final String supportedEntityType, final Long supportedEntityId, final String transactionId, final String url, final Long productId) {
|
||||
final String supportedEntityType, final Long supportedEntityId, final String transactionId, final String url,
|
||||
final Long productId) {
|
||||
this.commandId = commandId;
|
||||
this.jsonCommand = jsonCommand;
|
||||
this.parsedCommand = parsedCommand;
|
||||
|
||||
+13
-13
@@ -46,7 +46,7 @@ public final class JsonQuery {
|
||||
public String json() {
|
||||
return this.jsonQuery;
|
||||
}
|
||||
|
||||
|
||||
public JsonElement parsedJson() {
|
||||
return this.parsedQuery;
|
||||
}
|
||||
@@ -118,7 +118,7 @@ public final class JsonQuery {
|
||||
}
|
||||
|
||||
private boolean parameterExists(final String parameterName) {
|
||||
return this.fromApiJsonHelper.parameterExists(parameterName, parsedQuery);
|
||||
return this.fromApiJsonHelper.parameterExists(parameterName, this.parsedQuery);
|
||||
}
|
||||
|
||||
public boolean hasParameter(final String parameterName) {
|
||||
@@ -136,11 +136,11 @@ public final class JsonQuery {
|
||||
public Map<String, Boolean> mapValueOfParameterNamed(final String parameterName) {
|
||||
final Type typeOfMap = new TypeToken<Map<String, Boolean>>() {}.getType();
|
||||
|
||||
if (parsedQuery.getAsJsonObject().has(parameterName)) {
|
||||
parsedQuery.getAsJsonObject().get(parameterName);
|
||||
if (this.parsedQuery.getAsJsonObject().has(parameterName)) {
|
||||
this.parsedQuery.getAsJsonObject().get(parameterName);
|
||||
}
|
||||
|
||||
return this.fromApiJsonHelper.extractMap(typeOfMap, jsonQuery);
|
||||
return this.fromApiJsonHelper.extractMap(typeOfMap, this.jsonQuery);
|
||||
}
|
||||
|
||||
public boolean isChangeInLongParameterNamed(final String parameterName, final Long existingValue) {
|
||||
@@ -153,7 +153,7 @@ public final class JsonQuery {
|
||||
}
|
||||
|
||||
public Long longValueOfParameterNamed(final String parameterName) {
|
||||
return this.fromApiJsonHelper.extractLongNamed(parameterName, parsedQuery);
|
||||
return this.fromApiJsonHelper.extractLongNamed(parameterName, this.parsedQuery);
|
||||
}
|
||||
|
||||
public boolean isChangeInLocalDateParameterNamed(final String parameterName, final LocalDate existingValue) {
|
||||
@@ -166,7 +166,7 @@ public final class JsonQuery {
|
||||
}
|
||||
|
||||
public LocalDate localDateValueOfParameterNamed(final String parameterName) {
|
||||
return this.fromApiJsonHelper.extractLocalDateNamed(parameterName, parsedQuery);
|
||||
return this.fromApiJsonHelper.extractLocalDateNamed(parameterName, this.parsedQuery);
|
||||
}
|
||||
|
||||
public boolean isChangeInStringParameterNamed(final String parameterName, final String existingValue) {
|
||||
@@ -179,7 +179,7 @@ public final class JsonQuery {
|
||||
}
|
||||
|
||||
public String stringValueOfParameterNamed(final String parameterName) {
|
||||
final String value = this.fromApiJsonHelper.extractStringNamed(parameterName, parsedQuery);
|
||||
final String value = this.fromApiJsonHelper.extractStringNamed(parameterName, this.parsedQuery);
|
||||
return StringUtils.defaultIfEmpty(value, "");
|
||||
}
|
||||
|
||||
@@ -193,7 +193,7 @@ public final class JsonQuery {
|
||||
}
|
||||
|
||||
public BigDecimal bigDecimalValueOfParameterNamed(final String parameterName) {
|
||||
return this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed(parameterName, parsedQuery);
|
||||
return this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed(parameterName, this.parsedQuery);
|
||||
}
|
||||
|
||||
public boolean isChangeInIntegerParameterNamed(final String parameterName, final Integer existingValue) {
|
||||
@@ -206,7 +206,7 @@ public final class JsonQuery {
|
||||
}
|
||||
|
||||
public Integer integerValueOfParameterNamed(final String parameterName) {
|
||||
return this.fromApiJsonHelper.extractIntegerWithLocaleNamed(parameterName, parsedQuery);
|
||||
return this.fromApiJsonHelper.extractIntegerWithLocaleNamed(parameterName, this.parsedQuery);
|
||||
}
|
||||
|
||||
public boolean isChangeInBooleanParameterNamed(final String parameterName, final Boolean existingValue) {
|
||||
@@ -222,14 +222,14 @@ public final class JsonQuery {
|
||||
* Returns {@link Boolean} that could possibly be null.
|
||||
*/
|
||||
public Boolean booleanObjectValueOfParameterNamed(final String parameterName) {
|
||||
return this.fromApiJsonHelper.extractBooleanNamed(parameterName, parsedQuery);
|
||||
return this.fromApiJsonHelper.extractBooleanNamed(parameterName, this.parsedQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* always returns true or false
|
||||
*/
|
||||
public boolean booleanPrimitiveValueOfParameterNamed(final String parameterName) {
|
||||
final Boolean value = this.fromApiJsonHelper.extractBooleanNamed(parameterName, parsedQuery);
|
||||
final Boolean value = this.fromApiJsonHelper.extractBooleanNamed(parameterName, this.parsedQuery);
|
||||
return (Boolean) ObjectUtils.defaultIfNull(value, Boolean.FALSE);
|
||||
}
|
||||
|
||||
@@ -243,7 +243,7 @@ public final class JsonQuery {
|
||||
}
|
||||
|
||||
public String[] arrayValueOfParameterNamed(final String parameterName) {
|
||||
return this.fromApiJsonHelper.extractArrayNamed(parameterName, parsedQuery);
|
||||
return this.fromApiJsonHelper.extractArrayNamed(parameterName, this.parsedQuery);
|
||||
}
|
||||
|
||||
public boolean isChangeInPasswordParameterNamed(final String parameterName, final String existingValue,
|
||||
|
||||
+3
-3
@@ -23,13 +23,13 @@ public class ParameterListExclusionStrategy implements ExclusionStrategy {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldSkipField(FieldAttributes f) {
|
||||
return parameterNamesToSkip.contains(f.getName());
|
||||
public boolean shouldSkipField(final FieldAttributes f) {
|
||||
return this.parameterNamesToSkip.contains(f.getName());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Override
|
||||
public boolean shouldSkipClass(Class<?> clazz) {
|
||||
public boolean shouldSkipClass(final Class<?> clazz) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+21
-22
@@ -5,31 +5,30 @@
|
||||
*/
|
||||
package org.mifosplatform.infrastructure.core.data;
|
||||
|
||||
|
||||
public class ApiErrorMessageArg {
|
||||
|
||||
/**
|
||||
* The actual value of the parameter (if any) as passed to API.
|
||||
*/
|
||||
private Object value;
|
||||
|
||||
public static ApiErrorMessageArg from(Object object) {
|
||||
return new ApiErrorMessageArg(object);
|
||||
}
|
||||
|
||||
protected ApiErrorMessageArg() {
|
||||
//
|
||||
}
|
||||
/**
|
||||
* The actual value of the parameter (if any) as passed to API.
|
||||
*/
|
||||
private Object value;
|
||||
|
||||
public ApiErrorMessageArg(Object object) {
|
||||
this.value = object;
|
||||
}
|
||||
public static ApiErrorMessageArg from(final Object object) {
|
||||
return new ApiErrorMessageArg(object);
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
protected ApiErrorMessageArg() {
|
||||
//
|
||||
}
|
||||
|
||||
public void setValue(Object value) {
|
||||
this.value = value;
|
||||
}
|
||||
public ApiErrorMessageArg(final Object object) {
|
||||
this.value = object;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public void setValue(final Object value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
+21
-21
@@ -48,7 +48,7 @@ public class ApiGlobalErrorResponse {
|
||||
|
||||
public static ApiGlobalErrorResponse unAuthenticated() {
|
||||
|
||||
ApiGlobalErrorResponse globalErrorResponse = new ApiGlobalErrorResponse();
|
||||
final ApiGlobalErrorResponse globalErrorResponse = new ApiGlobalErrorResponse();
|
||||
globalErrorResponse.setHttpStatusCode("401");
|
||||
globalErrorResponse.setDeveloperMessage("Invalid authentication details were passed in api request.");
|
||||
globalErrorResponse.setUserMessageGlobalisationCode("error.msg.not.authenticated");
|
||||
@@ -59,7 +59,7 @@ public class ApiGlobalErrorResponse {
|
||||
|
||||
public static ApiGlobalErrorResponse invalidTenantIdentifier() {
|
||||
|
||||
ApiGlobalErrorResponse globalErrorResponse = new ApiGlobalErrorResponse();
|
||||
final ApiGlobalErrorResponse globalErrorResponse = new ApiGlobalErrorResponse();
|
||||
globalErrorResponse.setHttpStatusCode("401");
|
||||
globalErrorResponse.setDeveloperMessage("Invalid tenant details were passed in api request.");
|
||||
globalErrorResponse.setUserMessageGlobalisationCode("error.msg.invalid.tenant.identifier");
|
||||
@@ -69,14 +69,14 @@ public class ApiGlobalErrorResponse {
|
||||
}
|
||||
|
||||
public static ApiGlobalErrorResponse unAuthorized(final String defaultUserMessage) {
|
||||
ApiGlobalErrorResponse globalErrorResponse = new ApiGlobalErrorResponse();
|
||||
final ApiGlobalErrorResponse globalErrorResponse = new ApiGlobalErrorResponse();
|
||||
globalErrorResponse.setHttpStatusCode("403");
|
||||
globalErrorResponse
|
||||
.setDeveloperMessage("The user associated with credentials passed on this request does not have sufficient privileges to perform this action.");
|
||||
globalErrorResponse.setUserMessageGlobalisationCode("error.msg.not.authorized");
|
||||
globalErrorResponse.setDefaultUserMessage("Insufficient privileges to perform this action.");
|
||||
|
||||
List<ApiParameterError> errors = new ArrayList<ApiParameterError>();
|
||||
final List<ApiParameterError> errors = new ArrayList<ApiParameterError>();
|
||||
errors.add(ApiParameterError.generalError("error.msg.not.authorized", defaultUserMessage));
|
||||
globalErrorResponse.setErrors(errors);
|
||||
|
||||
@@ -85,13 +85,13 @@ public class ApiGlobalErrorResponse {
|
||||
|
||||
public static ApiGlobalErrorResponse domainRuleViolation(final String globalisationMessageCode, final String defaultUserMessage,
|
||||
final Object... defaultUserMessageArgs) {
|
||||
ApiGlobalErrorResponse globalErrorResponse = new ApiGlobalErrorResponse();
|
||||
final ApiGlobalErrorResponse globalErrorResponse = new ApiGlobalErrorResponse();
|
||||
globalErrorResponse.setHttpStatusCode("403");
|
||||
globalErrorResponse.setDeveloperMessage("Request was understood but caused a domain rule violation.");
|
||||
globalErrorResponse.setUserMessageGlobalisationCode("validation.msg.domain.rule.violation");
|
||||
globalErrorResponse.setDefaultUserMessage("Errors contain reason for domain rule violation.");
|
||||
|
||||
List<ApiParameterError> errors = new ArrayList<ApiParameterError>();
|
||||
final List<ApiParameterError> errors = new ArrayList<ApiParameterError>();
|
||||
errors.add(ApiParameterError.generalError(globalisationMessageCode, defaultUserMessage, defaultUserMessageArgs));
|
||||
globalErrorResponse.setErrors(errors);
|
||||
|
||||
@@ -101,13 +101,13 @@ public class ApiGlobalErrorResponse {
|
||||
public static ApiGlobalErrorResponse notFound(final String globalisationMessageCode, final String defaultUserMessage,
|
||||
final Object... defaultUserMessageArgs) {
|
||||
|
||||
ApiGlobalErrorResponse globalErrorResponse = new ApiGlobalErrorResponse();
|
||||
final ApiGlobalErrorResponse globalErrorResponse = new ApiGlobalErrorResponse();
|
||||
globalErrorResponse.setHttpStatusCode("404");
|
||||
globalErrorResponse.setDeveloperMessage("The requested resource is not available.");
|
||||
globalErrorResponse.setUserMessageGlobalisationCode("error.msg.resource.not.found");
|
||||
globalErrorResponse.setDefaultUserMessage("The requested resource is not available.");
|
||||
|
||||
List<ApiParameterError> errors = new ArrayList<ApiParameterError>();
|
||||
final List<ApiParameterError> errors = new ArrayList<ApiParameterError>();
|
||||
errors.add(ApiParameterError.resourceIdentifierNotFound(globalisationMessageCode, defaultUserMessage, defaultUserMessageArgs));
|
||||
globalErrorResponse.setErrors(errors);
|
||||
|
||||
@@ -117,13 +117,13 @@ public class ApiGlobalErrorResponse {
|
||||
public static ApiGlobalErrorResponse dataIntegrityError(final String globalisationMessageCode, final String defaultUserMessage,
|
||||
final String parameterName, final Object... defaultUserMessageArgs) {
|
||||
|
||||
ApiGlobalErrorResponse globalErrorResponse = new ApiGlobalErrorResponse();
|
||||
final ApiGlobalErrorResponse globalErrorResponse = new ApiGlobalErrorResponse();
|
||||
globalErrorResponse.setHttpStatusCode("403");
|
||||
globalErrorResponse.setDeveloperMessage("The request caused a data integrity issue to be fired by the database.");
|
||||
globalErrorResponse.setUserMessageGlobalisationCode(globalisationMessageCode);
|
||||
globalErrorResponse.setDefaultUserMessage(defaultUserMessage);
|
||||
|
||||
List<ApiParameterError> errors = new ArrayList<ApiParameterError>();
|
||||
final List<ApiParameterError> errors = new ArrayList<ApiParameterError>();
|
||||
errors.add(ApiParameterError.parameterError(globalisationMessageCode, defaultUserMessage, parameterName, defaultUserMessageArgs));
|
||||
globalErrorResponse.setErrors(errors);
|
||||
|
||||
@@ -133,7 +133,7 @@ public class ApiGlobalErrorResponse {
|
||||
public static ApiGlobalErrorResponse badClientRequest(final String globalisationMessageCode, final String defaultUserMessage,
|
||||
final List<ApiParameterError> errors) {
|
||||
|
||||
ApiGlobalErrorResponse globalErrorResponse = new ApiGlobalErrorResponse();
|
||||
final ApiGlobalErrorResponse globalErrorResponse = new ApiGlobalErrorResponse();
|
||||
globalErrorResponse.setHttpStatusCode("400");
|
||||
globalErrorResponse
|
||||
.setDeveloperMessage("The request was invalid. This typically will happen due to validation errors which are provided.");
|
||||
@@ -148,29 +148,29 @@ public class ApiGlobalErrorResponse {
|
||||
public static ApiGlobalErrorResponse serverSideError(final String globalisationMessageCode, final String defaultUserMessage,
|
||||
final Object... defaultUserMessageArgs) {
|
||||
|
||||
ApiGlobalErrorResponse globalErrorResponse = new ApiGlobalErrorResponse();
|
||||
final ApiGlobalErrorResponse globalErrorResponse = new ApiGlobalErrorResponse();
|
||||
globalErrorResponse.setHttpStatusCode("500");
|
||||
globalErrorResponse.setDeveloperMessage("An unexpected error occured on the platform server.");
|
||||
globalErrorResponse.setUserMessageGlobalisationCode("error.msg.platform.server.side.error");
|
||||
globalErrorResponse.setDefaultUserMessage("An unexpected error occured on the platform server.");
|
||||
|
||||
List<ApiParameterError> errors = new ArrayList<ApiParameterError>();
|
||||
final List<ApiParameterError> errors = new ArrayList<ApiParameterError>();
|
||||
errors.add(ApiParameterError.generalError(globalisationMessageCode, defaultUserMessage, defaultUserMessageArgs));
|
||||
globalErrorResponse.setErrors(errors);
|
||||
|
||||
return globalErrorResponse;
|
||||
}
|
||||
|
||||
|
||||
public static ApiGlobalErrorResponse serviceUnavailable(final String globalisationMessageCode, final String defaultUserMessage,
|
||||
final Object... defaultUserMessageArgs) {
|
||||
|
||||
ApiGlobalErrorResponse globalErrorResponse = new ApiGlobalErrorResponse();
|
||||
final ApiGlobalErrorResponse globalErrorResponse = new ApiGlobalErrorResponse();
|
||||
globalErrorResponse.setHttpStatusCode("503");
|
||||
globalErrorResponse.setDeveloperMessage("The server is currently unable to handle the request , please try after some time.");
|
||||
globalErrorResponse.setUserMessageGlobalisationCode("error.msg.platform.service.unavailable");
|
||||
globalErrorResponse.setDefaultUserMessage("The server is currently unable to handle the request , please try after some time.");
|
||||
|
||||
List<ApiParameterError> errors = new ArrayList<ApiParameterError>();
|
||||
final List<ApiParameterError> errors = new ArrayList<ApiParameterError>();
|
||||
errors.add(ApiParameterError.generalError(globalisationMessageCode, defaultUserMessage, defaultUserMessageArgs));
|
||||
globalErrorResponse.setErrors(errors);
|
||||
|
||||
@@ -188,7 +188,7 @@ public class ApiGlobalErrorResponse {
|
||||
@XmlElementWrapper(name = "errors")
|
||||
@XmlElement(name = "errorResponse")
|
||||
public List<ApiParameterError> getErrors() {
|
||||
return errors;
|
||||
return this.errors;
|
||||
}
|
||||
|
||||
public void setErrors(final List<ApiParameterError> errors) {
|
||||
@@ -196,7 +196,7 @@ public class ApiGlobalErrorResponse {
|
||||
}
|
||||
|
||||
public String getDeveloperMessage() {
|
||||
return developerMessage;
|
||||
return this.developerMessage;
|
||||
}
|
||||
|
||||
public void setDeveloperMessage(final String developerMessage) {
|
||||
@@ -204,7 +204,7 @@ public class ApiGlobalErrorResponse {
|
||||
}
|
||||
|
||||
public String getHttpStatusCode() {
|
||||
return httpStatusCode;
|
||||
return this.httpStatusCode;
|
||||
}
|
||||
|
||||
public void setHttpStatusCode(final String httpStatusCode) {
|
||||
@@ -212,7 +212,7 @@ public class ApiGlobalErrorResponse {
|
||||
}
|
||||
|
||||
public String getDefaultUserMessage() {
|
||||
return defaultUserMessage;
|
||||
return this.defaultUserMessage;
|
||||
}
|
||||
|
||||
public void setDefaultUserMessage(final String defaultUserMessage) {
|
||||
@@ -220,7 +220,7 @@ public class ApiGlobalErrorResponse {
|
||||
}
|
||||
|
||||
public String getUserMessageGlobalisationCode() {
|
||||
return userMessageGlobalisationCode;
|
||||
return this.userMessageGlobalisationCode;
|
||||
}
|
||||
|
||||
public void setUserMessageGlobalisationCode(final String userMessageGlobalisationCode) {
|
||||
|
||||
+19
-19
@@ -44,19 +44,19 @@ public class ApiParameterError {
|
||||
*/
|
||||
private List<ApiErrorMessageArg> args = new ArrayList<ApiErrorMessageArg>();
|
||||
|
||||
public static ApiParameterError generalError(String globalisationMessageCode, String defaultUserMessage,
|
||||
Object... defaultUserMessageArgs) {
|
||||
public static ApiParameterError generalError(final String globalisationMessageCode, final String defaultUserMessage,
|
||||
final Object... defaultUserMessageArgs) {
|
||||
return new ApiParameterError(globalisationMessageCode, defaultUserMessage, defaultUserMessageArgs);
|
||||
}
|
||||
|
||||
public static ApiParameterError resourceIdentifierNotFound(String globalisationMessageCode, String defaultUserMessage,
|
||||
Object... defaultUserMessageArgs) {
|
||||
public static ApiParameterError resourceIdentifierNotFound(final String globalisationMessageCode, final String defaultUserMessage,
|
||||
final Object... defaultUserMessageArgs) {
|
||||
return new ApiParameterError(globalisationMessageCode, defaultUserMessage, defaultUserMessageArgs);
|
||||
}
|
||||
|
||||
public static ApiParameterError parameterError(final String globalisationMessageCode, final String defaultUserMessage,
|
||||
final String parameterName, final Object... defaultUserMessageArgs) {
|
||||
ApiParameterError error = new ApiParameterError(globalisationMessageCode, defaultUserMessage, defaultUserMessageArgs);
|
||||
final ApiParameterError error = new ApiParameterError(globalisationMessageCode, defaultUserMessage, defaultUserMessageArgs);
|
||||
error.setParameterName(parameterName);
|
||||
return error;
|
||||
}
|
||||
@@ -70,9 +70,9 @@ public class ApiParameterError {
|
||||
this.developerMessage = defaultUserMessage;
|
||||
this.defaultUserMessage = defaultUserMessage;
|
||||
|
||||
List<ApiErrorMessageArg> messageArgs = new ArrayList<ApiErrorMessageArg>();
|
||||
final List<ApiErrorMessageArg> messageArgs = new ArrayList<ApiErrorMessageArg>();
|
||||
if (defaultUserMessageArgs != null) {
|
||||
for (Object object : defaultUserMessageArgs) {
|
||||
for (final Object object : defaultUserMessageArgs) {
|
||||
messageArgs.add(ApiErrorMessageArg.from(object));
|
||||
}
|
||||
}
|
||||
@@ -82,50 +82,50 @@ public class ApiParameterError {
|
||||
}
|
||||
|
||||
public String getDeveloperMessage() {
|
||||
return developerMessage;
|
||||
return this.developerMessage;
|
||||
}
|
||||
|
||||
public void setDeveloperMessage(String developerMessage) {
|
||||
public void setDeveloperMessage(final String developerMessage) {
|
||||
this.developerMessage = developerMessage;
|
||||
}
|
||||
|
||||
public String getDefaultUserMessage() {
|
||||
return defaultUserMessage;
|
||||
return this.defaultUserMessage;
|
||||
}
|
||||
|
||||
public void setDefaultUserMessage(String defaultUserMessage) {
|
||||
public void setDefaultUserMessage(final String defaultUserMessage) {
|
||||
this.defaultUserMessage = defaultUserMessage;
|
||||
}
|
||||
|
||||
public String getUserMessageGlobalisationCode() {
|
||||
return userMessageGlobalisationCode;
|
||||
return this.userMessageGlobalisationCode;
|
||||
}
|
||||
|
||||
public void setUserMessageGlobalisationCode(String userMessageGlobalisationCode) {
|
||||
public void setUserMessageGlobalisationCode(final String userMessageGlobalisationCode) {
|
||||
this.userMessageGlobalisationCode = userMessageGlobalisationCode;
|
||||
}
|
||||
|
||||
public String getParameterName() {
|
||||
return parameterName;
|
||||
return this.parameterName;
|
||||
}
|
||||
|
||||
public void setParameterName(String parameterName) {
|
||||
public void setParameterName(final String parameterName) {
|
||||
this.parameterName = parameterName;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public void setValue(Object value) {
|
||||
public void setValue(final Object value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public List<ApiErrorMessageArg> getArgs() {
|
||||
return args;
|
||||
return this.args;
|
||||
}
|
||||
|
||||
public void setArgs(List<ApiErrorMessageArg> args) {
|
||||
public void setArgs(final List<ApiErrorMessageArg> args) {
|
||||
this.args = args;
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -26,8 +26,8 @@ public class CommandProcessingResultBuilder {
|
||||
private Long productId;
|
||||
|
||||
public CommandProcessingResult build() {
|
||||
return CommandProcessingResult.fromDetails(commandId, officeId, groupId, clientId, loanId, savingsId, resourceIdentifier, entityId,
|
||||
transactionId, changes, productId);
|
||||
return CommandProcessingResult.fromDetails(this.commandId, this.officeId, this.groupId, this.clientId, this.loanId, this.savingsId,
|
||||
this.resourceIdentifier, this.entityId, this.transactionId, this.changes, this.productId);
|
||||
}
|
||||
|
||||
public CommandProcessingResultBuilder withCommandId(final Long withCommandId) {
|
||||
@@ -79,7 +79,7 @@ public class CommandProcessingResultBuilder {
|
||||
this.transactionId = withTransactionId;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public CommandProcessingResultBuilder withProductId(final Long productId) {
|
||||
this.productId = productId;
|
||||
return this;
|
||||
|
||||
+304
-294
@@ -37,7 +37,7 @@ public class DataValidatorBuilder {
|
||||
}
|
||||
|
||||
public DataValidatorBuilder reset() {
|
||||
return new DataValidatorBuilder(dataValidationErrors).resource(resource);
|
||||
return new DataValidatorBuilder(this.dataValidationErrors).resource(this.resource);
|
||||
}
|
||||
|
||||
public DataValidatorBuilder resource(final String resource) {
|
||||
@@ -67,211 +67,215 @@ public class DataValidatorBuilder {
|
||||
}
|
||||
|
||||
public DataValidatorBuilder andNotBlank(final String linkedParameterName, final String linkedValue) {
|
||||
if (value == null && linkedValue == null && ignoreNullValue) { return this; }
|
||||
if (this.value == null && linkedValue == null && this.ignoreNullValue) { return this; }
|
||||
|
||||
if (StringUtils.isBlank(linkedValue)) {
|
||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".")
|
||||
.append(linkedParameterName).append(".cannot.be.empty.when.").append(parameter).append(".is.populated");
|
||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(linkedParameterName)
|
||||
.append(" cannot be empty when ").append(parameter).append(" is populated.");
|
||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
|
||||
linkedParameterName, linkedValue, value);
|
||||
dataValidationErrors.add(error);
|
||||
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||
.append(linkedParameterName).append(".cannot.be.empty.when.").append(this.parameter).append(".is.populated");
|
||||
final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(linkedParameterName)
|
||||
.append(" cannot be empty when ").append(this.parameter).append(" is populated.");
|
||||
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||
defaultEnglishMessage.toString(), linkedParameterName, linkedValue, this.value);
|
||||
this.dataValidationErrors.add(error);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public void failWithCode(final String errorCode) {
|
||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(this.parameter)
|
||||
.append(".").append(errorCode);
|
||||
StringBuilder defaultEnglishMessage = new StringBuilder("Failed data validation due to: ").append(errorCode).append(".");
|
||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
|
||||
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||
.append(this.parameter).append(".").append(errorCode);
|
||||
final StringBuilder defaultEnglishMessage = new StringBuilder("Failed data validation due to: ").append(errorCode).append(".");
|
||||
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
|
||||
this.parameter, this.value);
|
||||
dataValidationErrors.add(error);
|
||||
this.dataValidationErrors.add(error);
|
||||
}
|
||||
|
||||
public void failWithCodeNoParameterAddedToErrorCode(final String errorCode) {
|
||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(errorCode);
|
||||
StringBuilder defaultEnglishMessage = new StringBuilder("Failed data validation due to: ").append(errorCode).append(".");
|
||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
|
||||
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".").append(errorCode);
|
||||
final StringBuilder defaultEnglishMessage = new StringBuilder("Failed data validation due to: ").append(errorCode).append(".");
|
||||
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
|
||||
this.parameter, this.value);
|
||||
dataValidationErrors.add(error);
|
||||
this.dataValidationErrors.add(error);
|
||||
}
|
||||
|
||||
public DataValidatorBuilder equalToParameter(final String linkedParameterName, final Object linkedValue) {
|
||||
if (value == null && linkedValue == null && ignoreNullValue) { return this; }
|
||||
if (this.value == null && linkedValue == null && this.ignoreNullValue) { return this; }
|
||||
|
||||
if (value != null && !value.equals(linkedValue)) {
|
||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".")
|
||||
.append(linkedParameterName).append(".not.equal.to.").append(parameter);
|
||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(linkedParameterName)
|
||||
.append(" is not equal to ").append(parameter).append(".");
|
||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
|
||||
linkedParameterName, linkedValue, value);
|
||||
dataValidationErrors.add(error);
|
||||
if (this.value != null && !this.value.equals(linkedValue)) {
|
||||
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||
.append(linkedParameterName).append(".not.equal.to.").append(this.parameter);
|
||||
final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(linkedParameterName)
|
||||
.append(" is not equal to ").append(this.parameter).append(".");
|
||||
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||
defaultEnglishMessage.toString(), linkedParameterName, linkedValue, this.value);
|
||||
this.dataValidationErrors.add(error);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public DataValidatorBuilder notSameAsParameter(final String linkedParameterName, final Object linkedValue) {
|
||||
if (value == null && linkedValue == null && ignoreNullValue) { return this; }
|
||||
if (this.value == null && linkedValue == null && this.ignoreNullValue) { return this; }
|
||||
|
||||
if (value != null && value.equals(linkedValue)) {
|
||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".")
|
||||
.append(linkedParameterName).append(".same.as.").append(parameter);
|
||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(linkedParameterName).append(" is same as ")
|
||||
.append(parameter).append(".");
|
||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
|
||||
linkedParameterName, linkedValue, value);
|
||||
dataValidationErrors.add(error);
|
||||
if (this.value != null && this.value.equals(linkedValue)) {
|
||||
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||
.append(linkedParameterName).append(".same.as.").append(this.parameter);
|
||||
final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(linkedParameterName)
|
||||
.append(" is same as ").append(this.parameter).append(".");
|
||||
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||
defaultEnglishMessage.toString(), linkedParameterName, linkedValue, this.value);
|
||||
this.dataValidationErrors.add(error);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/***FIXME: Vishwas, why does this method have a parameter? Seems wrong***/
|
||||
/*** FIXME: Vishwas, why does this method have a parameter? Seems wrong ***/
|
||||
public DataValidatorBuilder trueOrFalseRequired(final boolean trueOfFalseFieldProvided) {
|
||||
if (!trueOfFalseFieldProvided && !ignoreNullValue) {
|
||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter)
|
||||
.append(".must.be.true.or.false");
|
||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(
|
||||
if (!trueOfFalseFieldProvided && !this.ignoreNullValue) {
|
||||
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||
.append(this.parameter).append(".must.be.true.or.false");
|
||||
final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(this.parameter).append(
|
||||
" must be set as true or false.");
|
||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
|
||||
parameter);
|
||||
dataValidationErrors.add(error);
|
||||
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||
defaultEnglishMessage.toString(), this.parameter);
|
||||
this.dataValidationErrors.add(error);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public DataValidatorBuilder notNull() {
|
||||
if (value == null && !ignoreNullValue) {
|
||||
if (this.value == null && !this.ignoreNullValue) {
|
||||
|
||||
String realParameterName = this.parameter;
|
||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter);
|
||||
if (this.arrayIndex != null && StringUtils.isNotBlank(arrayPart)) {
|
||||
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||
.append(this.parameter);
|
||||
if (this.arrayIndex != null && StringUtils.isNotBlank(this.arrayPart)) {
|
||||
validationErrorCode.append(".").append(this.arrayPart);
|
||||
realParameterName = new StringBuilder(parameter).append('[').append(this.arrayIndex).append("][").append(arrayPart)
|
||||
.append(']').toString();
|
||||
realParameterName = new StringBuilder(this.parameter).append('[').append(this.arrayIndex).append("][")
|
||||
.append(this.arrayPart).append(']').toString();
|
||||
}
|
||||
|
||||
validationErrorCode.append(".cannot.be.blank");
|
||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(realParameterName).append(" is mandatory.");
|
||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
|
||||
realParameterName, arrayIndex);
|
||||
dataValidationErrors.add(error);
|
||||
final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(realParameterName).append(
|
||||
" is mandatory.");
|
||||
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||
defaultEnglishMessage.toString(), realParameterName, this.arrayIndex);
|
||||
this.dataValidationErrors.add(error);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public DataValidatorBuilder notBlank() {
|
||||
if (value == null && ignoreNullValue) { return this; }
|
||||
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||
|
||||
if (value == null || StringUtils.isBlank(value.toString())) {
|
||||
if (this.value == null || StringUtils.isBlank(this.value.toString())) {
|
||||
String realParameterName = this.parameter;
|
||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter);
|
||||
if (this.arrayIndex != null && StringUtils.isNotBlank(arrayPart)) {
|
||||
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||
.append(this.parameter);
|
||||
if (this.arrayIndex != null && StringUtils.isNotBlank(this.arrayPart)) {
|
||||
validationErrorCode.append(".").append(this.arrayPart);
|
||||
realParameterName = new StringBuilder(parameter).append('[').append(this.arrayIndex).append("][").append(arrayPart)
|
||||
.append(']').toString();
|
||||
realParameterName = new StringBuilder(this.parameter).append('[').append(this.arrayIndex).append("][")
|
||||
.append(this.arrayPart).append(']').toString();
|
||||
}
|
||||
|
||||
validationErrorCode.append(".cannot.be.blank");
|
||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(realParameterName).append(" is mandatory.");
|
||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
|
||||
realParameterName, arrayIndex);
|
||||
dataValidationErrors.add(error);
|
||||
final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(realParameterName).append(
|
||||
" is mandatory.");
|
||||
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||
defaultEnglishMessage.toString(), realParameterName, this.arrayIndex);
|
||||
this.dataValidationErrors.add(error);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public DataValidatorBuilder notExceedingLengthOf(final Integer maxLength) {
|
||||
if (value == null && ignoreNullValue) { return this; }
|
||||
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||
|
||||
if (value != null && value.toString().trim().length() > maxLength) {
|
||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter)
|
||||
.append(".exceeds.max.length");
|
||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(" exceeds max length of ")
|
||||
.append(maxLength).append(".");
|
||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
|
||||
parameter, maxLength, value.toString());
|
||||
dataValidationErrors.add(error);
|
||||
if (this.value != null && this.value.toString().trim().length() > maxLength) {
|
||||
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||
.append(this.parameter).append(".exceeds.max.length");
|
||||
final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(this.parameter)
|
||||
.append(" exceeds max length of ").append(maxLength).append(".");
|
||||
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||
defaultEnglishMessage.toString(), this.parameter, maxLength, this.value.toString());
|
||||
this.dataValidationErrors.add(error);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public DataValidatorBuilder inMinMaxRange(final Integer min, final Integer max) {
|
||||
if (value == null && ignoreNullValue) { return this; }
|
||||
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||
|
||||
if (value != null) {
|
||||
Integer number = Integer.valueOf(value.toString());
|
||||
if (this.value != null) {
|
||||
final Integer number = Integer.valueOf(this.value.toString());
|
||||
if (number < min || number > max) {
|
||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter)
|
||||
.append(".is.not.within.expected.range");
|
||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(" must be between ")
|
||||
.append(min).append(" and ").append(max).append(".");
|
||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||
defaultEnglishMessage.toString(), parameter, number, min, max);
|
||||
dataValidationErrors.add(error);
|
||||
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||
.append(this.parameter).append(".is.not.within.expected.range");
|
||||
final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(this.parameter)
|
||||
.append(" must be between ").append(min).append(" and ").append(max).append(".");
|
||||
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||
defaultEnglishMessage.toString(), this.parameter, number, min, max);
|
||||
this.dataValidationErrors.add(error);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public DataValidatorBuilder isOneOfTheseValues(final Object... values) {
|
||||
if (value == null && ignoreNullValue) { return this; }
|
||||
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||
|
||||
List<Object> valuesList = Arrays.asList(values);
|
||||
String valuesListStr = StringUtils.join(valuesList, ", ");
|
||||
final List<Object> valuesList = Arrays.asList(values);
|
||||
final String valuesListStr = StringUtils.join(valuesList, ", ");
|
||||
|
||||
if (this.value == null || !valuesList.contains(this.value)) {
|
||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter)
|
||||
.append(".is.not.one.of.expected.enumerations");
|
||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(" must be one of [ ")
|
||||
.append(valuesListStr).append(" ] ").append(".");
|
||||
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||
.append(this.parameter).append(".is.not.one.of.expected.enumerations");
|
||||
final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(this.parameter)
|
||||
.append(" must be one of [ ").append(valuesListStr).append(" ] ").append(".");
|
||||
|
||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
|
||||
parameter, this.value, values);
|
||||
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||
defaultEnglishMessage.toString(), this.parameter, this.value, values);
|
||||
|
||||
dataValidationErrors.add(error);
|
||||
this.dataValidationErrors.add(error);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public DataValidatorBuilder isNotOneOfTheseValues(final Object... values) {
|
||||
if (value == null && ignoreNullValue) { return this; }
|
||||
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||
|
||||
if (value != null) {
|
||||
List<Object> valuesList = Arrays.asList(values);
|
||||
String valuesListStr = StringUtils.join(valuesList, ", ");
|
||||
if (this.value != null) {
|
||||
final List<Object> valuesList = Arrays.asList(values);
|
||||
final String valuesListStr = StringUtils.join(valuesList, ", ");
|
||||
|
||||
if (valuesList.contains(this.value)) {
|
||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter)
|
||||
.append(".is.one.of.unwanted.enumerations");
|
||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter)
|
||||
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||
.append(this.parameter).append(".is.one.of.unwanted.enumerations");
|
||||
final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(this.parameter)
|
||||
.append(" must not be any of [ ").append(valuesListStr).append(" ] ").append(".");
|
||||
|
||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||
defaultEnglishMessage.toString(), parameter, this.value, values);
|
||||
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||
defaultEnglishMessage.toString(), this.parameter, this.value, values);
|
||||
|
||||
dataValidationErrors.add(error);
|
||||
this.dataValidationErrors.add(error);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public DataValidatorBuilder positiveAmount() {
|
||||
if (value == null && ignoreNullValue) { return this; }
|
||||
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||
|
||||
if (value != null) {
|
||||
BigDecimal number = BigDecimal.valueOf(Double.valueOf(value.toString()));
|
||||
if (this.value != null) {
|
||||
final BigDecimal number = BigDecimal.valueOf(Double.valueOf(this.value.toString()));
|
||||
if (number.compareTo(BigDecimal.ZERO) <= 0) {
|
||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter)
|
||||
.append(".not.greater.than.zero");
|
||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(
|
||||
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||
.append(this.parameter).append(".not.greater.than.zero");
|
||||
final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(this.parameter).append(
|
||||
" must be greater than 0.");
|
||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||
defaultEnglishMessage.toString(), parameter, number, 0);
|
||||
dataValidationErrors.add(error);
|
||||
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||
defaultEnglishMessage.toString(), this.parameter, number, 0);
|
||||
this.dataValidationErrors.add(error);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
@@ -281,18 +285,18 @@ public class DataValidatorBuilder {
|
||||
* should be used with .notNull() before it
|
||||
*/
|
||||
public DataValidatorBuilder zeroOrPositiveAmount() {
|
||||
if (value == null && ignoreNullValue) { return this; }
|
||||
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||
|
||||
if (value != null) {
|
||||
BigDecimal number = BigDecimal.valueOf(Double.valueOf(value.toString()));
|
||||
if (this.value != null) {
|
||||
final BigDecimal number = BigDecimal.valueOf(Double.valueOf(this.value.toString()));
|
||||
if (number.compareTo(BigDecimal.ZERO) < 0) {
|
||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter)
|
||||
.append(".not.zero.or.greater");
|
||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(
|
||||
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||
.append(this.parameter).append(".not.zero.or.greater");
|
||||
final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(this.parameter).append(
|
||||
" must be greater than or equal to 0.");
|
||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||
defaultEnglishMessage.toString(), parameter, number, 0);
|
||||
dataValidationErrors.add(error);
|
||||
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||
defaultEnglishMessage.toString(), this.parameter, number, 0);
|
||||
this.dataValidationErrors.add(error);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
@@ -302,18 +306,18 @@ public class DataValidatorBuilder {
|
||||
* should be used with .notNull() before it
|
||||
*/
|
||||
public DataValidatorBuilder integerZeroOrGreater() {
|
||||
if (value == null && ignoreNullValue) { return this; }
|
||||
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||
|
||||
if (value != null) {
|
||||
Integer number = Integer.valueOf(value.toString());
|
||||
if (this.value != null) {
|
||||
final Integer number = Integer.valueOf(this.value.toString());
|
||||
if (number < 0) {
|
||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter)
|
||||
.append(".not.zero.or.greater");
|
||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(
|
||||
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||
.append(this.parameter).append(".not.zero.or.greater");
|
||||
final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(this.parameter).append(
|
||||
" must be zero or greater.");
|
||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||
defaultEnglishMessage.toString(), parameter, number, 0);
|
||||
dataValidationErrors.add(error);
|
||||
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||
defaultEnglishMessage.toString(), this.parameter, number, 0);
|
||||
this.dataValidationErrors.add(error);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
@@ -323,18 +327,18 @@ public class DataValidatorBuilder {
|
||||
* should be used with .notNull() before it
|
||||
*/
|
||||
public DataValidatorBuilder integerGreaterThanZero() {
|
||||
if (value == null && ignoreNullValue) { return this; }
|
||||
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||
|
||||
if (value != null) {
|
||||
Integer number = Integer.valueOf(value.toString());
|
||||
if (this.value != null) {
|
||||
final Integer number = Integer.valueOf(this.value.toString());
|
||||
if (number < 1) {
|
||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter)
|
||||
.append(".not.greater.than.zero");
|
||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(
|
||||
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||
.append(this.parameter).append(".not.greater.than.zero");
|
||||
final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(this.parameter).append(
|
||||
" must be greater than 0.");
|
||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||
defaultEnglishMessage.toString(), parameter, number, 0);
|
||||
dataValidationErrors.add(error);
|
||||
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||
defaultEnglishMessage.toString(), this.parameter, number, 0);
|
||||
this.dataValidationErrors.add(error);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
@@ -344,67 +348,67 @@ public class DataValidatorBuilder {
|
||||
* should be used with .notNull() before it
|
||||
*/
|
||||
public DataValidatorBuilder longGreaterThanZero() {
|
||||
if (value == null && ignoreNullValue) { return this; }
|
||||
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||
|
||||
if (value != null) {
|
||||
Long number = Long.valueOf(value.toString());
|
||||
if (this.value != null) {
|
||||
final Long number = Long.valueOf(this.value.toString());
|
||||
if (number < 1) {
|
||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter)
|
||||
.append(".not.greater.than.zero");
|
||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(
|
||||
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||
.append(this.parameter).append(".not.greater.than.zero");
|
||||
final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(this.parameter).append(
|
||||
" must be greater than 0.");
|
||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||
defaultEnglishMessage.toString(), parameter, number, 0);
|
||||
dataValidationErrors.add(error);
|
||||
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||
defaultEnglishMessage.toString(), this.parameter, number, 0);
|
||||
this.dataValidationErrors.add(error);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public DataValidatorBuilder arrayNotEmpty() {
|
||||
if (value == null && ignoreNullValue) { return this; }
|
||||
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||
|
||||
Object[] array = (Object[]) value;
|
||||
final Object[] array = (Object[]) this.value;
|
||||
if (ObjectUtils.isEmpty(array)) {
|
||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter)
|
||||
.append(".cannot.be.empty");
|
||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(
|
||||
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||
.append(this.parameter).append(".cannot.be.empty");
|
||||
final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(this.parameter).append(
|
||||
" cannot be empty. You must select at least one.");
|
||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
|
||||
parameter);
|
||||
dataValidationErrors.add(error);
|
||||
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||
defaultEnglishMessage.toString(), this.parameter);
|
||||
this.dataValidationErrors.add(error);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public DataValidatorBuilder jsonArrayNotEmpty() {
|
||||
if (value == null && ignoreNullValue) { return this; }
|
||||
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||
|
||||
JsonArray array = (JsonArray) value;
|
||||
if (value != null && !array.iterator().hasNext()) {
|
||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter)
|
||||
.append(".cannot.be.empty");
|
||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(
|
||||
final JsonArray array = (JsonArray) this.value;
|
||||
if (this.value != null && !array.iterator().hasNext()) {
|
||||
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||
.append(this.parameter).append(".cannot.be.empty");
|
||||
final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(this.parameter).append(
|
||||
" cannot be empty. You must select at least one.");
|
||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
|
||||
parameter);
|
||||
dataValidationErrors.add(error);
|
||||
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||
defaultEnglishMessage.toString(), this.parameter);
|
||||
this.dataValidationErrors.add(error);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public void expectedArrayButIsNot() {
|
||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter)
|
||||
.append(".is.not.an.array");
|
||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(" is not an array.");
|
||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
|
||||
parameter);
|
||||
dataValidationErrors.add(error);
|
||||
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||
.append(this.parameter).append(".is.not.an.array");
|
||||
final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(this.parameter).append(" is not an array.");
|
||||
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
|
||||
this.parameter);
|
||||
this.dataValidationErrors.add(error);
|
||||
}
|
||||
|
||||
public DataValidatorBuilder anyOfNotNull(final Object... object) {
|
||||
boolean hasData = false;
|
||||
for (Object obj : object) {
|
||||
for (final Object obj : object) {
|
||||
if (obj != null) {
|
||||
hasData = true;
|
||||
break;
|
||||
@@ -412,100 +416,105 @@ public class DataValidatorBuilder {
|
||||
}
|
||||
|
||||
if (!hasData) {
|
||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".no.parameters.for.update");
|
||||
StringBuilder defaultEnglishMessage = new StringBuilder("No parameters passed for update.");
|
||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
|
||||
"id");
|
||||
dataValidationErrors.add(error);
|
||||
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(
|
||||
".no.parameters.for.update");
|
||||
final StringBuilder defaultEnglishMessage = new StringBuilder("No parameters passed for update.");
|
||||
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||
defaultEnglishMessage.toString(), "id");
|
||||
this.dataValidationErrors.add(error);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public DataValidatorBuilder inValidValue(final String parameterValueCode, final Object invalidValue) {
|
||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter)
|
||||
.append(".invalid.").append(parameterValueCode);
|
||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(" has an invalid value.");
|
||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
|
||||
parameter, invalidValue);
|
||||
dataValidationErrors.add(error);
|
||||
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||
.append(this.parameter).append(".invalid.").append(parameterValueCode);
|
||||
final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(this.parameter).append(
|
||||
" has an invalid value.");
|
||||
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
|
||||
this.parameter, invalidValue);
|
||||
this.dataValidationErrors.add(error);
|
||||
return this;
|
||||
}
|
||||
|
||||
public DataValidatorBuilder mustBeBlankWhenParameterProvided(final String parameterName, final Object parameterValue) {
|
||||
if (value == null && ignoreNullValue) { return this; }
|
||||
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||
|
||||
if (value == null && parameterValue != null) { return this; }
|
||||
if (this.value == null && parameterValue != null) { return this; }
|
||||
|
||||
if (value != null && StringUtils.isBlank(value.toString()) && parameterValue != null
|
||||
if (this.value != null && StringUtils.isBlank(this.value.toString()) && parameterValue != null
|
||||
&& StringUtils.isNotBlank(parameterValue.toString())) { return this; }
|
||||
|
||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter)
|
||||
.append(".cannot.also.be.provided.when.").append(parameterName).append(".is.populated");
|
||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter)
|
||||
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||
.append(this.parameter).append(".cannot.also.be.provided.when.").append(parameterName).append(".is.populated");
|
||||
final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(this.parameter)
|
||||
.append(" cannot also be provided when ").append(parameterName).append(" is populated.");
|
||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
|
||||
parameter, value, parameterName, parameterValue);
|
||||
dataValidationErrors.add(error);
|
||||
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
|
||||
this.parameter, this.value, parameterName, parameterValue);
|
||||
this.dataValidationErrors.add(error);
|
||||
return this;
|
||||
}
|
||||
|
||||
public DataValidatorBuilder mustBeBlankWhenParameterProvidedIs(final String parameterName, final Object parameterValue) {
|
||||
if (value == null && ignoreNullValue) { return this; }
|
||||
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||
|
||||
if (value == null && parameterValue != null) { return this; }
|
||||
if (this.value == null && parameterValue != null) { return this; }
|
||||
|
||||
if (value != null && StringUtils.isBlank(value.toString()) && parameterValue != null
|
||||
if (this.value != null && StringUtils.isBlank(this.value.toString()) && parameterValue != null
|
||||
&& StringUtils.isNotBlank(parameterValue.toString())) { return this; }
|
||||
|
||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter)
|
||||
.append(".cannot.also.be.provided.when.").append(parameterName).append(".is.").append(parameterValue);
|
||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter)
|
||||
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||
.append(this.parameter).append(".cannot.also.be.provided.when.").append(parameterName).append(".is.")
|
||||
.append(parameterValue);
|
||||
final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(this.parameter)
|
||||
.append(" cannot also be provided when ").append(parameterName).append(" is ").append(parameterValue);
|
||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
|
||||
parameter, value, parameterName, parameterValue);
|
||||
dataValidationErrors.add(error);
|
||||
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
|
||||
this.parameter, this.value, parameterName, parameterValue);
|
||||
this.dataValidationErrors.add(error);
|
||||
return this;
|
||||
}
|
||||
|
||||
public DataValidatorBuilder cantBeBlankWhenParameterProvidedIs(final String parameterName, final Object parameterValue) {
|
||||
if (value != null && StringUtils.isNotBlank(value.toString())) { return this; }
|
||||
if (this.value != null && StringUtils.isNotBlank(this.value.toString())) { return this; }
|
||||
|
||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter)
|
||||
.append(".must.be.provided.when.").append(parameterName).append(".is.").append(parameterValue);
|
||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(" must be provided when ")
|
||||
.append(parameterName).append(" is ").append(parameterValue);
|
||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
|
||||
parameter, value, parameterName, parameterValue);
|
||||
dataValidationErrors.add(error);
|
||||
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||
.append(this.parameter).append(".must.be.provided.when.").append(parameterName).append(".is.").append(parameterValue);
|
||||
final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(this.parameter)
|
||||
.append(" must be provided when ").append(parameterName).append(" is ").append(parameterValue);
|
||||
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
|
||||
this.parameter, this.value, parameterName, parameterValue);
|
||||
this.dataValidationErrors.add(error);
|
||||
return this;
|
||||
}
|
||||
|
||||
public DataValidatorBuilder comapareMinimumAndMaximumAmounts(final BigDecimal minimumBalance, final BigDecimal maximumBalance) {
|
||||
if (minimumBalance != null && maximumBalance != null)
|
||||
if (minimumBalance != null && maximumBalance != null) {
|
||||
if (maximumBalance.compareTo(minimumBalance) == -1) {
|
||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter)
|
||||
.append(".is.not.within.expected.range");
|
||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(" minimum amount ").append(minimumBalance)
|
||||
.append(" should less than maximum amount ").append(maximumBalance).append(".");
|
||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||
defaultEnglishMessage.toString(), parameter, minimumBalance, maximumBalance);
|
||||
dataValidationErrors.add(error);
|
||||
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||
.append(this.parameter).append(".is.not.within.expected.range");
|
||||
final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(" minimum amount ")
|
||||
.append(minimumBalance).append(" should less than maximum amount ").append(maximumBalance).append(".");
|
||||
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||
defaultEnglishMessage.toString(), this.parameter, minimumBalance, maximumBalance);
|
||||
this.dataValidationErrors.add(error);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public DataValidatorBuilder inMinAndMaxAmountRange(final BigDecimal minimumAmount, final BigDecimal maximumAmount) {
|
||||
if (minimumAmount != null && maximumAmount != null && value != null) {
|
||||
BigDecimal amount = BigDecimal.valueOf(Double.valueOf(value.toString()));
|
||||
if (minimumAmount != null && maximumAmount != null && this.value != null) {
|
||||
final BigDecimal amount = BigDecimal.valueOf(Double.valueOf(this.value.toString()));
|
||||
if (amount.compareTo(minimumAmount) == -1 || amount.compareTo(maximumAmount) == 1) {
|
||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter)
|
||||
.append(".amount.is.not.within.min.max.range");
|
||||
StringBuilder defaultEnglishMessage = new StringBuilder("The ").append(parameter).append(" amount ").append(amount)
|
||||
.append(" must be between ").append(minimumAmount).append(" and ").append(maximumAmount).append(" .");
|
||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||
defaultEnglishMessage.toString(), parameter, amount, minimumAmount, maximumAmount);
|
||||
dataValidationErrors.add(error);
|
||||
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||
.append(this.parameter).append(".amount.is.not.within.min.max.range");
|
||||
final StringBuilder defaultEnglishMessage = new StringBuilder("The ").append(this.parameter).append(" amount ")
|
||||
.append(amount).append(" must be between ").append(minimumAmount).append(" and ").append(maximumAmount)
|
||||
.append(" .");
|
||||
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||
defaultEnglishMessage.toString(), this.parameter, amount, minimumAmount, maximumAmount);
|
||||
this.dataValidationErrors.add(error);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -513,16 +522,16 @@ public class DataValidatorBuilder {
|
||||
}
|
||||
|
||||
public DataValidatorBuilder notLessThanMin(final BigDecimal min) {
|
||||
if (min != null && value != null) {
|
||||
BigDecimal amount = BigDecimal.valueOf(Double.valueOf(value.toString()));
|
||||
if (min != null && this.value != null) {
|
||||
final BigDecimal amount = BigDecimal.valueOf(Double.valueOf(this.value.toString()));
|
||||
if (amount.compareTo(min) == -1) {
|
||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter)
|
||||
.append(".is.less.than.min");
|
||||
StringBuilder defaultEnglishMessage = new StringBuilder("The ").append(parameter).append(" value ").append(amount)
|
||||
.append(" must not be less than minimum value ").append(min);
|
||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||
defaultEnglishMessage.toString(), parameter, amount, min);
|
||||
dataValidationErrors.add(error);
|
||||
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||
.append(this.parameter).append(".is.less.than.min");
|
||||
final StringBuilder defaultEnglishMessage = new StringBuilder("The ").append(this.parameter).append(" value ")
|
||||
.append(amount).append(" must not be less than minimum value ").append(min);
|
||||
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||
defaultEnglishMessage.toString(), this.parameter, amount, min);
|
||||
this.dataValidationErrors.add(error);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -530,16 +539,16 @@ public class DataValidatorBuilder {
|
||||
}
|
||||
|
||||
public DataValidatorBuilder notGreaterThanMax(final BigDecimal max) {
|
||||
if (max != null && value != null) {
|
||||
BigDecimal amount = BigDecimal.valueOf(Double.valueOf(value.toString()));
|
||||
if (max != null && this.value != null) {
|
||||
final BigDecimal amount = BigDecimal.valueOf(Double.valueOf(this.value.toString()));
|
||||
if (amount.compareTo(max) == 1) {
|
||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter)
|
||||
.append(".is.greater.than.max");
|
||||
StringBuilder defaultEnglishMessage = new StringBuilder("The ").append(parameter).append(" value ").append(amount)
|
||||
.append(" must not be more than maximum value ").append(max);
|
||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||
defaultEnglishMessage.toString(), parameter, amount, max);
|
||||
dataValidationErrors.add(error);
|
||||
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||
.append(this.parameter).append(".is.greater.than.max");
|
||||
final StringBuilder defaultEnglishMessage = new StringBuilder("The ").append(this.parameter).append(" value ")
|
||||
.append(amount).append(" must not be more than maximum value ").append(max);
|
||||
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||
defaultEnglishMessage.toString(), this.parameter, amount, max);
|
||||
this.dataValidationErrors.add(error);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -547,34 +556,35 @@ public class DataValidatorBuilder {
|
||||
}
|
||||
|
||||
public DataValidatorBuilder comapareMinAndMaxOfTwoBigDecmimalNos(final BigDecimal min, final BigDecimal max) {
|
||||
if (min != null && max != null)
|
||||
if (min != null && max != null) {
|
||||
if (max.compareTo(min) == -1) {
|
||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter)
|
||||
.append(".is.not.within.expected.range");
|
||||
StringBuilder defaultEnglishMessage = new StringBuilder("The ").append(" min number ").append(min)
|
||||
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||
.append(this.parameter).append(".is.not.within.expected.range");
|
||||
final StringBuilder defaultEnglishMessage = new StringBuilder("The ").append(" min number ").append(min)
|
||||
.append(" should less than max number ").append(max).append(".");
|
||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||
defaultEnglishMessage.toString(), parameter, min, max);
|
||||
dataValidationErrors.add(error);
|
||||
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||
defaultEnglishMessage.toString(), this.parameter, min, max);
|
||||
this.dataValidationErrors.add(error);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public DataValidatorBuilder isValidRecurringRule(final String recurringRule) {
|
||||
if (StringUtils.isNotBlank(recurringRule)) {
|
||||
try {
|
||||
RRule rRule = new RRule(recurringRule);
|
||||
final RRule rRule = new RRule(recurringRule);
|
||||
rRule.validate();
|
||||
} catch (ValidationException e) {
|
||||
ApiParameterError error = ApiParameterError.parameterError("validation.msg.invalid.recurring.rule",
|
||||
"The Recurring Rule value: " + recurringRule + " is not valid.", parameter, recurringRule);
|
||||
dataValidationErrors.add(error);
|
||||
} catch (final ValidationException e) {
|
||||
final ApiParameterError error = ApiParameterError.parameterError("validation.msg.invalid.recurring.rule",
|
||||
"The Recurring Rule value: " + recurringRule + " is not valid.", this.parameter, recurringRule);
|
||||
this.dataValidationErrors.add(error);
|
||||
return this;
|
||||
} catch (ParseException e) {
|
||||
ApiParameterError error = ApiParameterError.parameterError("validation.msg.recurring.rule.parsing.error",
|
||||
"Error in pasring the Recurring Rule value: " + recurringRule + ".", parameter, recurringRule);
|
||||
dataValidationErrors.add(error);
|
||||
} catch (final ParseException e) {
|
||||
final ApiParameterError error = ApiParameterError.parameterError("validation.msg.recurring.rule.parsing.error",
|
||||
"Error in pasring the Recurring Rule value: " + recurringRule + ".", this.parameter, recurringRule);
|
||||
this.dataValidationErrors.add(error);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -582,54 +592,54 @@ public class DataValidatorBuilder {
|
||||
}
|
||||
|
||||
public DataValidatorBuilder notLessThanMin(final Integer min) {
|
||||
if (value == null && ignoreNullValue) { return this; }
|
||||
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||
|
||||
if (value != null && min != null) {
|
||||
Integer number = Integer.valueOf(value.toString());
|
||||
if (this.value != null && min != null) {
|
||||
final Integer number = Integer.valueOf(this.value.toString());
|
||||
if (number < min) {
|
||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter)
|
||||
.append(".is.less.than.min");
|
||||
StringBuilder defaultEnglishMessage = new StringBuilder("The ").append(parameter)
|
||||
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||
.append(this.parameter).append(".is.less.than.min");
|
||||
final StringBuilder defaultEnglishMessage = new StringBuilder("The ").append(this.parameter)
|
||||
.append(" must be greater than minimum value ").append(min);
|
||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||
defaultEnglishMessage.toString(), parameter, number, min);
|
||||
dataValidationErrors.add(error);
|
||||
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||
defaultEnglishMessage.toString(), this.parameter, number, min);
|
||||
this.dataValidationErrors.add(error);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public DataValidatorBuilder notGreaterThanMax(final Integer max) {
|
||||
if (value == null && ignoreNullValue) { return this; }
|
||||
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||
|
||||
if (value != null && max != null) {
|
||||
Integer number = Integer.valueOf(value.toString());
|
||||
if (this.value != null && max != null) {
|
||||
final Integer number = Integer.valueOf(this.value.toString());
|
||||
if (number > max) {
|
||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter)
|
||||
.append(".is.greater.than.max");
|
||||
StringBuilder defaultEnglishMessage = new StringBuilder("The ").append(parameter)
|
||||
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||
.append(this.parameter).append(".is.greater.than.max");
|
||||
final StringBuilder defaultEnglishMessage = new StringBuilder("The ").append(this.parameter)
|
||||
.append(" must be less than maximum value ").append(max);
|
||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||
defaultEnglishMessage.toString(), parameter, number, max);
|
||||
dataValidationErrors.add(error);
|
||||
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||
defaultEnglishMessage.toString(), this.parameter, number, max);
|
||||
this.dataValidationErrors.add(error);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public DataValidatorBuilder matchesRegularExpression(final String expression) {
|
||||
if (value == null && ignoreNullValue) { return this; }
|
||||
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||
|
||||
if (value != null && !value.toString().matches(expression)) {
|
||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter)
|
||||
.append(".does.not.match.regexp");
|
||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter)
|
||||
if (this.value != null && !this.value.toString().matches(expression)) {
|
||||
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||
.append(this.parameter).append(".does.not.match.regexp");
|
||||
final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(this.parameter)
|
||||
.append(" must match the provided regular expression [ ").append(expression).append(" ] ").append(".");
|
||||
|
||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
|
||||
parameter, this.value, expression);
|
||||
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||
defaultEnglishMessage.toString(), this.parameter, this.value, expression);
|
||||
|
||||
dataValidationErrors.add(error);
|
||||
this.dataValidationErrors.add(error);
|
||||
}
|
||||
|
||||
return this;
|
||||
@@ -669,9 +679,9 @@ public class DataValidatorBuilder {
|
||||
* the beginning and can contain whitespaces in between and length
|
||||
* allowed is 0-25 chars.
|
||||
*/
|
||||
String regex = "^\\+?[0-9. ()-]{0,25}$";
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
Matcher matcher = pattern.matcher(this.value.toString());
|
||||
final String regex = "^\\+?[0-9. ()-]{0,25}$";
|
||||
final Pattern pattern = Pattern.compile(regex);
|
||||
final Matcher matcher = pattern.matcher(this.value.toString());
|
||||
if (matcher.matches()) {
|
||||
validationErr = false;
|
||||
}
|
||||
@@ -688,14 +698,14 @@ public class DataValidatorBuilder {
|
||||
}
|
||||
|
||||
public DataValidatorBuilder validateCronExpression() {
|
||||
if (value != null && !CronExpression.isValidExpression(this.value.toString().trim())) {
|
||||
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter)
|
||||
.append(".invalid");
|
||||
final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(
|
||||
if (this.value != null && !CronExpression.isValidExpression(this.value.toString().trim())) {
|
||||
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||
.append(this.parameter).append(".invalid");
|
||||
final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(this.parameter).append(
|
||||
" value is not a valid cron expression");
|
||||
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||
defaultEnglishMessage.toString(), parameter, this.value);
|
||||
dataValidationErrors.add(error);
|
||||
defaultEnglishMessage.toString(), this.parameter, this.value);
|
||||
this.dataValidationErrors.add(error);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
+2
-2
@@ -24,10 +24,10 @@ public class EnumOptionData {
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
return this.code;
|
||||
}
|
||||
}
|
||||
+19
-16
@@ -21,13 +21,16 @@ import org.springframework.data.jpa.domain.AbstractAuditable;
|
||||
import org.springframework.data.jpa.domain.AbstractPersistable;
|
||||
|
||||
/**
|
||||
* A custom copy of {@link AbstractAuditable} to override the column names used on database.
|
||||
* A custom copy of {@link AbstractAuditable} to override the column names used
|
||||
* on database.
|
||||
*
|
||||
* Abstract base class for auditable entities. Stores the audition values in
|
||||
* persistent fields.
|
||||
*
|
||||
* @param <U> the auditing type. Typically some kind of user.
|
||||
* @param <PK> the type of the auditing type's identifier
|
||||
* @param <U>
|
||||
* the auditing type. Typically some kind of user.
|
||||
* @param <PK>
|
||||
* the type of the auditing type's identifier
|
||||
*/
|
||||
@MappedSuperclass
|
||||
public abstract class AbstractAuditableCustom<U, PK extends Serializable> extends AbstractPersistable<PK> implements Auditable<U, PK> {
|
||||
@@ -35,26 +38,26 @@ public abstract class AbstractAuditableCustom<U, PK extends Serializable> extend
|
||||
private static final long serialVersionUID = 141481953116476081L;
|
||||
|
||||
@OneToOne
|
||||
@JoinColumn(name="createdby_id")
|
||||
private U createdBy;
|
||||
@JoinColumn(name = "createdby_id")
|
||||
private U createdBy;
|
||||
|
||||
@Column(name="created_date")
|
||||
@Column(name = "created_date")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date createdDate;
|
||||
private Date createdDate;
|
||||
|
||||
@OneToOne
|
||||
@JoinColumn(name="lastmodifiedby_id")
|
||||
private U lastModifiedBy;
|
||||
@JoinColumn(name = "lastmodifiedby_id")
|
||||
private U lastModifiedBy;
|
||||
|
||||
@Column(name="lastmodified_date")
|
||||
@Column(name = "lastmodified_date")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date lastModifiedDate;
|
||||
private Date lastModifiedDate;
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.data.domain.Auditable#getCreatedBy()
|
||||
*/
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.data.domain.Auditable#getCreatedBy()
|
||||
*/
|
||||
@Override
|
||||
public U getCreatedBy() {
|
||||
|
||||
|
||||
+4
-4
@@ -22,16 +22,16 @@ public class AuditorAwareImpl implements AuditorAware<AppUser> {
|
||||
public AppUser getCurrentAuditor() {
|
||||
|
||||
AppUser currentUser = null;
|
||||
SecurityContext securityContext = SecurityContextHolder.getContext();
|
||||
final SecurityContext securityContext = SecurityContextHolder.getContext();
|
||||
if (securityContext != null) {
|
||||
Authentication authentication = securityContext.getAuthentication();
|
||||
final Authentication authentication = securityContext.getAuthentication();
|
||||
if (authentication != null) {
|
||||
currentUser = (AppUser) authentication.getPrincipal();
|
||||
} else {
|
||||
currentUser = this.retrieveSuperUser();
|
||||
currentUser = retrieveSuperUser();
|
||||
}
|
||||
} else {
|
||||
currentUser = this.retrieveSuperUser();
|
||||
currentUser = retrieveSuperUser();
|
||||
}
|
||||
return currentUser;
|
||||
}
|
||||
|
||||
+3
-3
@@ -10,16 +10,16 @@ public class Base64EncodedImage {
|
||||
private final String base64EncodedString;
|
||||
private final String fileExtension;
|
||||
|
||||
public Base64EncodedImage(String base64EncodedString, String fileExtension) {
|
||||
public Base64EncodedImage(final String base64EncodedString, final String fileExtension) {
|
||||
this.base64EncodedString = base64EncodedString;
|
||||
this.fileExtension = fileExtension;
|
||||
}
|
||||
|
||||
public String getBase64EncodedString() {
|
||||
return base64EncodedString;
|
||||
return this.base64EncodedString;
|
||||
}
|
||||
|
||||
public String getFileExtension() {
|
||||
return fileExtension;
|
||||
return this.fileExtension;
|
||||
}
|
||||
}
|
||||
+22
-22
@@ -7,31 +7,31 @@ package org.mifosplatform.infrastructure.core.domain;
|
||||
|
||||
public class EmailDetail {
|
||||
|
||||
private final String organisationName;
|
||||
private final String username;
|
||||
private final String contactName;
|
||||
private final String address;
|
||||
private final String organisationName;
|
||||
private final String username;
|
||||
private final String contactName;
|
||||
private final String address;
|
||||
|
||||
public EmailDetail(String organisationName, String contactName, String address, String username) {
|
||||
this.organisationName = organisationName;
|
||||
this.contactName = contactName;
|
||||
this.address = address;
|
||||
this.username = username;
|
||||
}
|
||||
public EmailDetail(final String organisationName, final String contactName, final String address, final String username) {
|
||||
this.organisationName = organisationName;
|
||||
this.contactName = contactName;
|
||||
this.address = address;
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getOrganisationName() {
|
||||
return this.organisationName;
|
||||
}
|
||||
public String getOrganisationName() {
|
||||
return this.organisationName;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return this.username;
|
||||
}
|
||||
public String getUsername() {
|
||||
return this.username;
|
||||
}
|
||||
|
||||
public String getContactName() {
|
||||
return this.contactName;
|
||||
}
|
||||
public String getContactName() {
|
||||
return this.contactName;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return this.address;
|
||||
}
|
||||
public String getAddress() {
|
||||
return this.address;
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -23,7 +23,7 @@ public class JdbcSupport {
|
||||
|
||||
public static DateTime getDateTime(final ResultSet rs, final String columnName) throws SQLException {
|
||||
DateTime dateTime = null;
|
||||
Timestamp dateValue = rs.getTimestamp(columnName);
|
||||
final Timestamp dateValue = rs.getTimestamp(columnName);
|
||||
if (dateValue != null) {
|
||||
dateTime = new DateTime(dateValue.getTime());
|
||||
}
|
||||
@@ -48,7 +48,7 @@ public class JdbcSupport {
|
||||
}
|
||||
|
||||
public static Integer getIntegerDefaultToNullIfZero(final ResultSet rs, final String columnName) throws SQLException {
|
||||
Integer value = (Integer) JdbcUtils.getResultSetValue(rs, rs.findColumn(columnName), Integer.class);
|
||||
final Integer value = (Integer) JdbcUtils.getResultSetValue(rs, rs.findColumn(columnName), Integer.class);
|
||||
return defaultToNullIfZero(value);
|
||||
}
|
||||
|
||||
|
||||
+13
-14
@@ -15,10 +15,9 @@ public class Tenant {
|
||||
private final String schemaUsername;
|
||||
private final String schemaPassword;
|
||||
private final String timezoneId;
|
||||
|
||||
|
||||
public Tenant(final Long id, final String name, final String schemaName, final String schemaServer,
|
||||
final String schemaServerPort, final String schemaUsername, final String schemaPassword, String timezoneId) {
|
||||
public Tenant(final Long id, final String name, final String schemaName, final String schemaServer, final String schemaServerPort,
|
||||
final String schemaUsername, final String schemaPassword, final String timezoneId) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.schemaName = schemaName;
|
||||
@@ -27,39 +26,39 @@ public class Tenant {
|
||||
this.schemaUsername = schemaUsername;
|
||||
this.schemaPassword = schemaPassword;
|
||||
this.timezoneId = timezoneId;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public String getSchemaName() {
|
||||
return schemaName;
|
||||
return this.schemaName;
|
||||
}
|
||||
|
||||
public String getSchemaServer() {
|
||||
return schemaServer;
|
||||
return this.schemaServer;
|
||||
}
|
||||
|
||||
public String getSchemaServerPort() {
|
||||
return schemaServerPort;
|
||||
return this.schemaServerPort;
|
||||
}
|
||||
|
||||
public String getSchemaUsername() {
|
||||
return schemaUsername;
|
||||
return this.schemaUsername;
|
||||
}
|
||||
|
||||
public String getSchemaPassword() {
|
||||
return schemaPassword;
|
||||
return this.schemaPassword;
|
||||
}
|
||||
|
||||
|
||||
public String getTimezoneId() {
|
||||
return timezoneId;
|
||||
return this.timezoneId;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+5
-4
@@ -15,21 +15,22 @@ public abstract class AbstractPlatformDomainRuleException extends RuntimeExcepti
|
||||
private final String defaultUserMessage;
|
||||
private final Object[] defaultUserMessageArgs;
|
||||
|
||||
public AbstractPlatformDomainRuleException(final String globalisationMessageCode, final String defaultUserMessage, final Object... defaultUserMessageArgs) {
|
||||
public AbstractPlatformDomainRuleException(final String globalisationMessageCode, final String defaultUserMessage,
|
||||
final Object... defaultUserMessageArgs) {
|
||||
this.globalisationMessageCode = globalisationMessageCode;
|
||||
this.defaultUserMessage = defaultUserMessage;
|
||||
this.defaultUserMessageArgs = defaultUserMessageArgs;
|
||||
}
|
||||
|
||||
public String getGlobalisationMessageCode() {
|
||||
return globalisationMessageCode;
|
||||
return this.globalisationMessageCode;
|
||||
}
|
||||
|
||||
public String getDefaultUserMessage() {
|
||||
return defaultUserMessage;
|
||||
return this.defaultUserMessage;
|
||||
}
|
||||
|
||||
public Object[] getDefaultUserMessageArgs() {
|
||||
return defaultUserMessageArgs;
|
||||
return this.defaultUserMessageArgs;
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -23,14 +23,14 @@ public abstract class AbstractPlatformResourceNotFoundException extends RuntimeE
|
||||
}
|
||||
|
||||
public String getGlobalisationMessageCode() {
|
||||
return globalisationMessageCode;
|
||||
return this.globalisationMessageCode;
|
||||
}
|
||||
|
||||
public String getDefaultUserMessage() {
|
||||
return defaultUserMessage;
|
||||
return this.defaultUserMessage;
|
||||
}
|
||||
|
||||
public Object[] getDefaultUserMessageArgs() {
|
||||
return defaultUserMessageArgs;
|
||||
return this.defaultUserMessageArgs;
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -23,14 +23,14 @@ public abstract class AbstractPlatformServiceUnavailableException extends Runtim
|
||||
}
|
||||
|
||||
public String getGlobalisationMessageCode() {
|
||||
return globalisationMessageCode;
|
||||
return this.globalisationMessageCode;
|
||||
}
|
||||
|
||||
public String getDefaultUserMessage() {
|
||||
return defaultUserMessage;
|
||||
return this.defaultUserMessage;
|
||||
}
|
||||
|
||||
public Object[] getDefaultUserMessageArgs() {
|
||||
return defaultUserMessageArgs;
|
||||
return this.defaultUserMessageArgs;
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -32,14 +32,14 @@ public class PlatformApiDataValidationException extends RuntimeException {
|
||||
}
|
||||
|
||||
public String getGlobalisationMessageCode() {
|
||||
return globalisationMessageCode;
|
||||
return this.globalisationMessageCode;
|
||||
}
|
||||
|
||||
public String getDefaultUserMessage() {
|
||||
return defaultUserMessage;
|
||||
return this.defaultUserMessage;
|
||||
}
|
||||
|
||||
public List<ApiParameterError> getErrors() {
|
||||
return errors;
|
||||
return this.errors;
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -33,18 +33,18 @@ public class PlatformDataIntegrityException extends RuntimeException {
|
||||
}
|
||||
|
||||
public String getGlobalisationMessageCode() {
|
||||
return globalisationMessageCode;
|
||||
return this.globalisationMessageCode;
|
||||
}
|
||||
|
||||
public String getDefaultUserMessage() {
|
||||
return defaultUserMessage;
|
||||
return this.defaultUserMessage;
|
||||
}
|
||||
|
||||
public Object[] getDefaultUserMessageArgs() {
|
||||
return defaultUserMessageArgs;
|
||||
return this.defaultUserMessageArgs;
|
||||
}
|
||||
|
||||
public String getParameterName() {
|
||||
return parameterName;
|
||||
return this.parameterName;
|
||||
}
|
||||
}
|
||||
+5
-4
@@ -14,21 +14,22 @@ public class PlatformInternalServerException extends RuntimeException {
|
||||
private final String defaultUserMessage;
|
||||
private final Object[] defaultUserMessageArgs;
|
||||
|
||||
public PlatformInternalServerException(String globalisationMessageCode, String defaultUserMessage, Object... defaultUserMessageArgs) {
|
||||
public PlatformInternalServerException(final String globalisationMessageCode, final String defaultUserMessage,
|
||||
final Object... defaultUserMessageArgs) {
|
||||
this.globalisationMessageCode = globalisationMessageCode;
|
||||
this.defaultUserMessage = defaultUserMessage;
|
||||
this.defaultUserMessageArgs = defaultUserMessageArgs;
|
||||
}
|
||||
|
||||
public String getGlobalisationMessageCode() {
|
||||
return globalisationMessageCode;
|
||||
return this.globalisationMessageCode;
|
||||
}
|
||||
|
||||
public String getDefaultUserMessage() {
|
||||
return defaultUserMessage;
|
||||
return this.defaultUserMessage;
|
||||
}
|
||||
|
||||
public Object[] getDefaultUserMessageArgs() {
|
||||
return defaultUserMessageArgs;
|
||||
return this.defaultUserMessageArgs;
|
||||
}
|
||||
}
|
||||
+2
-3
@@ -2,10 +2,9 @@ package org.mifosplatform.infrastructure.core.exception;
|
||||
|
||||
public class PlatformServiceUnavailableException extends AbstractPlatformServiceUnavailableException {
|
||||
|
||||
public PlatformServiceUnavailableException(String globalisationMessageCode, String defaultUserMessage,
|
||||
Object... defaultUserMessageArgs) {
|
||||
public PlatformServiceUnavailableException(final String globalisationMessageCode, final String defaultUserMessage,
|
||||
final Object... defaultUserMessageArgs) {
|
||||
super(globalisationMessageCode, defaultUserMessage, defaultUserMessageArgs);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -18,11 +18,11 @@ public class UnrecognizedQueryParamException extends RuntimeException {
|
||||
}
|
||||
|
||||
public String getQueryParamKey() {
|
||||
return queryParamKey;
|
||||
return this.queryParamKey;
|
||||
}
|
||||
|
||||
public String getQueryParamValue() {
|
||||
return queryParamValue;
|
||||
return this.queryParamValue;
|
||||
}
|
||||
|
||||
public Object[] getSupportedParams() {
|
||||
|
||||
+2
-2
@@ -15,11 +15,11 @@ public class UnsupportedParameterException extends RuntimeException {
|
||||
|
||||
private final List<String> unsupportedParameters;
|
||||
|
||||
public UnsupportedParameterException(List<String> unsupportedParameters) {
|
||||
public UnsupportedParameterException(final List<String> unsupportedParameters) {
|
||||
this.unsupportedParameters = unsupportedParameters;
|
||||
}
|
||||
|
||||
public List<String> getUnsupportedParameters() {
|
||||
return unsupportedParameters;
|
||||
return this.unsupportedParameters;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user