Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions fineract-client-feign/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ tasks.register('buildJavaSdk', org.openapitools.generator.gradle.plugin.tasks.Ge
verbose = false
validateSpec = false
skipValidateSpec = true
skipOperationExample = true
inputSpec = "file:///$swaggerFile"
outputDir = "$buildDir/generated/temp-java".toString()
templateDir = "$projectDir/src/main/resources/templates/java"
Expand Down
3 changes: 3 additions & 0 deletions fineract-client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ task buildJavaSdk(type: org.openapitools.generator.gradle.plugin.tasks.GenerateT
verbose = false
validateSpec = false
skipValidateSpec = true
skipOperationExample = true
inputSpec = "file:///$swaggerFile"
outputDir = "$buildDir/generated/temp-java".toString()
templateDir = "$projectDir/src/main/resources/templates/java"
Expand All @@ -80,6 +81,7 @@ task buildTypescriptAngularSdk(type: org.openapitools.generator.gradle.plugin.ta
verbose = false
validateSpec = false
skipValidateSpec = true
skipOperationExample = true
inputSpec = "file:///$swaggerFile"
outputDir = "$buildDir/generated/typescript".toString()
apiPackage = 'apache-fineract-client/services'
Expand All @@ -100,6 +102,7 @@ task buildAsciidoc(type: org.openapitools.generator.gradle.plugin.tasks.Generate
verbose = false
validateSpec = false
skipValidateSpec = true
skipOperationExample = true
inputSpec = "file:///$swaggerFile"
outputDir = "$buildDir/generated/asciidoc".toString()
apiPackage = 'org.apache.fineract.client.services'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import jakarta.ws.rs.BeanParam;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.GET;
Expand All @@ -35,14 +36,14 @@
import jakarta.ws.rs.QueryParam;
import jakarta.ws.rs.core.MediaType;
import lombok.RequiredArgsConstructor;
import org.apache.fineract.commands.domain.CommandWrapper;
import org.apache.fineract.commands.service.CommandWrapperBuilder;
import org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
import org.apache.fineract.infrastructure.core.serialization.DefaultToApiJsonSerializer;
import org.apache.fineract.command.core.CommandDispatcher;
import org.apache.fineract.infrastructure.core.service.Page;
import org.apache.fineract.infrastructure.core.service.SearchParameters;
import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
import org.apache.fineract.portfolio.account.command.AccountTransferCreateCommand;
import org.apache.fineract.portfolio.account.command.AccountTransferRefundByTransferCommand;
import org.apache.fineract.portfolio.account.data.AccountTransferCreateRequest;
import org.apache.fineract.portfolio.account.data.AccountTransferCreateResponse;
import org.apache.fineract.portfolio.account.data.AccountTransferData;
import org.apache.fineract.portfolio.account.data.request.AccountTransSearchParam;
import org.apache.fineract.portfolio.account.data.request.AccountTransferRequest;
Expand All @@ -56,9 +57,8 @@
public class AccountTransfersApiResource {

private final PlatformSecurityContext context;
private final DefaultToApiJsonSerializer<AccountTransferData> toApiJsonSerializer;
private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService;
private final AccountTransfersReadPlatformService accountTransfersReadPlatformService;
private final CommandDispatcher dispatcher;

@GET
@Path("template")
Expand All @@ -70,7 +70,6 @@ public class AccountTransfersApiResource {
+ "accounttransfers/template?fromClientId=1&fromAccountType=2&fromAccountId=1")
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = AccountTransfersApiResourceSwagger.GetAccountTransfersTemplateResponse.class)))
public AccountTransferData template(@BeanParam AccountTransSearchParam accountTransSearchParam) {

context.authenticatedUser().validateHasReadPermission(AccountTransfersApiConstants.ACCOUNT_TRANSFER_RESOURCE_NAME);

return accountTransfersReadPlatformService.retrieveTemplate(accountTransSearchParam.getFromAccountId(),
Expand All @@ -86,11 +85,10 @@ public AccountTransferData template(@BeanParam AccountTransSearchParam accountTr
@Operation(summary = "Create new Transfer", operationId = "createAccountTransfer", description = "Ability to create new transfer of monetary funds from one account to another.")
@RequestBody(required = true, content = @Content(schema = @Schema(implementation = AccountTransferRequest.class)))
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = AccountTransfersApiResourceSwagger.PostAccountTransfersResponse.class)))
public CommandProcessingResult create(@Parameter(hidden = true) AccountTransferRequest accountTransferRequest) {
final CommandWrapper commandRequest = new CommandWrapperBuilder().createAccountTransfer()
.withJson(toApiJsonSerializer.serialize(accountTransferRequest)).build();

return commandsSourceWritePlatformService.logCommandSource(commandRequest);
public AccountTransferCreateResponse create(@Parameter(hidden = true) @Valid AccountTransferCreateRequest request) {
final var command = new AccountTransferCreateCommand();
command.setPayload(request);
return (AccountTransferCreateResponse) dispatcher.dispatch(command).get();
}

@GET
Expand All @@ -104,9 +102,7 @@ public Page<AccountTransferData> retrieveAll(@QueryParam("externalId") @Paramete
@QueryParam("orderBy") @Parameter(description = "orderBy") final String orderBy,
@QueryParam("sortOrder") @Parameter(description = "sortOrder") final String sortOrder,
@QueryParam("accountDetailId") @Parameter(description = "accountDetailId") final Long accountDetailId) {

context.authenticatedUser().validateHasReadPermission(AccountTransfersApiConstants.ACCOUNT_TRANSFER_RESOURCE_NAME);

final SearchParameters searchParameters = SearchParameters.builder().limit(limit).externalId(externalId).offset(offset)
.orderBy(orderBy).sortOrder(sortOrder).build();

Expand All @@ -121,6 +117,7 @@ public Page<AccountTransferData> retrieveAll(@QueryParam("externalId") @Paramete
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = AccountTransfersApiResourceSwagger.GetAccountTransfersResponse.GetAccountTransfersPageItems.class)))
public AccountTransferData retrieveOne(@PathParam("transferId") @Parameter(description = "transferId") final Long transferId) {
context.authenticatedUser().validateHasReadPermission(AccountTransfersApiConstants.ACCOUNT_TRANSFER_RESOURCE_NAME);

return accountTransfersReadPlatformService.retrieveOne(transferId);
}

Expand All @@ -133,6 +130,7 @@ public AccountTransferData retrieveOne(@PathParam("transferId") @Parameter(descr
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = AccountTransfersApiResourceSwagger.GetAccountTransfersTemplateRefundByTransferResponse.class)))
public AccountTransferData templateRefundByTransfer(@BeanParam AccountTransSearchParam accountTransSearchParam) {
context.authenticatedUser().validateHasReadPermission(AccountTransfersApiConstants.ACCOUNT_TRANSFER_RESOURCE_NAME);

return accountTransfersReadPlatformService.retrieveRefundByTransferTemplate(accountTransSearchParam.getFromAccountId(),
accountTransSearchParam.getFromClientId(), accountTransSearchParam.getFromAccountId(),
accountTransSearchParam.getFromAccountType(), accountTransSearchParam.getToOfficeId(),
Expand All @@ -147,9 +145,10 @@ public AccountTransferData templateRefundByTransfer(@BeanParam AccountTransSearc
@Operation(summary = "Refund of an Active Loan by Transfer", operationId = "refundByTransfer", description = "Ability to refund an active loan by transferring to a savings account.")
@RequestBody(required = true, content = @Content(schema = @Schema(implementation = AccountTransferRequest.class)))
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = AccountTransfersApiResourceSwagger.PostAccountTransfersRefundByTransferResponse.class)))
public CommandProcessingResult templateRefundByTransferPost(@Parameter(hidden = true) AccountTransferRequest accountTransferRequest) {
final CommandWrapper commandRequest = new CommandWrapperBuilder().refundByTransfer()
.withJson(toApiJsonSerializer.serialize(accountTransferRequest)).build();
return commandsSourceWritePlatformService.logCommandSource(commandRequest);
public AccountTransferCreateResponse templateRefundByTransferPost(@Parameter(hidden = true) AccountTransferCreateRequest request) {
final var command = new AccountTransferRefundByTransferCommand();
command.setPayload(request);

return (AccountTransferCreateResponse) dispatcher.dispatch(command).get();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import jakarta.ws.rs.BeanParam;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.GET;
Expand All @@ -37,27 +38,27 @@
import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.UriInfo;
import java.time.LocalDate;
import java.util.Arrays;
import java.util.Map;
import java.util.Set;
import lombok.RequiredArgsConstructor;
import org.apache.fineract.batch.command.CommandHandlerRegistry;
import org.apache.fineract.commands.domain.CommandWrapper;
import org.apache.fineract.commands.service.CommandWrapperBuilder;
import org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService;
import org.apache.fineract.command.core.CommandDispatcher;
import org.apache.fineract.infrastructure.core.api.ApiParameterHelper;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
import org.apache.fineract.infrastructure.core.exception.UnrecognizedQueryParamException;
import org.apache.fineract.infrastructure.core.serialization.DefaultToApiJsonSerializer;
import org.apache.fineract.infrastructure.core.service.CommandParameterUtil;
import org.apache.fineract.infrastructure.core.service.Page;
import org.apache.fineract.infrastructure.core.service.SearchParameters;
import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
import org.apache.fineract.infrastructure.security.service.SqlValidator;
import org.apache.fineract.portfolio.account.command.StandingInstructionCreateCommand;
import org.apache.fineract.portfolio.account.command.StandingInstructionDeleteCommand;
import org.apache.fineract.portfolio.account.command.StandingInstructionUpdateCommand;
import org.apache.fineract.portfolio.account.data.AccountTransferData;
import org.apache.fineract.portfolio.account.data.StandingInstructionCreateRequest;
import org.apache.fineract.portfolio.account.data.StandingInstructionCreateResponse;
import org.apache.fineract.portfolio.account.data.StandingInstructionDTO;
import org.apache.fineract.portfolio.account.data.StandingInstructionData;
import org.apache.fineract.portfolio.account.data.StandingInstructionDeleteRequest;
import org.apache.fineract.portfolio.account.data.StandingInstructionUpdateRequest;
import org.apache.fineract.portfolio.account.data.StandingInstructionUpdateResponse;
import org.apache.fineract.portfolio.account.data.request.StandingInstructionCreationRequest;
import org.apache.fineract.portfolio.account.data.request.StandingInstructionSearchParam;
import org.apache.fineract.portfolio.account.data.request.StandingInstructionUpdatesRequest;
Expand All @@ -73,17 +74,10 @@
public class StandingInstructionApiResource {

private final PlatformSecurityContext context;
private final DefaultToApiJsonSerializer<StandingInstructionData> toApiJsonSerializer;
private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService;
private final StandingInstructionReadPlatformService standingInstructionReadPlatformService;
private final AccountTransfersReadPlatformService accountTransfersReadPlatformService;
private final SqlValidator sqlValidator;

private static final CommandHandlerRegistry<String, Long, String, CommandWrapper> COMMAND_HANDLER_REGISTRY = new CommandHandlerRegistry<>(
Map.of(CommandParameterUtil.UPDATE_COMMAND_VALUE,
(id, json) -> new CommandWrapperBuilder().updateStandingInstruction(id).withJson(json).build(),
CommandParameterUtil.DELETE_COMMAND_VALUE,
(id, json) -> new CommandWrapperBuilder().deleteStandingInstruction(id).withJson(json).build()));
private final CommandDispatcher dispatcher;

@GET
@Path("template")
Expand All @@ -110,11 +104,11 @@ public StandingInstructionData template(@BeanParam StandingInstructionSearchPara
@Operation(summary = "Create new Standing Instruction", operationId = "createStandingInstruction", description = "Ability to create new instruction for transfer of monetary funds from one account to another")
@RequestBody(required = true, content = @Content(schema = @Schema(implementation = StandingInstructionCreationRequest.class)))
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = StandingInstructionApiResourceSwagger.PostStandingInstructionsResponse.class)))
public CommandProcessingResult create(@Parameter(hidden = true) StandingInstructionCreationRequest creationRequest) {
final CommandWrapper commandRequest = new CommandWrapperBuilder().createStandingInstruction()
.withJson(toApiJsonSerializer.serialize(creationRequest)).build();
public StandingInstructionCreateResponse create(@Parameter(hidden = true) @Valid StandingInstructionCreateRequest request) {
final var command = new StandingInstructionCreateCommand();
command.setPayload(request);

return commandsSourceWritePlatformService.logCommandSource(commandRequest);
return (StandingInstructionCreateResponse) dispatcher.dispatch(command).get();
}

@PUT
Expand All @@ -127,16 +121,24 @@ public CommandProcessingResult create(@Parameter(hidden = true) StandingInstruct
+ "PUT https://DomainName/api/v1/standinginstructions/1?command=delete")
@RequestBody(content = @Content(schema = @Schema(implementation = StandingInstructionUpdatesRequest.class)))
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = StandingInstructionApiResourceSwagger.PutStandingInstructionsStandingInstructionIdResponse.class)))
public CommandProcessingResult update(
public StandingInstructionUpdateResponse update(
@PathParam("standingInstructionId") @Parameter(description = "standingInstructionId") final Long standingInstructionId,
@Parameter(hidden = true) StandingInstructionUpdatesRequest updatesRequest,
@Parameter(hidden = true) StandingInstructionUpdateRequest updateRequest,
@QueryParam("command") @Parameter(description = "command") final String commandParam) {

final String serializedUpdatesRequest = toApiJsonSerializer.serialize(updatesRequest);
final CommandWrapper commandRequest = COMMAND_HANDLER_REGISTRY.execute(commandParam, standingInstructionId,
serializedUpdatesRequest, new UnrecognizedQueryParamException("command", commandParam));
if ("update".equals(commandParam)) {
updateRequest.setId(standingInstructionId);
final var command = new StandingInstructionUpdateCommand();
command.setPayload(updateRequest);

return (StandingInstructionUpdateResponse) dispatcher.dispatch(command).get();
} else if ("delete".equals(commandParam)) {
final var command = new StandingInstructionDeleteCommand();
command.setPayload(StandingInstructionDeleteRequest.builder().id(standingInstructionId).build());

return commandsSourceWritePlatformService.logCommandSource(commandRequest);
return (StandingInstructionUpdateResponse) dispatcher.dispatch(command).get();
}
throw new UnrecognizedQueryParamException("command", commandParam);
}

@GET
Expand All @@ -155,7 +157,6 @@ public Page<StandingInstructionData> retrieveAll(
@QueryParam("clientId") @Parameter(description = "clientId") final Long clientId,
@QueryParam("fromAccountId") @Parameter(description = "fromAccountId") final Long fromAccount,
@QueryParam("fromAccountType") @Parameter(description = "fromAccountType") final Integer fromAccountType) {

context.authenticatedUser().validateHasReadPermission(StandingInstructionApiConstants.STANDING_INSTRUCTION_RESOURCE_NAME);

sqlValidator.validate(orderBy);
Expand All @@ -164,10 +165,8 @@ public Page<StandingInstructionData> retrieveAll(
final SearchParameters searchParameters = SearchParameters.builder().limit(limit).externalId(externalId).offset(offset)
.orderBy(orderBy).sortOrder(sortOrder).build();

final LocalDate startDateRange = null;
final LocalDate endDateRange = null;
StandingInstructionDTO standingInstructionDTO = new StandingInstructionDTO(searchParameters, transferType, clientName, clientId,
fromAccount, fromAccountType, startDateRange, endDateRange);
final StandingInstructionDTO standingInstructionDTO = new StandingInstructionDTO(searchParameters, transferType, clientName,
clientId, fromAccount, fromAccountType, null, null);

return standingInstructionReadPlatformService.retrieveAll(standingInstructionDTO);
}
Expand All @@ -185,7 +184,6 @@ public StandingInstructionData retrieveOne(
@QueryParam("limit") @Parameter(description = "limit") final Integer limit,
@QueryParam("orderBy") @Parameter(description = "orderBy") final String orderBy,
@QueryParam("sortOrder") @Parameter(description = "sortOrder") final String sortOrder) {

context.authenticatedUser().validateHasReadPermission(StandingInstructionApiConstants.STANDING_INSTRUCTION_RESOURCE_NAME);

sqlValidator.validate(orderBy);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ public Page<StandingInstructionHistoryData> retrieveAll(
@QueryParam("dateFormat") @Parameter(description = "dateFormat") final String rawDateFormat,
@QueryParam("fromDate") @Parameter(description = "fromDate") final DateParam fromDateParam,
@QueryParam("toDate") @Parameter(description = "toDate") final DateParam toDateParam) {

this.context.authenticatedUser().validateHasReadPermission(StandingInstructionApiConstants.STANDING_INSTRUCTION_RESOURCE_NAME);

final DateFormat dateFormat = StringUtils.isBlank(rawDateFormat) ? null : new DateFormat(rawDateFormat);
Expand All @@ -93,8 +92,8 @@ public Page<StandingInstructionHistoryData> retrieveAll(
endDateRange = toDateParam.getDate("toDate", dateFormat, locale);
}

StandingInstructionDTO standingInstructionDTO = new StandingInstructionDTO(searchParameters, transferType, clientName, clientId,
fromAccount, fromAccountType, startDateRange, endDateRange);
final StandingInstructionDTO standingInstructionDTO = new StandingInstructionDTO(searchParameters, transferType, clientName,
clientId, fromAccount, fromAccountType, startDateRange, endDateRange);

return standingInstructionHistoryReadPlatformService.retrieveAll(standingInstructionDTO);
}
Expand Down
Loading
Loading