Skip to content

feat(batch): assemble csvImportStep and csvToJpaJob + run endpoint#54

Merged
kev405 merged 1 commit intomasterfrom
feature/F3-10-step-and-job-assembly
Aug 16, 2025
Merged

feat(batch): assemble csvImportStep and csvToJpaJob + run endpoint#54
kev405 merged 1 commit intomasterfrom
feature/F3-10-step-and-job-assembly

Conversation

@kev405
Copy link
Copy Markdown
Owner

@kev405 kev405 commented Aug 16, 2025

No description provided.

@kev405 kev405 requested a review from Copilot August 16, 2025 07:16
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements the end-to-end CSV to JPA batch job processing system, assembling the previously built components into a complete working solution. The implementation includes the job configuration, step configuration, a REST endpoint for job execution, and comprehensive end-to-end testing.

Key changes:

  • Assembles the CSV import step and job with proper dependency injection and parameter validation
  • Adds a REST controller for executing the batch job with configurable parameters
  • Implements comprehensive E2E testing using Testcontainers and PostgreSQL
  • Updates database schema and configuration for batch processing support

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
CsvToJpaJobConfig.java Defines the main batch job with listeners, validators, and incrementers
CsvImportStepConfig.java Configures the chunk-oriented step with reader, processor, and writer
JobRunController.java REST endpoint for triggering batch job execution
CsvToJpaJobE2ETest.java End-to-end test with Testcontainers and PostgreSQL
ImportRecordProcessor.java Adds default constructor for @StepScope compatibility
V2__batch_schema.sql Updates Spring Batch schema to newer format
V4__create_import_errors.sql Creates table for tracking import errors
application.yml & application-test.yml Adds batch configuration properties
README.md Comprehensive documentation of the implementation

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

.addString("storagePath", req.storagePath())
.addString("delimiter", req.delimiter() == null ? "," : req.delimiter())
.addLong("chunkSize", req.chunkSize() == null ? 500L : req.chunkSize().longValue())
.addString("requestTime", (req.requestTime() == null ? Instant.now() : req.requestTime()).toString())
Copy link

Copilot AI Aug 16, 2025

Choose a reason for hiding this comment

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

Converting Instant to String for job parameters may cause issues with date parsing and timezone handling. Consider using .addDate() with Date.from() or keeping it as a proper temporal type for better type safety.

Suggested change
.addString("requestTime", (req.requestTime() == null ? Instant.now() : req.requestTime()).toString())
.addDate("requestTime", Date.from(req.requestTime() == null ? Instant.now() : req.requestTime()))

Copilot uses AI. Check for mistakes.
--

CREATE TABLE BATCH_JOB_INSTANCE (
-- V0__spring_batch_metadata_v5.sql (ESQUEMA NUEVO)
Copy link

Copilot AI Aug 16, 2025

Choose a reason for hiding this comment

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

The comment references 'V0__spring_batch_metadata_v5.sql' but this file is named 'V2__batch_schema.sql'. This inconsistency could cause confusion about file versioning.

Suggested change
-- V0__spring_batch_metadata_v5.sql (ESQUEMA NUEVO)
-- V2__batch_schema.sql (ESQUEMA NUEVO)

Copilot uses AI. Check for mistakes.
row_num BIGINT NULL,
external_id VARCHAR(128) NULL,
reason TEXT NOT NULL,
raw_line TEXT NULL,
Copy link

Copilot AI Aug 16, 2025

Choose a reason for hiding this comment

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

[nitpick] The column alignment is inconsistent with the other columns above. All other columns have proper spacing alignment while 'reason' has extra spaces.

Suggested change
raw_line TEXT NULL,
reason TEXT NOT NULL,
raw_line TEXT NULL,

Copilot uses AI. Check for mistakes.
properties = {
"spring.batch.job.enabled=false",
"spring.flyway.enabled=true",
"spring.flyway.locations=classpath:db/migration", // solo tus tablas de negocio
Copy link

Copilot AI Aug 16, 2025

Choose a reason for hiding this comment

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

The Spanish comment 'solo tus tablas de negocio' should be in English to maintain consistency with the codebase language. Consider translating to 'only business tables' or similar.

Suggested change
"spring.flyway.locations=classpath:db/migration", // solo tus tablas de negocio
"spring.flyway.locations=classpath:db/migration", // only business tables

Copilot uses AI. Check for mistakes.
"spring.batch.job.enabled=false",
"spring.flyway.enabled=true",
"spring.flyway.locations=classpath:db/migration", // solo tus tablas de negocio
"spring.batch.jdbc.initialize-schema=never", // lo hacemos manual
Copy link

Copilot AI Aug 16, 2025

Choose a reason for hiding this comment

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

The Spanish comment 'lo hacemos manual' should be in English. Consider translating to 'we do it manually' or 'manual initialization'.

Suggested change
"spring.batch.jdbc.initialize-schema=never", // lo hacemos manual
"spring.flyway.locations=classpath:db/migration", // only your business tables
"spring.batch.jdbc.initialize-schema=never", // we do it manually

Copilot uses AI. Check for mistakes.

@BeforeAll
void initBatchSchema() {
// Drop + Create de las tablas BATCH_* correctas para PostgreSQL
Copy link

Copilot AI Aug 16, 2025

Choose a reason for hiding this comment

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

The Spanish comment should be in English. Consider translating to 'Drop + Create the correct BATCH_* tables for PostgreSQL'.

Suggested change
// Drop + Create de las tablas BATCH_* correctas para PostgreSQL
// Drop + Create the correct BATCH_* tables for PostgreSQL

Copilot uses AI. Check for mistakes.
@kev405 kev405 merged commit 47af149 into master Aug 16, 2025
2 checks passed
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.

2 participants