As part of exploring AI tools to support CA Gen modernization, I extracted the Entity Type Definitions and the ADD_DEPARTMENT action block from the standard sample model and asked an AI to generate a modern Java equivalent.
CA Gen Action Block (Original)
as a text
+- ADD_DEPARTMENT
IMPORTS: input division, input employee, import department
EXPORTS: output employee
+- READ required division WHERE number = input division number
+- WHEN not found → EXIT STATE division_nf
+- CREATE new department
| SET name, number
| ASSOCIATE with required division
+- WHEN already exists → EXIT STATE department_ae
+- IF input employee number != 0
| +- READ required employee
| +- WHEN successful
| | ASSOCIATE employee WITH new department (is_managed_by)
| | MOVE TO output employee
| +- WHEN not found → EXIT STATE employee_nf_dept
Modern Java Equivalent (Spring Boot 3 + JPA + Lombok)Key Entity
as a java
@Entity
@Table(name = "DEPARTMENT")
public class Department {
@Id
@Column(name = "NUMBER", length = 20)
private String number;
private String name;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "DIVISION_NUMBER", nullable = false)
private Division division;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "MANAGER_EMPLOYEE_NUMBER")
private Employee manager;
}
Service Method (Core Logic)
as a java
@Transactional
public AddDepartmentResponse addDepartment(AddDepartmentRequest request) {
Division division = divisionRepository.findById(request.getDivision().getNumber())
.orElseThrow(() -> new ExitStateException("division_nf", "Division not found"));
Department department = Department.builder()
.number(request.getDepartment().getNumber())
.name(request.getDepartment().getName())
.division(division)
.build();
try {
department = departmentRepository.save(department);
} catch (Exception e) {
if (e.getMessage().contains("Duplicate")) {
throw new ExitStateException("department_ae", "Department already exists");
}
}
if (isValidEmployeeNumber(request.getEmployee().getNumber())) {
Employee employee = employeeRepository.findById(request.getEmployee().getNumber())
.orElseThrow(() -> new ExitStateException("employee_nf_dept", "Employee not found"));
department.setManager(employee);
employee.setDepartment(department);
}
return buildResponse(department);
}
Results:
- High fidelity mapping of Gen concepts (Entity Views, READ/CREATE/ASSOCIATE, Exit States)
- Proper JPA relationship handling
- Clean, testable, maintainable code using current Java standards (Java 21, Spring Boot 3)
This demonstrates that AI can understand CA Gen semantics surprisingly well.