Skip to content

feat: Migrate COBOL codebase to Java Spring Boot application#82

Open
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin/1777491010-cobol-to-java-migration
Open

feat: Migrate COBOL codebase to Java Spring Boot application#82
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin/1777491010-cobol-to-java-migration

Conversation

@devin-ai-integration
Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot commented Apr 29, 2026

Summary

Migrates the ~18 COBOL example modules to a Java Spring Boot application under a new java-migration/ directory. The original COBOL code is preserved for side-by-side comparison.

What's included

Project Setup (Phase 1)

  • Maven-based Spring Boot 3.2.5 project with Spring Web, Data JPA, Validation, Flyway, Jackson XML, JAXB, and Apache POI

Data Layer (Phase 2)

  • Account JPA entity mapping the COBOL ws-sql-account-record (sql/sql_example.cbl lines 44-52) with field sizes matching PIC clauses
  • AccountRepository with Spring Data JPA query methods replacing the three COBOL cursors: ACCOUNT-ALL-CUR, ACCOUNT-DISABLED-CUR, ACCOUNT-QUERY-CUR
  • Flyway migration V1__create_accounts_table.sql derived from sql/create_test_db.sql
  • GlobalExceptionHandler (@RestControllerAdvice) replacing the check-sql-state paragraph

Service Layer (Phase 3)

  • AccountService encapsulating business logic from the COBOL procedure division (display-all-accounts, display-disabled-accounts, query-accounts)
  • SerializationService replacing JSON GENERATE and XML GENERATE with Jackson and JAXB
  • ReportService replacing COBOL Report Writer (RD, PAGE LIMIT, HEADING, DETAIL, FOOTING)
  • StringUtils utility class replacing COBOL intrinsics: TRIM, UNSTRING, IS NUMERIC, NUMVAL

DTOs (Phase 3)

  • JsonRecord with @JsonProperty annotations matching COBOL NAME OF mappings and @JsonInclude(NON_EMPTY) for SUPPRESS WHEN SPACES
  • XmlRecord with @XmlAttribute for TYPE OF ... IS ATTRIBUTE and null suppression for SUPPRESS WHEN SPACES
  • SearchItem with Comparable for SEARCH ALL binary search (ascending key pattern)

REST API (Phase 4)

  • AccountController: GET /api/accounts, GET /api/accounts/disabled, GET /api/accounts/search?q={value} — replacing the terminal menu system
  • DemoController: GET /api/demo/json, GET /api/demo/xml, GET /api/demo/report, GET /api/demo/search, GET /api/demo/args — demonstrating non-SQL module equivalents

Configuration (Phase 4)

  • application.properties with PostgreSQL connection details matching the COBOL connection string (localhost:5432/cobol_db_example)

Tests (Phase 5)

  • 41 passing tests across 5 test classes: AccountRepositoryTest (9 integration tests with H2), AccountServiceTest (5 unit tests), AccountControllerTest (4 web layer tests), SerializationServiceTest (7 tests), StringUtilsTest (17 tests)

COBOL-to-Java Mapping Summary

COBOL Module Java Equivalent
sql/sql_example.cbl (cursors, menu, check-sql-state) Account entity/repo/service/controller + GlobalExceptionHandler
json_generate/json_generate.cbl JsonRecord + SerializationService + DemoController
xml_generate/xml_generate.cbl XmlRecord + SerializationService + DemoController
report_writer/report_test.cbl ReportService + DemoController
search/search.cbl (SEARCH ALL) SearchItem + Collections.binarySearch()
sub_program/main_app.cbl (CALL BY CONTENT/REFERENCE) Spring service injection
unstring/, trim/, is_numeric/, numval_test/ StringUtils
comp_test/ (COMP/COMP-5) Native Java int/long
redifines/ (REDEFINES) Separate DTO classes
merge_sort/ (MERGE/SORT) Collections.sort() / SQL ORDER BY
read_command_args/ DemoController /api/demo/args endpoint

Review & Testing Checklist for Human

  • Verify AccountRepository.searchAccounts() LIKE query produces same results as the COBOL ACCOUNT-QUERY-CUR cursor with trimmed/wildcarded input
  • Confirm XmlRecord JAXB output matches the COBOL XML GENERATE structure (enabled as attribute, blank suppressed)
  • Check that the Flyway migration script matches your actual PostgreSQL schema and test data
  • Run mvn test locally to verify all 41 tests pass in your environment
  • Start the Spring Boot app against a real PostgreSQL instance and test the REST endpoints

Notes

  • The project uses Java 17 as the target (compatible with Java 21+ runtime)
  • H2 in-memory database is used for tests; production targets PostgreSQL
  • Added **/target/ to .gitignore to exclude Maven build artifacts

Link to Devin session: https://app.devin.ai/sessions/d18c2fba88af44dbb6e71e5957afb870
Requested by: @jerryoliphant-cog


Devin Review

Status Commit
⚪ Not started

💡 Connect your GitHub account to enable automatic code reviews.

Open in Devin Review (Staging)

Create java-migration/ directory with full Spring Boot project:

- Entity: Account JPA entity mapping COBOL ws-sql-account-record
- Repository: AccountRepository with Spring Data JPA methods replacing
  ACCOUNT-ALL-CUR, ACCOUNT-DISABLED-CUR, and ACCOUNT-QUERY-CUR cursors
- Services: AccountService, SerializationService, ReportService
- Controllers: AccountController (REST API replacing terminal menu),
  DemoController (JSON/XML/report/search/CLI arg demos)
- DTOs: JsonRecord, XmlRecord, SearchItem
- Utilities: StringUtils replacing COBOL TRIM, UNSTRING, IS NUMERIC, NUMVAL
- Config: AppConfig with GlobalExceptionHandler replacing check-sql-state
- Flyway migration: V1__create_accounts_table.sql from create_test_db.sql
- Tests: 41 passing tests covering repository, service, controller,
  serialization, and string utility layers
- application.properties configured for PostgreSQL localhost:5432/cobol_db_example

Original COBOL code preserved for side-by-side comparison.

Co-Authored-By: Jerry Oliphant <jerry.oliphant@cognition.ai>
@devin-ai-integration
Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

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.

0 participants