FINERACT-2169: Apply dto into GuarantorsApiResource
This commit is contained in:
committed by
Adam Saghy
parent
12617ea1df
commit
60bc3acaf1
+6
-1
@@ -18,6 +18,8 @@
|
||||
*/
|
||||
package org.apache.fineract.portfolio.loanaccount.data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
@@ -25,7 +27,10 @@ import org.springframework.integration.annotation.Default;
|
||||
|
||||
@Data
|
||||
@Getter
|
||||
public class LoanChargePaidByData {
|
||||
public class LoanChargePaidByData implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long id;
|
||||
private BigDecimal amount;
|
||||
|
||||
+6
-1
@@ -18,6 +18,8 @@
|
||||
*/
|
||||
package org.apache.fineract.portfolio.loanaccount.data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import lombok.AllArgsConstructor;
|
||||
@@ -25,7 +27,10 @@ import lombok.Getter;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public final class LoanRepaymentScheduleInstallmentData {
|
||||
public final class LoanRepaymentScheduleInstallmentData implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long id;
|
||||
|
||||
|
||||
+6
-1
@@ -18,6 +18,8 @@
|
||||
*/
|
||||
package org.apache.fineract.portfolio.loanaccount.data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Collection;
|
||||
@@ -35,7 +37,10 @@ import org.springframework.integration.annotation.Default;
|
||||
* Immutable data object representing a loan transaction.
|
||||
*/
|
||||
@Getter
|
||||
public class LoanTransactionData {
|
||||
public class LoanTransactionData implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final Long id;
|
||||
private final Long loanId;
|
||||
|
||||
+6
-1
@@ -18,6 +18,8 @@
|
||||
*/
|
||||
package org.apache.fineract.portfolio.loanaccount.data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import lombok.Getter;
|
||||
import org.apache.fineract.portfolio.loanaccount.domain.LoanTransactionType;
|
||||
|
||||
@@ -25,7 +27,10 @@ import org.apache.fineract.portfolio.loanaccount.domain.LoanTransactionType;
|
||||
* Immutable data object represent loan status enumerations.
|
||||
*/
|
||||
@Getter
|
||||
public class LoanTransactionEnumData {
|
||||
public class LoanTransactionEnumData implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final Long id;
|
||||
private final String code;
|
||||
|
||||
+20
-50
@@ -36,11 +36,8 @@ import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
import jakarta.ws.rs.core.UriInfo;
|
||||
import java.io.InputStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.fineract.commands.domain.CommandWrapper;
|
||||
import org.apache.fineract.commands.service.CommandWrapperBuilder;
|
||||
@@ -57,14 +54,13 @@ import org.apache.fineract.infrastructure.core.data.UploadRequest;
|
||||
import org.apache.fineract.infrastructure.core.serialization.ApiRequestJsonSerializationSettings;
|
||||
import org.apache.fineract.infrastructure.core.serialization.DefaultToApiJsonSerializer;
|
||||
import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.apache.fineract.portfolio.account.AccountDetailConstants;
|
||||
import org.apache.fineract.portfolio.account.PortfolioAccountType;
|
||||
import org.apache.fineract.portfolio.account.api.AccountTransfersApiConstants;
|
||||
import org.apache.fineract.portfolio.account.data.PortfolioAccountDTO;
|
||||
import org.apache.fineract.portfolio.account.data.PortfolioAccountData;
|
||||
import org.apache.fineract.portfolio.account.service.PortfolioAccountReadPlatformService;
|
||||
import org.apache.fineract.portfolio.loanaccount.guarantor.GuarantorConstants;
|
||||
import org.apache.fineract.portfolio.loanaccount.guarantor.data.GuarantorData;
|
||||
import org.apache.fineract.portfolio.loanaccount.guarantor.data.GuarantorsRequest;
|
||||
import org.apache.fineract.portfolio.loanaccount.guarantor.domain.GuarantorType;
|
||||
import org.apache.fineract.portfolio.loanaccount.guarantor.service.GuarantorEnumerations;
|
||||
import org.apache.fineract.portfolio.loanaccount.guarantor.service.GuarantorReadPlatformService;
|
||||
@@ -79,15 +75,6 @@ import org.springframework.stereotype.Component;
|
||||
@RequiredArgsConstructor
|
||||
public class GuarantorsApiResource {
|
||||
|
||||
private static final Set<String> RESPONSE_DATA_PARAMETERS = new HashSet<>(
|
||||
Arrays.asList("id", "loanId", "clientRelationshipType", "guarantorType", "firstname", "lastname", "entityId", "externalId",
|
||||
"officeName", "joinedDate", "addressLine1", "addressLine2", "city", "state", "zip", "country", "mobileNumber",
|
||||
"housePhoneNumber", "comment", "dob", "guarantorTypeOptions", "allowedClientRelationshipTypes"));
|
||||
|
||||
private static final Set<String> ACCOUNT_TRANSFER_API_RESPONSE_DATA_PARAMETERS = new HashSet<>(
|
||||
Arrays.asList(AccountDetailConstants.idParamName, AccountTransfersApiConstants.transferDescriptionParamName,
|
||||
AccountTransfersApiConstants.currencyParamName));
|
||||
|
||||
private static final String RESOURCE_NAME_FOR_PERMISSION = "GUARANTOR";
|
||||
|
||||
private final GuarantorReadPlatformService guarantorReadPlatformService;
|
||||
@@ -105,38 +92,30 @@ public class GuarantorsApiResource {
|
||||
@Path("template")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String newGuarantorTemplate(@Context final UriInfo uriInfo, @PathParam("loanId") final Long loanId) {
|
||||
public GuarantorData newGuarantorTemplate(@PathParam("loanId") final Long loanId) {
|
||||
this.context.authenticatedUser().validateHasReadPermission(RESOURCE_NAME_FOR_PERMISSION);
|
||||
|
||||
final List<EnumOptionData> guarantorTypeOptions = GuarantorEnumerations.guarantorType(GuarantorType.values());
|
||||
final Collection<CodeValueData> allowedClientRelationshipTypes = this.codeValueReadPlatformService
|
||||
.retrieveCodeValuesByCode(GuarantorConstants.GUARANTOR_RELATIONSHIP_CODE_NAME);
|
||||
final Collection<PortfolioAccountData> accountLinkingOptions = null;
|
||||
final GuarantorData guarantorData = GuarantorData.template(guarantorTypeOptions, allowedClientRelationshipTypes,
|
||||
accountLinkingOptions);
|
||||
|
||||
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
return this.apiJsonSerializerService.serialize(settings, guarantorData, RESPONSE_DATA_PARAMETERS);
|
||||
return GuarantorData.template(guarantorTypeOptions, allowedClientRelationshipTypes, accountLinkingOptions);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String retrieveGuarantorDetails(@Context final UriInfo uriInfo, @PathParam("loanId") final Long loanId) {
|
||||
public List<GuarantorData> retrieveGuarantorDetails(@PathParam("loanId") final Long loanId) {
|
||||
this.context.authenticatedUser().validateHasReadPermission(RESOURCE_NAME_FOR_PERMISSION);
|
||||
|
||||
final List<GuarantorData> guarantorDatas = this.guarantorReadPlatformService.retrieveGuarantorsForValidLoan(loanId);
|
||||
|
||||
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
|
||||
return this.apiJsonSerializerService.serialize(settings, guarantorDatas, RESPONSE_DATA_PARAMETERS);
|
||||
return this.guarantorReadPlatformService.retrieveGuarantorsForValidLoan(loanId);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("{guarantorId}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String retrieveGuarantorDetails(@Context final UriInfo uriInfo, @PathParam("loanId") final Long loanId,
|
||||
public GuarantorData retrieveGuarantorDetails(@Context final UriInfo uriInfo, @PathParam("loanId") final Long loanId,
|
||||
@PathParam("guarantorId") final Long guarantorId) {
|
||||
this.context.authenticatedUser().validateHasReadPermission(RESOURCE_NAME_FOR_PERMISSION);
|
||||
|
||||
@@ -151,55 +130,48 @@ public class GuarantorsApiResource {
|
||||
guarantorData = GuarantorData.templateOnTop(guarantorData, guarantorTypeOptions, allowedClientRelationshipTypes,
|
||||
accountLinkingOptions);
|
||||
}
|
||||
|
||||
return this.apiJsonSerializerService.serialize(settings, guarantorData, RESPONSE_DATA_PARAMETERS);
|
||||
return guarantorData;
|
||||
}
|
||||
|
||||
@POST
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String createGuarantor(@PathParam("loanId") final Long loanId, final String apiRequestBodyAsJson) {
|
||||
public CommandProcessingResult createGuarantor(@PathParam("loanId") final Long loanId, final GuarantorsRequest guarantorsRequest) {
|
||||
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder().createGuarantor(loanId).withJson(apiRequestBodyAsJson).build();
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder().createGuarantor(loanId)
|
||||
.withJson(apiJsonSerializerService.serialize(guarantorsRequest)).build();
|
||||
|
||||
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
|
||||
return this.apiJsonSerializerService.serialize(result);
|
||||
return this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
}
|
||||
|
||||
@PUT
|
||||
@Path("{guarantorId}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String updateGuarantor(@PathParam("loanId") final Long loanId, @PathParam("guarantorId") final Long guarantorId,
|
||||
final String jsonRequestBody) {
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder().updateGuarantor(loanId, guarantorId).withJson(jsonRequestBody)
|
||||
.build();
|
||||
public CommandProcessingResult updateGuarantor(@PathParam("loanId") final Long loanId, @PathParam("guarantorId") final Long guarantorId,
|
||||
final GuarantorsRequest guarantorsRequest) {
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder().updateGuarantor(loanId, guarantorId)
|
||||
.withJson(apiJsonSerializerService.serialize(guarantorsRequest)).build();
|
||||
|
||||
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
|
||||
return this.apiJsonSerializerService.serialize(result);
|
||||
return this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@Path("{guarantorId}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String deleteGuarantor(@PathParam("loanId") final Long loanId, @PathParam("guarantorId") final Long guarantorId,
|
||||
public CommandProcessingResult deleteGuarantor(@PathParam("loanId") final Long loanId, @PathParam("guarantorId") final Long guarantorId,
|
||||
@QueryParam("guarantorFundingId") final Long guarantorFundingId) {
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder().deleteGuarantor(loanId, guarantorId, guarantorFundingId).build();
|
||||
|
||||
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
|
||||
return this.apiJsonSerializerService.serialize(result);
|
||||
return this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("accounts/template")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String accountsTemplate(@QueryParam("clientId") final Long clientId, @PathParam("loanId") final Long loanId,
|
||||
@Context final UriInfo uriInfo) {
|
||||
public GuarantorData accountsTemplate(@QueryParam("clientId") final Long clientId, @PathParam("loanId") final Long loanId) {
|
||||
|
||||
this.context.authenticatedUser().validateHasReadPermission(RESOURCE_NAME_FOR_PERMISSION);
|
||||
|
||||
@@ -208,9 +180,7 @@ public class GuarantorsApiResource {
|
||||
if (this.loanReadPlatformService.isGuaranteeRequired(loanId)) {
|
||||
accountLinkingOptions = this.portfolioAccountReadPlatformService.retrieveAllForLookup(portfolioAccountDTO);
|
||||
}
|
||||
final GuarantorData guarantorData = GuarantorData.template(null, null, accountLinkingOptions);
|
||||
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
return this.apiJsonSerializerService.serialize(settings, guarantorData, ACCOUNT_TRANSFER_API_RESPONSE_DATA_PARAMETERS);
|
||||
return GuarantorData.template(null, null, accountLinkingOptions);
|
||||
}
|
||||
|
||||
@GET
|
||||
|
||||
+6
-1
@@ -18,6 +18,8 @@
|
||||
*/
|
||||
package org.apache.fineract.portfolio.loanaccount.guarantor.data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Collection;
|
||||
@@ -32,7 +34,10 @@ import org.apache.fineract.portfolio.loanaccount.guarantor.domain.GuarantorType;
|
||||
import org.apache.fineract.portfolio.loanaccount.guarantor.service.GuarantorEnumerations;
|
||||
|
||||
@Getter
|
||||
public class GuarantorData {
|
||||
public class GuarantorData implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final Long id;
|
||||
private final Long loanId;
|
||||
|
||||
+8
-1
@@ -18,12 +18,19 @@
|
||||
*/
|
||||
package org.apache.fineract.portfolio.loanaccount.guarantor.data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Collection;
|
||||
import lombok.Getter;
|
||||
import org.apache.fineract.infrastructure.core.data.EnumOptionData;
|
||||
import org.apache.fineract.portfolio.account.data.PortfolioAccountData;
|
||||
|
||||
public final class GuarantorFundingData {
|
||||
@Getter
|
||||
public final class GuarantorFundingData implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private final Long id;
|
||||
|
||||
+8
-1
@@ -18,10 +18,17 @@
|
||||
*/
|
||||
package org.apache.fineract.portfolio.loanaccount.guarantor.data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import lombok.Getter;
|
||||
import org.apache.fineract.portfolio.loanaccount.data.LoanTransactionData;
|
||||
import org.apache.fineract.portfolio.savings.data.DepositAccountOnHoldTransactionData;
|
||||
|
||||
public final class GuarantorTransactionData {
|
||||
@Getter
|
||||
public final class GuarantorTransactionData implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private final Long id;
|
||||
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.fineract.portfolio.loanaccount.guarantor.data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
public class GuarantorsRequest implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String locale;
|
||||
private String dateFormat; // "dd MMMM yyyy"
|
||||
|
||||
/*** Fields for capturing relationship of Guarantor with customer **/
|
||||
private Long clientRelationshipTypeId;
|
||||
|
||||
/*** Fields for current customers serving as guarantors **/
|
||||
private Integer guarantorTypeId;
|
||||
private Long entityId;
|
||||
|
||||
/*** Fields for external persons serving as guarantors ***/
|
||||
private String firstname;
|
||||
private String lastname;
|
||||
private String addressLine1;
|
||||
private String addressLine2;
|
||||
private String city;
|
||||
private String state;
|
||||
private String zip;
|
||||
private String country;
|
||||
private String mobileNumber;
|
||||
private String housePhoneNumber;
|
||||
private String comment;
|
||||
private String dob;
|
||||
private Long savingsId;
|
||||
private BigDecimal amount;
|
||||
|
||||
}
|
||||
+4
-2
@@ -40,6 +40,7 @@ import jakarta.ws.rs.core.Context;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.UriInfo;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.fineract.infrastructure.core.exception.UnrecognizedQueryParamException;
|
||||
@@ -53,6 +54,7 @@ import org.apache.fineract.portfolio.loanaccount.exception.LoanNotFoundException
|
||||
import org.apache.fineract.portfolio.loanaccount.exception.LoanTemplateTypeRequiredException;
|
||||
import org.apache.fineract.portfolio.loanaccount.exception.NotSupportedLoanTemplateTypeException;
|
||||
import org.apache.fineract.portfolio.loanaccount.guarantor.api.GuarantorsApiResource;
|
||||
import org.apache.fineract.portfolio.loanaccount.guarantor.data.GuarantorData;
|
||||
import org.apache.fineract.portfolio.self.client.service.AppuserClientMapperReadService;
|
||||
import org.apache.fineract.portfolio.self.loanaccount.data.SelfLoansDataValidator;
|
||||
import org.apache.fineract.portfolio.self.loanaccount.service.AppuserLoansMapperReadService;
|
||||
@@ -273,10 +275,10 @@ public class SelfLoansApiResource {
|
||||
@Path("{loanId}/guarantors")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String retrieveGuarantorDetails(@PathParam("loanId") final Long loanId, @Context final UriInfo uriInfo) {
|
||||
public List<GuarantorData> retrieveGuarantorDetails(@PathParam("loanId") final Long loanId) {
|
||||
|
||||
validateAppuserLoanMapping(loanId);
|
||||
return this.guarantorsApiResource.retrieveGuarantorDetails(uriInfo, loanId);
|
||||
return this.guarantorsApiResource.retrieveGuarantorDetails(loanId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+8
-1
@@ -18,11 +18,18 @@
|
||||
*/
|
||||
package org.apache.fineract.portfolio.savings.data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import lombok.Getter;
|
||||
import org.apache.fineract.infrastructure.core.data.EnumOptionData;
|
||||
|
||||
public final class DepositAccountOnHoldTransactionData {
|
||||
@Getter
|
||||
public final class DepositAccountOnHoldTransactionData implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private final Long id;
|
||||
|
||||
Reference in New Issue
Block a user