view office transactions api
This commit is contained in:
+58
-19
@@ -1,6 +1,7 @@
|
|||||||
package org.mifosng.platform.api;
|
package org.mifosng.platform.api;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@@ -33,43 +34,81 @@ public class OfficeTransactionsApiResource {
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private OfficeWritePlatformService writePlatformService;
|
private OfficeWritePlatformService writePlatformService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private OfficeReadPlatformService readPlatformService;
|
private OfficeReadPlatformService readPlatformService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ApiDataConversionService apiDataConversionService;
|
private ApiDataConversionService apiDataConversionService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ApiJsonSerializerService apiJsonSerializerService;
|
private ApiJsonSerializerService apiJsonSerializerService;
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("template")
|
@Consumes({ MediaType.APPLICATION_JSON })
|
||||||
@Consumes({MediaType.APPLICATION_JSON})
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
@Produces({MediaType.APPLICATION_JSON})
|
public String retrieveOfficeTransactions(@Context final UriInfo uriInfo) {
|
||||||
public String newOfficeTransactionDetails(@Context final UriInfo uriInfo) {
|
|
||||||
|
|
||||||
Set<String> typicalResponseParameters = new HashSet<String>(Arrays.asList("transactionDate", "allowedOffices", "currencyOptions"));
|
Set<String> typicalResponseParameters = new HashSet<String>(
|
||||||
|
Arrays.asList("id", "transactionDate", "fromOfficeId",
|
||||||
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
"fromOfficeName", "toOfficeId", "toOfficeIdName",
|
||||||
|
"currencyCode", "digitsAfterDecimal",
|
||||||
|
"transactionAmount", "description"));
|
||||||
|
|
||||||
|
Set<String> responseParameters = ApiParameterHelper
|
||||||
|
.extractFieldsForResponseIfProvided(uriInfo
|
||||||
|
.getQueryParameters());
|
||||||
if (responseParameters.isEmpty()) {
|
if (responseParameters.isEmpty()) {
|
||||||
responseParameters.addAll(typicalResponseParameters);
|
responseParameters.addAll(typicalResponseParameters);
|
||||||
}
|
}
|
||||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo
|
||||||
|
.getQueryParameters());
|
||||||
OfficeTransactionData officeTransactionData = this.readPlatformService.retrieveNewOfficeTransactionDetails();
|
|
||||||
|
|
||||||
return this.apiJsonSerializerService.serializeOfficeTransactionDataToJson(prettyPrint, responseParameters, officeTransactionData);
|
Collection<OfficeTransactionData> officeTransactions = this.readPlatformService
|
||||||
|
.retrieveAllOfficeTransactions();
|
||||||
|
|
||||||
|
return this.apiJsonSerializerService
|
||||||
|
.serializeOfficeTransactionDataToJson(prettyPrint,
|
||||||
|
responseParameters, officeTransactions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("template")
|
||||||
|
@Consumes({ MediaType.APPLICATION_JSON })
|
||||||
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
|
public String newOfficeTransactionDetails(@Context final UriInfo uriInfo) {
|
||||||
|
|
||||||
|
Set<String> typicalResponseParameters = new HashSet<String>(
|
||||||
|
Arrays.asList("transactionDate", "allowedOffices",
|
||||||
|
"currencyOptions"));
|
||||||
|
|
||||||
|
Set<String> responseParameters = ApiParameterHelper
|
||||||
|
.extractFieldsForResponseIfProvided(uriInfo
|
||||||
|
.getQueryParameters());
|
||||||
|
if (responseParameters.isEmpty()) {
|
||||||
|
responseParameters.addAll(typicalResponseParameters);
|
||||||
|
}
|
||||||
|
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo
|
||||||
|
.getQueryParameters());
|
||||||
|
|
||||||
|
OfficeTransactionData officeTransactionData = this.readPlatformService
|
||||||
|
.retrieveNewOfficeTransactionDetails();
|
||||||
|
|
||||||
|
return this.apiJsonSerializerService
|
||||||
|
.serializeOfficeTransactionDataToJson(prettyPrint,
|
||||||
|
responseParameters, officeTransactionData);
|
||||||
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Consumes({MediaType.APPLICATION_JSON})
|
@Consumes({ MediaType.APPLICATION_JSON })
|
||||||
@Produces({MediaType.APPLICATION_JSON})
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
public Response transferMoneyFrom(final String jsonRequestBody) {
|
public Response transferMoneyFrom(final String jsonRequestBody) {
|
||||||
|
|
||||||
BranchMoneyTransferCommand command = this.apiDataConversionService.convertJsonToBranchMoneyTransferCommand(jsonRequestBody);
|
BranchMoneyTransferCommand command = this.apiDataConversionService
|
||||||
|
.convertJsonToBranchMoneyTransferCommand(jsonRequestBody);
|
||||||
Long id = this.writePlatformService.externalBranchMoneyTransfer(command);
|
|
||||||
|
Long id = this.writePlatformService
|
||||||
|
.externalBranchMoneyTransfer(command);
|
||||||
return Response.ok().entity(new EntityIdentifier(id)).build();
|
return Response.ok().entity(new EntityIdentifier(id)).build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+80
-1
@@ -1,5 +1,6 @@
|
|||||||
package org.mifosng.platform.api.data;
|
package org.mifosng.platform.api.data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.joda.time.LocalDate;
|
import org.joda.time.LocalDate;
|
||||||
@@ -9,14 +10,55 @@ import org.joda.time.LocalDate;
|
|||||||
*/
|
*/
|
||||||
public class OfficeTransactionData {
|
public class OfficeTransactionData {
|
||||||
|
|
||||||
|
private final Long id;
|
||||||
private final LocalDate transactionDate;
|
private final LocalDate transactionDate;
|
||||||
|
private final Long fromOfficeId;
|
||||||
|
private final String fromOfficeName;
|
||||||
|
private final Long toOfficeId;
|
||||||
|
private final String toOfficeName;
|
||||||
|
private final String currencyCode;
|
||||||
|
private final Integer digitsAfterDecimal;
|
||||||
|
private final BigDecimal transactionAmount;
|
||||||
|
private final String description;
|
||||||
private final List<CurrencyData> currencyOptions;
|
private final List<CurrencyData> currencyOptions;
|
||||||
private final List<OfficeLookup> allowedOffices;
|
private final List<OfficeLookup> allowedOffices;
|
||||||
|
|
||||||
public OfficeTransactionData(final LocalDate transactionDate, final List<OfficeLookup> allowedOffices, final List<CurrencyData> currencyOptions) {
|
public OfficeTransactionData(final LocalDate transactionDate,
|
||||||
|
final List<OfficeLookup> allowedOffices,
|
||||||
|
final List<CurrencyData> currencyOptions) {
|
||||||
this.transactionDate = transactionDate;
|
this.transactionDate = transactionDate;
|
||||||
this.allowedOffices = allowedOffices;
|
this.allowedOffices = allowedOffices;
|
||||||
this.currencyOptions = currencyOptions;
|
this.currencyOptions = currencyOptions;
|
||||||
|
this.id = null;
|
||||||
|
this.fromOfficeId = null;
|
||||||
|
this.fromOfficeName = null;
|
||||||
|
this.toOfficeId = null;
|
||||||
|
this.toOfficeName = null;
|
||||||
|
this.currencyCode = null;
|
||||||
|
this.digitsAfterDecimal = null;
|
||||||
|
this.transactionAmount = null;
|
||||||
|
this.description = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OfficeTransactionData(final Long id,
|
||||||
|
final LocalDate transactionDate, final Long fromOfficeId,
|
||||||
|
final String fromOfficeName, final Long toOfficeId,
|
||||||
|
final String toOfficeName, final String currencyCode,
|
||||||
|
final Integer digitsAfterDecimal,
|
||||||
|
final BigDecimal transactionAmount, final String description) {
|
||||||
|
this.id = id;
|
||||||
|
this.fromOfficeId = fromOfficeId;
|
||||||
|
this.fromOfficeName = fromOfficeName;
|
||||||
|
this.toOfficeId = toOfficeId;
|
||||||
|
this.toOfficeName = toOfficeName;
|
||||||
|
this.currencyCode = currencyCode;
|
||||||
|
this.digitsAfterDecimal = digitsAfterDecimal;
|
||||||
|
this.transactionAmount = transactionAmount;
|
||||||
|
this.description = description;
|
||||||
|
this.transactionDate = transactionDate;
|
||||||
|
this.currencyOptions = null;
|
||||||
|
this.allowedOffices = null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public LocalDate getTransactionDate() {
|
public LocalDate getTransactionDate() {
|
||||||
@@ -30,4 +72,41 @@ public class OfficeTransactionData {
|
|||||||
public List<OfficeLookup> getAllowedOffices() {
|
public List<OfficeLookup> getAllowedOffices() {
|
||||||
return allowedOffices;
|
return allowedOffices;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getFromOfficeId() {
|
||||||
|
return fromOfficeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFromOfficeName() {
|
||||||
|
return fromOfficeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getToOfficeId() {
|
||||||
|
return toOfficeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getToOfficeName() {
|
||||||
|
return toOfficeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCurrencyCode() {
|
||||||
|
return currencyCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getDigitsAfterDecimal() {
|
||||||
|
return digitsAfterDecimal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getTransactionAmount() {
|
||||||
|
return transactionAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+2
@@ -48,6 +48,8 @@ public interface ApiJsonSerializerService {
|
|||||||
|
|
||||||
String serializeOfficeDataToJson(boolean prettyPrint, Set<String> responseParameters, OfficeData office);
|
String serializeOfficeDataToJson(boolean prettyPrint, Set<String> responseParameters, OfficeData office);
|
||||||
|
|
||||||
|
String serializeOfficeTransactionDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<OfficeTransactionData> officeTransactions);
|
||||||
|
|
||||||
String serializeOfficeTransactionDataToJson(boolean prettyPrint, Set<String> responseParameters, OfficeTransactionData officeTransaction);
|
String serializeOfficeTransactionDataToJson(boolean prettyPrint, Set<String> responseParameters, OfficeTransactionData officeTransaction);
|
||||||
|
|
||||||
String serializeConfigurationDataToJson(boolean prettyPrint, Set<String> responseParameters, ConfigurationData configuration);
|
String serializeConfigurationDataToJson(boolean prettyPrint, Set<String> responseParameters, ConfigurationData configuration);
|
||||||
|
|||||||
+355
-159
@@ -33,309 +33,505 @@ import org.springframework.stereotype.Service;
|
|||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of {@link ApiJsonSerializerService} that uses google-gson to serialize Java object representation into JSON.
|
* Implementation of {@link ApiJsonSerializerService} that uses google-gson to
|
||||||
|
* serialize Java object representation into JSON.
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class GoogleGsonApiJsonSerializerService implements ApiJsonSerializerService {
|
public class GoogleGsonApiJsonSerializerService implements
|
||||||
|
ApiJsonSerializerService {
|
||||||
|
|
||||||
private static final Set<String> PERMISSION_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("id", "name", "description", "code"));
|
private static final Set<String> PERMISSION_DATA_PARAMETERS = new HashSet<String>(
|
||||||
private static final Set<String> ROLE_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("id", "name", "description", "availablePermissions", "selectedPermissions"));
|
Arrays.asList("id", "name", "description", "code"));
|
||||||
|
private static final Set<String> ROLE_DATA_PARAMETERS = new HashSet<String>(
|
||||||
|
Arrays.asList("id", "name", "description", "availablePermissions",
|
||||||
|
"selectedPermissions"));
|
||||||
private static final Set<String> APP_USER_DATA_PARAMETERS = new HashSet<String>(
|
private static final Set<String> APP_USER_DATA_PARAMETERS = new HashSet<String>(
|
||||||
Arrays.asList("id", "officeId", "officeName", "username", "firstname", "lastname", "email",
|
Arrays.asList("id", "officeId", "officeName", "username",
|
||||||
"allowedOffices", "availableRoles", "selectedRoles"));
|
"firstname", "lastname", "email", "allowedOffices",
|
||||||
|
"availableRoles", "selectedRoles"));
|
||||||
private static final Set<String> OFFICE_DATA_PARAMETERS = new HashSet<String>(
|
private static final Set<String> OFFICE_DATA_PARAMETERS = new HashSet<String>(
|
||||||
Arrays.asList("id", "name", "nameDecorated", "externalId", "openingDate",
|
Arrays.asList("id", "name", "nameDecorated", "externalId",
|
||||||
"hierarchy", "parentId", "parentName", "allowedParents")
|
"openingDate", "hierarchy", "parentId", "parentName",
|
||||||
);
|
"allowedParents"));
|
||||||
private static final Set<String> OFFICE_TRANSACTIONS_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("transactionDate", "allowedOffices", "currencyOptions"));
|
private static final Set<String> OFFICE_TRANSACTIONS_DATA_PARAMETERS = new HashSet<String>(
|
||||||
private static final Set<String> CONFIGURATION_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("selectedCurrencyOptions", "currencyOptions"));
|
Arrays.asList("id", "transactionDate", "fromOfficeId",
|
||||||
private static final Set<String> FUND_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("id", "name", "externalId"));
|
"fromOfficeName", "toOfficeId", "toOfficeIdName",
|
||||||
|
"currencyCode", "digitsAfterDecimal", "transactionAmount",
|
||||||
|
"description", "allowedOffices", "currencyOptions"));
|
||||||
|
private static final Set<String> CONFIGURATION_DATA_PARAMETERS = new HashSet<String>(
|
||||||
|
Arrays.asList("selectedCurrencyOptions", "currencyOptions"));
|
||||||
|
private static final Set<String> FUND_DATA_PARAMETERS = new HashSet<String>(
|
||||||
|
Arrays.asList("id", "name", "externalId"));
|
||||||
|
|
||||||
private static final Set<String> LOAN_PRODUCT_DATA_PARAMETERS = new HashSet<String>(
|
private static final Set<String> LOAN_PRODUCT_DATA_PARAMETERS = new HashSet<String>(
|
||||||
Arrays.asList("id", "name", "description", "fundId", "fundName", "transactionProcessingStrategyId", "transactionProcessingStrategyName",
|
Arrays.asList("id", "name", "description", "fundId", "fundName",
|
||||||
"principal", "inArrearsTolerance", "numberOfRepayments",
|
"transactionProcessingStrategyId",
|
||||||
"repaymentEvery", "interestRatePerPeriod", "annualInterestRate",
|
"transactionProcessingStrategyName", "principal",
|
||||||
"repaymentFrequencyType", "interestRateFrequencyType", "amortizationType", "interestType", "interestCalculationPeriodType",
|
"inArrearsTolerance", "numberOfRepayments",
|
||||||
"createdOn", "lastModifedOn",
|
"repaymentEvery", "interestRatePerPeriod",
|
||||||
"currencyOptions", "amortizationTypeOptions", "interestTypeOptions", "interestCalculationPeriodTypeOptions",
|
"annualInterestRate", "repaymentFrequencyType",
|
||||||
"repaymentFrequencyTypeOptions", "interestRateFrequencyTypeOptions", "fundOptions", "transactionProcessingStrategyOptions")
|
"interestRateFrequencyType", "amortizationType",
|
||||||
);
|
"interestType", "interestCalculationPeriodType",
|
||||||
|
"createdOn", "lastModifedOn", "currencyOptions",
|
||||||
|
"amortizationTypeOptions", "interestTypeOptions",
|
||||||
|
"interestCalculationPeriodTypeOptions",
|
||||||
|
"repaymentFrequencyTypeOptions",
|
||||||
|
"interestRateFrequencyTypeOptions", "fundOptions",
|
||||||
|
"transactionProcessingStrategyOptions"));
|
||||||
|
|
||||||
private static final Set<String> SAVINGS_PRODUCT_DATA_PARAMETERS = new HashSet<String>(
|
private static final Set<String> SAVINGS_PRODUCT_DATA_PARAMETERS = new HashSet<String>(
|
||||||
Arrays.asList("id", "name", "description","createdOn", "lastModifedOn","interestRate","currencyCode","digitsAfterDecimal",
|
Arrays.asList("id", "name", "description", "createdOn",
|
||||||
"currencyOptions", "minimumBalance","maximumBalance")
|
"lastModifedOn", "interestRate", "currencyCode",
|
||||||
);
|
"digitsAfterDecimal", "currencyOptions", "minimumBalance",
|
||||||
|
"maximumBalance"));
|
||||||
|
|
||||||
private static final Set<String> SAVINGS_DEPOSIT_PRODUCT_DATA_PARAMETERS = new HashSet<String>(
|
private static final Set<String> SAVINGS_DEPOSIT_PRODUCT_DATA_PARAMETERS = new HashSet<String>(
|
||||||
Arrays.asList("currencyOptions", "interestCompoundedEveryPeriodTypeOptions",
|
Arrays.asList("currencyOptions",
|
||||||
"id", "externalId", "name", "description","createdOn", "lastModifedOn","currencyCode","digitsAfterDecimal",
|
"interestCompoundedEveryPeriodTypeOptions", "id",
|
||||||
"minimumBalance","maximumBalance","tenureInMonths","maturityDefaultInterestRate","maturityMinInterestRate",
|
"externalId", "name", "description", "createdOn",
|
||||||
"maturityMaxInterestRate", "interestCompoundedEvery", "interestCompoundedEveryPeriodType",
|
"lastModifedOn", "currencyCode", "digitsAfterDecimal",
|
||||||
"renewalAllowed","preClosureAllowed","preClosureInterestRate")
|
"minimumBalance", "maximumBalance", "tenureInMonths",
|
||||||
);
|
"maturityDefaultInterestRate", "maturityMinInterestRate",
|
||||||
|
"maturityMaxInterestRate", "interestCompoundedEvery",
|
||||||
|
"interestCompoundedEveryPeriodType", "renewalAllowed",
|
||||||
|
"preClosureAllowed", "preClosureInterestRate"));
|
||||||
|
|
||||||
private static final Set<String> SAVINGS_DEPOSIT_ACCOUNT_DATA_PARAMETERS = new HashSet<String>(
|
private static final Set<String> SAVINGS_DEPOSIT_ACCOUNT_DATA_PARAMETERS = new HashSet<String>(
|
||||||
Arrays.asList("productOptions", "interestCompoundedEveryPeriodTypeOptions",
|
Arrays.asList("productOptions",
|
||||||
"createdOn", "lastModifedOn",
|
"interestCompoundedEveryPeriodTypeOptions", "createdOn",
|
||||||
"id", "externalId", "clientId", "clientName", "productId", "productName",
|
"lastModifedOn", "id", "externalId", "clientId",
|
||||||
"currency", "deposit", "maturityInterestRate", "tenureInMonths",
|
"clientName", "productId", "productName", "currency",
|
||||||
"interestCompoundedEvery", "interestCompoundedEveryPeriodType",
|
"deposit", "maturityInterestRate", "tenureInMonths",
|
||||||
"renewalAllowed","preClosureAllowed","preClosureInterestRate"
|
"interestCompoundedEvery",
|
||||||
)
|
"interestCompoundedEveryPeriodType", "renewalAllowed",
|
||||||
);
|
"preClosureAllowed", "preClosureInterestRate"));
|
||||||
|
|
||||||
private static final Set<String> CLIENT_DATA_PARAMETERS = new HashSet<String>(
|
private static final Set<String> CLIENT_DATA_PARAMETERS = new HashSet<String>(
|
||||||
Arrays.asList("id", "officeId", "officeName", "externalId", "firstname", "lastname", "joinedDate", "displayName", "clientOrBusinessName", "allowedOffices")
|
Arrays.asList("id", "officeId", "officeName", "externalId",
|
||||||
);
|
"firstname", "lastname", "joinedDate", "displayName",
|
||||||
|
"clientOrBusinessName", "allowedOffices"));
|
||||||
|
|
||||||
private static final Set<String> CLIENT_ACCOUNTS_DATA_PARAMETERS = new HashSet<String>(
|
private static final Set<String> CLIENT_ACCOUNTS_DATA_PARAMETERS = new HashSet<String>(
|
||||||
Arrays.asList("pendingApprovalLoans", "awaitingDisbursalLoans", "openLoans", "closedLoans",
|
Arrays.asList("pendingApprovalLoans", "awaitingDisbursalLoans",
|
||||||
"anyLoanCount", "pendingApprovalLoanCount", "awaitingDisbursalLoanCount", "activeLoanCount", "closedLoanCount",
|
"openLoans", "closedLoans", "anyLoanCount",
|
||||||
"pendingApprovalDespositAccountsCount", "pendingApprovalDespositAccounts", "approvedDespositAccountsCount", "approvedDespositAccounts")
|
"pendingApprovalLoanCount", "awaitingDisbursalLoanCount",
|
||||||
);
|
"activeLoanCount", "closedLoanCount",
|
||||||
|
"pendingApprovalDespositAccountsCount",
|
||||||
|
"pendingApprovalDespositAccounts",
|
||||||
|
"approvedDespositAccountsCount", "approvedDespositAccounts"));
|
||||||
|
|
||||||
private static final Set<String> GROUP_DATA_PARAMETERS = new HashSet<String>(
|
private static final Set<String> GROUP_DATA_PARAMETERS = new HashSet<String>(
|
||||||
Arrays.asList("id", "name", "externalId", "clientMembers", "allowedClients")
|
Arrays.asList("id", "name", "externalId", "clientMembers",
|
||||||
);
|
"allowedClients"));
|
||||||
|
|
||||||
private static final Set<String> NOTE_DATA_PARAMETERS = new HashSet<String>(
|
private static final Set<String> NOTE_DATA_PARAMETERS = new HashSet<String>(
|
||||||
Arrays.asList("id", "clientId", "loanId", "loanTransactionId", "noteType", "note", "createdById", "createdByUsername",
|
Arrays.asList("id", "clientId", "loanId", "loanTransactionId",
|
||||||
"createdOn", "updatedById", "updatedByUsername", "updatedOn")
|
"noteType", "note", "createdById", "createdByUsername",
|
||||||
);
|
"createdOn", "updatedById", "updatedByUsername",
|
||||||
|
"updatedOn"));
|
||||||
|
|
||||||
private static final Set<String> NEW_LOAN_DATA_PARAMETERS = new HashSet<String>(
|
private static final Set<String> NEW_LOAN_DATA_PARAMETERS = new HashSet<String>(
|
||||||
Arrays.asList("clientId", "clientName", "productId", "productName",
|
Arrays.asList("clientId", "clientName", "productId", "productName",
|
||||||
"selectedProduct", "expectedDisbursementDate", "allowedProducts")
|
"selectedProduct", "expectedDisbursementDate",
|
||||||
);
|
"allowedProducts"));
|
||||||
|
|
||||||
private static final Set<String> LOAN_DATA_PARAMETERS = new HashSet<String>(
|
private static final Set<String> LOAN_DATA_PARAMETERS = new HashSet<String>(
|
||||||
Arrays.asList("id", "externalId", "fundId", "fundName", "loanProductId", "loanProductName", "principal", "inArrearsTolerance", "numberOfRepayments",
|
Arrays.asList("id", "externalId", "fundId", "fundName",
|
||||||
"repaymentEvery", "interestRatePerPeriod", "annualInterestRate",
|
"loanProductId", "loanProductName", "principal",
|
||||||
"repaymentFrequencyType", "interestRateFrequencyType", "amortizationType", "interestType", "interestCalculationPeriodType",
|
"inArrearsTolerance", "numberOfRepayments",
|
||||||
"submittedOnDate", "approvedOnDate", "expectedDisbursementDate", "actualDisbursementDate",
|
"repaymentEvery", "interestRatePerPeriod",
|
||||||
"expectedFirstRepaymentOnDate", "interestChargedFromDate", "closedOnDate", "expectedMaturityDate",
|
"annualInterestRate", "repaymentFrequencyType",
|
||||||
"lifeCycleStatusId", "lifeCycleStatusText", "lifeCycleStatusDate",
|
"interestRateFrequencyType", "amortizationType",
|
||||||
"summary", "repaymentSchedule", "loanRepayments", "permissions", "convenienceData")
|
"interestType", "interestCalculationPeriodType",
|
||||||
);
|
"submittedOnDate", "approvedOnDate",
|
||||||
|
"expectedDisbursementDate", "actualDisbursementDate",
|
||||||
|
"expectedFirstRepaymentOnDate", "interestChargedFromDate",
|
||||||
|
"closedOnDate", "expectedMaturityDate",
|
||||||
|
"lifeCycleStatusId", "lifeCycleStatusText",
|
||||||
|
"lifeCycleStatusDate", "summary", "repaymentSchedule",
|
||||||
|
"loanRepayments", "permissions", "convenienceData"));
|
||||||
|
|
||||||
private static final Set<String> LOAN_TRANSACTION_DATA_PARAMETERS = new HashSet<String>(
|
private static final Set<String> LOAN_TRANSACTION_DATA_PARAMETERS = new HashSet<String>(
|
||||||
Arrays.asList("id", "transactionType", "date", "principal", "interest", "total", "totalWaived", "overpaid")
|
Arrays.asList("id", "transactionType", "date", "principal",
|
||||||
);
|
"interest", "total", "totalWaived", "overpaid"));
|
||||||
|
|
||||||
private static final Set<String> CHARGES_DATA_PARAMETERS = new HashSet<String>(
|
private static final Set<String> CHARGES_DATA_PARAMETERS = new HashSet<String>(
|
||||||
Arrays.asList("id", "name", "amount", "currency", "active", "chargeAppliesTo", "chargeTimeType",
|
Arrays.asList("id", "name", "amount", "currency", "active",
|
||||||
"chargeCalculationType", "chargeCalculationTypeOptions", "currencyOptions")
|
"chargeAppliesTo", "chargeTimeType",
|
||||||
);
|
"chargeCalculationType", "chargeCalculationTypeOptions",
|
||||||
|
"currencyOptions"));
|
||||||
|
|
||||||
private final GoogleGsonSerializerHelper helper;
|
private final GoogleGsonSerializerHelper helper;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public GoogleGsonApiJsonSerializerService(final GoogleGsonSerializerHelper helper) {
|
public GoogleGsonApiJsonSerializerService(
|
||||||
|
final GoogleGsonSerializerHelper helper) {
|
||||||
this.helper = helper;
|
this.helper = helper;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String serializeAuthenticatedUserDataToJson(final boolean prettyPrint, final AuthenticatedUserData authenticatedUserData) {
|
|
||||||
final Gson gsonDeserializer = helper.createGsonBuilder(prettyPrint);
|
|
||||||
return helper.serializedJsonFrom(gsonDeserializer, authenticatedUserData);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String serializeGenericResultsetDataToJson(final boolean prettyPrint, final GenericResultsetData resultsetData) {
|
public String serializeAuthenticatedUserDataToJson(
|
||||||
|
final boolean prettyPrint,
|
||||||
|
final AuthenticatedUserData authenticatedUserData) {
|
||||||
|
final Gson gsonDeserializer = helper.createGsonBuilder(prettyPrint);
|
||||||
|
return helper.serializedJsonFrom(gsonDeserializer,
|
||||||
|
authenticatedUserData);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String serializeGenericResultsetDataToJson(
|
||||||
|
final boolean prettyPrint, final GenericResultsetData resultsetData) {
|
||||||
final Gson gsonDeserializer = helper.createGsonBuilder(prettyPrint);
|
final Gson gsonDeserializer = helper.createGsonBuilder(prettyPrint);
|
||||||
return helper.serializedJsonFrom(gsonDeserializer, resultsetData);
|
return helper.serializedJsonFrom(gsonDeserializer, resultsetData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String serializeAdditionalFieldsSetDataToJson(final boolean prettyPrint, final Collection<AdditionalFieldsSetData> datasets) {
|
public String serializeAdditionalFieldsSetDataToJson(
|
||||||
|
final boolean prettyPrint,
|
||||||
|
final Collection<AdditionalFieldsSetData> datasets) {
|
||||||
final Gson gsonDeserializer = helper.createGsonBuilder(prettyPrint);
|
final Gson gsonDeserializer = helper.createGsonBuilder(prettyPrint);
|
||||||
return helper.serializedJsonFrom(gsonDeserializer, datasets.toArray(new AdditionalFieldsSetData[datasets.size()]));
|
return helper.serializedJsonFrom(gsonDeserializer,
|
||||||
|
datasets.toArray(new AdditionalFieldsSetData[datasets.size()]));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String serializePermissionDataToJson(final boolean prettyPrint, final Set<String> responseParameters, final Collection<PermissionData> permissions) {
|
public String serializePermissionDataToJson(final boolean prettyPrint,
|
||||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(PERMISSION_DATA_PARAMETERS, prettyPrint, responseParameters);
|
final Set<String> responseParameters,
|
||||||
return helper.serializedJsonFrom(gsonDeserializer, permissions.toArray(new PermissionData[permissions.size()]));
|
final Collection<PermissionData> permissions) {
|
||||||
|
final Gson gsonDeserializer = helper
|
||||||
|
.createGsonBuilderWithParameterExclusionSerializationStrategy(
|
||||||
|
PERMISSION_DATA_PARAMETERS, prettyPrint,
|
||||||
|
responseParameters);
|
||||||
|
return helper.serializedJsonFrom(gsonDeserializer,
|
||||||
|
permissions.toArray(new PermissionData[permissions.size()]));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String serializeRoleDataToJson(final boolean prettyPrint, final Set<String> responseParameters, final Collection<RoleData> roles) {
|
public String serializeRoleDataToJson(final boolean prettyPrint,
|
||||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(ROLE_DATA_PARAMETERS, prettyPrint, responseParameters);
|
final Set<String> responseParameters,
|
||||||
return helper.serializedJsonFrom(gsonDeserializer, roles.toArray(new RoleData[roles.size()]));
|
final Collection<RoleData> roles) {
|
||||||
|
final Gson gsonDeserializer = helper
|
||||||
|
.createGsonBuilderWithParameterExclusionSerializationStrategy(
|
||||||
|
ROLE_DATA_PARAMETERS, prettyPrint, responseParameters);
|
||||||
|
return helper.serializedJsonFrom(gsonDeserializer,
|
||||||
|
roles.toArray(new RoleData[roles.size()]));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String serializeRoleDataToJson(final boolean prettyPrint, final Set<String> responseParameters, final RoleData role) {
|
public String serializeRoleDataToJson(final boolean prettyPrint,
|
||||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(ROLE_DATA_PARAMETERS, prettyPrint, responseParameters);
|
final Set<String> responseParameters, final RoleData role) {
|
||||||
|
final Gson gsonDeserializer = helper
|
||||||
|
.createGsonBuilderWithParameterExclusionSerializationStrategy(
|
||||||
|
ROLE_DATA_PARAMETERS, prettyPrint, responseParameters);
|
||||||
return helper.serializedJsonFrom(gsonDeserializer, role);
|
return helper.serializedJsonFrom(gsonDeserializer, role);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String serializeAppUserDataToJson(final boolean prettyPrint, final Set<String> responseParameters, final Collection<AppUserData> users) {
|
public String serializeAppUserDataToJson(final boolean prettyPrint,
|
||||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(APP_USER_DATA_PARAMETERS, prettyPrint, responseParameters);
|
final Set<String> responseParameters,
|
||||||
return helper.serializedJsonFrom(gsonDeserializer, users.toArray(new AppUserData[users.size()]));
|
final Collection<AppUserData> users) {
|
||||||
|
final Gson gsonDeserializer = helper
|
||||||
|
.createGsonBuilderWithParameterExclusionSerializationStrategy(
|
||||||
|
APP_USER_DATA_PARAMETERS, prettyPrint,
|
||||||
|
responseParameters);
|
||||||
|
return helper.serializedJsonFrom(gsonDeserializer,
|
||||||
|
users.toArray(new AppUserData[users.size()]));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String serializeAppUserDataToJson(final boolean prettyPrint, final Set<String> responseParameters, final AppUserData user) {
|
public String serializeAppUserDataToJson(final boolean prettyPrint,
|
||||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(APP_USER_DATA_PARAMETERS, prettyPrint, responseParameters);
|
final Set<String> responseParameters, final AppUserData user) {
|
||||||
|
final Gson gsonDeserializer = helper
|
||||||
|
.createGsonBuilderWithParameterExclusionSerializationStrategy(
|
||||||
|
APP_USER_DATA_PARAMETERS, prettyPrint,
|
||||||
|
responseParameters);
|
||||||
return helper.serializedJsonFrom(gsonDeserializer, user);
|
return helper.serializedJsonFrom(gsonDeserializer, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String serializeOfficeDataToJson(final boolean prettyPrint, final Set<String> responseParameters, final Collection<OfficeData> offices) {
|
public String serializeOfficeDataToJson(final boolean prettyPrint,
|
||||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(OFFICE_DATA_PARAMETERS, prettyPrint, responseParameters);
|
final Set<String> responseParameters,
|
||||||
return helper.serializedJsonFrom(gsonDeserializer, offices.toArray(new OfficeData[offices.size()]));
|
final Collection<OfficeData> offices) {
|
||||||
|
final Gson gsonDeserializer = helper
|
||||||
|
.createGsonBuilderWithParameterExclusionSerializationStrategy(
|
||||||
|
OFFICE_DATA_PARAMETERS, prettyPrint, responseParameters);
|
||||||
|
return helper.serializedJsonFrom(gsonDeserializer,
|
||||||
|
offices.toArray(new OfficeData[offices.size()]));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String serializeOfficeDataToJson(final boolean prettyPrint, final Set<String> responseParameters, final OfficeData office) {
|
public String serializeOfficeDataToJson(final boolean prettyPrint,
|
||||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(OFFICE_DATA_PARAMETERS, prettyPrint, responseParameters);
|
final Set<String> responseParameters, final OfficeData office) {
|
||||||
|
final Gson gsonDeserializer = helper
|
||||||
|
.createGsonBuilderWithParameterExclusionSerializationStrategy(
|
||||||
|
OFFICE_DATA_PARAMETERS, prettyPrint, responseParameters);
|
||||||
return helper.serializedJsonFrom(gsonDeserializer, office);
|
return helper.serializedJsonFrom(gsonDeserializer, office);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String serializeOfficeTransactionDataToJson(final boolean prettyPrint, final Set<String> responseParameters, final OfficeTransactionData officeTransaction) {
|
public String serializeOfficeTransactionDataToJson(
|
||||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(OFFICE_TRANSACTIONS_DATA_PARAMETERS, prettyPrint, responseParameters);
|
final boolean prettyPrint, final Set<String> responseParameters,
|
||||||
|
final Collection<OfficeTransactionData> officeTransactions) {
|
||||||
|
final Gson gsonDeserializer = helper
|
||||||
|
.createGsonBuilderWithParameterExclusionSerializationStrategy(
|
||||||
|
OFFICE_TRANSACTIONS_DATA_PARAMETERS, prettyPrint,
|
||||||
|
responseParameters);
|
||||||
|
return helper.serializedJsonFrom(gsonDeserializer, officeTransactions);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String serializeOfficeTransactionDataToJson(
|
||||||
|
final boolean prettyPrint, final Set<String> responseParameters,
|
||||||
|
final OfficeTransactionData officeTransaction) {
|
||||||
|
final Gson gsonDeserializer = helper
|
||||||
|
.createGsonBuilderWithParameterExclusionSerializationStrategy(
|
||||||
|
OFFICE_TRANSACTIONS_DATA_PARAMETERS, prettyPrint,
|
||||||
|
responseParameters);
|
||||||
return helper.serializedJsonFrom(gsonDeserializer, officeTransaction);
|
return helper.serializedJsonFrom(gsonDeserializer, officeTransaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String serializeConfigurationDataToJson(final boolean prettyPrint, final Set<String> responseParameters, final ConfigurationData configuration) {
|
public String serializeConfigurationDataToJson(final boolean prettyPrint,
|
||||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(CONFIGURATION_DATA_PARAMETERS, prettyPrint, responseParameters);
|
final Set<String> responseParameters,
|
||||||
|
final ConfigurationData configuration) {
|
||||||
|
final Gson gsonDeserializer = helper
|
||||||
|
.createGsonBuilderWithParameterExclusionSerializationStrategy(
|
||||||
|
CONFIGURATION_DATA_PARAMETERS, prettyPrint,
|
||||||
|
responseParameters);
|
||||||
return helper.serializedJsonFrom(gsonDeserializer, configuration);
|
return helper.serializedJsonFrom(gsonDeserializer, configuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String serializeFundDataToJson(final boolean prettyPrint, final Set<String> responseParameters, final Collection<FundData> funds) {
|
public String serializeFundDataToJson(final boolean prettyPrint,
|
||||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(FUND_DATA_PARAMETERS, prettyPrint, responseParameters);
|
final Set<String> responseParameters,
|
||||||
return helper.serializedJsonFrom(gsonDeserializer, funds.toArray(new FundData[funds.size()]));
|
final Collection<FundData> funds) {
|
||||||
|
final Gson gsonDeserializer = helper
|
||||||
|
.createGsonBuilderWithParameterExclusionSerializationStrategy(
|
||||||
|
FUND_DATA_PARAMETERS, prettyPrint, responseParameters);
|
||||||
|
return helper.serializedJsonFrom(gsonDeserializer,
|
||||||
|
funds.toArray(new FundData[funds.size()]));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String serializeFundDataToJson(final boolean prettyPrint, final Set<String> responseParameters, final FundData fund) {
|
public String serializeFundDataToJson(final boolean prettyPrint,
|
||||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(FUND_DATA_PARAMETERS, prettyPrint, responseParameters);
|
final Set<String> responseParameters, final FundData fund) {
|
||||||
|
final Gson gsonDeserializer = helper
|
||||||
|
.createGsonBuilderWithParameterExclusionSerializationStrategy(
|
||||||
|
FUND_DATA_PARAMETERS, prettyPrint, responseParameters);
|
||||||
return helper.serializedJsonFrom(gsonDeserializer, fund);
|
return helper.serializedJsonFrom(gsonDeserializer, fund);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String serializeLoanProductDataToJson(final boolean prettyPrint, final Set<String> responseParameters, final Collection<LoanProductData> products) {
|
public String serializeLoanProductDataToJson(final boolean prettyPrint,
|
||||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(LOAN_PRODUCT_DATA_PARAMETERS, prettyPrint, responseParameters);
|
final Set<String> responseParameters,
|
||||||
return helper.serializedJsonFrom(gsonDeserializer, products.toArray(new LoanProductData[products.size()]));
|
final Collection<LoanProductData> products) {
|
||||||
|
final Gson gsonDeserializer = helper
|
||||||
|
.createGsonBuilderWithParameterExclusionSerializationStrategy(
|
||||||
|
LOAN_PRODUCT_DATA_PARAMETERS, prettyPrint,
|
||||||
|
responseParameters);
|
||||||
|
return helper.serializedJsonFrom(gsonDeserializer,
|
||||||
|
products.toArray(new LoanProductData[products.size()]));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String serializeLoanProductDataToJson(final boolean prettyPrint, final Set<String> responseParameters, final LoanProductData product) {
|
public String serializeLoanProductDataToJson(final boolean prettyPrint,
|
||||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(LOAN_PRODUCT_DATA_PARAMETERS, prettyPrint, responseParameters);
|
final Set<String> responseParameters, final LoanProductData product) {
|
||||||
|
final Gson gsonDeserializer = helper
|
||||||
|
.createGsonBuilderWithParameterExclusionSerializationStrategy(
|
||||||
|
LOAN_PRODUCT_DATA_PARAMETERS, prettyPrint,
|
||||||
|
responseParameters);
|
||||||
return helper.serializedJsonFrom(gsonDeserializer, product);
|
return helper.serializedJsonFrom(gsonDeserializer, product);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String serializeSavingProductDataToJson(final boolean prettyPrint, final Set<String> responseParameters, final Collection<SavingProductData> products) {
|
public String serializeSavingProductDataToJson(final boolean prettyPrint,
|
||||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(SAVINGS_PRODUCT_DATA_PARAMETERS, prettyPrint, responseParameters);
|
final Set<String> responseParameters,
|
||||||
return helper.serializedJsonFrom(gsonDeserializer, products.toArray(new SavingProductData[products.size()]));
|
final Collection<SavingProductData> products) {
|
||||||
|
final Gson gsonDeserializer = helper
|
||||||
|
.createGsonBuilderWithParameterExclusionSerializationStrategy(
|
||||||
|
SAVINGS_PRODUCT_DATA_PARAMETERS, prettyPrint,
|
||||||
|
responseParameters);
|
||||||
|
return helper.serializedJsonFrom(gsonDeserializer,
|
||||||
|
products.toArray(new SavingProductData[products.size()]));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String serializeSavingProductDataToJson(final boolean prettyPrint, final Set<String> responseParameters, final SavingProductData savingProduct) {
|
public String serializeSavingProductDataToJson(final boolean prettyPrint,
|
||||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(SAVINGS_PRODUCT_DATA_PARAMETERS, prettyPrint, responseParameters);
|
final Set<String> responseParameters,
|
||||||
|
final SavingProductData savingProduct) {
|
||||||
|
final Gson gsonDeserializer = helper
|
||||||
|
.createGsonBuilderWithParameterExclusionSerializationStrategy(
|
||||||
|
SAVINGS_PRODUCT_DATA_PARAMETERS, prettyPrint,
|
||||||
|
responseParameters);
|
||||||
return helper.serializedJsonFrom(gsonDeserializer, savingProduct);
|
return helper.serializedJsonFrom(gsonDeserializer, savingProduct);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String serializeDepositProductDataToJson(final boolean prettyPrint, final Set<String> responseParameters, final Collection<DepositProductData> products) {
|
public String serializeDepositProductDataToJson(final boolean prettyPrint,
|
||||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(SAVINGS_DEPOSIT_PRODUCT_DATA_PARAMETERS, prettyPrint, responseParameters);
|
final Set<String> responseParameters,
|
||||||
return helper.serializedJsonFrom(gsonDeserializer, products.toArray(new DepositProductData[products.size()]));
|
final Collection<DepositProductData> products) {
|
||||||
|
final Gson gsonDeserializer = helper
|
||||||
|
.createGsonBuilderWithParameterExclusionSerializationStrategy(
|
||||||
|
SAVINGS_DEPOSIT_PRODUCT_DATA_PARAMETERS, prettyPrint,
|
||||||
|
responseParameters);
|
||||||
|
return helper.serializedJsonFrom(gsonDeserializer,
|
||||||
|
products.toArray(new DepositProductData[products.size()]));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String serializeDepositProductDataToJson(final boolean prettyPrint, final Set<String> responseParameters, final DepositProductData depositProduct) {
|
public String serializeDepositProductDataToJson(final boolean prettyPrint,
|
||||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(SAVINGS_DEPOSIT_PRODUCT_DATA_PARAMETERS, prettyPrint, responseParameters);
|
final Set<String> responseParameters,
|
||||||
|
final DepositProductData depositProduct) {
|
||||||
|
final Gson gsonDeserializer = helper
|
||||||
|
.createGsonBuilderWithParameterExclusionSerializationStrategy(
|
||||||
|
SAVINGS_DEPOSIT_PRODUCT_DATA_PARAMETERS, prettyPrint,
|
||||||
|
responseParameters);
|
||||||
return helper.serializedJsonFrom(gsonDeserializer, depositProduct);
|
return helper.serializedJsonFrom(gsonDeserializer, depositProduct);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String serializeDepositAccountDataToJson(final boolean prettyPrint, final Set<String> responseParameters, final Collection<DepositAccountData> accounts) {
|
public String serializeDepositAccountDataToJson(final boolean prettyPrint,
|
||||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(SAVINGS_DEPOSIT_ACCOUNT_DATA_PARAMETERS, prettyPrint, responseParameters);
|
final Set<String> responseParameters,
|
||||||
return helper.serializedJsonFrom(gsonDeserializer, accounts.toArray(new DepositAccountData[accounts.size()]));
|
final Collection<DepositAccountData> accounts) {
|
||||||
|
final Gson gsonDeserializer = helper
|
||||||
|
.createGsonBuilderWithParameterExclusionSerializationStrategy(
|
||||||
|
SAVINGS_DEPOSIT_ACCOUNT_DATA_PARAMETERS, prettyPrint,
|
||||||
|
responseParameters);
|
||||||
|
return helper.serializedJsonFrom(gsonDeserializer,
|
||||||
|
accounts.toArray(new DepositAccountData[accounts.size()]));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String serializeDepositAccountDataToJson(final boolean prettyPrint, final Set<String> responseParameters, final DepositAccountData account) {
|
public String serializeDepositAccountDataToJson(final boolean prettyPrint,
|
||||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(SAVINGS_DEPOSIT_ACCOUNT_DATA_PARAMETERS, prettyPrint, responseParameters);
|
final Set<String> responseParameters,
|
||||||
|
final DepositAccountData account) {
|
||||||
|
final Gson gsonDeserializer = helper
|
||||||
|
.createGsonBuilderWithParameterExclusionSerializationStrategy(
|
||||||
|
SAVINGS_DEPOSIT_ACCOUNT_DATA_PARAMETERS, prettyPrint,
|
||||||
|
responseParameters);
|
||||||
return helper.serializedJsonFrom(gsonDeserializer, account);
|
return helper.serializedJsonFrom(gsonDeserializer, account);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String serializeClientDataToJson(final boolean prettyPrint, final Set<String> responseParameters, final Collection<ClientData> clients) {
|
public String serializeClientDataToJson(final boolean prettyPrint,
|
||||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(CLIENT_DATA_PARAMETERS, prettyPrint, responseParameters);
|
final Set<String> responseParameters,
|
||||||
return helper.serializedJsonFrom(gsonDeserializer, clients.toArray(new ClientData[clients.size()]));
|
final Collection<ClientData> clients) {
|
||||||
|
final Gson gsonDeserializer = helper
|
||||||
|
.createGsonBuilderWithParameterExclusionSerializationStrategy(
|
||||||
|
CLIENT_DATA_PARAMETERS, prettyPrint, responseParameters);
|
||||||
|
return helper.serializedJsonFrom(gsonDeserializer,
|
||||||
|
clients.toArray(new ClientData[clients.size()]));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String serializeClientDataToJson(final boolean prettyPrint, final Set<String> responseParameters, final ClientData client) {
|
public String serializeClientDataToJson(final boolean prettyPrint,
|
||||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(CLIENT_DATA_PARAMETERS, prettyPrint, responseParameters);
|
final Set<String> responseParameters, final ClientData client) {
|
||||||
|
final Gson gsonDeserializer = helper
|
||||||
|
.createGsonBuilderWithParameterExclusionSerializationStrategy(
|
||||||
|
CLIENT_DATA_PARAMETERS, prettyPrint, responseParameters);
|
||||||
return helper.serializedJsonFrom(gsonDeserializer, client);
|
return helper.serializedJsonFrom(gsonDeserializer, client);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String serializeClientAccountSummaryCollectionDataToJson(final boolean prettyPrint, final Set<String> responseParameters,
|
public String serializeClientAccountSummaryCollectionDataToJson(
|
||||||
|
final boolean prettyPrint, final Set<String> responseParameters,
|
||||||
final ClientAccountSummaryCollectionData clientAccount) {
|
final ClientAccountSummaryCollectionData clientAccount) {
|
||||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(CLIENT_ACCOUNTS_DATA_PARAMETERS, prettyPrint, responseParameters);
|
final Gson gsonDeserializer = helper
|
||||||
|
.createGsonBuilderWithParameterExclusionSerializationStrategy(
|
||||||
|
CLIENT_ACCOUNTS_DATA_PARAMETERS, prettyPrint,
|
||||||
|
responseParameters);
|
||||||
return helper.serializedJsonFrom(gsonDeserializer, clientAccount);
|
return helper.serializedJsonFrom(gsonDeserializer, clientAccount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String serializeGroupDataToJson(final boolean prettyPrint, final Set<String> responseParameters, final Collection<GroupData> groups) {
|
public String serializeGroupDataToJson(final boolean prettyPrint,
|
||||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(GROUP_DATA_PARAMETERS, prettyPrint, responseParameters);
|
final Set<String> responseParameters,
|
||||||
return helper.serializedJsonFrom(gsonDeserializer, groups.toArray(new GroupData[groups.size()]));
|
final Collection<GroupData> groups) {
|
||||||
|
final Gson gsonDeserializer = helper
|
||||||
|
.createGsonBuilderWithParameterExclusionSerializationStrategy(
|
||||||
|
GROUP_DATA_PARAMETERS, prettyPrint, responseParameters);
|
||||||
|
return helper.serializedJsonFrom(gsonDeserializer,
|
||||||
|
groups.toArray(new GroupData[groups.size()]));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String serializeGroupDataToJson(final boolean prettyPrint, final Set<String> responseParameters, final GroupData group) {
|
public String serializeGroupDataToJson(final boolean prettyPrint,
|
||||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(GROUP_DATA_PARAMETERS, prettyPrint, responseParameters);
|
final Set<String> responseParameters, final GroupData group) {
|
||||||
|
final Gson gsonDeserializer = helper
|
||||||
|
.createGsonBuilderWithParameterExclusionSerializationStrategy(
|
||||||
|
GROUP_DATA_PARAMETERS, prettyPrint, responseParameters);
|
||||||
return helper.serializedJsonFrom(gsonDeserializer, group);
|
return helper.serializedJsonFrom(gsonDeserializer, group);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String serializeNoteDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<NoteData> notes) {
|
public String serializeNoteDataToJson(boolean prettyPrint,
|
||||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(NOTE_DATA_PARAMETERS, prettyPrint, responseParameters);
|
Set<String> responseParameters, Collection<NoteData> notes) {
|
||||||
return helper.serializedJsonFrom(gsonDeserializer, notes.toArray(new NoteData[notes.size()]));
|
final Gson gsonDeserializer = helper
|
||||||
|
.createGsonBuilderWithParameterExclusionSerializationStrategy(
|
||||||
|
NOTE_DATA_PARAMETERS, prettyPrint, responseParameters);
|
||||||
|
return helper.serializedJsonFrom(gsonDeserializer,
|
||||||
|
notes.toArray(new NoteData[notes.size()]));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String serializeNoteDataToJson(final boolean prettyPrint, final Set<String> responseParameters, final NoteData note) {
|
public String serializeNoteDataToJson(final boolean prettyPrint,
|
||||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(NOTE_DATA_PARAMETERS, prettyPrint, responseParameters);
|
final Set<String> responseParameters, final NoteData note) {
|
||||||
|
final Gson gsonDeserializer = helper
|
||||||
|
.createGsonBuilderWithParameterExclusionSerializationStrategy(
|
||||||
|
NOTE_DATA_PARAMETERS, prettyPrint, responseParameters);
|
||||||
return helper.serializedJsonFrom(gsonDeserializer, note);
|
return helper.serializedJsonFrom(gsonDeserializer, note);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String serializeNewLoanDataToJson(final boolean prettyPrint, final Set<String> responseParameters, final NewLoanData newLoan) {
|
public String serializeNewLoanDataToJson(final boolean prettyPrint,
|
||||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(NEW_LOAN_DATA_PARAMETERS, prettyPrint, responseParameters);
|
final Set<String> responseParameters, final NewLoanData newLoan) {
|
||||||
|
final Gson gsonDeserializer = helper
|
||||||
|
.createGsonBuilderWithParameterExclusionSerializationStrategy(
|
||||||
|
NEW_LOAN_DATA_PARAMETERS, prettyPrint,
|
||||||
|
responseParameters);
|
||||||
return helper.serializedJsonFrom(gsonDeserializer, newLoan);
|
return helper.serializedJsonFrom(gsonDeserializer, newLoan);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String serialzieLoanAccountDataToJson(final boolean prettyPrint, final Set<String> responseParameters, final LoanAccountData loanAccount) {
|
public String serialzieLoanAccountDataToJson(final boolean prettyPrint,
|
||||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(LOAN_DATA_PARAMETERS, prettyPrint, responseParameters);
|
final Set<String> responseParameters,
|
||||||
|
final LoanAccountData loanAccount) {
|
||||||
|
final Gson gsonDeserializer = helper
|
||||||
|
.createGsonBuilderWithParameterExclusionSerializationStrategy(
|
||||||
|
LOAN_DATA_PARAMETERS, prettyPrint, responseParameters);
|
||||||
return helper.serializedJsonFrom(gsonDeserializer, loanAccount);
|
return helper.serializedJsonFrom(gsonDeserializer, loanAccount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String serializeLoanTransactionDataToJson(final boolean prettyPrint, final Set<String> responseParameters, final LoanTransactionData transaction) {
|
public String serializeLoanTransactionDataToJson(final boolean prettyPrint,
|
||||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(LOAN_TRANSACTION_DATA_PARAMETERS, prettyPrint, responseParameters);
|
final Set<String> responseParameters,
|
||||||
|
final LoanTransactionData transaction) {
|
||||||
|
final Gson gsonDeserializer = helper
|
||||||
|
.createGsonBuilderWithParameterExclusionSerializationStrategy(
|
||||||
|
LOAN_TRANSACTION_DATA_PARAMETERS, prettyPrint,
|
||||||
|
responseParameters);
|
||||||
return helper.serializedJsonFrom(gsonDeserializer, transaction);
|
return helper.serializedJsonFrom(gsonDeserializer, transaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String serializeChargeDataToJson(final boolean prettyPrint, final Set<String> responseParameters, final Collection<ChargeData> charges) {
|
public String serializeChargeDataToJson(final boolean prettyPrint,
|
||||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(CHARGES_DATA_PARAMETERS, prettyPrint, responseParameters);
|
final Set<String> responseParameters,
|
||||||
return helper.serializedJsonFrom(gsonDeserializer, charges.toArray(new ChargeData[charges.size()]));
|
final Collection<ChargeData> charges) {
|
||||||
|
final Gson gsonDeserializer = helper
|
||||||
|
.createGsonBuilderWithParameterExclusionSerializationStrategy(
|
||||||
|
CHARGES_DATA_PARAMETERS, prettyPrint,
|
||||||
|
responseParameters);
|
||||||
|
return helper.serializedJsonFrom(gsonDeserializer,
|
||||||
|
charges.toArray(new ChargeData[charges.size()]));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String serializeChargeDataToJson(final boolean prettyPrint, final Set<String> responseParameters, final ChargeData charge) {
|
public String serializeChargeDataToJson(final boolean prettyPrint,
|
||||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(CHARGES_DATA_PARAMETERS, prettyPrint, responseParameters);
|
final Set<String> responseParameters, final ChargeData charge) {
|
||||||
|
final Gson gsonDeserializer = helper
|
||||||
|
.createGsonBuilderWithParameterExclusionSerializationStrategy(
|
||||||
|
CHARGES_DATA_PARAMETERS, prettyPrint,
|
||||||
|
responseParameters);
|
||||||
return helper.serializedJsonFrom(gsonDeserializer, charge);
|
return helper.serializedJsonFrom(gsonDeserializer, charge);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+3
-1
@@ -18,6 +18,8 @@ public interface OfficeReadPlatformService {
|
|||||||
OfficeData retrieveNewOfficeTemplate();
|
OfficeData retrieveNewOfficeTemplate();
|
||||||
|
|
||||||
List<OfficeLookup> retrieveAllowedParents(Long officeId);
|
List<OfficeLookup> retrieveAllowedParents(Long officeId);
|
||||||
|
|
||||||
|
Collection<OfficeTransactionData> retrieveAllOfficeTransactions();
|
||||||
|
|
||||||
OfficeTransactionData retrieveNewOfficeTransactionDetails();
|
OfficeTransactionData retrieveNewOfficeTransactionDetails();
|
||||||
}
|
}
|
||||||
+68
-9
@@ -1,5 +1,6 @@
|
|||||||
package org.mifosng.platform.organisation.service;
|
package org.mifosng.platform.organisation.service;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -63,7 +64,9 @@ public class OfficeReadPlatformServiceImpl implements OfficeReadPlatformService
|
|||||||
String parentName = rs.getString("parentName");
|
String parentName = rs.getString("parentName");
|
||||||
|
|
||||||
List<OfficeLookup> allowedParents = new ArrayList<OfficeLookup>();
|
List<OfficeLookup> allowedParents = new ArrayList<OfficeLookup>();
|
||||||
return new OfficeData(id, name, nameDecorated, externalId, openingDate, hierarchy, parentId, parentName, allowedParents);
|
return new OfficeData(id, name, nameDecorated, externalId,
|
||||||
|
openingDate, hierarchy, parentId, parentName,
|
||||||
|
allowedParents);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,6 +90,43 @@ public class OfficeReadPlatformServiceImpl implements OfficeReadPlatformService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final class OfficeTransactionMapper implements
|
||||||
|
RowMapper<OfficeTransactionData> {
|
||||||
|
|
||||||
|
public String officeTransactionSchema() {
|
||||||
|
return " ot.id as id, ot.transaction_date as transactionDate, ot.from_office_id as fromOfficeId, fromoff.name as fromOfficeName, "
|
||||||
|
+ " ot.to_office_id as toOfficeId, tooff.name as toOfficeName, ot.transaction_amount as transactionAmount, ot.description as description, "
|
||||||
|
+ " ot.currency_code as currencyCode, rc.decimal_places as digitsAfterDecimal"
|
||||||
|
+ " from m_office_transaction ot "
|
||||||
|
+ " left join m_office fromoff on fromoff.id = ot.from_office_id "
|
||||||
|
+ " left join m_office tooff on tooff.id = ot.to_office_id "
|
||||||
|
+ " join m_currency rc on rc.`code` = ot.currency_code";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OfficeTransactionData mapRow(final ResultSet rs, final int rowNum)
|
||||||
|
throws SQLException {
|
||||||
|
|
||||||
|
Long id = rs.getLong("id");
|
||||||
|
LocalDate transactionDate = JdbcSupport.getLocalDate(rs,
|
||||||
|
"transactionDate");
|
||||||
|
Long fromOfficeId = JdbcSupport.getLong(rs, "fromOfficeId");
|
||||||
|
String fromOfficeName = rs.getString("fromOfficeName");
|
||||||
|
Long toOfficeId = JdbcSupport.getLong(rs, "toOfficeId");
|
||||||
|
String toOfficeName = rs.getString("toOfficeName");
|
||||||
|
String currencyCode = rs.getString("currencyCode");
|
||||||
|
Integer digitsAfterDecimal = JdbcSupport.getInteger(rs,
|
||||||
|
"digitsAfterDecimal");
|
||||||
|
BigDecimal transactionAmount = rs
|
||||||
|
.getBigDecimal("transactionAmount");
|
||||||
|
String description = rs.getString("description");
|
||||||
|
|
||||||
|
return new OfficeTransactionData(id, transactionDate, fromOfficeId,
|
||||||
|
fromOfficeName, toOfficeId, toOfficeName, currencyCode,
|
||||||
|
digitsAfterDecimal, transactionAmount, description);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<OfficeData> retrieveAllOffices() {
|
public Collection<OfficeData> retrieveAllOffices() {
|
||||||
|
|
||||||
@@ -151,13 +191,13 @@ public class OfficeReadPlatformServiceImpl implements OfficeReadPlatformService
|
|||||||
|
|
||||||
context.authenticatedUser();
|
context.authenticatedUser();
|
||||||
List<OfficeLookup> filterParentLookups = new ArrayList<OfficeLookup>();
|
List<OfficeLookup> filterParentLookups = new ArrayList<OfficeLookup>();
|
||||||
|
|
||||||
if (isNotHeadOffice(officeId)) {
|
if (isNotHeadOffice(officeId)) {
|
||||||
List<OfficeLookup> parentLookups = new ArrayList<OfficeLookup>(retrieveAllOfficesForLookup());
|
List<OfficeLookup> parentLookups = new ArrayList<OfficeLookup>(
|
||||||
|
retrieveAllOfficesForLookup());
|
||||||
|
|
||||||
for (OfficeLookup office : parentLookups) {
|
for (OfficeLookup office : parentLookups) {
|
||||||
|
|
||||||
if (!office.getId().equals(officeId)) {
|
if (!office.getId().equals(officeId)) {
|
||||||
filterParentLookups.add(office);
|
filterParentLookups.add(office);
|
||||||
}
|
}
|
||||||
@@ -172,13 +212,32 @@ public class OfficeReadPlatformServiceImpl implements OfficeReadPlatformService
|
|||||||
return !Long.valueOf(1).equals(officeId);
|
return !Long.valueOf(1).equals(officeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<OfficeTransactionData> retrieveAllOfficeTransactions() {
|
||||||
|
|
||||||
|
AppUser currentUser = context.authenticatedUser();
|
||||||
|
|
||||||
|
String hierarchy = currentUser.getOffice().getHierarchy();
|
||||||
|
String hierarchySearchString = hierarchy + "%";
|
||||||
|
|
||||||
|
OfficeTransactionMapper rm = new OfficeTransactionMapper();
|
||||||
|
String sql = "select " + rm.officeTransactionSchema()
|
||||||
|
+ " where (fromoff.hierarchy like ? or tooff.hierarchy like ?) order by ot.transaction_date, ot.id";
|
||||||
|
|
||||||
|
return this.jdbcTemplate.query(sql, rm,
|
||||||
|
new Object[] { hierarchySearchString, hierarchySearchString }); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OfficeTransactionData retrieveNewOfficeTransactionDetails() {
|
public OfficeTransactionData retrieveNewOfficeTransactionDetails() {
|
||||||
context.authenticatedUser();
|
context.authenticatedUser();
|
||||||
|
|
||||||
List<OfficeLookup> parentLookups = new ArrayList<OfficeLookup>(retrieveAllOfficesForLookup());
|
List<OfficeLookup> parentLookups = new ArrayList<OfficeLookup>(
|
||||||
List<CurrencyData> currencyOptions = currencyReadPlatformService.retrieveAllowedCurrencies();
|
retrieveAllOfficesForLookup());
|
||||||
|
List<CurrencyData> currencyOptions = currencyReadPlatformService
|
||||||
|
.retrieveAllowedCurrencies();
|
||||||
|
|
||||||
return new OfficeTransactionData(new LocalDate(), parentLookups, currencyOptions);
|
return new OfficeTransactionData(new LocalDate(), parentLookups,
|
||||||
|
currencyOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user