Skip to content

FINERACT-2493: New command processing - job scheduling#5903

Open
nidhiii128 wants to merge 1 commit into
apache:developfrom
nidhiii128:FINERACT-2493-update-job
Open

FINERACT-2493: New command processing - job scheduling#5903
nidhiii128 wants to merge 1 commit into
apache:developfrom
nidhiii128:FINERACT-2493-update-job

Conversation

@nidhiii128
Copy link
Copy Markdown
Contributor

@nidhiii128 nidhiii128 commented May 28, 2026

Description

Migrates the "update job" REST endpoint (by jobId) from the legacy command-processing path to the new fineract-command framework.

Scope (PR 1 of 2 for FINERACT-2493)

  • New typed UpdateJobRequest / UpdateJobResponse POJOs with Jakarta Validation
  • New UpdateJobCommand and UpdateJobCommandHandler using CommandHandler<REQ, RES>
  • SchedularWritePlatformService.updateJobDetail signature changed to accept typed request
  • Change-detection logic moved from entity into service (per Aleks's guidance)
  • Hand-written JobDetailDataValidator no longer called, replaced by @AssertTrue annotations
  • Backward-compatible: existing integration tests pass unchanged

Not in this PR

  • "Update job by short-name" - deferred pending Aleks's guidance on where short-name resolution should live
  • "Execute job" migration - separate follow-up PR

Checklist

Please make sure these boxes are checked before submitting your pull request - thanks!

  • Write the commit message as per our guidelines
  • Acknowledge that we will not review PRs that are not passing the build ("green") - it is your responsibility to get a proposed PR to pass the build, not primarily the project's maintainers.
  • Create/update unit or integration tests for verifying the changes made.
  • Follow our coding conventions.
  • Add required Swagger annotation and update API documentation at fineract-provider/src/main/resources/static/legacy-docs/apiLive.htm with details of any API changes
  • This PR must not be a "code dump". Large changes can be made in a branch, with assistance. Ask for help on the developer mailing list.

Your assigned reviewer(s) will follow our guidelines for code reviews.

@nidhiii128 nidhiii128 force-pushed the FINERACT-2493-update-job branch from 52322d5 to 9851afe Compare May 29, 2026 10:01
@Aman-Mittal
Copy link
Copy Markdown
Member

@nidhiii128 Fix that failing checks.

@nidhiii128 nidhiii128 force-pushed the FINERACT-2493-update-job branch from 9851afe to a1278c6 Compare May 31, 2026 05:28
@nidhiii128 nidhiii128 force-pushed the FINERACT-2493-update-job branch from a1278c6 to 28d0073 Compare May 31, 2026 05:52
@Aman-Mittal Aman-Mittal requested a review from vidakovic May 31, 2026 07:01
@Aman-Mittal
Copy link
Copy Markdown
Member

@vidakovic please review

@Aman-Mittal Aman-Mittal requested a review from budaidev May 31, 2026 07:01
import org.apache.fineract.client.models.ExecuteJobRequest;
import org.apache.fineract.client.models.GetJobsResponse;
import org.apache.fineract.client.models.PutJobsJobIDRequest;
import org.apache.fineract.client.models.UpdateJobRequest;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep the following pattern for the DTOs (aka request/response classes):

[Domain] + [Action] + [Suffix]

... in this case...

JobUpdateRequest

There are and will be a lot of "Update" commands in the code base... with the proposed naming pattern you will immediately see the relevant classes while typing instead listing half of the classes available in the entire system.

@Consumes(MediaType.APPLICATION_JSON)
@Operation(summary = "Update a Job", description = "Updates the details of a job.")
@RequestBody(required = true, content = @Content(schema = @Schema(implementation = SchedulerJobApiResourceSwagger.PutJobsJobIDRequest.class)))
@ApiResponse(responseCode = "200", description = "OK")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This annotation is trivial. HTTP 200 is the normal case, don't have to indicate explicitly (I know, we've done that in a lot of places... but let's avoid code if we don't really need it). Please remove. Note: the API compatibility plugin will indicate a backwards incompatible change... ignore it, not an error.

public String updateJobDetail(@PathParam(SchedulerJobApiConstants.JOB_ID) @Parameter(description = "jobId") final Long jobId,
@Parameter(hidden = true) final String jsonRequestBody) {
return updateJobDetail(IdTypeResolver.resolveDefault(), Objects.toString(jobId, null), jsonRequestBody);
public UpdateJobResponse updateJobDetail(@PathParam("jobId") Long jobId, UpdateJobRequest request) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above comment about naming request/response.

@Data
@NoArgsConstructor
@AllArgsConstructor
public class UpdateJobResponse implements Serializable {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming pattern.

@Slf4j
@Component
@RequiredArgsConstructor
public class UpdateJobCommandHandler implements CommandHandler<UpdateJobRequest, UpdateJobResponse> {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming pattern:

[Domain] + [Action] + "CommandHandler"

... in this case...

JobUpdateCommandHandler

@@ -39,7 +39,7 @@ public interface SchedularWritePlatformService {

ScheduledJobDetail findByJobId(Long jobId);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this belong in a "read" service?

CommandProcessingResult updateJobDetail(Long jobId, JsonCommand command);
UpdateJobResponse updateJobDetail(UpdateJobRequest request);

SchedulerDetail retriveSchedulerDetail();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this belong in a "read" service? Also: typo. "retrive" vs "retrieve".

private final JobDetailDataValidator dataValidator;

@Autowired
public SchedularWritePlatformServiceJpaRepositoryImpl(final ScheduledJobDetailRepository scheduledJobDetailsRepository,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use of "@Autowired" is deprecated and not necessary anymore. Let's use Lombok "@requiredargsconstructor" then we can avoid the constructor boilerplate code.

}

public void updateSchedulerJob(long jobId, PutJobsJobIDRequest request) {
public void updateSchedulerJob(long jobId, UpdateJobRequest request) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not adding "jobId" to the request object? Having multiple parameters in a function signature makes it over time brittle. If you only have the request object as input parameter and tomorrow you add a new attribute to it then the function stays the same doesn't trigger a refactoring fest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants