MIFOSX-97: continue tidy up of serialization.
This commit is contained in:
@@ -0,0 +1 @@
|
||||
ALTER TABLE `m_portfolio_command_source` CHANGE COLUMN `api_resource` `api_resource` VARCHAR(100) NOT NULL;
|
||||
+29
-21
@@ -1,6 +1,8 @@
|
||||
package org.mifosplatform.commands.api;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
@@ -19,10 +21,11 @@ import org.apache.commons.lang.StringUtils;
|
||||
import org.mifosplatform.commands.data.CommandSourceData;
|
||||
import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformService;
|
||||
import org.mifosplatform.commands.service.PortfolioCommandsReadPlatformService;
|
||||
import org.mifosplatform.infrastructure.core.api.ApiParameterHelper;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioApiJsonSerializerService;
|
||||
import org.mifosplatform.infrastructure.core.api.ApiRequestParameterHelper;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.exception.UnrecognizedQueryParamException;
|
||||
import org.mifosplatform.infrastructure.core.serialization.ApiRequestJsonSerializationSettings;
|
||||
import org.mifosplatform.infrastructure.core.serialization.DefaultToApiJsonSerializer;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
@@ -33,40 +36,45 @@ import org.springframework.stereotype.Component;
|
||||
@Scope("singleton")
|
||||
public class CommandsApiResource {
|
||||
|
||||
@Autowired
|
||||
private PortfolioCommandsReadPlatformService readPlatformService;
|
||||
private final Set<String> RESPONSE_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("id", "taskName", "madeOnDate"));
|
||||
private final String resourceNameForPermissions = "MAKERCHECKER";
|
||||
|
||||
private final PlatformSecurityContext context;
|
||||
private final PortfolioCommandsReadPlatformService readPlatformService;
|
||||
private final DefaultToApiJsonSerializer<CommandSourceData> toApiJsonSerializer;
|
||||
private final ApiRequestParameterHelper apiRequestParameterHelper;
|
||||
private final PortfolioCommandSourceWritePlatformService writePlatformService;
|
||||
|
||||
@Autowired
|
||||
private PortfolioCommandSourceWritePlatformService writePlatformService;
|
||||
|
||||
@Autowired
|
||||
private PortfolioApiJsonSerializerService apiJsonSerializerService;
|
||||
|
||||
private final String entityType = "MAKERCHECKER";
|
||||
@Autowired
|
||||
private PlatformSecurityContext context;
|
||||
public CommandsApiResource(final PlatformSecurityContext context, final PortfolioCommandsReadPlatformService readPlatformService,
|
||||
final DefaultToApiJsonSerializer<CommandSourceData> toApiJsonSerializer,
|
||||
final ApiRequestParameterHelper apiRequestParameterHelper,
|
||||
final PortfolioCommandSourceWritePlatformService writePlatformService) {
|
||||
this.context = context;
|
||||
this.readPlatformService = readPlatformService;
|
||||
this.toApiJsonSerializer = toApiJsonSerializer;
|
||||
this.apiRequestParameterHelper = apiRequestParameterHelper;
|
||||
this.writePlatformService = writePlatformService;
|
||||
}
|
||||
|
||||
@GET
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String retrieveCodes(@Context final UriInfo uriInfo) {
|
||||
|
||||
context.authenticatedUser().validateHasReadPermission(entityType);
|
||||
|
||||
final Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
final boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
context.authenticatedUser().validateHasReadPermission(resourceNameForPermissions);
|
||||
|
||||
final Collection<CommandSourceData> entries = this.readPlatformService.retrieveAllEntriesToBeChecked();
|
||||
|
||||
return this.apiJsonSerializerService.serializeMakerCheckerDataToJson(prettyPrint, responseParameters, entries);
|
||||
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
return this.toApiJsonSerializer.serialize(settings, entries, RESPONSE_DATA_PARAMETERS);
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("{commandId}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String approveMakerCheckerEntry(@PathParam("commandId") final Long commandId,
|
||||
@QueryParam("command") final String commandParam) {
|
||||
public String approveMakerCheckerEntry(@PathParam("commandId") final Long commandId, @QueryParam("command") final String commandParam) {
|
||||
|
||||
EntityIdentifier result = null;
|
||||
if (is(commandParam, "approve")) {
|
||||
@@ -75,7 +83,7 @@ public class CommandsApiResource {
|
||||
throw new UnrecognizedQueryParamException("command", commandParam);
|
||||
}
|
||||
|
||||
return this.apiJsonSerializerService.serializeEntityIdentifier(result);
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
}
|
||||
|
||||
private boolean is(final String commandParam, final String commandValue) {
|
||||
@@ -90,6 +98,6 @@ public class CommandsApiResource {
|
||||
|
||||
final Long id = this.writePlatformService.deleteEntry(commandId);
|
||||
|
||||
return this.apiJsonSerializerService.serializeEntityIdentifier(EntityIdentifier.makerChecker(id));
|
||||
return this.toApiJsonSerializer.serialize(EntityIdentifier.makerChecker(id));
|
||||
}
|
||||
}
|
||||
+11
-12
@@ -1,8 +1,8 @@
|
||||
package org.mifosplatform.commands.service;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioApiDataConversionService;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioApiJsonSerializerService;
|
||||
import org.mifosplatform.infrastructure.core.serialization.CommandSerializer;
|
||||
import org.mifosplatform.infrastructure.core.serialization.DefaultToApiJsonSerializer;
|
||||
import org.mifosplatform.portfolio.client.command.ClientCommand;
|
||||
import org.mifosplatform.portfolio.client.data.ClientData;
|
||||
import org.mifosplatform.portfolio.client.service.ClientReadPlatformService;
|
||||
@@ -13,19 +13,17 @@ import org.springframework.stereotype.Service;
|
||||
public class ChangeDetectionServiceJdbc implements ChangeDetectionService {
|
||||
|
||||
private final PortfolioApiDataConversionService apiDataConversionService;
|
||||
private final PortfolioApiJsonSerializerService apiJsonSerializerService;
|
||||
private final ClientReadPlatformService clientReadPlatformService;
|
||||
private final CommandSerializer commandSerializerService;
|
||||
private final DefaultToApiJsonSerializer<ClientData> toApiJsonSerializer;
|
||||
|
||||
@Autowired
|
||||
public ChangeDetectionServiceJdbc(
|
||||
final PortfolioApiDataConversionService apiDataConversionService,
|
||||
final CommandSerializer commandSerializerService,
|
||||
final PortfolioApiJsonSerializerService apiJsonSerializerService,
|
||||
public ChangeDetectionServiceJdbc(final DefaultToApiJsonSerializer<ClientData> toApiJsonSerializer,
|
||||
final PortfolioApiDataConversionService apiDataConversionService, final CommandSerializer commandSerializerService,
|
||||
final ClientReadPlatformService clientReadPlatformService) {
|
||||
this.toApiJsonSerializer = toApiJsonSerializer;
|
||||
this.apiDataConversionService = apiDataConversionService;
|
||||
this.commandSerializerService = commandSerializerService;
|
||||
this.apiJsonSerializerService = apiJsonSerializerService;
|
||||
this.clientReadPlatformService = clientReadPlatformService;
|
||||
}
|
||||
|
||||
@@ -36,16 +34,17 @@ public class ChangeDetectionServiceJdbc implements ChangeDetectionService {
|
||||
|
||||
if ("clients".equalsIgnoreCase(resourceName)) {
|
||||
// FIXME - KW/JW - this change detection code for update of clients
|
||||
// using ClientCommand can re placed when more suitable sql version is
|
||||
// using ClientCommand can re placed when more suitable sql version
|
||||
// is
|
||||
// implemented.
|
||||
final ClientData originalClient = this.clientReadPlatformService.retrieveIndividualClient(resourceId);
|
||||
final ClientData changedClient = this.apiDataConversionService.convertInternalJsonFormatToClientDataChange(resourceId,
|
||||
commandSerializedAsJson);
|
||||
|
||||
final String baseJson = this.apiJsonSerializerService.serializeClientDataToJson(originalClient);
|
||||
final String workingJson = this.apiJsonSerializerService.serializeClientDataToJson(changedClient);
|
||||
|
||||
final String baseJson = this.toApiJsonSerializer.serialize(originalClient);
|
||||
final String workingJson = this.toApiJsonSerializer.serialize(changedClient);
|
||||
final ClientCommand changesOnly = this.apiDataConversionService.detectChanges(resourceId, baseJson, workingJson);
|
||||
|
||||
|
||||
changesOnlyJson = this.commandSerializerService.serializeCommandToJson(changesOnly);
|
||||
} else {
|
||||
changesOnlyJson = commandSerializedAsJson;
|
||||
|
||||
+9
-138
@@ -5,8 +5,6 @@ import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.mifosplatform.commands.data.CommandSourceData;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.serialization.GoogleGsonSerializerHelper;
|
||||
import org.mifosplatform.infrastructure.dataqueries.data.DatatableData;
|
||||
import org.mifosplatform.infrastructure.dataqueries.data.GenericResultsetData;
|
||||
@@ -14,19 +12,14 @@ import org.mifosplatform.infrastructure.documentmanagement.data.DocumentData;
|
||||
import org.mifosplatform.infrastructure.security.data.AuthenticatedUserData;
|
||||
import org.mifosplatform.organisation.staff.data.BulkTransferLoanOfficerData;
|
||||
import org.mifosplatform.organisation.staff.data.StaffData;
|
||||
import org.mifosplatform.portfolio.charge.data.ChargeData;
|
||||
import org.mifosplatform.portfolio.client.data.ClientAccountSummaryCollectionData;
|
||||
import org.mifosplatform.portfolio.client.data.ClientData;
|
||||
import org.mifosplatform.portfolio.client.data.ClientIdentifierData;
|
||||
import org.mifosplatform.portfolio.client.data.NoteData;
|
||||
import org.mifosplatform.portfolio.group.data.GroupAccountSummaryCollectionData;
|
||||
import org.mifosplatform.portfolio.group.data.GroupData;
|
||||
import org.mifosplatform.portfolio.loanaccount.data.LoanAccountData;
|
||||
import org.mifosplatform.portfolio.loanaccount.data.LoanChargeData;
|
||||
import org.mifosplatform.portfolio.loanaccount.data.LoanTransactionData;
|
||||
import org.mifosplatform.portfolio.loanaccount.gaurantor.data.GuarantorData;
|
||||
import org.mifosplatform.portfolio.loanaccount.loanschedule.data.LoanScheduleData;
|
||||
import org.mifosplatform.portfolio.loanproduct.data.LoanProductData;
|
||||
import org.mifosplatform.portfolio.savingsaccount.data.SavingAccountData;
|
||||
import org.mifosplatform.portfolio.savingsaccount.data.SavingScheduleData;
|
||||
import org.mifosplatform.portfolio.savingsaccountproduct.data.SavingProductData;
|
||||
@@ -46,13 +39,6 @@ public class GoogleGsonPortfolioApiJsonSerializerService implements PortfolioApi
|
||||
|
||||
private static final Set<String> STAFF_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("id", "firstname", "lastname",
|
||||
"displayName", "officeId", "officeName", "loanOfficerFlag", "allowedOffices"));
|
||||
private static final Set<String> LOAN_PRODUCT_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("id", "name", "description",
|
||||
"fundId", "fundName", "transactionProcessingStrategyId", "transactionProcessingStrategyName", "principal",
|
||||
"inArrearsTolerance", "numberOfRepayments", "repaymentEvery", "interestRatePerPeriod", "annualInterestRate",
|
||||
"repaymentFrequencyType", "interestRateFrequencyType", "amortizationType", "interestType", "interestCalculationPeriodType",
|
||||
"charges", "createdOn", "lastModifedOn", "currencyOptions", "amortizationTypeOptions", "interestTypeOptions",
|
||||
"interestCalculationPeriodTypeOptions", "repaymentFrequencyTypeOptions", "interestRateFrequencyTypeOptions", "fundOptions",
|
||||
"transactionProcessingStrategyOptions", "chargeOptions"));
|
||||
|
||||
private static final Set<String> SAVINGS_PRODUCT_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("currencyOptions", "id",
|
||||
"createdOn", "lastModifedOn", "locale", "name", "description", "currencyCode", "digitsAfterDecimal", "interstRate",
|
||||
@@ -76,12 +62,6 @@ public class GoogleGsonPortfolioApiJsonSerializerService implements PortfolioApi
|
||||
"interestCompoundingAllowed", "availableInterestForWithdrawal", "availableWithdrawalAmount", "todaysDate",
|
||||
"isLockinPeriodAllowed", "lockinPeriod", "lockinPeriodType"));
|
||||
|
||||
private static final Set<String> CLIENT_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("id", "officeId", "officeName",
|
||||
"externalId", "firstname", "lastname", "joinedDate", "displayName", "clientOrBusinessName", "allowedOffices", "imagePresent"));
|
||||
|
||||
private static final Set<String> CLIENT_IDENTIFIER_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("id", "clientId",
|
||||
"documentTypeId", "documentKey", "description", "documentTypeName", "allowedDocumentTypes"));
|
||||
|
||||
private static final Set<String> DOCUMENT_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("id", "parentEntityType",
|
||||
"parentEntityId", "name", "fileName", "type", "size", "description"));
|
||||
|
||||
@@ -106,31 +86,14 @@ public class GoogleGsonPortfolioApiJsonSerializerService implements PortfolioApi
|
||||
private static final Set<String> LOAN_SCHEDULE_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("periods",
|
||||
"cumulativePrincipalDisbursed"));
|
||||
|
||||
private static final Set<String> LOAN_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("id", "externalId", "clientId", "groupId",
|
||||
"clientName", "groupName", "fundId", "fundName", "loanProductId", "loanProductName", "loanProductDescription", "currency",
|
||||
"principal", "inArrearsTolerance", "numberOfRepayments", "repaymentEvery", "interestRatePerPeriod", "annualInterestRate",
|
||||
"repaymentFrequencyType", "interestRateFrequencyType", "amortizationType", "interestType", "interestCalculationPeriodType",
|
||||
"submittedOnDate", "approvedOnDate", "expectedDisbursementDate", "actualDisbursementDate", "expectedFirstRepaymentOnDate",
|
||||
"interestChargedFromDate", "closedOnDate", "expectedMaturityDate", "status", "lifeCycleStatusDate", "repaymentSchedule",
|
||||
"transactions", "permissions", "convenienceData", "charges", "productOptions", "amortizationTypeOptions",
|
||||
"interestTypeOptions", "interestCalculationPeriodTypeOptions", "repaymentFrequencyTypeOptions",
|
||||
"interestRateFrequencyTypeOptions", "fundOptions", "repaymentStrategyOptions", "chargeOptions", "loanOfficerId",
|
||||
"loanOfficerName", "loanOfficerOptions", "chargeTemplate"));
|
||||
|
||||
private static final Set<String> LOAN_TRANSACTION_NEW_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("id", "type", "date",
|
||||
"currency", "amount"));
|
||||
|
||||
private static final Set<String> LOAN_REASSIGNMENT_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("officeId", "fromLoanOfficerId",
|
||||
"assignmentDate", "officeOptions", "loanOfficerOptions", "accountSummaryCollection"));
|
||||
|
||||
private static final Set<String> CHARGES_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("id", "name", "amount", "currency",
|
||||
"penalty", "active", "chargeAppliesTo", "chargeTimeType", "chargeCalculationType", "chargeCalculationTypeOptions",
|
||||
"chargeAppliesToOptions", "chargeTimeTypeOptions", "currencyOptions"));
|
||||
|
||||
private static final Set<String> LOAN_CHARGES_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("chargeOptions"));
|
||||
|
||||
private static final Set<String> MAKER_CHECKER_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("id", "taskName", "madeOnDate"));
|
||||
|
||||
private static final Set<String> SAVINGS_ACCOUNTS_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("id", "status", "externalId",
|
||||
"clientId", "clientName", "productId", "productName", "productType", "currencyData", "savingsDepostiAmountPerPeriod",
|
||||
"savingsFrequencyType", "totalDepositAmount", "reccuringInterestRate", "savingInterestRate", "interestType",
|
||||
@@ -143,9 +106,8 @@ public class GoogleGsonPortfolioApiJsonSerializerService implements PortfolioApi
|
||||
private static final Set<String> GUARANTOR_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("externalGuarantor", "existingClientId",
|
||||
"firstname", "lastname", "addressLine1", "addressLine2", "city", "state", "zip", "country", "mobileNumber", "housePhoneNumber",
|
||||
"comment", "dob"));
|
||||
|
||||
private static final Set<String> SAVING_SCHEDULE_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("periods",
|
||||
"cumulativeDepositDue"));
|
||||
|
||||
private static final Set<String> SAVING_SCHEDULE_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("periods", "cumulativeDepositDue"));
|
||||
|
||||
private final GoogleGsonSerializerHelper helper;
|
||||
|
||||
@@ -172,22 +134,6 @@ public class GoogleGsonPortfolioApiJsonSerializerService implements PortfolioApi
|
||||
return helper.serializedJsonFrom(gsonDeserializer, datatables.toArray(new DatatableData[datatables.size()]));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serializeLoanProductDataToJson(final boolean prettyPrint, final Set<String> responseParameters,
|
||||
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
|
||||
public String serializeLoanProductDataToJson(final boolean prettyPrint, final Set<String> responseParameters,
|
||||
final LoanProductData product) {
|
||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(LOAN_PRODUCT_DATA_PARAMETERS,
|
||||
prettyPrint, responseParameters);
|
||||
return helper.serializedJsonFrom(gsonDeserializer, product);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serializeSavingProductDataToJson(final boolean prettyPrint, final Set<String> responseParameters,
|
||||
final Collection<SavingProductData> products) {
|
||||
@@ -236,26 +182,6 @@ public class GoogleGsonPortfolioApiJsonSerializerService implements PortfolioApi
|
||||
return helper.serializedJsonFrom(gsonDeserializer, account);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serializeClientDataToJson(final ClientData client) {
|
||||
return serializeClientDataToJson(false, new HashSet<String>(), client);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serializeClientDataToJson(final boolean prettyPrint, final Set<String> responseParameters, final ClientData client) {
|
||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(CLIENT_DATA_PARAMETERS,
|
||||
prettyPrint, responseParameters);
|
||||
return helper.serializedJsonFrom(gsonDeserializer, client);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serializeClientDataToJson(final boolean prettyPrint, final Set<String> responseParameters,
|
||||
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
|
||||
public String serializeClientAccountSummaryCollectionDataToJson(final boolean prettyPrint, final Set<String> responseParameters,
|
||||
final ClientAccountSummaryCollectionData clientAccount) {
|
||||
@@ -309,14 +235,6 @@ public class GoogleGsonPortfolioApiJsonSerializerService implements PortfolioApi
|
||||
return helper.serializedJsonFrom(gsonDeserializer, loanSchedule);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serializeLoanAccountDataToJson(final boolean prettyPrint, final Set<String> responseParameters,
|
||||
final LoanAccountData loanAccount) {
|
||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(LOAN_DATA_PARAMETERS,
|
||||
prettyPrint, responseParameters);
|
||||
return helper.serializedJsonFrom(gsonDeserializer, loanAccount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serializeLoanTransactionDataToJson(final boolean prettyPrint, final Set<String> responseParameters,
|
||||
final LoanTransactionData transaction) {
|
||||
@@ -333,21 +251,6 @@ public class GoogleGsonPortfolioApiJsonSerializerService implements PortfolioApi
|
||||
return helper.serializedJsonFrom(gsonDeserializer, loanReassignmentData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serializeChargeDataToJson(final boolean prettyPrint, final Set<String> responseParameters,
|
||||
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
|
||||
public String serializeChargeDataToJson(final boolean prettyPrint, final Set<String> responseParameters, final ChargeData charge) {
|
||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(CHARGES_DATA_PARAMETERS,
|
||||
prettyPrint, responseParameters);
|
||||
return helper.serializedJsonFrom(gsonDeserializer, charge);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serializeLoanChargeDataToJson(boolean prettyPrint, Set<String> responseParameters, LoanChargeData charge) {
|
||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(LOAN_CHARGES_DATA_PARAMETERS,
|
||||
@@ -369,31 +272,6 @@ public class GoogleGsonPortfolioApiJsonSerializerService implements PortfolioApi
|
||||
return helper.serializedJsonFrom(gsonDeserializer, staff.toArray(new StaffData[staff.size()]));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public String serializeEntityIdentifier(final EntityIdentifier identifier) {
|
||||
final Set<String> DATA_PARAMETERS = new HashSet<String>(Arrays.asList("entityId"));
|
||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(DATA_PARAMETERS, false,
|
||||
DATA_PARAMETERS);
|
||||
return helper.serializedJsonFrom(gsonDeserializer, identifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serializeClientIdentifierDataToJson(boolean prettyPrint, Set<String> responseParameters,
|
||||
Collection<ClientIdentifierData> clientIdentifiers) {
|
||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(
|
||||
CLIENT_IDENTIFIER_DATA_PARAMETERS, prettyPrint, responseParameters);
|
||||
return helper.serializedJsonFrom(gsonDeserializer, clientIdentifiers.toArray(new ClientIdentifierData[clientIdentifiers.size()]));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serializeClientIdentifierDataToJson(boolean prettyPrint, Set<String> responseParameters,
|
||||
ClientIdentifierData clientIdentifierData) {
|
||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(
|
||||
CLIENT_IDENTIFIER_DATA_PARAMETERS, prettyPrint, responseParameters);
|
||||
return helper.serializedJsonFrom(gsonDeserializer, clientIdentifierData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serializeDocumentDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<DocumentData> documentDatas) {
|
||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(DOCUMENT_DATA_PARAMETERS,
|
||||
@@ -408,14 +286,6 @@ public class GoogleGsonPortfolioApiJsonSerializerService implements PortfolioApi
|
||||
return helper.serializedJsonFrom(gsonDeserializer, documentData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serializeMakerCheckerDataToJson(final boolean prettyPrint, final Set<String> responseParameters,
|
||||
final Collection<CommandSourceData> entries) {
|
||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(MAKER_CHECKER_DATA_PARAMETERS,
|
||||
prettyPrint, responseParameters);
|
||||
return helper.serializedJsonFrom(gsonDeserializer, entries.toArray(new CommandSourceData[entries.size()]));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serializeSavingAccountsDataToJson(boolean prettyPrint, Set<String> responseParameters, SavingAccountData account) {
|
||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(SAVINGS_ACCOUNTS_DATA_PARAMETERS,
|
||||
@@ -438,10 +308,11 @@ public class GoogleGsonPortfolioApiJsonSerializerService implements PortfolioApi
|
||||
return helper.serializedJsonFrom(gsonDeserializer, guarantorData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serializeSavingScheduleDataToJson(boolean prettyPrint, Set<String> responseParameters, SavingScheduleData savingScheduleData) {
|
||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(SAVING_SCHEDULE_DATA_PARAMETERS,
|
||||
prettyPrint, responseParameters);
|
||||
return helper.serializedJsonFrom(gsonDeserializer, savingScheduleData);
|
||||
}
|
||||
@Override
|
||||
public String serializeSavingScheduleDataToJson(boolean prettyPrint, Set<String> responseParameters,
|
||||
SavingScheduleData savingScheduleData) {
|
||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(SAVING_SCHEDULE_DATA_PARAMETERS,
|
||||
prettyPrint, responseParameters);
|
||||
return helper.serializedJsonFrom(gsonDeserializer, savingScheduleData);
|
||||
}
|
||||
}
|
||||
+1
-41
@@ -3,28 +3,20 @@ package org.mifosplatform.infrastructure.core.api;
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
import org.mifosplatform.commands.data.CommandSourceData;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
|
||||
import org.mifosplatform.infrastructure.dataqueries.data.DatatableData;
|
||||
import org.mifosplatform.infrastructure.dataqueries.data.GenericResultsetData;
|
||||
import org.mifosplatform.infrastructure.documentmanagement.data.DocumentData;
|
||||
import org.mifosplatform.infrastructure.security.data.AuthenticatedUserData;
|
||||
import org.mifosplatform.organisation.staff.data.BulkTransferLoanOfficerData;
|
||||
import org.mifosplatform.organisation.staff.data.StaffData;
|
||||
import org.mifosplatform.portfolio.charge.data.ChargeData;
|
||||
import org.mifosplatform.portfolio.client.data.ClientAccountSummaryCollectionData;
|
||||
import org.mifosplatform.portfolio.client.data.ClientData;
|
||||
import org.mifosplatform.portfolio.client.data.ClientIdentifierData;
|
||||
import org.mifosplatform.portfolio.client.data.NoteData;
|
||||
import org.mifosplatform.portfolio.group.data.GroupAccountSummaryCollectionData;
|
||||
import org.mifosplatform.portfolio.group.data.GroupData;
|
||||
import org.mifosplatform.portfolio.loanaccount.data.LoanAccountData;
|
||||
import org.mifosplatform.portfolio.loanaccount.data.LoanChargeData;
|
||||
import org.mifosplatform.portfolio.loanaccount.data.LoanTransactionData;
|
||||
import org.mifosplatform.portfolio.loanaccount.gaurantor.data.GuarantorData;
|
||||
import org.mifosplatform.portfolio.loanaccount.loanschedule.data.LoanScheduleData;
|
||||
import org.mifosplatform.portfolio.loanproduct.data.LoanProductData;
|
||||
import org.mifosplatform.portfolio.savingsaccount.data.SavingAccountData;
|
||||
import org.mifosplatform.portfolio.savingsaccount.data.SavingScheduleData;
|
||||
import org.mifosplatform.portfolio.savingsaccountproduct.data.SavingProductData;
|
||||
@@ -39,10 +31,6 @@ public interface PortfolioApiJsonSerializerService {
|
||||
|
||||
String serializeDatatableDataToJson(boolean prettyPrint, Collection<DatatableData> result);
|
||||
|
||||
String serializeLoanProductDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<LoanProductData> products);
|
||||
|
||||
String serializeLoanProductDataToJson(boolean prettyPrint, Set<String> responseParameters, LoanProductData loanProduct);
|
||||
|
||||
String serializeSavingProductDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<SavingProductData> products);
|
||||
|
||||
String serializeSavingProductDataToJson(boolean prettyPrint, Set<String> responseParameters, SavingProductData savingProduct);
|
||||
@@ -55,12 +43,6 @@ public interface PortfolioApiJsonSerializerService {
|
||||
|
||||
String serializeDepositAccountDataToJson(boolean prettyPrint, Set<String> responseParameters, DepositAccountData account);
|
||||
|
||||
String serializeClientDataToJson(ClientData clientData);
|
||||
|
||||
String serializeClientDataToJson(boolean prettyPrint, Set<String> responseParameters, ClientData clientData);
|
||||
|
||||
String serializeClientDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<ClientData> clients);
|
||||
|
||||
String serializeClientAccountSummaryCollectionDataToJson(boolean prettyPrint, Set<String> responseParameters,
|
||||
ClientAccountSummaryCollectionData clientAccount);
|
||||
|
||||
@@ -77,49 +59,27 @@ public interface PortfolioApiJsonSerializerService {
|
||||
|
||||
String serializeLoanScheduleDataToJson(boolean prettyPrint, Set<String> responseParameters, LoanScheduleData loanSchedule);
|
||||
|
||||
String serializeLoanAccountDataToJson(boolean prettyPrint, Set<String> responseParameters, LoanAccountData loanAccount);
|
||||
|
||||
String serializeLoanTransactionDataToJson(boolean prettyPrint, Set<String> responseParameters, LoanTransactionData newTransactionData);
|
||||
|
||||
String serializeLoanReassignmentDataToJson(boolean prettyPrint, Set<String> responseParameters,
|
||||
BulkTransferLoanOfficerData loanReassignmentData);
|
||||
|
||||
String serializeChargeDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<ChargeData> charges);
|
||||
|
||||
String serializeChargeDataToJson(boolean prettyPrint, Set<String> responseParameters, ChargeData charge);
|
||||
|
||||
String serializeLoanChargeDataToJson(boolean prettyPrint, Set<String> responseParameters, LoanChargeData charge);
|
||||
|
||||
String serializeStaffDataToJson(boolean prettyPrint, Set<String> responseParameters, StaffData staff);
|
||||
|
||||
String serializeStaffDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<StaffData> staff);
|
||||
|
||||
/**
|
||||
* @deprecated see
|
||||
* {@link CodesToApiJsonSerializer#serialize(EntityIdentifier)}
|
||||
* for example for what to use now.
|
||||
*/
|
||||
@Deprecated
|
||||
String serializeEntityIdentifier(EntityIdentifier identifier);
|
||||
|
||||
String serializeClientIdentifierDataToJson(boolean prettyPrint, Set<String> responseParameters,
|
||||
Collection<ClientIdentifierData> clientIdentifiers);
|
||||
|
||||
String serializeClientIdentifierDataToJson(boolean prettyPrint, Set<String> responseParameters,
|
||||
ClientIdentifierData clientIdentifierData);
|
||||
|
||||
String serializeDocumentDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<DocumentData> documentDatas);
|
||||
|
||||
String serializeDocumentDataToJson(boolean prettyPrint, Set<String> responseParameters, DocumentData documentData);
|
||||
|
||||
String serializeMakerCheckerDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<CommandSourceData> entries);
|
||||
|
||||
String serializeSavingAccountsDataToJson(boolean prettyPrint, Set<String> responseParameters, SavingAccountData account);
|
||||
|
||||
String serializeSavingAccountsDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<SavingAccountData> accounts);
|
||||
|
||||
String serializeGuarantorDataToJson(boolean prettyPrint, Set<String> responseParameters, GuarantorData guarantorData);
|
||||
|
||||
String serializeSavingScheduleDataToJson(boolean prettyPrint, Set<String> responseParameters, SavingScheduleData savingScheduleData);
|
||||
String serializeSavingScheduleDataToJson(boolean prettyPrint, Set<String> responseParameters, SavingScheduleData savingScheduleData);
|
||||
|
||||
}
|
||||
+1
-1
@@ -152,7 +152,7 @@ public class PortfolioCommandDeerializerServiceGoogleGson implements PortfolioCo
|
||||
|
||||
Long actualClientId = clientId;
|
||||
final Long clientIdInternal = helper.extractLongNamed("clientId", element, parametersPassedInRequest);
|
||||
if (clientId != null) {
|
||||
if (clientIdInternal != null) {
|
||||
actualClientId = clientIdInternal;
|
||||
}
|
||||
final Long documentTypeId = helper.extractLongNamed("documentTypeId", element, parametersPassedInRequest);
|
||||
|
||||
+27
-25
@@ -2,6 +2,7 @@ package org.mifosplatform.portfolio.charge.api;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -18,11 +19,12 @@ import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformService;
|
||||
import org.mifosplatform.infrastructure.core.api.ApiParameterHelper;
|
||||
import org.mifosplatform.infrastructure.core.api.ApiRequestParameterHelper;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioApiDataConversionService;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioApiJsonSerializerService;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.serialization.ApiRequestJsonSerializationSettings;
|
||||
import org.mifosplatform.infrastructure.core.serialization.CommandSerializer;
|
||||
import org.mifosplatform.infrastructure.core.serialization.DefaultToApiJsonSerializer;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.portfolio.charge.command.ChargeDefinitionCommand;
|
||||
import org.mifosplatform.portfolio.charge.data.ChargeData;
|
||||
@@ -36,27 +38,35 @@ import org.springframework.stereotype.Component;
|
||||
@Scope("singleton")
|
||||
public class ChargesApiResource {
|
||||
|
||||
private final Set<String> CHARGES_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("id", "name", "amount", "currency",
|
||||
"penalty", "active", "chargeAppliesTo", "chargeTimeType", "chargeCalculationType", "chargeCalculationTypeOptions",
|
||||
"chargeAppliesToOptions", "chargeTimeTypeOptions", "currencyOptions"));
|
||||
|
||||
private final String resourceNameForPermissions = "CHARGE";
|
||||
|
||||
private final PlatformSecurityContext context;
|
||||
private final ChargeReadPlatformService readPlatformService;
|
||||
private final DefaultToApiJsonSerializer<ChargeData> toApiJsonSerializer;
|
||||
private final ApiRequestParameterHelper apiRequestParameterHelper;
|
||||
|
||||
private final PortfolioApiDataConversionService apiDataConversionService;
|
||||
private final CommandSerializer commandSerializerService;
|
||||
private final PortfolioApiJsonSerializerService apiJsonSerializerService;
|
||||
private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService;
|
||||
|
||||
@Autowired
|
||||
public ChargesApiResource(final PlatformSecurityContext context,
|
||||
final ChargeReadPlatformService readPlatformService,
|
||||
final DefaultToApiJsonSerializer<ChargeData> toApiJsonSerializer,
|
||||
final ApiRequestParameterHelper apiRequestParameterHelper,
|
||||
final PortfolioApiDataConversionService apiDataConversionService,
|
||||
final CommandSerializer commandSerializerService,
|
||||
final PortfolioApiJsonSerializerService apiJsonSerializerService,
|
||||
final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService) {
|
||||
this.context = context;
|
||||
this.readPlatformService = readPlatformService;
|
||||
this.toApiJsonSerializer = toApiJsonSerializer;
|
||||
this.apiRequestParameterHelper = apiRequestParameterHelper;
|
||||
this.apiDataConversionService = apiDataConversionService;
|
||||
this.commandSerializerService = commandSerializerService;
|
||||
this.apiJsonSerializerService = apiJsonSerializerService;
|
||||
this.commandsSourceWritePlatformService = commandsSourceWritePlatformService;
|
||||
}
|
||||
|
||||
@@ -67,12 +77,10 @@ public class ChargesApiResource {
|
||||
|
||||
context.authenticatedUser().validateHasReadPermission(resourceNameForPermissions);
|
||||
|
||||
final Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
final boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
|
||||
final Collection<ChargeData> charges = this.readPlatformService.retrieveAllCharges();
|
||||
|
||||
return this.apiJsonSerializerService.serializeChargeDataToJson(prettyPrint, responseParameters, charges);
|
||||
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
return this.toApiJsonSerializer.serialize(settings, charges, CHARGES_DATA_PARAMETERS);
|
||||
}
|
||||
|
||||
@GET
|
||||
@@ -83,18 +91,15 @@ public class ChargesApiResource {
|
||||
|
||||
context.authenticatedUser().validateHasReadPermission(resourceNameForPermissions);
|
||||
|
||||
final Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
|
||||
final boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
final boolean template = ApiParameterHelper.template(uriInfo.getQueryParameters());
|
||||
|
||||
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
|
||||
ChargeData charge = this.readPlatformService.retrieveCharge(chargeId);
|
||||
if (template) {
|
||||
if (settings.isTemplate()) {
|
||||
ChargeData templateData = this.readPlatformService.retrieveNewChargeDetails();
|
||||
charge = new ChargeData(charge, templateData);
|
||||
}
|
||||
|
||||
return this.apiJsonSerializerService.serializeChargeDataToJson(prettyPrint, responseParameters, charge);
|
||||
return this.toApiJsonSerializer.serialize(settings, charge, CHARGES_DATA_PARAMETERS);
|
||||
}
|
||||
|
||||
@GET
|
||||
@@ -105,13 +110,10 @@ public class ChargesApiResource {
|
||||
|
||||
context.authenticatedUser().validateHasReadPermission(resourceNameForPermissions);
|
||||
|
||||
final Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
final ChargeData charge = this.readPlatformService.retrieveNewChargeDetails();
|
||||
|
||||
final boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
|
||||
final ChargeData chargeData = this.readPlatformService.retrieveNewChargeDetails();
|
||||
|
||||
return this.apiJsonSerializerService.serializeChargeDataToJson(prettyPrint, responseParameters, chargeData);
|
||||
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
return this.toApiJsonSerializer.serialize(settings, charge, CHARGES_DATA_PARAMETERS);
|
||||
}
|
||||
|
||||
@POST
|
||||
@@ -127,7 +129,7 @@ public class ChargesApiResource {
|
||||
|
||||
final EntityIdentifier result = this.commandsSourceWritePlatformService.logCommandSource("CREATE", "charges", null, commandSerializedAsJson);
|
||||
|
||||
return this.apiJsonSerializerService.serializeEntityIdentifier(result);
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
}
|
||||
|
||||
@PUT
|
||||
@@ -144,7 +146,7 @@ public class ChargesApiResource {
|
||||
|
||||
final EntityIdentifier result = this.commandsSourceWritePlatformService.logCommandSource("UPDATE", "charges", chargeId, commandSerializedAsJson);
|
||||
|
||||
return this.apiJsonSerializerService.serializeEntityIdentifier(result);
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@@ -158,6 +160,6 @@ public class ChargesApiResource {
|
||||
|
||||
final EntityIdentifier result = this.commandsSourceWritePlatformService.logCommandSource("DELETE", "charges", chargeId, "{}");
|
||||
|
||||
return this.apiJsonSerializerService.serializeEntityIdentifier(result);
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
}
|
||||
}
|
||||
+27
-26
@@ -2,6 +2,7 @@ package org.mifosplatform.portfolio.client.api;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -20,11 +21,12 @@ import javax.ws.rs.core.UriInfo;
|
||||
import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformService;
|
||||
import org.mifosplatform.infrastructure.codes.data.CodeValueData;
|
||||
import org.mifosplatform.infrastructure.codes.service.CodeValueReadPlatformService;
|
||||
import org.mifosplatform.infrastructure.core.api.ApiParameterHelper;
|
||||
import org.mifosplatform.infrastructure.core.api.ApiRequestParameterHelper;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioApiDataConversionService;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioApiJsonSerializerService;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.serialization.ApiRequestJsonSerializationSettings;
|
||||
import org.mifosplatform.infrastructure.core.serialization.CommandSerializer;
|
||||
import org.mifosplatform.infrastructure.core.serialization.DefaultToApiJsonSerializer;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.portfolio.client.command.ClientIdentifierCommand;
|
||||
import org.mifosplatform.portfolio.client.data.ClientData;
|
||||
@@ -40,29 +42,34 @@ import org.springframework.stereotype.Component;
|
||||
@Scope("singleton")
|
||||
public class ClientIdentifiersApiResource {
|
||||
|
||||
private final String entityType = "CLIENTIDENTIFIER";
|
||||
private static final Set<String> CLIENT_IDENTIFIER_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("id", "clientId",
|
||||
"documentTypeId", "documentKey", "description", "documentTypeName", "allowedDocumentTypes"));
|
||||
|
||||
private final String resourceNameForPermissions = "CLIENTIDENTIFIER";
|
||||
|
||||
private final PlatformSecurityContext context;
|
||||
private final ClientReadPlatformService clientReadPlatformService;
|
||||
private final CodeValueReadPlatformService codeValueReadPlatformService;
|
||||
private final DefaultToApiJsonSerializer<ClientIdentifierData> toApiJsonSerializer;
|
||||
private final ApiRequestParameterHelper apiRequestParameterHelper;
|
||||
private final PortfolioApiDataConversionService apiDataConversionService;
|
||||
private final CommandSerializer commandSerializerService;
|
||||
private final PortfolioApiJsonSerializerService apiJsonSerializerService;
|
||||
private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService;
|
||||
|
||||
@Autowired
|
||||
public ClientIdentifiersApiResource(final PlatformSecurityContext context, final ClientReadPlatformService readPlatformService,
|
||||
final CodeValueReadPlatformService codeValueReadPlatformService,
|
||||
final PortfolioApiDataConversionService apiDataConversionService,
|
||||
final DefaultToApiJsonSerializer<ClientIdentifierData> toApiJsonSerializer,
|
||||
final ApiRequestParameterHelper apiRequestParameterHelper, final PortfolioApiDataConversionService apiDataConversionService,
|
||||
final CommandSerializer commandSerializerService,
|
||||
final PortfolioApiJsonSerializerService apiJsonSerializerService,
|
||||
final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService) {
|
||||
this.context = context;
|
||||
this.clientReadPlatformService = readPlatformService;
|
||||
this.codeValueReadPlatformService = codeValueReadPlatformService;
|
||||
this.toApiJsonSerializer = toApiJsonSerializer;
|
||||
this.apiRequestParameterHelper = apiRequestParameterHelper;
|
||||
this.apiDataConversionService = apiDataConversionService;
|
||||
this.commandSerializerService = commandSerializerService;
|
||||
this.apiJsonSerializerService = apiJsonSerializerService;
|
||||
this.commandsSourceWritePlatformService = commandsSourceWritePlatformService;
|
||||
}
|
||||
|
||||
@@ -71,14 +78,12 @@ public class ClientIdentifiersApiResource {
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String retrieveAllClientIdentifiers(@Context final UriInfo uriInfo, @PathParam("clientId") final Long clientId) {
|
||||
|
||||
context.authenticatedUser().validateHasReadPermission(entityType);
|
||||
|
||||
final Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
final boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
context.authenticatedUser().validateHasReadPermission(resourceNameForPermissions);
|
||||
|
||||
final Collection<ClientIdentifierData> clientIdentifiers = this.clientReadPlatformService.retrieveClientIdentifiers(clientId);
|
||||
|
||||
return this.apiJsonSerializerService.serializeClientIdentifierDataToJson(prettyPrint, responseParameters, clientIdentifiers);
|
||||
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
return this.toApiJsonSerializer.serialize(settings, clientIdentifiers, CLIENT_IDENTIFIER_DATA_PARAMETERS);
|
||||
}
|
||||
|
||||
@GET
|
||||
@@ -87,15 +92,13 @@ public class ClientIdentifiersApiResource {
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String newClientDetails(@Context final UriInfo uriInfo) {
|
||||
|
||||
context.authenticatedUser().validateHasReadPermission(entityType);
|
||||
|
||||
final Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
final boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
context.authenticatedUser().validateHasReadPermission(resourceNameForPermissions);
|
||||
|
||||
Collection<CodeValueData> codeValues = codeValueReadPlatformService.retrieveCustomIdentifierCodeValues();
|
||||
ClientIdentifierData clientIdentifierData = ClientIdentifierData.template(codeValues);
|
||||
|
||||
return this.apiJsonSerializerService.serializeClientIdentifierDataToJson(prettyPrint, responseParameters, clientIdentifierData);
|
||||
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
return this.toApiJsonSerializer.serialize(settings, clientIdentifierData, CLIENT_IDENTIFIER_DATA_PARAMETERS);
|
||||
}
|
||||
|
||||
@POST
|
||||
@@ -116,7 +119,7 @@ public class ClientIdentifiersApiResource {
|
||||
final EntityIdentifier result = this.commandsSourceWritePlatformService.logCommandSource("CREATE", resourceUrl, null,
|
||||
commandSerializedAsJson);
|
||||
|
||||
return this.apiJsonSerializerService.serializeEntityIdentifier(result);
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
} catch (DuplicateClientIdentifierException e) {
|
||||
DuplicateClientIdentifierException rethrowas = e;
|
||||
if (e.getDocumentTypeId() != null) {
|
||||
@@ -137,19 +140,17 @@ public class ClientIdentifiersApiResource {
|
||||
public String getClientIdentifier(@PathParam("clientId") final Long clientId, @PathParam("identifierId") final Long clientIdentifierId,
|
||||
@Context final UriInfo uriInfo) {
|
||||
|
||||
context.authenticatedUser().validateHasReadPermission(entityType);
|
||||
context.authenticatedUser().validateHasReadPermission(resourceNameForPermissions);
|
||||
|
||||
final Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
final boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
final boolean template = ApiParameterHelper.template(uriInfo.getQueryParameters());
|
||||
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
|
||||
ClientIdentifierData clientIdentifierData = this.clientReadPlatformService.retrieveClientIdentifier(clientId, clientIdentifierId);
|
||||
if (template) {
|
||||
if (settings.isTemplate()) {
|
||||
final Collection<CodeValueData> codeValues = codeValueReadPlatformService.retrieveCustomIdentifierCodeValues();
|
||||
clientIdentifierData = ClientIdentifierData.template(clientIdentifierData, codeValues);
|
||||
}
|
||||
|
||||
return this.apiJsonSerializerService.serializeClientIdentifierDataToJson(prettyPrint, responseParameters, clientIdentifierData);
|
||||
return this.toApiJsonSerializer.serialize(settings, clientIdentifierData, CLIENT_IDENTIFIER_DATA_PARAMETERS);
|
||||
}
|
||||
|
||||
@PUT
|
||||
@@ -172,7 +173,7 @@ public class ClientIdentifiersApiResource {
|
||||
final EntityIdentifier result = this.commandsSourceWritePlatformService.logCommandSource("UPDATE", resourceUrl,
|
||||
clientIdentifierId, commandSerializedAsJson);
|
||||
|
||||
return this.apiJsonSerializerService.serializeEntityIdentifier(result);
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
} catch (DuplicateClientIdentifierException e) {
|
||||
DuplicateClientIdentifierException reThrowAs = e;
|
||||
if (e.getDocumentTypeId() != null) {
|
||||
@@ -200,6 +201,6 @@ public class ClientIdentifiersApiResource {
|
||||
final EntityIdentifier result = this.commandsSourceWritePlatformService.logCommandSource("DELETE", resourceUrl, clientIdentifierId,
|
||||
"{}");
|
||||
|
||||
return this.apiJsonSerializerService.serializeEntityIdentifier(result);
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
}
|
||||
}
|
||||
+49
-43
@@ -4,6 +4,7 @@ import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -19,7 +20,6 @@ import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@@ -28,11 +28,14 @@ import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformSer
|
||||
import org.mifosplatform.commands.service.PortfolioCommandsReadPlatformService;
|
||||
import org.mifosplatform.infrastructure.core.api.ApiConstants;
|
||||
import org.mifosplatform.infrastructure.core.api.ApiParameterHelper;
|
||||
import org.mifosplatform.infrastructure.core.api.ApiRequestParameterHelper;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioApiDataConversionService;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioApiJsonSerializerService;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.domain.Base64EncodedImage;
|
||||
import org.mifosplatform.infrastructure.core.serialization.ApiRequestJsonSerializationSettings;
|
||||
import org.mifosplatform.infrastructure.core.serialization.CommandSerializer;
|
||||
import org.mifosplatform.infrastructure.core.serialization.DefaultToApiJsonSerializer;
|
||||
import org.mifosplatform.infrastructure.core.service.FileUtils;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.organisation.office.data.OfficeLookup;
|
||||
@@ -63,10 +66,15 @@ public class ClientsApiResource {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(ClientsApiResource.class);
|
||||
|
||||
private final Set<String> CLIENT_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("id", "officeId", "officeName", "externalId",
|
||||
"firstname", "lastname", "joinedDate", "displayName", "clientOrBusinessName", "allowedOffices", "imagePresent"));
|
||||
|
||||
private final PlatformSecurityContext context;
|
||||
private final ClientReadPlatformService clientReadPlatformService;
|
||||
private final ClientWritePlatformService clientWritePlatformService;
|
||||
private final OfficeReadPlatformService officeReadPlatformService;
|
||||
private final DefaultToApiJsonSerializer<ClientData> toApiJsonSerializer;
|
||||
private final ApiRequestParameterHelper apiRequestParameterHelper;
|
||||
private final PortfolioApiDataConversionService apiDataConversionService;
|
||||
private final CommandSerializer commandSerializerService;
|
||||
private final PortfolioApiJsonSerializerService apiJsonSerializerService;
|
||||
@@ -76,8 +84,8 @@ public class ClientsApiResource {
|
||||
@Autowired
|
||||
public ClientsApiResource(final PlatformSecurityContext context, final ClientReadPlatformService readPlatformService,
|
||||
final ClientWritePlatformService clientWritePlatformService, final OfficeReadPlatformService officeReadPlatformService,
|
||||
final PortfolioApiDataConversionService apiDataConversionService,
|
||||
final CommandSerializer commandSerializerService,
|
||||
final DefaultToApiJsonSerializer<ClientData> toApiJsonSerializer, final ApiRequestParameterHelper apiRequestParameterHelper,
|
||||
final PortfolioApiDataConversionService apiDataConversionService, final CommandSerializer commandSerializerService,
|
||||
final PortfolioApiJsonSerializerService apiJsonSerializerService,
|
||||
final PortfolioCommandsReadPlatformService commandsReadPlatformService,
|
||||
final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService) {
|
||||
@@ -85,6 +93,8 @@ public class ClientsApiResource {
|
||||
this.clientReadPlatformService = readPlatformService;
|
||||
this.clientWritePlatformService = clientWritePlatformService;
|
||||
this.officeReadPlatformService = officeReadPlatformService;
|
||||
this.toApiJsonSerializer = toApiJsonSerializer;
|
||||
this.apiRequestParameterHelper = apiRequestParameterHelper;
|
||||
this.apiDataConversionService = apiDataConversionService;
|
||||
this.commandSerializerService = commandSerializerService;
|
||||
this.apiJsonSerializerService = apiJsonSerializerService;
|
||||
@@ -104,12 +114,10 @@ public class ClientsApiResource {
|
||||
|
||||
final String extraCriteria = getClientCriteria(sqlSearch, officeId, externalId, displayName, firstName, lastName, hierarchy);
|
||||
|
||||
final Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
final boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
|
||||
final Collection<ClientData> clients = this.clientReadPlatformService.retrieveAllIndividualClients(extraCriteria);
|
||||
|
||||
return this.apiJsonSerializerService.serializeClientDataToJson(prettyPrint, responseParameters, clients);
|
||||
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
return this.toApiJsonSerializer.serialize(settings, clients, CLIENT_DATA_PARAMETERS);
|
||||
}
|
||||
|
||||
private String getClientCriteria(String sqlSearch, Integer officeId, String externalId, String displayName, String firstName,
|
||||
@@ -163,18 +171,15 @@ public class ClientsApiResource {
|
||||
|
||||
context.authenticatedUser().validateHasReadPermission("CLIENT");
|
||||
|
||||
final Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
final boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
final boolean template = ApiParameterHelper.template(uriInfo.getQueryParameters());
|
||||
final Long commandId = ApiParameterHelper.commandId(uriInfo.getQueryParameters());
|
||||
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
|
||||
ClientData clientData = this.clientReadPlatformService.retrieveIndividualClient(clientId);
|
||||
if (template) {
|
||||
if (settings.isTemplate()) {
|
||||
final List<OfficeLookup> allowedOffices = new ArrayList<OfficeLookup>(officeReadPlatformService.retrieveAllOfficesForLookup());
|
||||
clientData = ClientData.templateOnTop(clientData, allowedOffices);
|
||||
}
|
||||
if (commandId != null) {
|
||||
clientData = handleRequestToIntegrateProposedChangesFromCommand(clientId, commandId, clientData);
|
||||
if (settings.isCommandIdPassed()) {
|
||||
clientData = handleRequestToIntegrateProposedChangesFromCommand(clientId, settings.getCommandId(), clientData);
|
||||
}
|
||||
|
||||
// pick up possibility of changes by default - might push down a layer
|
||||
@@ -182,7 +187,7 @@ public class ClientsApiResource {
|
||||
final Collection<ClientData> dataChanges = retrieveAllUnprocessedDataChanges(clientId);
|
||||
clientData = ClientData.integrateChanges(clientData, clientData.currentChange(), dataChanges);
|
||||
|
||||
return this.apiJsonSerializerService.serializeClientDataToJson(prettyPrint, responseParameters, clientData);
|
||||
return this.toApiJsonSerializer.serialize(settings, clientData, CLIENT_DATA_PARAMETERS);
|
||||
}
|
||||
|
||||
private ClientData handleRequestToIntegrateProposedChangesFromCommand(final Long clientId, final Long commandId,
|
||||
@@ -220,16 +225,14 @@ public class ClientsApiResource {
|
||||
|
||||
context.authenticatedUser().validateHasReadPermission("CLIENT");
|
||||
|
||||
final Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
final boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
final Long makerCheckerId = ApiParameterHelper.commandId(uriInfo.getQueryParameters());
|
||||
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
|
||||
ClientData clientData = this.clientReadPlatformService.retrieveNewClientDetails();
|
||||
if (makerCheckerId != null) {
|
||||
clientData = handleRequestToIntegrateProposedChangesFromCommand(null, makerCheckerId, clientData);
|
||||
if (settings.isCommandIdPassed()) {
|
||||
clientData = handleRequestToIntegrateProposedChangesFromCommand(null, settings.getCommandId(), clientData);
|
||||
}
|
||||
|
||||
return this.apiJsonSerializerService.serializeClientDataToJson(prettyPrint, responseParameters, clientData);
|
||||
return this.toApiJsonSerializer.serialize(settings, clientData, CLIENT_DATA_PARAMETERS);
|
||||
}
|
||||
|
||||
@POST
|
||||
@@ -246,7 +249,7 @@ public class ClientsApiResource {
|
||||
final EntityIdentifier result = this.commandsSourceWritePlatformService.logCommandSource("CREATE", "clients", null,
|
||||
commandSerializedAsJson);
|
||||
|
||||
return this.apiJsonSerializerService.serializeEntityIdentifier(result);
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
}
|
||||
|
||||
@PUT
|
||||
@@ -264,7 +267,7 @@ public class ClientsApiResource {
|
||||
final EntityIdentifier result = this.commandsSourceWritePlatformService.logCommandSource("UPDATE", "clients", clientId,
|
||||
commandSerializedAsJson);
|
||||
|
||||
return this.apiJsonSerializerService.serializeEntityIdentifier(result);
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@@ -278,7 +281,7 @@ public class ClientsApiResource {
|
||||
|
||||
final EntityIdentifier result = this.commandsSourceWritePlatformService.logCommandSource("DELETE", "clients", clientId, "{}");
|
||||
|
||||
return this.apiJsonSerializerService.serializeEntityIdentifier(result);
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
}
|
||||
|
||||
@GET
|
||||
@@ -318,13 +321,13 @@ public class ClientsApiResource {
|
||||
@Path("{clientId}/notes")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public Response addNewClientNote(@PathParam("clientId") final Long clientId, final String jsonRequestBody) {
|
||||
public String addNewClientNote(@PathParam("clientId") final Long clientId, final String jsonRequestBody) {
|
||||
|
||||
final NoteCommand command = this.apiDataConversionService.convertJsonToNoteCommand(null, clientId, jsonRequestBody);
|
||||
|
||||
final EntityIdentifier identifier = this.clientWritePlatformService.addClientNote(command);
|
||||
final EntityIdentifier result = this.clientWritePlatformService.addClientNote(command);
|
||||
|
||||
return Response.ok().entity(identifier).build();
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
}
|
||||
|
||||
@GET
|
||||
@@ -348,14 +351,14 @@ public class ClientsApiResource {
|
||||
@Path("{clientId}/notes/{noteId}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public Response updateClientNote(@PathParam("clientId") final Long clientId, @PathParam("noteId") final Long noteId,
|
||||
public String updateClientNote(@PathParam("clientId") final Long clientId, @PathParam("noteId") final Long noteId,
|
||||
final String jsonRequestBody) {
|
||||
|
||||
final NoteCommand command = this.apiDataConversionService.convertJsonToNoteCommand(noteId, clientId, jsonRequestBody);
|
||||
|
||||
final EntityIdentifier identifier = this.clientWritePlatformService.updateNote(command);
|
||||
final EntityIdentifier result = this.clientWritePlatformService.updateNote(command);
|
||||
|
||||
return Response.ok().entity(identifier).build();
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -365,7 +368,7 @@ public class ClientsApiResource {
|
||||
@Path("{clientId}/image")
|
||||
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public Response addNewClientImage(@PathParam("clientId") final Long clientId, @HeaderParam("Content-Length") Long fileSize,
|
||||
public String addNewClientImage(@PathParam("clientId") final Long clientId, @HeaderParam("Content-Length") Long fileSize,
|
||||
@FormDataParam("file") InputStream inputStream, @FormDataParam("file") FormDataContentDisposition fileDetails,
|
||||
@FormDataParam("file") FormDataBodyPart bodyPart) {
|
||||
|
||||
@@ -378,10 +381,10 @@ public class ClientsApiResource {
|
||||
|
||||
// logger.debug(bodyPart.getMediaType().toString());
|
||||
|
||||
final EntityIdentifier entityIdentifier = this.clientWritePlatformService.saveOrUpdateClientImage(clientId,
|
||||
fileDetails.getFileName(), inputStream);
|
||||
final EntityIdentifier result = this.clientWritePlatformService.saveOrUpdateClientImage(clientId, fileDetails.getFileName(),
|
||||
inputStream);
|
||||
|
||||
return Response.ok().entity(entityIdentifier).build();
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -391,13 +394,13 @@ public class ClientsApiResource {
|
||||
@Path("{clientId}/image")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public Response addNewClientImage(@PathParam("clientId") final Long clientId, final String jsonRequestBody) {
|
||||
public String addNewClientImage(@PathParam("clientId") final Long clientId, final String jsonRequestBody) {
|
||||
|
||||
final Base64EncodedImage base64EncodedImage = FileUtils.extractImageFromDataURL(jsonRequestBody);
|
||||
|
||||
final EntityIdentifier entityIdentifier = this.clientWritePlatformService.saveOrUpdateClientImage(clientId, base64EncodedImage);
|
||||
final EntityIdentifier result = this.clientWritePlatformService.saveOrUpdateClientImage(clientId, base64EncodedImage);
|
||||
|
||||
return Response.ok().entity(entityIdentifier).build();
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -407,14 +410,15 @@ public class ClientsApiResource {
|
||||
@Path("{clientId}/image")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public Response retrieveClientImage(@PathParam("clientId") final Long clientId) {
|
||||
public String retrieveClientImage(@PathParam("clientId") final Long clientId) {
|
||||
|
||||
context.authenticatedUser().validateHasReadPermission("CLIENTIMAGE");
|
||||
|
||||
final ClientData clientData = this.clientReadPlatformService.retrieveIndividualClient(clientId);
|
||||
|
||||
if (clientData.imageKeyDoesNotExist()) { throw new ImageNotFoundException("clients", clientId); }
|
||||
return Response.ok().entity(Base64.encodeFromFile(clientData.imageKey())).build();
|
||||
|
||||
return Base64.encodeFromFile(clientData.imageKey());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -425,9 +429,10 @@ public class ClientsApiResource {
|
||||
@Path("{clientId}/image")
|
||||
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public Response updateClientImage(@PathParam("clientId") final Long clientId, @HeaderParam("Content-Length") Long fileSize,
|
||||
public String updateClientImage(@PathParam("clientId") final Long clientId, @HeaderParam("Content-Length") Long fileSize,
|
||||
@FormDataParam("file") InputStream inputStream, @FormDataParam("file") FormDataContentDisposition fileDetails,
|
||||
@FormDataParam("file") FormDataBodyPart bodyPart) {
|
||||
|
||||
return addNewClientImage(clientId, fileSize, inputStream, fileDetails, bodyPart);
|
||||
}
|
||||
|
||||
@@ -435,9 +440,10 @@ public class ClientsApiResource {
|
||||
@Path("{clientId}/image")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public Response deleteClientImage(@PathParam("clientId") final Long clientId) {
|
||||
public String deleteClientImage(@PathParam("clientId") final Long clientId) {
|
||||
this.clientWritePlatformService.deleteClientImage(clientId);
|
||||
return Response.ok(new EntityIdentifier(clientId)).build();
|
||||
|
||||
return this.toApiJsonSerializer.serialize(new EntityIdentifier(clientId));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -450,7 +456,7 @@ public class ClientsApiResource {
|
||||
@Path("{clientId}/image")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public Response updateClientImage(@PathParam("clientId") final Long clientId, final String jsonRequestBody) {
|
||||
public String updateClientImage(@PathParam("clientId") final Long clientId, final String jsonRequestBody) {
|
||||
return addNewClientImage(clientId, jsonRequestBody);
|
||||
}
|
||||
}
|
||||
+31
-23
@@ -2,6 +2,7 @@ package org.mifosplatform.portfolio.loanaccount.api;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
@@ -20,14 +21,15 @@ import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformService;
|
||||
import org.mifosplatform.infrastructure.core.api.ApiParameterHelper;
|
||||
import org.mifosplatform.infrastructure.core.api.ApiRequestParameterHelper;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioApiDataConversionService;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioApiJsonSerializerService;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.EnumOptionData;
|
||||
import org.mifosplatform.infrastructure.core.exception.UnrecognizedQueryParamException;
|
||||
import org.mifosplatform.infrastructure.core.serialization.CommandSerializer;
|
||||
import org.mifosplatform.infrastructure.core.serialization.ApiRequestJsonSerializationSettings;
|
||||
import org.mifosplatform.infrastructure.core.serialization.DefaultToApiJsonSerializer;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.organisation.monetary.domain.MonetaryCurrency;
|
||||
import org.mifosplatform.organisation.monetary.domain.Money;
|
||||
@@ -75,6 +77,17 @@ import org.springframework.util.CollectionUtils;
|
||||
@Scope("singleton")
|
||||
public class LoansApiResource {
|
||||
|
||||
private final Set<String> LOAN_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("id", "externalId", "clientId", "groupId",
|
||||
"clientName", "groupName", "fundId", "fundName", "loanProductId", "loanProductName", "loanProductDescription", "currency",
|
||||
"principal", "inArrearsTolerance", "numberOfRepayments", "repaymentEvery", "interestRatePerPeriod", "annualInterestRate",
|
||||
"repaymentFrequencyType", "interestRateFrequencyType", "amortizationType", "interestType", "interestCalculationPeriodType",
|
||||
"submittedOnDate", "approvedOnDate", "expectedDisbursementDate", "actualDisbursementDate", "expectedFirstRepaymentOnDate",
|
||||
"interestChargedFromDate", "closedOnDate", "expectedMaturityDate", "status", "lifeCycleStatusDate", "repaymentSchedule",
|
||||
"transactions", "permissions", "convenienceData", "charges", "productOptions", "amortizationTypeOptions",
|
||||
"interestTypeOptions", "interestCalculationPeriodTypeOptions", "repaymentFrequencyTypeOptions",
|
||||
"interestRateFrequencyTypeOptions", "fundOptions", "repaymentStrategyOptions", "chargeOptions", "loanOfficerId",
|
||||
"loanOfficerName", "loanOfficerOptions", "chargeTemplate"));
|
||||
|
||||
// private final String resourceNameForPermissions = "OFFICE";
|
||||
|
||||
private final PlatformSecurityContext context;
|
||||
@@ -90,8 +103,8 @@ public class LoansApiResource {
|
||||
private final GuarantorReadPlatformService guarantorReadPlatformService;
|
||||
private final PortfolioApiJsonSerializerService apiJsonSerializerService;
|
||||
private final PortfolioApiDataConversionService apiDataConversionService;
|
||||
private final CommandSerializer commandSerializerService;
|
||||
private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService;
|
||||
private final DefaultToApiJsonSerializer<LoanAccountData> toApiJsonSerializer;
|
||||
private final ApiRequestParameterHelper apiRequestParameterHelper;
|
||||
|
||||
@Autowired
|
||||
public LoansApiResource(final PlatformSecurityContext context, final LoanReadPlatformService loanReadPlatformService,
|
||||
@@ -100,10 +113,9 @@ public class LoansApiResource {
|
||||
final ChargeReadPlatformService chargeReadPlatformService, final CalculationPlatformService calculationPlatformService,
|
||||
final StaffReadPlatformService staffReadPlatformService, final OfficeReadPlatformService officeReadPlatformService,
|
||||
final GuarantorReadPlatformService guarantorReadPlatformService,
|
||||
final PortfolioApiJsonSerializerService apiJsonSerializerService,
|
||||
final PortfolioApiDataConversionService apiDataConversionService,
|
||||
final CommandSerializer commandSerializerService,
|
||||
final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService) {
|
||||
final DefaultToApiJsonSerializer<LoanAccountData> toApiJsonSerializer,
|
||||
final ApiRequestParameterHelper apiRequestParameterHelper, final PortfolioApiJsonSerializerService apiJsonSerializerService,
|
||||
final PortfolioApiDataConversionService apiDataConversionService) {
|
||||
this.context = context;
|
||||
this.loanReadPlatformService = loanReadPlatformService;
|
||||
this.loanWritePlatformService = loanWritePlatformService;
|
||||
@@ -115,10 +127,10 @@ public class LoansApiResource {
|
||||
this.staffReadPlatformService = staffReadPlatformService;
|
||||
this.officeReadPlatformService = officeReadPlatformService;
|
||||
this.guarantorReadPlatformService = guarantorReadPlatformService;
|
||||
this.toApiJsonSerializer = toApiJsonSerializer;
|
||||
this.apiRequestParameterHelper = apiRequestParameterHelper;
|
||||
this.apiJsonSerializerService = apiJsonSerializerService;
|
||||
this.apiDataConversionService = apiDataConversionService;
|
||||
this.commandSerializerService = commandSerializerService;
|
||||
this.commandsSourceWritePlatformService = commandsSourceWritePlatformService;
|
||||
}
|
||||
|
||||
@GET
|
||||
@@ -130,9 +142,6 @@ public class LoansApiResource {
|
||||
|
||||
context.authenticatedUser().validateHasReadPermission("LOAN");
|
||||
|
||||
final Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
final boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
|
||||
// tempate related
|
||||
Collection<LoanProductData> productOptions = this.loanProductReadPlatformService.retrieveAllLoanProductsForLookup();
|
||||
Collection<EnumOptionData> loanTermFrequencyTypeOptions = dropdownReadPlatformService.retrieveLoanTermFrequencyTypeOptions();
|
||||
@@ -174,7 +183,8 @@ public class LoansApiResource {
|
||||
interestRateFrequencyTypeOptions, amortizationTypeOptions, interestTypeOptions, interestCalculationPeriodTypeOptions,
|
||||
fundOptions, chargeOptions, chargeTemplate, allowedLoanOfficers, null);
|
||||
|
||||
return this.apiJsonSerializerService.serializeLoanAccountDataToJson(prettyPrint, responseParameters, newLoanAccount);
|
||||
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
return this.toApiJsonSerializer.serialize(settings, newLoanAccount, LOAN_DATA_PARAMETERS);
|
||||
}
|
||||
|
||||
@GET
|
||||
@@ -185,9 +195,6 @@ public class LoansApiResource {
|
||||
|
||||
context.authenticatedUser().validateHasReadPermission("LOAN");
|
||||
|
||||
final Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
final boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
|
||||
final LoanBasicDetailsData loanBasicDetails = this.loanReadPlatformService.retrieveLoanAccountDetails(loanId);
|
||||
|
||||
int loanRepaymentsCount = 0;
|
||||
@@ -290,7 +297,8 @@ public class LoansApiResource {
|
||||
repaymentStrategyOptions, interestRateFrequencyTypeOptions, amortizationTypeOptions, interestTypeOptions,
|
||||
interestCalculationPeriodTypeOptions, fundOptions, chargeOptions, chargeTemplate, null, guarantorData);
|
||||
|
||||
return this.apiJsonSerializerService.serializeLoanAccountDataToJson(prettyPrint, responseParameters, loanAccount);
|
||||
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
return this.toApiJsonSerializer.serialize(settings, loanAccount, LOAN_DATA_PARAMETERS);
|
||||
}
|
||||
|
||||
private int retrieveNonDisbursementTransactions(final Collection<LoanTransactionData> loanRepayments) {
|
||||
@@ -323,7 +331,7 @@ public class LoansApiResource {
|
||||
|
||||
final EntityIdentifier identifier = this.loanWritePlatformService.submitLoanApplication(command);
|
||||
|
||||
return this.apiJsonSerializerService.serializeEntityIdentifier(identifier);
|
||||
return this.toApiJsonSerializer.serialize(identifier);
|
||||
}
|
||||
|
||||
private String calculateLoanSchedule(final UriInfo uriInfo, final CalculateLoanScheduleCommand command) {
|
||||
@@ -347,7 +355,7 @@ public class LoansApiResource {
|
||||
|
||||
final EntityIdentifier identifier = this.loanWritePlatformService.modifyLoanApplication(command);
|
||||
|
||||
return this.apiJsonSerializerService.serializeEntityIdentifier(identifier);
|
||||
return this.toApiJsonSerializer.serialize(identifier);
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@@ -554,7 +562,7 @@ public class LoansApiResource {
|
||||
|
||||
final EntityIdentifier identifier = this.loanWritePlatformService.updateLoanCharge(command);
|
||||
|
||||
return this.apiJsonSerializerService.serializeEntityIdentifier(identifier);
|
||||
return this.toApiJsonSerializer.serialize(identifier);
|
||||
}
|
||||
|
||||
@POST
|
||||
@@ -569,7 +577,7 @@ public class LoansApiResource {
|
||||
String json = "";
|
||||
if (is(commandParam, "waive")) {
|
||||
final EntityIdentifier identifier = this.loanWritePlatformService.waiveLoanCharge(command);
|
||||
json = this.apiJsonSerializerService.serializeEntityIdentifier(identifier);
|
||||
json = this.toApiJsonSerializer.serialize(identifier);
|
||||
} else {
|
||||
throw new UnrecognizedQueryParamException("command", commandParam);
|
||||
}
|
||||
@@ -584,7 +592,7 @@ public class LoansApiResource {
|
||||
public String deleteLoanCharge(@PathParam("loanId") final Long loanId, @PathParam("chargeId") final Long loanChargeId) {
|
||||
|
||||
final EntityIdentifier identifier = this.loanWritePlatformService.deleteLoanCharge(loanId, loanChargeId);
|
||||
return this.apiJsonSerializerService.serializeEntityIdentifier(identifier);
|
||||
return this.toApiJsonSerializer.serialize(identifier);
|
||||
}
|
||||
|
||||
@POST
|
||||
|
||||
+27
-21
@@ -2,6 +2,7 @@ package org.mifosplatform.portfolio.loanproduct.api;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -17,12 +18,13 @@ import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformService;
|
||||
import org.mifosplatform.infrastructure.core.api.ApiParameterHelper;
|
||||
import org.mifosplatform.infrastructure.core.api.ApiRequestParameterHelper;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioApiDataConversionService;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioApiJsonSerializerService;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.EnumOptionData;
|
||||
import org.mifosplatform.infrastructure.core.serialization.ApiRequestJsonSerializationSettings;
|
||||
import org.mifosplatform.infrastructure.core.serialization.CommandSerializer;
|
||||
import org.mifosplatform.infrastructure.core.serialization.DefaultToApiJsonSerializer;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.organisation.monetary.data.CurrencyData;
|
||||
import org.mifosplatform.organisation.monetary.service.CurrencyReadPlatformService;
|
||||
@@ -44,6 +46,14 @@ import org.springframework.stereotype.Component;
|
||||
@Scope("singleton")
|
||||
public class LoanProductsApiResource {
|
||||
|
||||
private final Set<String> LOAN_PRODUCT_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("id", "name", "description", "fundId",
|
||||
"fundName", "transactionProcessingStrategyId", "transactionProcessingStrategyName", "principal", "inArrearsTolerance",
|
||||
"numberOfRepayments", "repaymentEvery", "interestRatePerPeriod", "annualInterestRate", "repaymentFrequencyType",
|
||||
"interestRateFrequencyType", "amortizationType", "interestType", "interestCalculationPeriodType", "charges", "createdOn",
|
||||
"lastModifedOn", "currencyOptions", "amortizationTypeOptions", "interestTypeOptions", "interestCalculationPeriodTypeOptions",
|
||||
"repaymentFrequencyTypeOptions", "interestRateFrequencyTypeOptions", "fundOptions", "transactionProcessingStrategyOptions",
|
||||
"chargeOptions"));
|
||||
|
||||
private final String resourceNameForPermissions = "LOANPRODUCT";
|
||||
|
||||
private final PlatformSecurityContext context;
|
||||
@@ -51,8 +61,9 @@ public class LoanProductsApiResource {
|
||||
private final ChargeReadPlatformService chargeReadPlatformService;
|
||||
private final CurrencyReadPlatformService currencyReadPlatformService;
|
||||
private final FundReadPlatformService fundReadPlatformService;
|
||||
private final DefaultToApiJsonSerializer<LoanProductData> toApiJsonSerializer;
|
||||
private final ApiRequestParameterHelper apiRequestParameterHelper;
|
||||
private final LoanDropdownReadPlatformService dropdownReadPlatformService;
|
||||
private final PortfolioApiJsonSerializerService apiJsonSerializerService;
|
||||
private final PortfolioApiDataConversionService apiDataConversionService;
|
||||
private final CommandSerializer commandSerializerService;
|
||||
private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService;
|
||||
@@ -61,8 +72,8 @@ public class LoanProductsApiResource {
|
||||
public LoanProductsApiResource(final PlatformSecurityContext context, final LoanProductReadPlatformService readPlatformService,
|
||||
final ChargeReadPlatformService chargeReadPlatformService, final CurrencyReadPlatformService currencyReadPlatformService,
|
||||
final FundReadPlatformService fundReadPlatformService, final LoanDropdownReadPlatformService dropdownReadPlatformService,
|
||||
final PortfolioApiJsonSerializerService apiJsonSerializerService,
|
||||
final PortfolioApiDataConversionService apiDataConversionService,
|
||||
final DefaultToApiJsonSerializer<LoanProductData> toApiJsonSerializer,
|
||||
final ApiRequestParameterHelper apiRequestParameterHelper, final PortfolioApiDataConversionService apiDataConversionService,
|
||||
final CommandSerializer commandSerializerService,
|
||||
final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService) {
|
||||
this.context = context;
|
||||
@@ -71,7 +82,8 @@ public class LoanProductsApiResource {
|
||||
this.currencyReadPlatformService = currencyReadPlatformService;
|
||||
this.fundReadPlatformService = fundReadPlatformService;
|
||||
this.dropdownReadPlatformService = dropdownReadPlatformService;
|
||||
this.apiJsonSerializerService = apiJsonSerializerService;
|
||||
this.toApiJsonSerializer = toApiJsonSerializer;
|
||||
this.apiRequestParameterHelper = apiRequestParameterHelper;
|
||||
this.apiDataConversionService = apiDataConversionService;
|
||||
this.commandSerializerService = commandSerializerService;
|
||||
this.commandsSourceWritePlatformService = commandsSourceWritePlatformService;
|
||||
@@ -93,7 +105,7 @@ public class LoanProductsApiResource {
|
||||
final EntityIdentifier result = this.commandsSourceWritePlatformService.logCommandSource("CREATE", "loanproducts", null,
|
||||
commandSerializedAsJson);
|
||||
|
||||
return this.apiJsonSerializerService.serializeEntityIdentifier(result);
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
}
|
||||
|
||||
@GET
|
||||
@@ -103,12 +115,10 @@ public class LoanProductsApiResource {
|
||||
|
||||
context.authenticatedUser().validateHasReadPermission(resourceNameForPermissions);
|
||||
|
||||
final Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
final boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
|
||||
final Collection<LoanProductData> products = this.loanProductReadPlatformService.retrieveAllLoanProducts();
|
||||
|
||||
return this.apiJsonSerializerService.serializeLoanProductDataToJson(prettyPrint, responseParameters, products);
|
||||
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
return this.toApiJsonSerializer.serialize(settings, products, LOAN_PRODUCT_DATA_PARAMETERS);
|
||||
}
|
||||
|
||||
@GET
|
||||
@@ -119,13 +129,11 @@ public class LoanProductsApiResource {
|
||||
|
||||
context.authenticatedUser().validateHasReadPermission(resourceNameForPermissions);
|
||||
|
||||
final Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
final boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
|
||||
LoanProductData loanProduct = this.loanProductReadPlatformService.retrieveNewLoanProductDetails();
|
||||
loanProduct = handleTemplate(loanProduct);
|
||||
|
||||
return this.apiJsonSerializerService.serializeLoanProductDataToJson(prettyPrint, responseParameters, loanProduct);
|
||||
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
return this.toApiJsonSerializer.serialize(settings, loanProduct, LOAN_PRODUCT_DATA_PARAMETERS);
|
||||
}
|
||||
|
||||
@GET
|
||||
@@ -136,16 +144,14 @@ public class LoanProductsApiResource {
|
||||
|
||||
context.authenticatedUser().validateHasReadPermission(resourceNameForPermissions);
|
||||
|
||||
final Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
final boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
final boolean template = ApiParameterHelper.template(uriInfo.getQueryParameters());
|
||||
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
|
||||
LoanProductData loanProduct = this.loanProductReadPlatformService.retrieveLoanProduct(productId);
|
||||
if (template) {
|
||||
if (settings.isTemplate()) {
|
||||
loanProduct = handleTemplate(loanProduct);
|
||||
}
|
||||
|
||||
return this.apiJsonSerializerService.serializeLoanProductDataToJson(prettyPrint, responseParameters, loanProduct);
|
||||
return this.toApiJsonSerializer.serialize(settings, loanProduct, LOAN_PRODUCT_DATA_PARAMETERS);
|
||||
}
|
||||
|
||||
@PUT
|
||||
@@ -165,7 +171,7 @@ public class LoanProductsApiResource {
|
||||
final EntityIdentifier result = this.commandsSourceWritePlatformService.logCommandSource("UPDATE", "loanproducts", null,
|
||||
commandSerializedAsJson);
|
||||
|
||||
return this.apiJsonSerializerService.serializeEntityIdentifier(result);
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
}
|
||||
|
||||
private LoanProductData handleTemplate(final LoanProductData productData) {
|
||||
|
||||
+5
-1
@@ -23,6 +23,7 @@ import org.mifosplatform.infrastructure.core.api.ApiParameterHelper;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioApiDataConversionService;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioApiJsonSerializerService;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.serialization.ToApiJsonSerializer;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.portfolio.savingsaccount.command.CalculateSavingScheduleCommand;
|
||||
import org.mifosplatform.portfolio.savingsaccount.command.SavingAccountCommand;
|
||||
@@ -60,6 +61,9 @@ public class SavingsAccountApiResource {
|
||||
@Autowired
|
||||
private CalculateSavingSchedule calculateSavingSchedule;
|
||||
|
||||
@Autowired
|
||||
private ToApiJsonSerializer<SavingAccountData> toApiJsonSerializer;
|
||||
|
||||
private static final Set<String> typicalResponseParameters = new HashSet<String>(Arrays.asList("id", "status", "externalId",
|
||||
"clientId", "clientName", "productId", "productName", "productType", "currencyData", "savingsDepostiAmountPerPeriod",
|
||||
"savingsFrequencyType", "totalDepositAmount", "reccuringInterestRate", "savingInterestRate", "interestType",
|
||||
@@ -83,7 +87,7 @@ public class SavingsAccountApiResource {
|
||||
|
||||
EntityIdentifier entityIdentifier = this.savingAccountWritePlatformService.createSavingAccount(command);
|
||||
|
||||
return this.apiJsonSerializerService.serializeEntityIdentifier(entityIdentifier);
|
||||
return this.toApiJsonSerializer.serialize(entityIdentifier);
|
||||
}
|
||||
|
||||
private String calculateSavingSchedule(final UriInfo uriInfo, final CalculateSavingScheduleCommand command) {
|
||||
|
||||
+8
-2
@@ -18,27 +18,34 @@ import org.mifosplatform.useradministration.domain.AppUser;
|
||||
@Table(name = "m_saving_schedule")
|
||||
public class SavingScheduleInstallments extends AbstractAuditableCustom<AppUser, Long> {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@ManyToOne(optional = false)
|
||||
@JoinColumn(name = "saving_account_id", nullable = false)
|
||||
private SavingAccount savingAccount;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Temporal(TemporalType.DATE)
|
||||
@Column(name = "duedate", nullable = false)
|
||||
private final Date dueDate;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Column(name = "installment", nullable = false)
|
||||
private final Integer installmentNumber;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Column(name = "deposit", scale = 6, precision = 19, nullable = false)
|
||||
private BigDecimal deposit;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Temporal(TemporalType.DATE)
|
||||
@Column(name = "payment_date", nullable = true)
|
||||
private final Date paymentDate;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Column(name = "deposit_paid", scale = 6, precision = 19, nullable = true)
|
||||
private BigDecimal depositPaid;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Column(name = "completed_derived", nullable = false)
|
||||
private boolean completed;
|
||||
|
||||
@@ -55,5 +62,4 @@ public class SavingScheduleInstallments extends AbstractAuditableCustom<AppUser,
|
||||
public void updateAccount(SavingAccount account) {
|
||||
this.savingAccount = account;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+8
-11
@@ -1,9 +1,5 @@
|
||||
package org.mifosplatform.portfolio.savingsaccount.service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
import org.mifosplatform.organisation.monetary.domain.MonetaryCurrency;
|
||||
import org.mifosplatform.portfolio.savingsaccount.command.CalculateSavingScheduleCommand;
|
||||
import org.mifosplatform.portfolio.savingsaccountproduct.domain.SavingProduct;
|
||||
import org.mifosplatform.portfolio.savingsaccountproduct.domain.SavingProductRelatedDetail;
|
||||
@@ -22,17 +18,18 @@ public class SavingProductRelatedDetailAssembler {
|
||||
this.savingProductRepository = savingProductRepository;
|
||||
}
|
||||
|
||||
public SavingProductRelatedDetail assembleFrom(CalculateSavingScheduleCommand command) {
|
||||
public SavingProductRelatedDetail assembleFrom(final CalculateSavingScheduleCommand command) {
|
||||
|
||||
// final BigDecimal depositAmountForPeriod = command.getDeposit();
|
||||
// final BigDecimal depositInterestRate = command.getInterestRate();
|
||||
// final LocalDate installmentDate = command.getPaymentsStartingFromDate();
|
||||
// final Integer payEvery = command.getPayEvery();
|
||||
// final Integer paymentFrequencyType = command.getPaymentFrequencyType();
|
||||
|
||||
final BigDecimal depositAmountForPeriod = command.getDeposit();
|
||||
final BigDecimal depositInterestRate = command.getInterestRate();
|
||||
final LocalDate installmentDate = command.getPaymentsStartingFromDate();
|
||||
final Integer payEvery = command.getPayEvery();
|
||||
final Integer paymentFrequencyType = command.getPaymentFrequencyType();
|
||||
final SavingProduct savingProduct = this.savingProductRepository.findOne(command.getProductId());
|
||||
if (savingProduct == null) { throw new SavingProductNotFoundException(command.getProductId()); }
|
||||
|
||||
final MonetaryCurrency currency = savingProduct.getCurrency();
|
||||
// final MonetaryCurrency currency = savingProduct.getCurrency();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
+1
@@ -752,6 +752,7 @@ public class DepositAccount extends AbstractAuditableCustom<AppUser, Long> {
|
||||
// add transaction entry for each interest posting
|
||||
DepositAccountTransaction depositaccountTransaction = DepositAccountTransaction.postInterest(null,
|
||||
nextInterestPostingDate, futureValueOnMaturity.minus(deposit));
|
||||
|
||||
depositaccountTransaction.updateAccount(this);
|
||||
this.depositaccountTransactions.add(depositaccountTransaction);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user