taskain7 commented on code in PR #2777: URL: https://github.com/apache/fineract/pull/2777#discussion_r1068752548
########## fineract-provider/src/main/java/org/apache/fineract/cob/api/LoanCOBCatchUpApiResource.java: ########## @@ -0,0 +1,73 @@ +/** + * 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.cob.api; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.tags.Tag; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import lombok.RequiredArgsConstructor; +import org.apache.fineract.cob.data.OldestCOBProcessedLoanDTO; +import org.apache.fineract.cob.service.LoanCOBCatchUpService; +import org.apache.fineract.infrastructure.core.serialization.DefaultToApiJsonSerializer; +import org.springframework.stereotype.Component; + +@Path("/loans") +@Component +@Tag(name = "Loan COB Catch Up", description = "") +@RequiredArgsConstructor +public class LoanCOBCatchUpApiResource { + + private final DefaultToApiJsonSerializer<OldestCOBProcessedLoanDTO> oldestCOBProcessedLoanSerializeService; + private final LoanCOBCatchUpService loanCOBCatchUpService; + + @GET + @Path("oldest_cob_processed_loan") + @Consumes({ MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_JSON }) + @Operation(summary = "Retrieves the oldest COB processed loan", description = "Retrieves the COB business date and the oldest COB processed loan") + @ApiResponses({ + @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = LoanCOBCatchUpApiResourceSwagger.GetOldestCOBProcessedLoanResponse.class))) }) + public String getOldestCOBProcessedLoan() { + OldestCOBProcessedLoanDTO response = loanCOBCatchUpService.getOldestCOBProcessedLoan(); + + return oldestCOBProcessedLoanSerializeService.serialize(response); + } + + @POST + @Path("loan_cob_catch_up") + @Consumes({ MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_JSON }) + @Operation(summary = "Executes Loan COB Catch Up", description = "Executes the Loan COB job on every day from the oldest Loan to the current COB business date") + @ApiResponses({ @ApiResponse(responseCode = "200", description = "OK") }) + public Response executeLoanCOBCatchUp() { + loanCOBCatchUpService.executeLoanCOBCatchUp(); + + return Response.status(202).build(); Review Comment: We decided to not returning any ID, since we will have multiple Spring Batch Execution IDs, instead of it we will introduce a new API that can tell whether the catch up is running or not -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
