Fineract Asset Externalization models

- [x] Liquibase database model
- [x] JPA model
- [x] API endpoint without implementation
- [x] API endpoint requirements
  - [x] Json Serialization and Deserialization and dependencies
  - [x] New Authentication check interface to the core level
  - [x] CommandWrapperBuilder and dependencies
This commit is contained in:
Janos Haber
2023-05-16 21:43:54 +02:00
committed by Arnold Gálovics
parent 6e69e66b86
commit da1aa9e5a8
56 changed files with 685 additions and 9 deletions
@@ -0,0 +1,439 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.accounting.common;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.fineract.accounting.financialactivityaccount.data.FinancialActivityData;
import org.apache.fineract.accounting.glaccount.domain.GLAccountType;
public final class AccountingConstants {
private AccountingConstants() {
}
/***
* Accounting placeholders for cash based accounting for loan products
***/
public enum CashAccountsForLoan {
FUND_SOURCE(1), LOAN_PORTFOLIO(2), INTEREST_ON_LOANS(3), INCOME_FROM_FEES(4), INCOME_FROM_PENALTIES(5), LOSSES_WRITTEN_OFF(
6), TRANSFERS_SUSPENSE(10), OVERPAYMENT(11), INCOME_FROM_RECOVERY(12), GOODWILL_CREDIT(13), INCOME_FROM_CHARGE_OFF_INTEREST(
14), INCOME_FROM_CHARGE_OFF_FEES(15), CHARGE_OFF_EXPENSE(16), CHARGE_OFF_FRAUD_EXPENSE(
17), INCOME_FROM_CHARGE_OFF_PENALTY(18), INCOME_FROM_GOODWILL_CREDIT_INTEREST(
19), INCOME_FROM_GOODWILL_CREDIT_FEES(20), INCOME_FROM_GOODWILL_CREDIT_PENALTY(21);
private final Integer value;
CashAccountsForLoan(final Integer value) {
this.value = value;
}
@Override
public String toString() {
return name().toString().replaceAll("_", " ");
}
public Integer getValue() {
return this.value;
}
private static final Map<Integer, CashAccountsForLoan> intToEnumMap = new HashMap<>();
static {
for (final CashAccountsForLoan type : CashAccountsForLoan.values()) {
intToEnumMap.put(type.value, type);
}
}
public static CashAccountsForLoan fromInt(final int i) {
final CashAccountsForLoan type = intToEnumMap.get(Integer.valueOf(i));
return type;
}
}
/***
* Accounting placeholders for accrual based accounting for loan products
***/
public enum AccrualAccountsForLoan {
FUND_SOURCE(1), LOAN_PORTFOLIO(2), INTEREST_ON_LOANS(3), INCOME_FROM_FEES(4), INCOME_FROM_PENALTIES(5), //
LOSSES_WRITTEN_OFF(6), INTEREST_RECEIVABLE(7), FEES_RECEIVABLE(8), PENALTIES_RECEIVABLE(9), //
TRANSFERS_SUSPENSE(10), OVERPAYMENT(11), INCOME_FROM_RECOVERY(12), GOODWILL_CREDIT(13), INCOME_FROM_CHARGE_OFF_INTEREST(
14), INCOME_FROM_CHARGE_OFF_FEES(15), CHARGE_OFF_EXPENSE(16), CHARGE_OFF_FRAUD_EXPENSE(17), INCOME_FROM_CHARGE_OFF_PENALTY(
18), INCOME_FROM_GOODWILL_CREDIT_INTEREST(
19), INCOME_FROM_GOODWILL_CREDIT_FEES(20), INCOME_FROM_GOODWILL_CREDIT_PENALTY(21);
private final Integer value;
AccrualAccountsForLoan(final Integer value) {
this.value = value;
}
@Override
public String toString() {
return name().toString().replaceAll("_", " ");
}
public Integer getValue() {
return this.value;
}
private static final Map<Integer, AccrualAccountsForLoan> intToEnumMap = new HashMap<>();
static {
for (final AccrualAccountsForLoan type : AccrualAccountsForLoan.values()) {
intToEnumMap.put(type.value, type);
}
}
public static AccrualAccountsForLoan fromInt(final int i) {
final AccrualAccountsForLoan type = intToEnumMap.get(Integer.valueOf(i));
return type;
}
}
/***
* Enum of all accounting related input parameter names used while creating/updating a loan product
***/
public enum LoanProductAccountingParams {
FUND_SOURCE("fundSourceAccountId"), LOAN_PORTFOLIO("loanPortfolioAccountId"), INTEREST_ON_LOANS(
"interestOnLoanAccountId"), INCOME_FROM_FEES("incomeFromFeeAccountId"), INCOME_FROM_PENALTIES(
"incomeFromPenaltyAccountId"), LOSSES_WRITTEN_OFF("writeOffAccountId"), GOODWILL_CREDIT(
"goodwillCreditAccountId"), OVERPAYMENT("overpaymentLiabilityAccountId"), INTEREST_RECEIVABLE(
"receivableInterestAccountId"), FEES_RECEIVABLE("receivableFeeAccountId"), PENALTIES_RECEIVABLE(
"receivablePenaltyAccountId"), TRANSFERS_SUSPENSE(
"transfersInSuspenseAccountId"), PAYMENT_CHANNEL_FUND_SOURCE_MAPPING(
"paymentChannelToFundSourceMappings"), PAYMENT_TYPE(
"paymentTypeId"), FEE_INCOME_ACCOUNT_MAPPING(
"feeToIncomeAccountMappings"), PENALTY_INCOME_ACCOUNT_MAPPING(
"penaltyToIncomeAccountMappings"), CHARGE_ID(
"chargeId"), INCOME_ACCOUNT_ID(
"incomeAccountId"), INCOME_FROM_RECOVERY(
"incomeFromRecoveryAccountId"), INCOME_FROM_CHARGE_OFF_INTEREST(
"incomeFromChargeOffInterestAccountId"), INCOME_FROM_CHARGE_OFF_FEES(
"incomeFromChargeOffFeesAccountId"), CHARGE_OFF_EXPENSE(
"chargeOffExpenseAccountId"), CHARGE_OFF_FRAUD_EXPENSE(
"chargeOffFraudExpenseAccountId"), INCOME_FROM_CHARGE_OFF_PENALTY(
"incomeFromChargeOffPenaltyAccountId"), INCOME_FROM_GOODWILL_CREDIT_INTEREST(
"incomeFromGoodwillCreditInterestAccountId"), INCOME_FROM_GOODWILL_CREDIT_FEES(
"incomeFromGoodwillCreditFeesAccountId"), INCOME_FROM_GOODWILL_CREDIT_PENALTY(
"incomeFromGoodwillCreditPenaltyAccountId");
private final String value;
LoanProductAccountingParams(final String value) {
this.value = value;
}
@Override
public String toString() {
return name().toString().replaceAll("_", " ");
}
public String getValue() {
return this.value;
}
}
public enum LoanProductAccountingDataParams {
FUND_SOURCE("fundSourceAccount"), LOAN_PORTFOLIO("loanPortfolioAccount"), INTEREST_ON_LOANS(
"interestOnLoanAccount"), INCOME_FROM_FEES("incomeFromFeeAccount"), INCOME_FROM_PENALTIES(
"incomeFromPenaltyAccount"), LOSSES_WRITTEN_OFF("writeOffAccount"), GOODWILL_CREDIT(
"goodwillCreditAccount"), OVERPAYMENT("overpaymentLiabilityAccount"), INTEREST_RECEIVABLE(
"receivableInterestAccount"), FEES_RECEIVABLE("receivableFeeAccount"), PENALTIES_RECEIVABLE(
"receivablePenaltyAccount"), TRANSFERS_SUSPENSE(
"transfersInSuspenseAccount"), INCOME_ACCOUNT_ID(
"incomeAccount"), INCOME_FROM_RECOVERY(
"incomeFromRecoveryAccount"), LIABILITY_TRANSFER_SUSPENSE(
"liabilityTransferInSuspenseAccount"), INCOME_FROM_CHARGE_OFF_INTEREST(
"incomeFromChargeOffInterestAccount"), INCOME_FROM_CHARGE_OFF_FEES(
"incomeFromChargeOffFeesAccount"), CHARGE_OFF_EXPENSE(
"chargeOffExpenseAccount"), CHARGE_OFF_FRAUD_EXPENSE(
"chargeOffFraudExpenseAccount"), INCOME_FROM_CHARGE_OFF_PENALTY(
"incomeFromChargeOffPenaltyAccount"), INCOME_FROM_GOODWILL_CREDIT_INTEREST(
"incomeFromGoodwillCreditInterestAccount"), INCOME_FROM_GOODWILL_CREDIT_FEES(
"incomeFromGoodwillCreditFeesAccount"), INCOME_FROM_GOODWILL_CREDIT_PENALTY(
"incomeFromGoodwillCreditPenaltyAccount");
private final String value;
LoanProductAccountingDataParams(final String value) {
this.value = value;
}
@Override
public String toString() {
return name().toString().replaceAll("_", " ");
}
public String getValue() {
return this.value;
}
}
/***
* Accounting placeholders for cash based accounting for savings products
***/
public enum CashAccountsForSavings {
SAVINGS_REFERENCE(1), SAVINGS_CONTROL(2), INTEREST_ON_SAVINGS(3), INCOME_FROM_FEES(4), INCOME_FROM_PENALTIES(5), TRANSFERS_SUSPENSE(
10), OVERDRAFT_PORTFOLIO_CONTROL(11), INCOME_FROM_INTEREST(12), LOSSES_WRITTEN_OFF(13), ESCHEAT_LIABILITY(14);
private final Integer value;
CashAccountsForSavings(final Integer value) {
this.value = value;
}
@Override
public String toString() {
return name().toString().replaceAll("_", " ");
}
public Integer getValue() {
return this.value;
}
private static final Map<Integer, CashAccountsForSavings> intToEnumMap = new HashMap<>();
static {
for (final CashAccountsForSavings type : CashAccountsForSavings.values()) {
intToEnumMap.put(type.value, type);
}
}
public static CashAccountsForSavings fromInt(final int i) {
final CashAccountsForSavings type = intToEnumMap.get(Integer.valueOf(i));
return type;
}
}
/***
* Enum of all accounting related input parameter names used while creating/updating a savings product
***/
public enum SavingProductAccountingParams {
SAVINGS_REFERENCE("savingsReferenceAccountId"), SAVINGS_CONTROL("savingsControlAccountId"), INCOME_FROM_FEES(
"incomeFromFeeAccountId"), INCOME_FROM_PENALTIES("incomeFromPenaltyAccountId"), INTEREST_ON_SAVINGS(
"interestOnSavingsAccountId"), PAYMENT_CHANNEL_FUND_SOURCE_MAPPING(
"paymentChannelToFundSourceMappings"), PAYMENT_TYPE("paymentTypeId"), FUND_SOURCE(
"fundSourceAccountId"), TRANSFERS_SUSPENSE(
"transfersInSuspenseAccountId"), FEE_INCOME_ACCOUNT_MAPPING(
"feeToIncomeAccountMappings"), PENALTY_INCOME_ACCOUNT_MAPPING(
"penaltyToIncomeAccountMappings"), CHARGE_ID("chargeId"), INCOME_ACCOUNT_ID(
"incomeAccountId"), OVERDRAFT_PORTFOLIO_CONTROL(
"overdraftPortfolioControlId"), INCOME_FROM_INTEREST(
"incomeFromInterestId"), LOSSES_WRITTEN_OFF(
"writeOffAccountId"), ESCHEAT_LIABILITY(
"escheatLiabilityId");
private final String value;
SavingProductAccountingParams(final String value) {
this.value = value;
}
@Override
public String toString() {
return name().toString().replaceAll("_", " ");
}
public String getValue() {
return this.value;
}
}
public enum SavingProductAccountingDataParams {
SAVINGS_REFERENCE("savingsReferenceAccount"), SAVINGS_CONTROL("savingsControlAccount"), INCOME_FROM_FEES(
"incomeFromFeeAccount"), INCOME_FROM_PENALTIES("incomeFromPenaltyAccount"), INTEREST_ON_SAVINGS(
"interestOnSavingsAccount"), PAYMENT_TYPE("paymentType"), FUND_SOURCE("fundSourceAccount"), TRANSFERS_SUSPENSE(
"transfersInSuspenseAccount"), PENALTY_INCOME_ACCOUNT_MAPPING("penaltyToIncomeAccountMappings"), CHARGE_ID(
"charge"), INCOME_ACCOUNT_ID("incomeAccount"), OVERDRAFT_PORTFOLIO_CONTROL(
"overdraftPortfolioControl"), INCOME_FROM_INTEREST(
"incomeFromInterest"), LOSSES_WRITTEN_OFF(
"writeOffAccount"), ESCHEAT_LIABILITY("escheatLiabilityAccount");
private final String value;
SavingProductAccountingDataParams(final String value) {
this.value = value;
}
@Override
public String toString() {
return name().toString().replaceAll("_", " ");
}
public String getValue() {
return this.value;
}
}
public enum FinancialActivity {
ASSET_TRANSFER(100, "assetTransfer", GLAccountType.ASSET), LIABILITY_TRANSFER(200, "liabilityTransfer",
GLAccountType.LIABILITY), CASH_AT_MAINVAULT(101, "cashAtMainVault", GLAccountType.ASSET), CASH_AT_TELLER(102,
"cashAtTeller", GLAccountType.ASSET), OPENING_BALANCES_TRANSFER_CONTRA(300, "openingBalancesTransferContra",
GLAccountType.EQUITY), ASSET_FUND_SOURCE(103, "fundSource",
GLAccountType.ASSET), PAYABLE_DIVIDENDS(201, "payableDividends", GLAccountType.LIABILITY);
private final Integer value;
private final String code;
private final GLAccountType mappedGLAccountType;
private static List<FinancialActivityData> financialActivities;
static {
financialActivities = new ArrayList<>();
for (final FinancialActivity type : FinancialActivity.values()) {
FinancialActivityData financialActivityData = convertToFinancialActivityData(type);
financialActivities.add(financialActivityData);
}
}
FinancialActivity(final Integer value, final String code, final GLAccountType mappedGLAccountType) {
this.value = value;
this.code = code;
this.mappedGLAccountType = mappedGLAccountType;
}
@Override
public String toString() {
return name().toString().replaceAll("_", " ");
}
public Integer getValue() {
return this.value;
}
public String getCode() {
return this.code;
}
public GLAccountType getMappedGLAccountType() {
return mappedGLAccountType;
}
public String getValueAsString() {
return this.value.toString();
}
private static final Map<Integer, FinancialActivity> intToEnumMap = new HashMap<>();
static {
for (final FinancialActivity type : FinancialActivity.values()) {
intToEnumMap.put(type.value, type);
}
}
public static FinancialActivity fromInt(final int financialActivityId) {
final FinancialActivity type = intToEnumMap.get(Integer.valueOf(financialActivityId));
return type;
}
public static FinancialActivityData toFinancialActivityData(final int financialActivityId) {
final FinancialActivity type = fromInt(financialActivityId);
return convertToFinancialActivityData(type);
}
public static List<FinancialActivityData> getAllFinancialActivities() {
return financialActivities;
}
private static FinancialActivityData convertToFinancialActivityData(final FinancialActivity type) {
FinancialActivityData financialActivityData = new FinancialActivityData(type.value, type.code, type.getMappedGLAccountType());
return financialActivityData;
}
}
/***
* Accounting placeholders for cash based accounting for Share products
***/
public enum CashAccountsForShares {
SHARES_REFERENCE(1), SHARES_SUSPENSE(2), INCOME_FROM_FEES(3), SHARES_EQUITY(4);
private final Integer value;
CashAccountsForShares(final Integer value) {
this.value = value;
}
@Override
public String toString() {
return name().toString().replaceAll("_", " ");
}
public Integer getValue() {
return this.value;
}
private static final Map<Integer, CashAccountsForShares> intToEnumMap = new HashMap<>();
static {
for (final CashAccountsForShares type : CashAccountsForShares.values()) {
intToEnumMap.put(type.value, type);
}
}
public static CashAccountsForShares fromInt(final int i) {
final CashAccountsForShares type = intToEnumMap.get(Integer.valueOf(i));
return type;
}
}
/***
* Enum of all accounting related input parameter names used while creating/updating a savings product
***/
public enum SharesProductAccountingParams {
SHARES_REFERENCE("shareReferenceId"), SHARES_SUSPENSE("shareSuspenseId"), INCOME_FROM_FEES("incomeFromFeeAccountId"), SHARES_EQUITY(
"shareEquityId");
private final String value;
SharesProductAccountingParams(final String value) {
this.value = value;
}
@Override
public String toString() {
return name().toString().replaceAll("_", " ");
}
public String getValue() {
return this.value;
}
}
public static final String ASSESTS_TAG_OPTION_CODE_NAME = "AssetAccountTags";
public static final String LIABILITIES_TAG_OPTION_CODE_NAME = "LiabilityAccountTags";
public static final String EQUITY_TAG_OPTION_CODE_NAME = "EquityAccountTags";
public static final String INCOME_TAG_OPTION_CODE_NAME = "IncomeAccountTags";
public static final String EXPENSES_TAG_OPTION_CODE_NAME = "ExpenseAccountTags";
}
@@ -0,0 +1,30 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.accounting.financialactivityaccount.data;
import lombok.Data;
import org.apache.fineract.accounting.glaccount.domain.GLAccountType;
@Data
public class FinancialActivityData {
private final Integer id;
private final String name;
private final GLAccountType mappedGLAccountType;
}
@@ -0,0 +1,127 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.accounting.glaccount.domain;
import java.util.HashMap;
import java.util.Map;
import org.apache.fineract.infrastructure.core.data.EnumOptionData;
public enum GLAccountType {
ASSET(1, "accountType.asset"), LIABILITY(2, "accountType.liability"), EQUITY(3, "accountType.equity"), INCOME(4,
"accountType.income"), EXPENSE(5, "accountType.expense");
private final Integer value;
private final String code;
GLAccountType(final Integer value, final String code) {
this.value = value;
this.code = code;
}
public Integer getValue() {
return this.value;
}
public String getCode() {
return this.code;
}
private static final Map<Integer, GLAccountType> intToEnumMap = new HashMap<>();
private static int minValue;
private static int maxValue;
static {
int i = 0;
for (final GLAccountType type : GLAccountType.values()) {
if (i == 0) {
minValue = type.value;
}
intToEnumMap.put(type.value, type);
if (minValue >= type.value) {
minValue = type.value;
}
if (maxValue < type.value) {
maxValue = type.value;
}
i = i + 1;
}
}
public static EnumOptionData fromString(String accountType) {
Long accountTypeId = null;
if (accountType != null && accountType.equalsIgnoreCase(ASSET.toString())) {
accountTypeId = 1L;
return new EnumOptionData(accountTypeId, null, null);
} else if (accountType != null && accountType.equalsIgnoreCase(LIABILITY.toString())) {
accountTypeId = 2L;
return new EnumOptionData(accountTypeId, null, null);
} else if (accountType != null && accountType.equalsIgnoreCase(EQUITY.toString())) {
accountTypeId = 3L;
return new EnumOptionData(accountTypeId, null, null);
} else if (accountType != null && accountType.equalsIgnoreCase(INCOME.toString())) {
accountTypeId = 4L;
return new EnumOptionData(accountTypeId, null, null);
} else if (accountType != null && accountType.equalsIgnoreCase(EXPENSE.toString())) {
accountTypeId = 5L;
return new EnumOptionData(accountTypeId, null, null);
} else {
return null;
}
}
public static GLAccountType fromInt(final int i) {
final GLAccountType type = intToEnumMap.get(Integer.valueOf(i));
return type;
}
public static int getMinValue() {
return minValue;
}
public static int getMaxValue() {
return maxValue;
}
@Override
public String toString() {
return name().toString();
}
public boolean isAssetType() {
return this.value.equals(GLAccountType.ASSET.getValue());
}
public boolean isLiabilityType() {
return this.value.equals(GLAccountType.LIABILITY.getValue());
}
public boolean isEquityType() {
return this.value.equals(GLAccountType.EQUITY.getValue());
}
public boolean isIncomeType() {
return this.value.equals(GLAccountType.INCOME.getValue());
}
public boolean isExpenseType() {
return this.value.equals(GLAccountType.EXPENSE.getValue());
}
}
@@ -0,0 +1,358 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.commands.domain;
import org.apache.fineract.useradministration.api.PasswordPreferencesApiConstants;
public class CommandWrapper {
private final Long commandId;
@SuppressWarnings("unused")
private final Long officeId;
private final Long groupId;
private final Long clientId;
private final Long loanId;
private final Long savingsId;
private final String actionName;
private final String entityName;
private final String taskPermissionName;
private final Long entityId;
private final Long subentityId;
private final String href;
private final String json;
private final String transactionId;
private final Long productId;
private final Long creditBureauId;
private final Long organisationCreditBureauId;
private final String jobName;
private final String idempotencyKey;
@SuppressWarnings("unused")
private Long templateId;
public static CommandWrapper wrap(final String actionName, final String entityName, final Long resourceId, final Long subresourceId) {
return new CommandWrapper(null, actionName, entityName, resourceId, subresourceId, null, null);
}
public static CommandWrapper fromExistingCommand(final Long commandId, final String actionName, final String entityName,
final Long resourceId, final Long subresourceId, final String resourceGetUrl, final Long productId) {
return new CommandWrapper(commandId, actionName, entityName, resourceId, subresourceId, resourceGetUrl, productId);
}
public static CommandWrapper fromExistingCommand(final Long commandId, final String actionName, final String entityName,
final Long resourceId, final Long subresourceId, final String resourceGetUrl, final Long productId, final Long officeId,
final Long groupId, final Long clientId, final Long loanId, final Long savingsId, final String transactionId,
final Long creditBureauId, final Long organisationCreditBureauId, final String idempotencyKey) {
return new CommandWrapper(commandId, actionName, entityName, resourceId, subresourceId, resourceGetUrl, productId, officeId,
groupId, clientId, loanId, savingsId, transactionId, creditBureauId, organisationCreditBureauId, idempotencyKey);
}
private CommandWrapper(final Long commandId, final String actionName, final String entityName, final Long resourceId,
final Long subresourceId, final String resourceGetUrl, final Long productId) {
this.commandId = commandId;
this.officeId = null;
this.groupId = null;
this.clientId = null;
this.loanId = null;
this.savingsId = null;
this.actionName = actionName;
this.entityName = entityName;
this.taskPermissionName = actionName + "_" + entityName;
this.entityId = resourceId;
this.subentityId = subresourceId;
this.href = resourceGetUrl;
this.json = null;
this.transactionId = null;
this.productId = productId;
this.creditBureauId = null;
this.organisationCreditBureauId = null;
this.jobName = null;
this.idempotencyKey = null;
}
public CommandWrapper(final Long officeId, final Long groupId, final Long clientId, final Long loanId, final Long savingsId,
final String actionName, final String entityName, final Long entityId, final Long subentityId, final String href,
final String json, final String transactionId, final Long productId, final Long templateId, final Long creditBureauId,
final Long organisationCreditBureauId, final String jobName, final String idempotencyKey) {
this.commandId = null;
this.officeId = officeId;
this.groupId = groupId;
this.clientId = clientId;
this.loanId = loanId;
this.savingsId = savingsId;
this.actionName = actionName;
this.entityName = entityName;
this.taskPermissionName = actionName + "_" + entityName;
this.entityId = entityId;
this.subentityId = subentityId;
this.href = href;
this.json = json;
this.transactionId = transactionId;
this.productId = productId;
this.templateId = templateId;
this.creditBureauId = creditBureauId;
this.organisationCreditBureauId = organisationCreditBureauId;
this.jobName = jobName;
this.idempotencyKey = idempotencyKey;
}
private CommandWrapper(final Long commandId, final String actionName, final String entityName, final Long resourceId,
final Long subresourceId, final String resourceGetUrl, final Long productId, final Long officeId, final Long groupId,
final Long clientId, final Long loanId, final Long savingsId, final String transactionId, final Long creditBureauId,
final Long organisationCreditBureauId, final String idempotencyKey) {
this.commandId = commandId;
this.officeId = officeId;
this.groupId = groupId;
this.clientId = clientId;
this.loanId = loanId;
this.savingsId = savingsId;
this.actionName = actionName;
this.entityName = entityName;
this.taskPermissionName = actionName + "_" + entityName;
this.entityId = resourceId;
this.subentityId = subresourceId;
this.href = resourceGetUrl;
this.json = null;
this.transactionId = transactionId;
this.productId = productId;
this.creditBureauId = creditBureauId;
this.organisationCreditBureauId = organisationCreditBureauId;
this.jobName = null;
this.idempotencyKey = idempotencyKey;
}
public Long getCreditBureauId() {
return this.creditBureauId;
}
public Long getOrganisationCreditBureauId() {
return this.organisationCreditBureauId;
}
public String getIdempotencyKey() {
return idempotencyKey;
}
public String getHref() {
return this.href;
}
public String getJson() {
return this.json;
}
public boolean isCreate() {
return this.actionName.equalsIgnoreCase("CREATE");
}
public boolean isCreateDatatable() {
return this.actionName.equalsIgnoreCase("CREATE") && this.href.startsWith("/datatables/") && this.entityId == null;
}
public boolean isDeleteDatatable() {
return this.actionName.equalsIgnoreCase("DELETE") && this.href.startsWith("/datatables/") && this.entityId == null;
}
public boolean isUpdateDatatable() {
return this.actionName.equalsIgnoreCase("UPDATE") && this.href.startsWith("/datatables/") && this.entityId == null;
}
public boolean isDatatableResource() {
return this.href.startsWith("/datatables/");
}
public boolean isDeleteOneToOne() {
/* also covers case of deleting all of a one to many */
return isDatatableResource() && isDeleteOperation() && this.subentityId == null;
}
public boolean isDeleteMultiple() {
return isDatatableResource() && isDeleteOperation() && this.subentityId != null;
}
public boolean isUpdateOneToOne() {
return isDatatableResource() && isUpdateOperation() && this.subentityId == null;
}
public boolean isUpdateMultiple() {
return isDatatableResource() && isUpdateOperation() && this.subentityId != null;
}
public boolean isRegisterDatatable() {
return this.actionName.equalsIgnoreCase("REGISTER") && this.href.startsWith("/datatables/") && this.entityId == null;
}
public boolean isNoteResource() {
boolean isnoteResource = false;
if (this.entityName.equalsIgnoreCase("CLIENTNOTE") || this.entityName.equalsIgnoreCase("LOANNOTE")
|| this.entityName.equalsIgnoreCase("LOANTRANSACTIONNOTE") || this.entityName.equalsIgnoreCase("SAVINGNOTE")
|| this.entityName.equalsIgnoreCase("GROUPNOTE")) {
isnoteResource = true;
}
return isnoteResource;
}
public boolean isUpdateOfOwnUserDetails(final Long loggedInUserId) {
return isUserResource() && isUpdate() && loggedInUserId.equals(this.entityId);
}
public boolean isUpdate() {
// permissions resource has special update which involves no resource.
return (isPermissionResource() && isUpdateOperation()) || (isCurrencyResource() && isUpdateOperation())
|| (isCacheResource() && isUpdateOperation()) || (isWorkingDaysResource() && isUpdateOperation())
|| (isPasswordPreferencesResource() && isUpdateOperation()) || (isUpdateOperation() && (this.entityId != null));
}
public boolean isCacheResource() {
return this.entityName.equalsIgnoreCase("CACHE");
}
public Long getSubentityId() {
return this.subentityId;
}
public String getTransactionId() {
return this.transactionId;
}
public String getEntityName() {
return this.entityName;
}
public Long getEntityId() {
return this.entityId;
}
public boolean isUpdateOperation() {
return this.actionName.equalsIgnoreCase("UPDATE");
}
public boolean isDelete() {
return isDeleteOperation() && this.entityId != null;
}
public boolean isDeleteOperation() {
return this.actionName.equalsIgnoreCase("DELETE");
}
public boolean isSurveyResource() {
return this.href.startsWith("/survey/");
}
public boolean isRegisterSurvey() {
return this.actionName.equalsIgnoreCase("REGISTER");
}
public boolean isFullFilSurvey() {
return this.actionName.equalsIgnoreCase("CREATE");
}
public boolean isWorkingDaysResource() {
return this.entityName.equalsIgnoreCase("WORKINGDAYS");
}
public boolean isPasswordPreferencesResource() {
return this.entityName.equalsIgnoreCase(PasswordPreferencesApiConstants.ENTITY_NAME);
}
public Long commandId() {
return this.commandId;
}
public String actionName() {
return this.actionName;
}
public String entityName() {
return this.entityName;
}
public Long resourceId() {
return this.entityId;
}
public Long subresourceId() {
return this.subentityId;
}
public String taskPermissionName() {
return this.actionName + "_" + this.entityName;
}
public String getTaskPermissionName() {
return this.taskPermissionName;
}
public Long getGroupId() {
return this.groupId;
}
public Long getClientId() {
return this.clientId;
}
public Long getLoanId() {
return this.loanId;
}
public Long getSavingsId() {
return this.savingsId;
}
public Long getProductId() {
return this.productId;
}
public boolean isPermissionResource() {
return this.entityName.equalsIgnoreCase("PERMISSION");
}
public boolean isUserResource() {
return this.entityName.equalsIgnoreCase("USER");
}
public boolean isCurrencyResource() {
return this.entityName.equalsIgnoreCase("CURRENCY");
}
public String commandName() {
return this.actionName + "_" + this.entityName;
}
public boolean isLoanDisburseDetailResource() {
return this.entityName.equalsIgnoreCase("DISBURSEMENTDETAIL");
}
public boolean isUpdateDisbursementDate() {
return this.actionName.equalsIgnoreCase("UPDATE") && this.entityName.equalsIgnoreCase("DISBURSEMENTDETAIL")
&& this.entityId != null;
}
public boolean addAndDeleteDisbursementDetails() {
return this.actionName.equalsIgnoreCase("UPDATE") && this.entityName.equalsIgnoreCase("DISBURSEMENTDETAIL")
&& this.entityId == null;
}
public String getJobName() {
return jobName;
}
}
@@ -0,0 +1,84 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.infrastructure.accountnumberformat.data;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import org.apache.fineract.infrastructure.core.data.EnumOptionData;
public class AccountNumberFormatData implements Serializable {
private final Long id;
private final EnumOptionData accountType;
private final EnumOptionData prefixType;
// template options
private List<EnumOptionData> accountTypeOptions;
private Map<String, List<EnumOptionData>> prefixTypeOptions;
private String prefixCharacter;
public AccountNumberFormatData(final Long id, final EnumOptionData accountType, final EnumOptionData prefixType,
final String prefixCharacter) {
this(id, accountType, prefixType, null, null, prefixCharacter);
}
public AccountNumberFormatData(final List<EnumOptionData> accountTypeOptions, Map<String, List<EnumOptionData>> prefixTypeOptions) {
this(null, null, null, accountTypeOptions, prefixTypeOptions, null);
}
public void templateOnTop(List<EnumOptionData> accountTypeOptions, Map<String, List<EnumOptionData>> prefixTypeOptions) {
this.accountTypeOptions = accountTypeOptions;
this.prefixTypeOptions = prefixTypeOptions;
}
private AccountNumberFormatData(final Long id, final EnumOptionData accountType, final EnumOptionData prefixType,
final List<EnumOptionData> accountTypeOptions, Map<String, List<EnumOptionData>> prefixTypeOptions,
final String prefixCharacter) {
this.id = id;
this.accountType = accountType;
this.prefixType = prefixType;
this.accountTypeOptions = accountTypeOptions;
this.prefixTypeOptions = prefixTypeOptions;
this.prefixCharacter = prefixCharacter;
}
public Long getId() {
return this.id;
}
public EnumOptionData getAccountType() {
return this.accountType;
}
public EnumOptionData getPrefixType() {
return this.prefixType;
}
public List<EnumOptionData> getAccountTypeOptions() {
return this.accountTypeOptions;
}
public Map<String, List<EnumOptionData>> getPrefixTypeOptions() {
return this.prefixTypeOptions;
}
}
@@ -0,0 +1,68 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.infrastructure.accountnumberformat.service;
import org.apache.fineract.infrastructure.accountnumberformat.data.AccountNumberFormatData;
public final class AccountNumberFormatConstants {
private AccountNumberFormatConstants() {
}
// resource name for validation
public static final String ENTITY_NAME = "accountNumberFormat";
// general
public static final String localeParamName = "locale";
public static final String dateFormatParamName = "dateFormat";
// REST end point
public static final String resourceRelativeURL = "/v1/accountnumberformats";
// request parameters
public static final String idParamName = "id";
public static final String accountTypeParamName = "accountType";
public static final String prefixTypeParamName = "prefixType";
public static final String prefixCharacterParamName = "prefixCharacter";
// response parameters
// associations related part of response
// template related part of response
public static final String accountTypeOptionsParamName = "accountTypeOptions";
public static final String prefixTypeOptionsParamName = "prefixTypeOptions";
/**
* These parameters will match the class level parameters of {@link AccountNumberFormatData}. Where possible, we try
* to get response parameters to match those of request parameters.
*/
// Error messages codes
public static final String EXCEPTION_DUPLICATE_ACCOUNT_TYPE = "error.msg.account.number.format.duplicate.account.type";
public static final String EXCEPTION_ACCOUNT_NUMBER_FORMAT_NOT_FOUND = "error.msg.account.number.format.id.invalid";
// JPA related constants
public static final String ACCOUNT_NUMBER_FORMAT_TABLE_NAME = "c_account_number_format";
public static final String ACCOUNT_TYPE_ENUM_COLUMN_NAME = "account_type_enum";
public static final String PREFIX_TYPE_ENUM_COLUMN_NAME = "prefix_type_enum";
public static final String ACCOUNT_TYPE_UNIQUE_CONSTRAINT_NAME = "account_type_enum";
public static final String PREFIX_CHARACTER_COLUMN_NAME = "prefix_character";
}
@@ -0,0 +1,163 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.infrastructure.core.api;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import javax.ws.rs.core.MultivaluedMap;
import org.apache.commons.lang3.StringUtils;
import org.apache.fineract.infrastructure.core.serialization.JsonParserHelper;
public final class ApiParameterHelper {
private ApiParameterHelper() {
}
public static Long commandId(final MultivaluedMap<String, String> queryParams) {
Long id = null;
if (queryParams.getFirst("commandId") != null) {
final String value = queryParams.getFirst("commandId");
if (StringUtils.isNotBlank(value)) {
id = Long.valueOf(value);
}
}
return id;
}
public static Set<String> extractFieldsForResponseIfProvided(final MultivaluedMap<String, String> queryParams) {
Set<String> fields = new HashSet<>();
String commaSeparatedParameters = "";
if (queryParams.getFirst("fields") != null) {
commaSeparatedParameters = queryParams.getFirst("fields");
if (StringUtils.isNotBlank(commaSeparatedParameters)) {
fields = new HashSet<>(Arrays.asList(commaSeparatedParameters.split("\\s*,\\s*"))); // NOSONAR
}
}
return fields;
}
public static Set<String> extractAssociationsForResponseIfProvided(final MultivaluedMap<String, String> queryParams) {
Set<String> fields = new HashSet<>();
String commaSeparatedParameters = "";
if (queryParams.getFirst("associations") != null) {
commaSeparatedParameters = queryParams.getFirst("associations");
if (StringUtils.isNotBlank(commaSeparatedParameters)) {
fields = new HashSet<>(Arrays.asList(commaSeparatedParameters.split("\\s*,\\s*"))); // NOSONAR
}
}
return fields;
}
public static void excludeAssociationsForResponseIfProvided(final String commaSeparatedParameters, Set<String> fields) {
if (StringUtils.isNotBlank(commaSeparatedParameters)) {
fields.removeAll(new HashSet<>(Arrays.asList(commaSeparatedParameters.split("\\s*,\\s*")))); // NOSONAR
}
}
public static void excludeAssociationsForResponseIfProvided(final MultivaluedMap<String, String> queryParams, Set<String> fields) {
if (queryParams.getFirst("exclude") != null) {
excludeAssociationsForResponseIfProvided(queryParams.getFirst("exclude"), fields);
}
}
public static boolean prettyPrint(final MultivaluedMap<String, String> queryParams) {
boolean prettyPrint = false;
if (queryParams.getFirst("pretty") != null) {
final String prettyPrintValue = queryParams.getFirst("pretty");
prettyPrint = "true".equalsIgnoreCase(prettyPrintValue);
}
return prettyPrint;
}
public static Locale extractLocale(final MultivaluedMap<String, String> queryParams) {
Locale locale = null;
if (queryParams.getFirst("locale") != null) {
final String localeAsString = queryParams.getFirst("locale");
locale = JsonParserHelper.localeFromString(localeAsString);
}
return locale;
}
public static boolean parameterType(final MultivaluedMap<String, String> queryParams) {
boolean parameterType = false;
if (queryParams.getFirst("parameterType") != null) {
final String parameterTypeValue = queryParams.getFirst("parameterType");
parameterType = "true".equalsIgnoreCase(parameterTypeValue);
}
return parameterType;
}
public static boolean template(final MultivaluedMap<String, String> queryParams) {
boolean template = false;
if (queryParams.getFirst("template") != null) {
final String prettyPrintValue = queryParams.getFirst("template");
template = "true".equalsIgnoreCase(prettyPrintValue);
}
return template;
}
public static boolean makerCheckerable(final MultivaluedMap<String, String> queryParams) {
boolean makerCheckerable = false;
if (queryParams.getFirst("makerCheckerable") != null) {
final String prettyPrintValue = queryParams.getFirst("makerCheckerable");
makerCheckerable = "true".equalsIgnoreCase(prettyPrintValue);
}
return makerCheckerable;
}
public static boolean includeJson(final MultivaluedMap<String, String> queryParams) {
boolean includeJson = false;
if (queryParams.getFirst("includeJson") != null) {
final String includeJsonValue = queryParams.getFirst("includeJson");
includeJson = "true".equalsIgnoreCase(includeJsonValue);
}
return includeJson;
}
public static boolean genericResultSet(final MultivaluedMap<String, String> queryParams) {
boolean genericResultSet = false;
if (queryParams.getFirst("genericResultSet") != null) {
final String genericResultSetValue = queryParams.getFirst("genericResultSet");
genericResultSet = "true".equalsIgnoreCase(genericResultSetValue);
}
return genericResultSet;
}
public static boolean genericResultSetPassed(final MultivaluedMap<String, String> queryParams) {
return queryParams.getFirst("genericResultSet") != null;
}
public static Map<String, String> asMap(final MultivaluedMap<String, String> queryParameters) {
final Map<String, String> map = new HashMap<>(queryParameters.size());
for (final String parameterName : queryParameters.keySet()) {
final List<String> values = queryParameters.get(parameterName);
map.put(parameterName, values.get(0));
}
return map;
}
}
@@ -0,0 +1,64 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.infrastructure.core.api;
import java.util.Set;
import javax.ws.rs.core.MultivaluedMap;
import org.apache.fineract.infrastructure.core.serialization.ApiRequestJsonSerializationSettings;
import org.springframework.stereotype.Component;
/**
* <p>
* Used to process the query parameters provided in a API request to see features of the RESTful API are being asked for
* such as:
* </p>
* <ul>
* <li>Pretty printing through pretty=true, defaults to false</li>
* <li>Partial response through fields=id, name etc, when empty, the full data is returned by default.</li>
* </ul>
*/
@Component
public class ApiRequestParameterHelper {
public ApiRequestJsonSerializationSettings process(final MultivaluedMap<String, String> queryParameters,
final Set<String> mandatoryResponseParameters) {
final Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(queryParameters);
if (!responseParameters.isEmpty()) {
responseParameters.addAll(mandatoryResponseParameters);
}
final boolean prettyPrint = ApiParameterHelper.prettyPrint(queryParameters);
final boolean template = ApiParameterHelper.template(queryParameters);
final boolean makerCheckerable = ApiParameterHelper.makerCheckerable(queryParameters);
final boolean includeJson = ApiParameterHelper.includeJson(queryParameters);
return ApiRequestJsonSerializationSettings.from(prettyPrint, responseParameters, template, makerCheckerable, includeJson);
}
public ApiRequestJsonSerializationSettings process(final MultivaluedMap<String, String> queryParameters) {
final Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(queryParameters);
final boolean prettyPrint = ApiParameterHelper.prettyPrint(queryParameters);
final boolean template = ApiParameterHelper.template(queryParameters);
final boolean makerCheckerable = ApiParameterHelper.makerCheckerable(queryParameters);
final boolean includeJson = ApiParameterHelper.includeJson(queryParameters);
return ApiRequestJsonSerializationSettings.from(prettyPrint, responseParameters, template, makerCheckerable, includeJson);
}
}
@@ -0,0 +1,47 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.infrastructure.core.api;
import com.google.gson.JsonElement;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import java.lang.reflect.Type;
import java.time.format.DateTimeFormatter;
import java.util.Date;
/**
* GSON Serializer for JUL Dates (java.util.Date) in ISO-8601 format using {@link DateTimeFormatter#ISO_INSTANT} (see
* FINERACT-926).
*
* @author Michael Vorburger.ch
*/
public class DateAdapter implements JsonSerializer<Date> {
private static final DateTimeFormatter formatter = DateTimeFormatter.ISO_INSTANT;
@Override
@SuppressWarnings("unused")
public JsonElement serialize(Date src, Type typeOfSrc, JsonSerializationContext context) {
if (src == null) {
return null;
}
return new JsonPrimitive(formatter.format(src.toInstant()));
}
}
@@ -0,0 +1,42 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.infrastructure.core.api;
import com.google.gson.JsonElement;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import java.lang.reflect.Type;
import org.apache.fineract.infrastructure.core.domain.ExternalId;
/**
* GSON Serializer for ExternalId
*
*/
public class ExternalIdAdapter implements JsonSerializer<ExternalId> {
@Override
@SuppressWarnings("unused")
public JsonElement serialize(ExternalId src, Type typeOfSrc, JsonSerializationContext context) {
if (src == null || src.isEmpty()) {
return null;
}
return new JsonPrimitive(src.getValue());
}
}
@@ -0,0 +1,44 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.infrastructure.core.api;
import com.google.gson.JsonElement;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import java.lang.reflect.Type;
import java.time.ZonedDateTime;
/**
* Serializer for Joda Time {@link ZonedDateTime} that returns the date as long to match previous (Jackson)
* functionality.
*/
public class JodaDateTimeAdapter implements JsonSerializer<ZonedDateTime> {
@Override
@SuppressWarnings("unused")
public JsonElement serialize(final ZonedDateTime src, final Type typeOfSrc, final JsonSerializationContext context) {
JsonElement element = null;
if (src != null) {
element = new JsonPrimitive(src.toInstant().toEpochMilli());
}
return element;
}
}
@@ -0,0 +1,48 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.infrastructure.core.api;
import static java.time.temporal.ChronoField.MONTH_OF_YEAR;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import java.lang.reflect.Type;
import java.time.MonthDay;
/**
* Serializer for Joda Time {@link MonthDay} that returns the date in array format to match previous Jackson
* functionality.
*/
public class JodaMonthDayAdapter implements JsonSerializer<MonthDay> {
@Override
@SuppressWarnings("unused")
public JsonElement serialize(final MonthDay src, final Type typeOfSrc, final JsonSerializationContext context) {
JsonArray array = null;
if (src != null) {
array = new JsonArray();
array.add(new JsonPrimitive(src.get(MONTH_OF_YEAR)));
array.add(new JsonPrimitive(src.getDayOfMonth()));
}
return array;
}
}
@@ -0,0 +1,48 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.infrastructure.core.api;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import java.lang.reflect.Type;
import java.time.LocalDate;
import java.time.temporal.ChronoField;
/**
* Serializer for Java Local Time {@link LocalDate} that returns the date in array format to match previous Jackson
* functionality.
*/
public class LocalDateAdapter implements JsonSerializer<LocalDate> {
@Override
@SuppressWarnings("unused")
public JsonElement serialize(final LocalDate src, final Type typeOfSrc, final JsonSerializationContext context) {
JsonArray array = null;
if (src != null) {
array = new JsonArray();
array.add(new JsonPrimitive(src.get(ChronoField.YEAR_OF_ERA)));
array.add(new JsonPrimitive(src.getMonthValue()));
array.add(new JsonPrimitive(src.getDayOfMonth()));
}
return array;
}
}
@@ -0,0 +1,51 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.infrastructure.core.api;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import java.lang.reflect.Type;
import java.time.LocalDateTime;
import java.time.temporal.ChronoField;
/**
* Serializer for Java Local Date Time {@link LocalDateTime} that returns the date in array format to match previous
* Jackson functionality.
*/
public class LocalDateTimeAdapter implements JsonSerializer<LocalDateTime> {
@Override
@SuppressWarnings("unused")
public JsonElement serialize(final LocalDateTime src, final Type typeOfSrc, final JsonSerializationContext context) {
JsonArray array = null;
if (src != null) {
array = new JsonArray();
array.add(new JsonPrimitive(src.get(ChronoField.YEAR_OF_ERA)));
array.add(new JsonPrimitive(src.getMonthValue()));
array.add(new JsonPrimitive(src.getDayOfMonth()));
array.add(new JsonPrimitive(src.getHour()));
array.add(new JsonPrimitive(src.getMinute()));
array.add(new JsonPrimitive(src.getSecond()));
}
return array;
}
}
@@ -0,0 +1,47 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.infrastructure.core.api;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import java.lang.reflect.Type;
import java.time.LocalTime;
/**
* Serializer for Java Local Time {@link LocalTime} that returns the time in array format to match previous Jackson
* functionality.
*/
public class LocalTimeAdapter implements JsonSerializer<LocalTime> {
@Override
@SuppressWarnings("unused")
public JsonElement serialize(final LocalTime src, final Type typeOfSrc, final JsonSerializationContext context) {
JsonArray array = null;
if (src != null) {
array = new JsonArray();
array.add(new JsonPrimitive(src.getHour()));
array.add(new JsonPrimitive(src.getMinute()));
array.add(new JsonPrimitive(src.getSecond()));
}
return array;
}
}
@@ -0,0 +1,43 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.infrastructure.core.api;
import com.google.gson.JsonElement;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import java.lang.reflect.Type;
import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;
/**
* Serializer for Java Offset Date Time {@link OffsetDateTime} that returns the date in ISO-8601 Offset date time format
*/
public class OffsetDateTimeAdapter implements JsonSerializer<OffsetDateTime> {
@Override
@SuppressWarnings("unused")
public JsonElement serialize(final OffsetDateTime dateTime, final Type typeOfSrc, final JsonSerializationContext context) {
JsonElement object = null;
if (dateTime != null) {
object = new JsonPrimitive(DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(dateTime));
}
return object;
}
}
@@ -0,0 +1,47 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.infrastructure.core.api;
import com.google.gson.ExclusionStrategy;
import com.google.gson.FieldAttributes;
import java.util.Set;
// FIXME - KW - General thing to fix about REST API is if use partial response approach of fields=id,name,selectedPermissions
// It will return just id,name parameters of RoleData and ignore description, however as PermissionData used in selectedPermissions collection
// also has a field called description it gets ignored also. This is because of the implementation of ParameterListExclusionStrategy which doesnt take
// into account the Object its looking at.
public class ParameterListExclusionStrategy implements ExclusionStrategy {
private final Set<String> parameterNamesToSkip;
public ParameterListExclusionStrategy(final Set<String> parameterNamesToSkip) {
this.parameterNamesToSkip = parameterNamesToSkip;
}
@Override
public boolean shouldSkipField(final FieldAttributes f) {
return this.parameterNamesToSkip.contains(f.getName());
}
@SuppressWarnings("unused")
@Override
public boolean shouldSkipClass(final Class<?> clazz) {
return false;
}
}
@@ -0,0 +1,43 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.infrastructure.core.api;
import com.google.gson.ExclusionStrategy;
import com.google.gson.FieldAttributes;
import java.util.Set;
public class ParameterListInclusionStrategy implements ExclusionStrategy {
private final Set<String> parameterNamesToInclude;
public ParameterListInclusionStrategy(final Set<String> parameterNamesToSkip) {
this.parameterNamesToInclude = parameterNamesToSkip;
}
@Override
public boolean shouldSkipField(final FieldAttributes f) {
return !this.parameterNamesToInclude.contains(f.getName());
}
@SuppressWarnings("unused")
@Override
public boolean shouldSkipClass(final Class<?> clazz) {
return false;
}
}
@@ -0,0 +1,39 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.infrastructure.core.data;
import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
/**
* <p>
* Immutable data object representing generic enumeration value.
* </p>
*/
@Getter
@EqualsAndHashCode
@AllArgsConstructor
public class EnumOptionData implements Serializable {
private final Long id;
private final String code;
private final String value;
}
@@ -0,0 +1,95 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.infrastructure.core.domain;
import java.time.LocalDateTime;
import java.util.Optional;
import javax.persistence.Column;
import javax.persistence.MappedSuperclass;
import org.springframework.data.domain.Auditable;
import org.springframework.data.jpa.domain.AbstractAuditable;
/**
* A custom copy of {@link AbstractAuditable} to override the column names used on database. It also uses Instant
* instead of LocalDateTime for created and modified.
*
* Abstract base class for auditable entities. Stores the audit values in persistent fields.
*
* @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 extends AbstractPersistableCustom implements Auditable<Long, Long, LocalDateTime> {
private static final long serialVersionUID = 141481953116476081L;
@Column(name = "createdby_id")
private Long createdBy;
@Column(name = "created_date")
private LocalDateTime createdDate;
@Column(name = "lastmodifiedby_id")
private Long lastModifiedBy;
@Column(name = "lastmodified_date")
private LocalDateTime lastModifiedDate;
@Override
public Optional<Long> getCreatedBy() {
return Optional.ofNullable(this.createdBy);
}
@Override
public void setCreatedBy(final Long createdBy) {
this.createdBy = createdBy;
}
@Override
public Optional<LocalDateTime> getCreatedDate() {
return null == this.createdDate ? Optional.empty() : Optional.of(this.createdDate);
}
@Override
public void setCreatedDate(final LocalDateTime createdDate) {
this.createdDate = createdDate;
}
@Override
public Optional<Long> getLastModifiedBy() {
return Optional.ofNullable(this.lastModifiedBy);
}
@Override
public void setLastModifiedBy(final Long lastModifiedBy) {
this.lastModifiedBy = lastModifiedBy;
}
@Override
public Optional<LocalDateTime> getLastModifiedDate() {
return null == this.lastModifiedDate ? Optional.empty() : Optional.of(this.lastModifiedDate);
}
@Override
public void setLastModifiedDate(final LocalDateTime lastModifiedDate) {
this.lastModifiedDate = lastModifiedDate;
}
}
@@ -0,0 +1,68 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.infrastructure.core.domain;
import java.io.Serializable;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.PostLoad;
import javax.persistence.PrePersist;
import javax.persistence.Transient;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.data.domain.Persistable;
/**
* Abstract base class for entities.
*
* Inspired by {@link org.springframework.data.jpa.domain.AbstractPersistable}, but Id is always Long (and this class
* thus does not require generic parameterization), and auto-generation is of strategy
* {@link javax.persistence.GenerationType#IDENTITY}.
*
* The {@link #equals(Object)} and {@link #hashCode()} methods are NOT implemented here, which is untypical for JPA
* (it's usually implemented based on the Id), because "we end up with issues on OpenJPA" (TODO clarify this).
*/
@MappedSuperclass
@Getter
@Setter
@NoArgsConstructor
public abstract class AbstractPersistableCustom implements Persistable<Long>, Serializable {
private static final long serialVersionUID = 9181640245194392646L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Getter(onMethod = @__(@Override))
private Long id;
@Transient
@Setter(value = AccessLevel.NONE)
@Getter(onMethod = @__(@Override))
private boolean isNew = true;
@PrePersist
@PostLoad
void markNotNew() {
this.isNew = false;
}
}
@@ -0,0 +1,76 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.infrastructure.core.serialization;
import java.util.Set;
/**
* A class to encapsulate settings we allow on API that affect how JSON is to be serialized for the response to api
* call.
*/
public class ApiRequestJsonSerializationSettings {
private final boolean prettyPrint;
private final Set<String> parametersForPartialResponse;
private final boolean template;
private final boolean makerCheckerable;
private final boolean includeJson;
public ApiRequestJsonSerializationSettings(final boolean prettyPrint, final Set<String> parametersForPartialResponse,
final boolean template, final boolean makerCheckerable, final boolean includeJson) {
this.prettyPrint = prettyPrint;
this.parametersForPartialResponse = parametersForPartialResponse;
this.template = template;
this.makerCheckerable = makerCheckerable;
this.includeJson = includeJson;
}
public static ApiRequestJsonSerializationSettings from(final boolean prettyPrint, final Set<String> parametersForPartialResponse,
final boolean template, final boolean makerCheckerable, final boolean includeJson) {
// FIXME - KW - rather than always creating new objects for this could
// just send by common ones like, prettyprint=false, empty response
// parameters
return new ApiRequestJsonSerializationSettings(prettyPrint, parametersForPartialResponse, template, makerCheckerable, includeJson);
}
public boolean isPrettyPrint() {
return this.prettyPrint;
}
public boolean isTemplate() {
return this.template;
}
public boolean isMakerCheckerable() {
return this.makerCheckerable;
}
public boolean isIncludeJson() {
return this.includeJson;
}
public Set<String> getParametersForPartialResponse() {
return this.parametersForPartialResponse;
}
public boolean isPartialResponseRequired() {
return !this.parametersForPartialResponse.isEmpty();
}
}
@@ -0,0 +1,50 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.infrastructure.core.serialization;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import org.springframework.stereotype.Component;
/**
* A Google GSON implementation of contract.
*
* It serializes all fields of any Java {@link Object} passed to it.
*/
@Component
public final class CommandProcessingResultJsonSerializer {
private final Gson gson;
public CommandProcessingResultJsonSerializer() {
final GsonBuilder builder = new GsonBuilder();
GoogleGsonSerializerHelper.registerTypeAdapters(builder);
builder.serializeNulls();
this.gson = builder.create();
}
public String serialize(final Object result) {
String returnedResult = null;
final String serializedResult = this.gson.toJson(result);
if (!"null".equalsIgnoreCase(serializedResult)) {
returnedResult = serializedResult;
}
return returnedResult;
}
}
@@ -0,0 +1,33 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.infrastructure.core.serialization;
/**
* Service for serializing commands into another format.
*
* <p>
* Known implementations:
* </p>
*
* @see CommandSerializerDefaultToJson
*/
public interface CommandSerializer {
String serializeCommandToJson(Object command);
}
@@ -0,0 +1,42 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.infrastructure.core.serialization;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* Implementation of {@link CommandSerializer} that serializes the commands into JSON using google-gson.
*/
@Component
public class CommandSerializerDefaultToJson implements CommandSerializer {
private final ExcludeNothingWithPrettyPrintingOffJsonSerializerGoogleGson excludeNothingWithPrettyPrintingOff;
@Autowired
public CommandSerializerDefaultToJson(
final ExcludeNothingWithPrettyPrintingOffJsonSerializerGoogleGson excludeNothingWithPrettyPrintingOff) {
this.excludeNothingWithPrettyPrintingOff = excludeNothingWithPrettyPrintingOff;
}
@Override
public String serializeCommandToJson(final Object command) {
return this.excludeNothingWithPrettyPrintingOff.serialize(command);
}
}
@@ -0,0 +1,157 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.infrastructure.core.serialization;
import com.google.gson.Gson;
import java.util.Collection;
import java.util.Set;
import org.apache.fineract.infrastructure.core.service.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* An abstract helper implementation of {@link ToApiJsonSerializer} for resources to serialize their Java data objects
* into JSON.
*/
@Component
public class DefaultToApiJsonSerializer<T> implements ToApiJsonSerializer<T> {
private final ExcludeNothingWithPrettyPrintingOffJsonSerializerGoogleGson excludeNothingWithPrettyPrintingOff;
private final ExcludeNothingWithPrettyPrintingOnJsonSerializerGoogleGson excludeNothingWithPrettyPrintingOn;
private final CommandProcessingResultJsonSerializer commandProcessingResultSerializer;
private final GoogleGsonSerializerHelper helper;
@Autowired
public DefaultToApiJsonSerializer(final ExcludeNothingWithPrettyPrintingOffJsonSerializerGoogleGson excludeNothingWithPrettyPrintingOff,
final ExcludeNothingWithPrettyPrintingOnJsonSerializerGoogleGson excludeNothingWithPrettyPrintingOn,
final CommandProcessingResultJsonSerializer commandProcessingResultSerializer, final GoogleGsonSerializerHelper helper) {
this.excludeNothingWithPrettyPrintingOff = excludeNothingWithPrettyPrintingOff;
this.excludeNothingWithPrettyPrintingOn = excludeNothingWithPrettyPrintingOn;
this.commandProcessingResultSerializer = commandProcessingResultSerializer;
this.helper = helper;
}
@Override
public String serializeResult(final Object object) {
return this.commandProcessingResultSerializer.serialize(object);
}
@Override
public String serialize(final Object object) {
return this.excludeNothingWithPrettyPrintingOff.serialize(object);
}
@Override
public String serializePretty(final boolean prettyOn, final Object object) {
String json = "";
if (prettyOn) {
json = this.excludeNothingWithPrettyPrintingOn.serialize(object);
} else {
json = serialize(object);
}
return json;
}
@Override
public String serialize(final ApiRequestJsonSerializationSettings settings, final Collection<T> collection,
final Set<String> supportedResponseParameters) {
final Gson delegatedSerializer = findAppropriateSerializer(settings, supportedResponseParameters);
return serializeWithSettings(delegatedSerializer, settings, collection.toArray());
}
@Override
public String serialize(final ApiRequestJsonSerializationSettings settings, final T singleObject,
final Set<String> supportedResponseParameters) {
final Gson delegatedSerializer = findAppropriateSerializer(settings, supportedResponseParameters);
return serializeWithSettings(delegatedSerializer, settings, singleObject);
}
@Override
public String serialize(final ApiRequestJsonSerializationSettings settings, final Page<T> singleObject,
final Set<String> supportedResponseParameters) {
final Gson delegatedSerializer = findAppropriateSerializer(settings, supportedResponseParameters);
return serializeWithSettings(delegatedSerializer, settings, singleObject);
}
@Override
public String serialize(final ApiRequestJsonSerializationSettings settings, final Collection<T> collection) {
final Gson delegatedSerializer = findAppropriateSerializer(settings);
return serializeWithSettings(delegatedSerializer, settings, collection.toArray());
}
@Override
public String serialize(final ApiRequestJsonSerializationSettings settings, final T singleObject) {
final Gson delegatedSerializer = findAppropriateSerializer(settings);
return serializeWithSettings(delegatedSerializer, settings, singleObject);
}
@Override
public String serialize(final ApiRequestJsonSerializationSettings settings, final Page<T> singleObject) {
final Gson delegatedSerializer = findAppropriateSerializer(settings);
return serializeWithSettings(delegatedSerializer, settings, singleObject);
}
private String serializeWithSettings(final Gson gson, final ApiRequestJsonSerializationSettings settings, final Object[] dataObject) {
String json = null;
if (gson != null) {
json = this.helper.serializedJsonFrom(gson, dataObject);
} else {
if (settings.isPrettyPrint()) {
json = this.excludeNothingWithPrettyPrintingOn.serialize(dataObject);
} else {
json = serialize(dataObject);
}
}
return json;
}
private String serializeWithSettings(final Gson gson, final ApiRequestJsonSerializationSettings settings, final Object dataObject) {
String json = null;
if (gson != null) {
json = this.helper.serializedJsonFrom(gson, dataObject);
} else {
if (settings.isPrettyPrint()) {
json = this.excludeNothingWithPrettyPrintingOn.serialize(dataObject);
} else {
json = serialize(dataObject);
}
}
return json;
}
private Gson findAppropriateSerializer(final ApiRequestJsonSerializationSettings settings,
final Set<String> supportedResponseParameters) {
Gson gson = null;
if (settings.isPartialResponseRequired()) {
gson = this.helper.createGsonBuilderWithParameterExclusionSerializationStrategy(supportedResponseParameters,
settings.isPrettyPrint(), settings.getParametersForPartialResponse());
}
return gson;
}
private Gson findAppropriateSerializer(final ApiRequestJsonSerializationSettings settings) {
Gson gson = null;
if (settings.isPartialResponseRequired()) {
gson = this.helper.createGsonBuilderForPartialResponseFiltering(settings.isPrettyPrint(),
settings.getParametersForPartialResponse());
}
return gson;
}
}
@@ -0,0 +1,50 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.infrastructure.core.serialization;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import org.springframework.stereotype.Component;
/**
* A Google GSON implementation of contract.
*
* It serializes all fields of any Java {@link Object} passed to it.
*/
@Component
public final class ExcludeNothingWithPrettyPrintingOffJsonSerializerGoogleGson {
private final Gson gson;
public ExcludeNothingWithPrettyPrintingOffJsonSerializerGoogleGson() {
final GsonBuilder builder = new GsonBuilder();
GoogleGsonSerializerHelper.registerTypeAdapters(builder);
this.gson = builder.create();
}
public String serialize(final Object result) {
String returnedResult = null;
final String serializedResult = this.gson.toJson(result);
if (!"null".equalsIgnoreCase(serializedResult)) {
returnedResult = serializedResult;
}
return returnedResult;
}
}
@@ -0,0 +1,46 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.infrastructure.core.serialization;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import org.springframework.stereotype.Component;
/**
* A Google GSON implementation of contract.
*
* It serializes all fields of any Java {@link Object} passed to it.
*/
@Component
public final class ExcludeNothingWithPrettyPrintingOnJsonSerializerGoogleGson {
private final Gson gson;
public ExcludeNothingWithPrettyPrintingOnJsonSerializerGoogleGson() {
final GsonBuilder builder = new GsonBuilder();
GoogleGsonSerializerHelper.registerTypeAdapters(builder);
builder.setPrettyPrinting();
this.gson = builder.create();
}
public String serialize(final Object result) {
return this.gson.toJson(result);
}
}
@@ -0,0 +1,129 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.infrastructure.core.serialization;
import com.google.gson.ExclusionStrategy;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.MonthDay;
import java.time.OffsetDateTime;
import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
import org.apache.fineract.infrastructure.core.api.DateAdapter;
import org.apache.fineract.infrastructure.core.api.ExternalIdAdapter;
import org.apache.fineract.infrastructure.core.api.JodaDateTimeAdapter;
import org.apache.fineract.infrastructure.core.api.JodaMonthDayAdapter;
import org.apache.fineract.infrastructure.core.api.LocalDateAdapter;
import org.apache.fineract.infrastructure.core.api.LocalDateTimeAdapter;
import org.apache.fineract.infrastructure.core.api.LocalTimeAdapter;
import org.apache.fineract.infrastructure.core.api.OffsetDateTimeAdapter;
import org.apache.fineract.infrastructure.core.api.ParameterListExclusionStrategy;
import org.apache.fineract.infrastructure.core.api.ParameterListInclusionStrategy;
import org.apache.fineract.infrastructure.core.domain.ExternalId;
import org.apache.fineract.infrastructure.core.exception.UnsupportedParameterException;
import org.springframework.stereotype.Service;
/**
* Helper class for serialization of Java objects into JSON using Google's GSON.
*/
@Service
public final class GoogleGsonSerializerHelper {
public Gson createGsonBuilderForPartialResponseFiltering(final boolean prettyPrint, final Set<String> responseParameters) {
final ExclusionStrategy strategy = new ParameterListInclusionStrategy(responseParameters);
final GsonBuilder builder = new GsonBuilder().addSerializationExclusionStrategy(strategy);
registerTypeAdapters(builder);
if (prettyPrint) {
builder.setPrettyPrinting();
}
return builder.create();
}
public Gson createGsonBuilderWithParameterExclusionSerializationStrategy(final Set<String> supportedParameters,
final boolean prettyPrint, final Set<String> responseParameters) {
final Set<String> parameterNamesToSkip = new HashSet<>();
if (!responseParameters.isEmpty()) {
// strip out all known support parameters from expected response to
// see if unsupported parameters requested for response.
final Set<String> differentParametersDetectedSet = new HashSet<>(responseParameters);
differentParametersDetectedSet.removeAll(supportedParameters);
if (!differentParametersDetectedSet.isEmpty()) {
throw new UnsupportedParameterException(new ArrayList<>(differentParametersDetectedSet));
}
parameterNamesToSkip.addAll(supportedParameters);
parameterNamesToSkip.removeAll(responseParameters);
}
final ExclusionStrategy strategy = new ParameterListExclusionStrategy(parameterNamesToSkip);
final GsonBuilder builder = new GsonBuilder().addSerializationExclusionStrategy(strategy);
registerTypeAdapters(builder);
if (prettyPrint) {
builder.setPrettyPrinting();
}
return builder.create();
}
public String serializedJsonFrom(final Gson serializer, final Object[] dataObjects) {
return serializer.toJson(dataObjects);
}
public String serializedJsonFrom(final Gson serializer, final Object singleDataObject) {
return serializer.toJson(singleDataObject);
}
public static Gson createSimpleGson() {
return createGsonBuilder().create();
}
public static GsonBuilder createGsonBuilder() {
return createGsonBuilder(false);
}
public static GsonBuilder createGsonBuilder(final boolean prettyPrint) {
final GsonBuilder builder = new GsonBuilder();
registerTypeAdapters(builder);
if (prettyPrint) {
builder.setPrettyPrinting();
}
return builder;
}
public static void registerTypeAdapters(final GsonBuilder builder) {
builder.registerTypeAdapter(java.util.Date.class, new DateAdapter());
builder.registerTypeAdapter(LocalDate.class, new LocalDateAdapter());
// NOTE: was missing, necessary for GSON serialization with JDK 17's restrictive module access
builder.registerTypeAdapter(LocalTime.class, new LocalTimeAdapter());
builder.registerTypeAdapter(ZonedDateTime.class, new JodaDateTimeAdapter());
builder.registerTypeAdapter(MonthDay.class, new JodaMonthDayAdapter());
builder.registerTypeAdapter(LocalDateTime.class, new LocalDateTimeAdapter());
builder.registerTypeAdapter(OffsetDateTime.class, new OffsetDateTimeAdapter());
builder.registerTypeAdapter(ExternalId.class, new ExternalIdAdapter());
}
}
@@ -0,0 +1,49 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.infrastructure.core.serialization;
import java.util.Collection;
import java.util.Set;
import org.apache.fineract.infrastructure.core.service.Page;
public interface ToApiJsonSerializer<T> {
String serialize(Object object);
String serializePretty(boolean prettyOn, Object object);
String serializeResult(Object object);
String serialize(ApiRequestJsonSerializationSettings settings, Collection<T> collection);
String serialize(ApiRequestJsonSerializationSettings settings, T single);
String serialize(ApiRequestJsonSerializationSettings settings, Page<T> singleObject);
// TODO: TECHDEBT - bottom three will be deprecated going forward to remove
// need for people to pass full list of supported parameters. It was only
// used in cases where the partial response features was used (fields=x,y,x)
// to report error if incorrect field was passed. From now on it will just
// ignore unknown fields and fail silently
String serialize(ApiRequestJsonSerializationSettings settings, Collection<T> collection, Set<String> supportedResponseParameters);
String serialize(ApiRequestJsonSerializationSettings settings, T single, Set<String> supportedResponseParameters);
String serialize(ApiRequestJsonSerializationSettings settings, Page<T> singleObject, Set<String> supportedResponseParameters);
}
@@ -0,0 +1,41 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.infrastructure.core.service;
import java.io.Serializable;
import java.util.List;
public class Page<E> implements Serializable {
private final int totalFilteredRecords;
private final List<E> pageItems;
public Page(final List<E> pageItems, final int totalFilteredRecords) {
this.pageItems = pageItems;
this.totalFilteredRecords = totalFilteredRecords;
}
public int getTotalFilteredRecords() {
return this.totalFilteredRecords;
}
public List<E> getPageItems() {
return this.pageItems;
}
}
@@ -0,0 +1,24 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.infrastructure.security.service;
public interface PlatformUserRightsContext {
void isAuthenticated();
}
@@ -0,0 +1,211 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.portfolio.client.api;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
@SuppressWarnings({ "HideUtilityClassConstructor" })
public class ClientApiConstants {
public static final String CLIENT_RESOURCE_NAME = "client";
public static final String CLIENT_CHARGES_RESOURCE_NAME = "CLIENTCHARGE";
// Client Charge Action Names
public static final String CLIENT_CHARGE_ACTION_CREATE = "CREATE";
public static final String CLIENT_CHARGE_ACTION_DELETE = "DELETE";
public static final String CLIENT_CHARGE_ACTION_WAIVE = "WAIVE";
public static final String CLIENT_CHARGE_ACTION_PAY = "PAY";
public static final String CLIENT_CHARGE_ACTION_INACTIVATE = "INACTIVATE";
// Client charge associations and query parameters
public static final String CLIENT_CHARGE_QUERY_PARAM_STATUS = "chargeStatus";
public static final String CLIENT_CHARGE_QUERY_PARAM_STATUS_VALUE_ALL = "all";
public static final String CLIENT_CHARGE_QUERY_PARAM_STATUS_VALUE_ACTIVE = "active";
public static final String CLIENT_CHARGE_QUERY_PARAM_STATUS_VALUE_INACTIVE = "inactive";
public static final String CLIENT_CHARGE_ASSOCIATIONS_TRANSACTIONS = "transactions";
// Client transaction action names
public static final String CLIENT_TRANSACTION_ACTION_READ = "READTRANSACTION";
public static final String CLIENT_TRANSACTION_ACTION_UNDO = "UNDOTRANSACTION";
// Commands
public static final String CLIENT_CHARGE_COMMAND_WAIVE_CHARGE = "waive";
public static final String CLIENT_CHARGE_COMMAND_PAY_CHARGE = "paycharge";
public static final String CLIENT_CHARGE_COMMAND_INACTIVATE_CHARGE = "inactivate";
public static final String CLIENT_TRANSACTION_COMMAND_UNDO = "undo";
public static final String CLIENT_CLOSURE_REASON = "ClientClosureReason";
public static final String CLIENT_ACTION_REASON = "ClientActionReason";
public static final String CLIENT_REJECT_REASON = "ClientRejectReason";
public static final String CLIENT_WITHDRAW_REASON = "ClientWithdrawReason";
public static final String GENDER = "Gender";
public static final String CLIENT_TYPE = "ClientType";
public static final String CLIENT_CLASSIFICATION = "ClientClassification";
public static final String CLIENT_NON_PERSON_CONSTITUTION = "Constitution";
public static final String CLIENT_NON_PERSON_MAIN_BUSINESS_LINE = "Main Business Line";
// general
public static final String localeParamName = "locale";
public static final String dateFormatParamName = "dateFormat";
public static final String address = "address";
public static final String familyMembers = "familyMembers";
public static final String MARITALSTATUS = "MARITALSTATUS";
public static final String maritalStatusIdParamName = "maritalStatusId";
public static final String CLIENT_TYPE_INDIVIDUAL = "Individual";
// request parameters
public static final String idParamName = "id";
public static final String groupIdParamName = "groupId";
public static final String accountNoParamName = "accountNo";
public static final String externalIdParamName = "externalId";
public static final String mobileNoParamName = "mobileNo";
public static final String emailAddressParamName = "emailAddress";
public static final String firstnameParamName = "firstname";
public static final String middlenameParamName = "middlename";
public static final String lastnameParamName = "lastname";
public static final String fullnameParamName = "fullname";
public static final String displaynameParamName = "displayname";
public static final String officeIdParamName = "officeId";
public static final String transferOfficeIdParamName = "transferOfficeIdParamName";
public static final String activeParamName = "active";
public static final String activationDateParamName = "activationDate";
public static final String reactivationDateParamName = "reactivationDate";
public static final String staffIdParamName = "staffId";
public static final String isStaffParamName = "isStaff";
public static final String closureDateParamName = "closureDate";
public static final String closureReasonIdParamName = "closureReasonId";
public static final String reopenedDateParamName = "reopenedDate";
public static final String rejectionDateParamName = "rejectionDate";
public static final String rejectionReasonIdParamName = "rejectionReasonId";
public static final String withdrawalDateParamName = "withdrawalDate";
public static final String withdrawalReasonIdParamName = "withdrawalReasonId";
public static final String submittedOnDateParamName = "submittedOnDate";
public static final String savingsProductIdParamName = "savingsProductId";
public static final String savingsAccountIdParamName = "savingsAccountId";
public static final String dateOfBirthParamName = "dateOfBirth";
public static final String genderIdParamName = "genderId";
public static final String genderParamName = "gender";
public static final String clientTypeIdParamName = "clientTypeId";
public static final String clientTypeParamName = "clientType";
public static final String clientClassificationIdParamName = "clientClassificationId";
public static final String clientClassificationParamName = "clientClassification";
public static final String legalFormIdParamName = "legalFormId";
public static final String legalFormParamName = "legalForm";
// request parameters for payment details
public static final String paymentTypeIdParamName = "paymentTypeId";
public static final String transactionAccountNumberParamName = "accountNumber";
public static final String checkNumberParamName = "checkNumber";
public static final String routingCodeParamName = "routingCode";
public static final String receiptNumberParamName = "receiptNumber";
public static final String bankNumberParamName = "bankNumber";
// request parameters for client non person
public static final String clientNonPersonDetailsParamName = "clientNonPersonDetails";
public static final String incorpNumberParamName = "incorpNumber";
public static final String remarksParamName = "remarks";
public static final String incorpValidityTillParamName = "incorpValidityTillDate";
public static final String constitutionIdParamName = "constitutionId";
public static final String mainBusinessLineIdParamName = "mainBusinessLineId";
// response parameters
public static final String statusParamName = "status";
public static final String hierarchyParamName = "hierarchy";
public static final String displayNameParamName = "displayName";
public static final String officeNameParamName = "officeName";
public static final String staffNameParamName = "staffName";
public static final String trasnferOfficeNameParamName = "transferOfficeName";
public static final String transferToOfficeNameParamName = "transferToOfficeName";
public static final String transferToOfficeIdParamName = "transferToOfficeId";
public static final String imageKeyParamName = "imageKey";
public static final String imageIdParamName = "imageId";
public static final String imagePresentParamName = "imagePresent";
public static final String timelineParamName = "timeline";
// client charges response parameters
public static final String chargeIdParamName = "chargeId";
public static final String clientIdParamName = "clientId";
public static final String chargesParamName = "charges";
public static final String chargeNameParamName = "name";
public static final String penaltyParamName = "penalty";
public static final String chargeTimeTypeParamName = "chargeTimeType";
public static final String dueAsOfDateParamName = "dueDate";
public static final String transactionDateParamName = "transactionDate";
public static final String chargeCalculationTypeParamName = "chargeCalculationType";
public static final String currencyParamName = "currency";
public static final String amountWaivedParamName = "amountWaived";
public static final String amountWrittenOffParamName = "amountWrittenOff";
public static final String amountOutstandingParamName = "amountOutstanding";
public static final String amountOrPercentageParamName = "amountOrPercentage";
public static final String amountParamName = "amount";
public static final String amountPaidParamName = "amountPaid";
public static final String chargeOptionsParamName = "chargeOptions";
public static final String transactionsParamName = "transactions";
// client transactions response parameters
public static final String transactionAmountParamName = "transactionAmount";
public static final String paymentDetailDataParamName = "paymentDetailData";
public static final String reversedParamName = "reversed";
public static final String dateParamName = "date";
private static final String transactionTypeParamName = "type";
private static final String transactionCurrencyParamName = "currency";
// associations related part of response
public static final String groupsParamName = "groups";
// template related part of response
public static final String officeOptionsParamName = "officeOptions";
public static final String staffOptionsParamName = "staffOptions";
public static final String datatables = "datatables";
public static final String obligeeData = "ObligeeDetails";
public static final String clientEntityName = "clients";
public static final Set<String> CLIENT_ACCOUNTS_DATA_PARAMETERS = new HashSet<>(
Arrays.asList("loanAccounts", "savingsAccounts", "shareAccounts"));
/**
* These parameters will match the class level parameters of ClientData. Where possible, we try to get response
* parameters to match those of request parameters.
*/
protected static final Set<String> CLIENT_RESPONSE_DATA_PARAMETERS = new HashSet<>(Arrays.asList(idParamName, accountNoParamName,
externalIdParamName, statusParamName, activeParamName, activationDateParamName, firstnameParamName, middlenameParamName,
lastnameParamName, fullnameParamName, displayNameParamName, mobileNoParamName, emailAddressParamName, officeIdParamName,
officeNameParamName, transferToOfficeIdParamName, transferToOfficeNameParamName, hierarchyParamName, imageIdParamName,
imagePresentParamName, staffIdParamName, staffNameParamName, timelineParamName, groupsParamName, officeOptionsParamName,
staffOptionsParamName, dateOfBirthParamName, genderParamName, clientTypeParamName, clientClassificationParamName,
legalFormParamName, clientNonPersonDetailsParamName, isStaffParamName));
protected static final Set<String> CLIENT_CHARGES_RESPONSE_DATA_PARAMETERS = new HashSet<>(Arrays.asList(chargeIdParamName,
clientIdParamName, chargeNameParamName, penaltyParamName, chargeTimeTypeParamName, dueAsOfDateParamName,
chargeCalculationTypeParamName, currencyParamName, amountWaivedParamName, amountWrittenOffParamName, amountOutstandingParamName,
amountOrPercentageParamName, amountParamName, amountPaidParamName, chargeOptionsParamName, transactionsParamName));
protected static final Set<String> CLIENT_TRANSACTION_RESPONSE_DATA_PARAMETERS = new HashSet<>(Arrays.asList(idParamName,
transactionAmountParamName, paymentDetailDataParamName, reversedParamName, dateParamName, officeIdParamName,
officeNameParamName, transactionTypeParamName, transactionCurrencyParamName, externalIdParamName, submittedOnDateParamName));
}
@@ -0,0 +1,44 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.portfolio.paymenttype.api;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
public final class PaymentTypeApiResourceConstants {
private PaymentTypeApiResourceConstants() {
}
public static final String RESOURCE_NAME = "paymenttype";
public static final String ENTITY_NAME = "PAYMENTTYPE";
public static final String resourceNameForPermissions = "PAYMENT_TYPE";
public static final String ID = "id";
public static final String NAME = "name";
public static final String DESCRIPTION = "description";
public static final String ISCASHPAYMENT = "isCashPayment";
public static final String POSITION = "position";
public static final String CODE_NAME = "code_name";
public static final String IS_SYSTEM_DEFINED = "system_defined";
static final Set<String> RESPONSE_DATA_PARAMETERS = new HashSet<>(Arrays.asList(ID, NAME, DESCRIPTION, ISCASHPAYMENT));
}
@@ -0,0 +1,369 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.portfolio.savings;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import org.apache.fineract.accounting.common.AccountingConstants.SavingProductAccountingParams;
public final class DepositsApiConstants {
private DepositsApiConstants() {
}
// Deposit products
public static final String FIXED_DEPOSIT_PRODUCT_RESOURCE_NAME = "fixeddeposit";
public static final String RECURRING_DEPOSIT_PRODUCT_RESOURCE_NAME = "recurringdeposit";
// Deposit accounts
public static final String FIXED_DEPOSIT_ACCOUNT_RESOURCE_NAME = "fixeddepositaccount";
public static final String RECURRING_DEPOSIT_ACCOUNT_RESOURCE_NAME = "recurringdepositaccount";
public static final String SAVINGS_ACCOUNT_RESOURCE_NAME = "savingsaccount";
public static final String SAVINGS_ACCOUNT_TRANSACTION_RESOURCE_NAME = "savingsaccount.transaction";
public static final String SAVINGS_ACCOUNT_CHARGE_RESOURCE_NAME = "savingsaccountcharge";
// deposit product actions
public static final String summitalAction = ".summital";
public static final String approvalAction = ".approval";
public static final String undoApprovalAction = ".undoApproval";
public static final String rejectAction = ".reject";
public static final String withdrawnByApplicantAction = ".withdrawnByApplicant";
public static final String activateAction = ".activate";
public static final String modifyApplicationAction = ".modify";
public static final String deleteApplicationAction = ".delete";
public static final String undoTransactionAction = ".undotransaction";
public static final String applyAnnualFeeTransactionAction = ".applyannualfee";
public static final String adjustTransactionAction = ".adjusttransaction";
public static final String closeAction = ".close";
public static final String preMatureCloseAction = ".preMatureClose";
public static final String payChargeTransactionAction = ".paycharge";
public static final String waiveChargeTransactionAction = ".waivecharge";
// command
public static final String COMMAND_UNDO_TRANSACTION = "undo";
public static final String COMMAND_ADJUST_TRANSACTION = "modify";
public static final String COMMAND_WAIVE_CHARGE = "waive";
public static final String COMMAND_PAY_CHARGE = "paycharge";
public static final String UPDATE_DEPOSIT_AMOUNT = "updateDepositAmount";
// general
public static final String localeParamName = "locale";
public static final String dateFormatParamName = "dateFormat";
public static final String monthDayFormatParamName = "monthDayFormat";
// deposit product and account parameters
public static final String idParamName = "id";
public static final String accountNoParamName = "accountNo";
public static final String externalIdParamName = "externalId";
public static final String statusParamName = "status";
public static final String clientIdParamName = "clientId";
public static final String groupIdParamName = "groupId";
public static final String productIdParamName = "productId";
public static final String fieldOfficerIdParamName = "fieldOfficerId";
public static final String submittedOnDateParamName = "submittedOnDate";
public static final String rejectedOnDateParamName = "rejectedOnDate";
public static final String withdrawnOnDateParamName = "withdrawnOnDate";
public static final String approvedOnDateParamName = "approvedOnDate";
public static final String activatedOnDateParamName = "activatedOnDate";
public static final String closedOnDateParamName = "closedOnDate";
public static final String expectedFirstDepositOnDateParamName = "expectedFirstDepositOnDate";
public static final String activeParamName = "active";
public static final String nameParamName = "name";
public static final String shortNameParamName = "shortName";
public static final String descriptionParamName = "description";
public static final String currencyCodeParamName = "currencyCode";
public static final String digitsAfterDecimalParamName = "digitsAfterDecimal";
public static final String inMultiplesOfParamName = "inMultiplesOf";
public static final String nominalAnnualInterestRateParamName = "nominalAnnualInterestRate";
public static final String interestCompoundingPeriodTypeParamName = "interestCompoundingPeriodType";
public static final String interestPostingPeriodTypeParamName = "interestPostingPeriodType";
public static final String interestCalculationTypeParamName = "interestCalculationType";
public static final String interestCalculationDaysInYearTypeParamName = "interestCalculationDaysInYearType";
public static final String lockinPeriodFrequencyParamName = "lockinPeriodFrequency";
public static final String lockinPeriodFrequencyTypeParamName = "lockinPeriodFrequencyType";
public static final String feeAmountParamName = "feeAmount";// to be deleted
public static final String feeOnMonthDayParamName = "feeOnMonthDay";
public static final String feeIntervalParamName = "feeInterval";
public static final String accountingRuleParamName = "accountingRule";
public static final String paymentTypeIdParamName = "paymentTypeId";
public static final String transactionAccountNumberParamName = "accountNumber";
public static final String checkNumberParamName = "checkNumber";
public static final String routingCodeParamName = "routingCode";
public static final String receiptNumberParamName = "receiptNumber";
public static final String bankNumberParamName = "bankNumber";
// Preclosure parameters
public static final String preClosurePenalApplicableParamName = "preClosurePenalApplicable";
public static final String preClosurePenalInterestParamName = "preClosurePenalInterest";
public static final String preClosurePenalInterestOnTypeIdParamName = "preClosurePenalInterestOnTypeId";
public static final String interestFreePeriodFrequencyType = "interestFreePeriodFrequencyType";
public static final String preClosurePenalInterestOnType = "preClosurePenalInterestOnType";
// term paramters
public static final String minDepositTermParamName = "minDepositTerm";
public static final String maxDepositTermParamName = "maxDepositTerm";
public static final String minDepositTermTypeIdParamName = "minDepositTermTypeId";
public static final String maxDepositTermTypeIdParamName = "maxDepositTermTypeId";
public static final String minDepositTermType = "minDepositTermType";
public static final String maxDepositTermType = "maxDepositTermType";
public static final String inMultiplesOfDepositTermParamName = "inMultiplesOfDepositTerm";
public static final String inMultiplesOfDepositTermTypeIdParamName = "inMultiplesOfDepositTermTypeId";
public static final String inMultiplesOfDepositTermType = "inMultiplesOfDepositTermType";
public static final String depositAmountParamName = "depositAmount";
public static final String depositMinAmountParamName = "minDepositAmount";
public static final String depositMaxAmountParamName = "maxDepositAmount";
public static final String depositPeriodParamName = "depositPeriod";
public static final String depositPeriodFrequencyIdParamName = "depositPeriodFrequencyId";
// recurring parameters
public static final String mandatoryRecommendedDepositAmountParamName = "mandatoryRecommendedDepositAmount";
public static final String isMandatoryDepositParamName = "isMandatoryDeposit";
public static final String allowWithdrawalParamName = "allowWithdrawal";
public static final String adjustAdvanceTowardsFuturePaymentsParamName = "adjustAdvanceTowardsFuturePayments";
public static final String recurringFrequencyTypeParamName = "recurringFrequencyType";
public static final String recurringFrequencyParamName = "recurringFrequency";
public static final String isCalendarInheritedParamName = "isCalendarInherited";
// transaction parameters
public static final String transactionDateParamName = "transactionDate";
public static final String transactionAmountParamName = "transactionAmount";
public static final String paymentDetailDataParamName = "paymentDetailData";
public static final String runningBalanceParamName = "runningBalance";
public static final String reversedParamName = "reversed";
public static final String dateParamName = "date";
public static final String accountIdParamName = "accountId";
// recurring deposits update parameters
public static final String effectiveDateParamName = "effectiveDate";
// charges parameters
public static final String chargeIdParamName = "chargeId";
public static final String chargesParamName = "charges";
public static final String savingsAccountChargeIdParamName = "savingsAccountChargeId";
public static final String chargeNameParamName = "name";
public static final String penaltyParamName = "penalty";
public static final String chargeTimeTypeParamName = "chargeTimeType";
public static final String dueAsOfDateParamName = "dueDate";
public static final String chargeCalculationTypeParamName = "chargeCalculationType";
public static final String percentageParamName = "percentage";
public static final String amountPercentageAppliedToParamName = "amountPercentageAppliedTo";
public static final String currencyParamName = "currency";
public static final String amountWaivedParamName = "amountWaived";
public static final String amountWrittenOffParamName = "amountWrittenOff";
public static final String amountOutstandingParamName = "amountOutstanding";
public static final String amountOrPercentageParamName = "amountOrPercentage";
public static final String amountParamName = "amount";
public static final String amountPaidParamName = "amountPaid";
public static final String chargeOptionsParamName = "chargeOptions";
public static final String chargePaymentModeParamName = "chargePaymentMode";
public static final String noteParamName = "note";
public static final String chartsParamName = "charts";
public static final String chartIdParamName = "chartId";
// deposit account associations
public static final String transactions = "transactions";
public static final String charges = "charges";
public static final String activeChart = "activeChart";
// account closure
public static final String onAccountClosureIdParamName = "onAccountClosureId";
public static final String transferDescriptionParamName = "transferDescription";
public static final String toSavingsAccountIdParamName = "toSavingsAccountId";
public static final String savingsAccounts = "savingsAccounts";
public static final String maturityInstructionIdParamName = "maturityInstructionId";
public static final String transferToSavingsIdParamName = "transferToSavingsId";
public static final String preMatureCloseOnDateParamName = "preMatureCloseOnDate";
public static final String linkedAccountParamName = "linkAccountId";
public static final String transferInterestToSavingsParamName = "transferInterestToSavings";
// template
public static final String chartTemplate = "chartTemplate";
/**
* Deposit Product Parameters
*/
private static final Set<String> DEPOSIT_PRODUCT_REQUEST_DATA_PARAMETERS = new HashSet<>(Arrays.asList(localeParamName,
monthDayFormatParamName, nameParamName, shortNameParamName, descriptionParamName, currencyCodeParamName,
digitsAfterDecimalParamName, inMultiplesOfParamName, nominalAnnualInterestRateParamName, interestCompoundingPeriodTypeParamName,
interestPostingPeriodTypeParamName, interestCalculationTypeParamName, interestCalculationDaysInYearTypeParamName,
lockinPeriodFrequencyParamName, lockinPeriodFrequencyTypeParamName, accountingRuleParamName, chargesParamName,
SavingProductAccountingParams.INCOME_FROM_FEES.getValue(), SavingProductAccountingParams.INCOME_FROM_PENALTIES.getValue(),
SavingProductAccountingParams.INTEREST_ON_SAVINGS.getValue(),
SavingProductAccountingParams.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue(),
SavingProductAccountingParams.SAVINGS_CONTROL.getValue(), SavingProductAccountingParams.TRANSFERS_SUSPENSE.getValue(),
SavingProductAccountingParams.SAVINGS_REFERENCE.getValue(), SavingProductAccountingParams.FEE_INCOME_ACCOUNT_MAPPING.getValue(),
SavingProductAccountingParams.PENALTY_INCOME_ACCOUNT_MAPPING.getValue(), chartsParamName,
SavingsApiConstants.withHoldTaxParamName, SavingsApiConstants.taxGroupIdParamName));
private static final Set<String> PRECLOSURE_REQUEST_DATA_PARAMETERS = new HashSet<>(
Arrays.asList(preClosurePenalApplicableParamName, preClosurePenalInterestParamName, preClosurePenalInterestOnTypeIdParamName));
private static final Set<String> PRECLOSURE_RESPONSE_DATA_PARAMETERS = new HashSet<>(
Arrays.asList(preClosurePenalApplicableParamName, preClosurePenalInterestParamName, preClosurePenalInterestOnType));
private static final Set<String> DEPOSIT_TERM_REQUEST_DATA_PARAMETERS = new HashSet<>(Arrays.asList(minDepositTermParamName,
maxDepositTermParamName, minDepositTermTypeIdParamName, maxDepositTermTypeIdParamName, inMultiplesOfDepositTermParamName,
inMultiplesOfDepositTermTypeIdParamName, depositAmountParamName, depositMinAmountParamName, depositMaxAmountParamName));
private static final Set<String> DEPOSIT_TERM_RESPONSE_DATA_PARAMETERS = new HashSet<>(Arrays.asList(minDepositTermParamName,
maxDepositTermParamName, minDepositTermType, maxDepositTermType, inMultiplesOfDepositTermParamName,
inMultiplesOfDepositTermType, depositAmountParamName, depositMinAmountParamName, depositMaxAmountParamName));
private static final Set<String> RECURRING_DETAILS_REQUEST_DATA_PARAMETERS = new HashSet<>(
Arrays.asList(mandatoryRecommendedDepositAmountParamName, isMandatoryDepositParamName, allowWithdrawalParamName,
adjustAdvanceTowardsFuturePaymentsParamName, recurringFrequencyTypeParamName, recurringFrequencyParamName,
isCalendarInheritedParamName));
private static final Set<String> RECURRING_DETAILS_RESPONSE_DATA_PARAMETERS = new HashSet<>(
Arrays.asList(mandatoryRecommendedDepositAmountParamName, isMandatoryDepositParamName, allowWithdrawalParamName,
adjustAdvanceTowardsFuturePaymentsParamName, recurringFrequencyTypeParamName, recurringFrequencyParamName,
isCalendarInheritedParamName));
private static final Set<String> DEPOSIT_PRECLOSURE_CALCULATION_REQUEST_DATA_PARAMETERS = new HashSet<>(
Arrays.asList(preMatureCloseOnDateParamName));
public static final Set<String> FIXED_DEPOSIT_PRODUCT_REQUEST_DATA_PARAMETERS = fixedDepositProductRequestData();
public static final Set<String> FIXED_DEPOSIT_PRODUCT_RESPONSE_DATA_PARAMETERS = fixedDepositProductResponseData();
public static final Set<String> RECURRING_DEPOSIT_PRODUCT_REQUEST_DATA_PARAMETERS = recurringDepositProductRequestData();
public static final Set<String> RECURRING_DEPOSIT_PRODUCT_RESPONSE_DATA_PARAMETERS = recurringDepositProductResponseData();
private static Set<String> fixedDepositProductRequestData() {
final Set<String> fixedDepositRequestData = new HashSet<>();
fixedDepositRequestData.addAll(DEPOSIT_PRODUCT_REQUEST_DATA_PARAMETERS);
fixedDepositRequestData.addAll(PRECLOSURE_REQUEST_DATA_PARAMETERS);
fixedDepositRequestData.addAll(DEPOSIT_TERM_REQUEST_DATA_PARAMETERS);
return fixedDepositRequestData;
}
private static Set<String> fixedDepositProductResponseData() {
final Set<String> fixedDepositRequestData = new HashSet<>();
fixedDepositRequestData.addAll(DEPOSIT_PRODUCT_REQUEST_DATA_PARAMETERS);
fixedDepositRequestData.addAll(PRECLOSURE_RESPONSE_DATA_PARAMETERS);
fixedDepositRequestData.addAll(DEPOSIT_TERM_RESPONSE_DATA_PARAMETERS);
return fixedDepositRequestData;
}
private static Set<String> recurringDepositProductRequestData() {
final Set<String> recurringDepositRequestData = new HashSet<>();
recurringDepositRequestData.addAll(DEPOSIT_PRODUCT_REQUEST_DATA_PARAMETERS);
recurringDepositRequestData.addAll(PRECLOSURE_REQUEST_DATA_PARAMETERS);
recurringDepositRequestData.addAll(DEPOSIT_TERM_REQUEST_DATA_PARAMETERS);
recurringDepositRequestData.addAll(RECURRING_DETAILS_REQUEST_DATA_PARAMETERS);
recurringDepositRequestData.add(SavingsApiConstants.minBalanceForInterestCalculationParamName);
return recurringDepositRequestData;
}
private static Set<String> recurringDepositProductResponseData() {
final Set<String> recurringDepositRequestData = new HashSet<>();
recurringDepositRequestData.addAll(DEPOSIT_PRODUCT_REQUEST_DATA_PARAMETERS);
recurringDepositRequestData.addAll(PRECLOSURE_RESPONSE_DATA_PARAMETERS);
recurringDepositRequestData.addAll(DEPOSIT_TERM_RESPONSE_DATA_PARAMETERS);
recurringDepositRequestData.addAll(RECURRING_DETAILS_RESPONSE_DATA_PARAMETERS);
recurringDepositRequestData.add(SavingsApiConstants.minBalanceForInterestCalculationParamName);
return recurringDepositRequestData;
}
/**
* Depost Account parameters
*/
private static final Set<String> DEPOSIT_ACCOUNT_REQUEST_DATA_PARAMETERS = new HashSet<>(
Arrays.asList(localeParamName, dateFormatParamName, monthDayFormatParamName, accountNoParamName, externalIdParamName,
clientIdParamName, groupIdParamName, productIdParamName, fieldOfficerIdParamName, submittedOnDateParamName,
nominalAnnualInterestRateParamName, interestCompoundingPeriodTypeParamName, interestPostingPeriodTypeParamName,
interestCalculationTypeParamName, interestCalculationDaysInYearTypeParamName, lockinPeriodFrequencyParamName,
lockinPeriodFrequencyTypeParamName, chargesParamName, chartsParamName, depositAmountParamName, depositPeriodParamName,
depositPeriodFrequencyIdParamName, savingsAccounts, expectedFirstDepositOnDateParamName,
SavingsApiConstants.withHoldTaxParamName, maturityInstructionIdParamName, transferToSavingsIdParamName));
public static final Set<String> FIXED_DEPOSIT_ACCOUNT_REQUEST_DATA_PARAMETERS = fixedDepositAccountRequestData();
public static final Set<String> FIXED_DEPOSIT_ACCOUNT_RESPONSE_DATA_PARAMETERS = fixedDepositAccountResponseData();
public static final Set<String> RECURRING_DEPOSIT_ACCOUNT_REQUEST_DATA_PARAMETERS = recurringDepositAccountRequestData();
public static final Set<String> RECURRING_DEPOSIT_ACCOUNT_RESPONSE_DATA_PARAMETERS = recurringDepositAccountResponseData();
private static Set<String> fixedDepositAccountRequestData() {
final Set<String> fixedDepositRequestData = new HashSet<>();
fixedDepositRequestData.addAll(DEPOSIT_ACCOUNT_REQUEST_DATA_PARAMETERS);
fixedDepositRequestData.addAll(PRECLOSURE_REQUEST_DATA_PARAMETERS);
fixedDepositRequestData.addAll(DEPOSIT_TERM_REQUEST_DATA_PARAMETERS);
fixedDepositRequestData.add(linkedAccountParamName);
fixedDepositRequestData.add(transferInterestToSavingsParamName);
return fixedDepositRequestData;
}
private static Set<String> fixedDepositAccountResponseData() {
final Set<String> fixedDepositResponseData = new HashSet<>();
fixedDepositResponseData.addAll(DEPOSIT_ACCOUNT_REQUEST_DATA_PARAMETERS);
fixedDepositResponseData.addAll(PRECLOSURE_RESPONSE_DATA_PARAMETERS);
fixedDepositResponseData.addAll(DEPOSIT_TERM_RESPONSE_DATA_PARAMETERS);
fixedDepositResponseData.add(linkedAccountParamName);
fixedDepositResponseData.add(transferInterestToSavingsParamName);
return fixedDepositResponseData;
}
private static Set<String> recurringDepositAccountRequestData() {
final Set<String> recurringDepositRequestData = new HashSet<>();
recurringDepositRequestData.addAll(DEPOSIT_ACCOUNT_REQUEST_DATA_PARAMETERS);
recurringDepositRequestData.addAll(PRECLOSURE_REQUEST_DATA_PARAMETERS);
recurringDepositRequestData.addAll(DEPOSIT_TERM_REQUEST_DATA_PARAMETERS);
recurringDepositRequestData.addAll(RECURRING_DETAILS_REQUEST_DATA_PARAMETERS);
return recurringDepositRequestData;
}
private static Set<String> recurringDepositAccountResponseData() {
final Set<String> recurringDepositResponseData = new HashSet<>();
recurringDepositResponseData.addAll(DEPOSIT_ACCOUNT_REQUEST_DATA_PARAMETERS);
recurringDepositResponseData.addAll(PRECLOSURE_RESPONSE_DATA_PARAMETERS);
recurringDepositResponseData.addAll(DEPOSIT_TERM_RESPONSE_DATA_PARAMETERS);
recurringDepositResponseData.addAll(RECURRING_DETAILS_RESPONSE_DATA_PARAMETERS);
return recurringDepositResponseData;
}
private static final Set<String> RECURRING_DEPOSIT_TRANSACTION_RESPONSE_DATA_PARAMETERS = new HashSet<>(
Arrays.asList(idParamName, "accountId", accountNoParamName, "currency", "amount", dateParamName, paymentDetailDataParamName,
runningBalanceParamName, reversedParamName));
private static final Set<String> SAVINGS_ACCOUNT_ACTIVATION_REQUEST_DATA_PARAMETERS = new HashSet<>(
Arrays.asList(localeParamName, dateFormatParamName, activatedOnDateParamName));
private static final Set<String> SAVINGS_ACCOUNT_CHARGES_RESPONSE_DATA_PARAMETERS = new HashSet<>(
Arrays.asList(chargeIdParamName, savingsAccountChargeIdParamName, chargeNameParamName, penaltyParamName,
chargeTimeTypeParamName, dueAsOfDateParamName, chargeCalculationTypeParamName, percentageParamName,
amountPercentageAppliedToParamName, currencyParamName, amountWaivedParamName, amountWrittenOffParamName,
amountOutstandingParamName, amountOrPercentageParamName, amountParamName, amountPaidParamName, chargeOptionsParamName));
private static final Set<String> SAVINGS_ACCOUNT_CHARGES_ADD_REQUEST_DATA_PARAMETERS = new HashSet<>(
Arrays.asList(chargeIdParamName, amountParamName, dueAsOfDateParamName, dateFormatParamName, localeParamName,
feeOnMonthDayParamName, monthDayFormatParamName, feeIntervalParamName));
private static final Set<String> SAVINGS_ACCOUNT_CHARGES_PAY_CHARGE_REQUEST_DATA_PARAMETERS = new HashSet<>(
Arrays.asList(amountParamName, dueAsOfDateParamName, dateFormatParamName, localeParamName));
}
@@ -0,0 +1,202 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.portfolio.savings;
@SuppressWarnings({ "HideUtilityClassConstructor" })
public class SavingsApiConstants {
public static final String SAVINGS_PRODUCT_RESOURCE_NAME = "savingsproduct";
public static final String SAVINGS_ACCOUNT_RESOURCE_NAME = "savingsaccount";
public static final String SAVINGS_ACCOUNT_TRANSACTION_RESOURCE_NAME = "savingsaccount.transaction";
public static final String SAVINGS_ACCOUNT_CHARGE_RESOURCE_NAME = "savingsaccountcharge";
// actions
public static final String postInterestValidationOnClosure = "postInterestValidationOnClosure";
public static final String summitalAction = ".summital";
public static final String approvalAction = ".approval";
public static final String undoApprovalAction = ".undoApproval";
public static final String rejectAction = ".reject";
public static final String withdrawnByApplicantAction = ".withdrawnByApplicant";
public static final String activateAction = ".activate";
public static final String modifyApplicationAction = ".modify";
public static final String deleteApplicationAction = ".delete";
public static final String undoTransactionAction = ".undotransaction";
public static final String applyAnnualFeeTransactionAction = ".applyannualfee";
public static final String adjustTransactionAction = ".adjusttransaction";
public static final String closeAction = ".close";
public static final String payChargeTransactionAction = ".paycharge";
public static final String waiveChargeTransactionAction = ".waivecharge";
public static final String updateMaturityDetailsAction = ".updateMaturityDetails";
public static final String blockAction = ".block";
public static final String unblockAction = ".unblock";
public static final String blockCreditsAction = ".blockCredits";
public static final String unblockCreditsAction = ".unblockCredits";
public static final String blockDebitsAction = ".blockDebits";
public static final String unblockDebitsAction = ".unblockDebits";
// command
public static final String COMMAND_UNDO_TRANSACTION = "undo";
public static final String COMMAND_REVERSE_TRANSACTION = "reverse";
public static final String COMMAND_ADJUST_TRANSACTION = "modify";
public static final String COMMAND_WAIVE_CHARGE = "waive";
public static final String COMMAND_PAY_CHARGE = "paycharge";
public static final String COMMAND_INACTIVATE_CHARGE = "inactivate";
public static final String COMMAND_HOLD_AMOUNT = "holdAmount";
public static final String COMMAND_RELEASE_AMOUNT = "releaseAmount";
public static final String COMMAND_UNBLOCK_ACCOUNT = "unblock";
public static final String COMMAND_BLOCK_ACCOUNT = "block";
public static final String COMMAND_BLOCK_CREDIT = "blockCredit";
public static final String COMMAND_BLOCK_DEBIT = "blockDebit";
public static final String COMMAND_UNBLOCK_DEBIT = "unblockDebit";
public static final String COMMAND_UNBLOCK_CREDIT = "unblockCredit";
// general
public static final String localeParamName = "locale";
public static final String dateFormatParamName = "dateFormat";
public static final String monthDayFormatParamName = "monthDayFormat";
public static final String staffIdParamName = "savingsOfficerId";
// savings product and account parameters
public static final String idParamName = "id";
public static final String isGSIM = "isGSIM";
public static final String isParentAccount = "isParentAccount";
public static final String accountNoParamName = "accountNo";
public static final String externalIdParamName = "externalId";
public static final String statusParamName = "status";
public static final String subStatusParamName = "subStatus";
public static final String reasonForBlockParamName = "reasonForBlock";
public static final String clientIdParamName = "clientId";
public static final String isRetailAccountParamName = "isRetailAccount";
public static final String autogenerateTransactionIdParamName = "autogenerateTransactionId";
public static final String transactionUpperLimitParamName = "transactionUpperLimit";
public static final String transactionLowerLimitParamName = "transactionLowerLimit";
public static final String retailEntriesParamName = "retailEntries";
public static final String childAccountIdParamName = "childAccountId";
public static final String interestPostedTillDate = "interestPostedTillDate";
public static final String groupIdParamName = "groupId";
public static final String productIdParamName = "productId";
public static final String fieldOfficerIdParamName = "fieldOfficerId";
public static final String submittedOnDateParamName = "submittedOnDate";
public static final String rejectedOnDateParamName = "rejectedOnDate";
public static final String withdrawnOnDateParamName = "withdrawnOnDate";
public static final String approvedOnDateParamName = "approvedOnDate";
public static final String activatedOnDateParamName = "activatedOnDate";
public static final String closedOnDateParamName = "closedOnDate";
public static final String activeParamName = "active";
public static final String nameParamName = "name";
public static final String shortNameParamName = "shortName";
public static final String descriptionParamName = "description";
public static final String currencyCodeParamName = "currencyCode";
public static final String digitsAfterDecimalParamName = "digitsAfterDecimal";
public static final String inMultiplesOfParamName = "inMultiplesOf";
public static final String nominalAnnualInterestRateParamName = "nominalAnnualInterestRate";
public static final String interestCompoundingPeriodTypeParamName = "interestCompoundingPeriodType";
public static final String interestPostingPeriodTypeParamName = "interestPostingPeriodType";
public static final String interestCalculationTypeParamName = "interestCalculationType";
public static final String interestCalculationDaysInYearTypeParamName = "interestCalculationDaysInYearType";
public static final String minRequiredOpeningBalanceParamName = "minRequiredOpeningBalance";
public static final String lockinPeriodFrequencyParamName = "lockinPeriodFrequency";
public static final String lockinPeriodFrequencyTypeParamName = "lockinPeriodFrequencyType";
public static final String withdrawalFeeAmountParamName = "withdrawalFeeAmount";
public static final String withdrawalFeeTypeParamName = "withdrawalFeeType";
public static final String withdrawalFeeForTransfersParamName = "withdrawalFeeForTransfers";
public static final String feeAmountParamName = "feeAmount";// to be deleted
public static final String feeOnMonthDayParamName = "feeOnMonthDay";
public static final String feeIntervalParamName = "feeInterval";
public static final String accountingRuleParamName = "accountingRule";
public static final String paymentTypeIdParamName = "paymentTypeId";
public static final String transactionAccountNumberParamName = "accountNumber";
public static final String checkNumberParamName = "checkNumber";
public static final String routingCodeParamName = "routingCode";
public static final String receiptNumberParamName = "receiptNumber";
public static final String bankNumberParamName = "bankNumber";
public static final String allowOverdraftParamName = "allowOverdraft";
public static final String overdraftLimitParamName = "overdraftLimit";
public static final String nominalAnnualInterestRateOverdraftParamName = "nominalAnnualInterestRateOverdraft";
public static final String minOverdraftForInterestCalculationParamName = "minOverdraftForInterestCalculation";
public static final String minRequiredBalanceParamName = "minRequiredBalance";
public static final String enforceMinRequiredBalanceParamName = "enforceMinRequiredBalance";
public static final String maxAllowedLienLimitParamName = "maxAllowedLienLimit";
public static final String lienAllowedParamName = "lienAllowed";
public static final String minBalanceForInterestCalculationParamName = "minBalanceForInterestCalculation";
public static final String withdrawBalanceParamName = "withdrawBalance";
public static final String onHoldFundsParamName = "onHoldFunds";
public static final String savingsAmountOnHold = "savingsAmountOnHold";
public static final String withHoldTaxParamName = "withHoldTax";
public static final String taxGroupIdParamName = "taxGroupId";
// transaction parameters
public static final String transactionDateParamName = "transactionDate";
public static final String lienParamName = "lien";
public static final String transactionAmountParamName = "transactionAmount";
public static final String paymentDetailDataParamName = "paymentDetailData";
public static final String runningBalanceParamName = "runningBalance";
public static final String reversedParamName = "reversed";
public static final String dateParamName = "date";
// charges parameters
public static final String chargeIdParamName = "chargeId";
public static final String chargesParamName = "charges";
public static final String savingsAccountChargeIdParamName = "savingsAccountChargeId";
public static final String chargeNameParamName = "name";
public static final String penaltyParamName = "penalty";
public static final String chargeTimeTypeParamName = "chargeTimeType";
public static final String dueAsOfDateParamName = "dueDate";
public static final String chargeCalculationTypeParamName = "chargeCalculationType";
public static final String percentageParamName = "percentage";
public static final String amountPercentageAppliedToParamName = "amountPercentageAppliedTo";
public static final String currencyParamName = "currency";
public static final String amountWaivedParamName = "amountWaived";
public static final String amountWrittenOffParamName = "amountWrittenOff";
public static final String amountOutstandingParamName = "amountOutstanding";
public static final String amountOrPercentageParamName = "amountOrPercentage";
public static final String amountParamName = "amount";
public static final String amountPaidParamName = "amountPaid";
public static final String chargeOptionsParamName = "chargeOptions";
public static final String chargePaymentModeParamName = "chargePaymentMode";
public static final String noteParamName = "note";
// Savings account associations
public static final String transactions = "transactions";
public static final String charges = "charges";
public static final String linkedAccount = "linkedAccount";
// Savings on hold transaction
public static final String onHoldTransactionTypeParamName = "transactionType";
public static final String onHoldTransactionDateParamName = "transactionDate";
public static final String onHoldReversedParamName = "reversed";
// Savings Dormancy
public static final String isDormancyTrackingActiveParamName = "isDormancyTrackingActive";
public static final String daysToInactiveParamName = "daysToInactive";
public static final String daysToDormancyParamName = "daysToDormancy";
public static final String daysToEscheatParamName = "daysToEscheat";
public static final String datatables = "datatables";
public static final String gsimApplicationId = "applicationId";
public static final String gsimLastApplication = "lastApplication";
public static final String ERROR_MSG_SAVINGS_ACCOUNT_NOT_ACTIVE = "not.in.active.state";
public static final String accountMappingForPaymentParamName = "accountMappingForPayment";
}
@@ -0,0 +1,49 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.portfolio.self.pockets.api;
public interface PocketApiConstants {
String pocketsResourceName = "pockets";
String linkAccountsToPocketCommandParam = "linkAccounts";
String delinkAccountsFromPocketCommandParam = "delinkAccounts";
String linkAccountsActionName = "LINK_ACCOUNT_TO";
String pocketEntityName = "POCKET";
String delinkAccountsActionName = "DELINK_ACCOUNT_FROM";
String accountIdParamName = "accountId";
String accountTypeParamName = "accountType";
String accountsDetail = "accountsDetail";
String pocketAccountMappingList = "pocketAccountMappingIds";
String pocketAccountMappingId = "pocketAccountMappingId";
String dataValidationMessage = "validation.msg.validation.errors.exist";
String validationErrorMessage = "Validation errors exist.";
String pocketNotFoundException = "error.msg.pocket.not.found";
String pocketNotFoundErrorMessage = "Pocket not found.";
String mappingIdNotLinkedToPocketException = "mapping.id.not.linked.to.pocket.exception";
String mappingIdNotLinkedToPocketErrorMessage = "Mapping Id is not linked to Pocket.";
String uniqueConstraintName = "m_pocket_account_unique_mapping";
String duplicateMappingException = "error.msg.one.or.more.accounts.are.already.mapped.to.pocket.";
String duplicateMappingExceptionMessage = "One or more accounts are already mapped to pocket.";
String unknownDataIntegrityException = "error.msg.unknown.data.integrity.issue";
String unknownDataIntegrityExceptionMessage = "Unknown data integrity issue with resource.";
}
@@ -0,0 +1,46 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.useradministration.api;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
public final class PasswordPreferencesApiConstants {
private PasswordPreferencesApiConstants() {
}
public static final String RESOURCE_NAME = "passwordpreferences";
public static final String ENTITY_NAME = "PASSWORD_PREFERENCES";
// response parameters
public static final String DESCRIPTION = "description";
public static final String ACTIVE = "active";
public static final String ID_PARAM_NAME = "id";
// request parameters
public static final String VALIDATION_POLICY_ID = "validationPolicyId";
static final Set<String> RESPONSE_DATA_PARAMETERS = new HashSet<>(Arrays.asList(ID_PARAM_NAME, ACTIVE, DESCRIPTION));
}