0% found this document useful (0 votes)
10 views4 pages

COBOL to Java Conversion Design Document

This design document outlines the process for converting COBOL code to Java using AI, detailing UI modifications, license validation, API integration, and response handling. It emphasizes user interaction, error management, and the creation of Java files from the converted code, while also addressing testing and future considerations for improving the conversion accuracy. The document aims to enhance user experience and streamline the conversion process through effective UI and backend communication.

Uploaded by

pankaj bachhav
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views4 pages

COBOL to Java Conversion Design Document

This design document outlines the process for converting COBOL code to Java using AI, detailing UI modifications, license validation, API integration, and response handling. It emphasizes user interaction, error management, and the creation of Java files from the converted code, while also addressing testing and future considerations for improving the conversion accuracy. The document aims to enhance user experience and streamline the conversion process through effective UI and backend communication.

Uploaded by

pankaj bachhav
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Design Document: COBOL to Java Code

Conversion using AI

1. Overview
This design outlines the steps for implementing the conversion of COBOL code to Java using
Artificial Intelligence (AI). The conversion process will involve multiple stages, from UI
integration to backend API calls, and validation of the AI-generated Java code. This design
focuses on user interaction, API communication, and handling of the conversion results.

2. User Interface (UI) Modifications


2.1 New UI Options

To enable the COBOL-to-Java conversion, we need to add two specific UI options:

 Option 1: Add a context menu item in the Project Explorer under the "Code Insights Extract"
folder. This option will be available when the user right-clicks on an extracted COBOL program.
 Option 2: Add an option within the extract dialog, enabling users to initiate the conversion from
this interface.

These additions will allow users to easily trigger the conversion process from the main UI.

3. License Validation
3.1 License Check

Before proceeding with the conversion, we must ensure that the user has a valid license for the
AI service.

 Action: When the user selects the COBOL-to-Java conversion option, check if the license is valid.
 Invalid License: If the license is not valid, display an error message to the user and prompt them
to update their settings, specifically to provide the correct CES URL or AI Token in the
preferences dialog.
4. Request Construction and API Integration
4.1 API Request Setup

Once the license is validated, the next step is to send a conversion request to the AI backend. The
request will be a POST method, with the following key details:

 Endpoint: /code/conversion/snippet
 Content-Type: application/json
 Authorization: Bearer Token
 Request Payload:
o code_snippet: (String) The COBOL code snippet to be converted.
o source_language: (String) Always set to 'COBOL'.
o target_language: (String) Always set to 'JAVA'.
o request_type: (String) Can be either 'new' or 'regen' depending on whether it’s a
fresh conversion or a re-generation of a previous conversion.
o source: (Optional) The product or module initiating the request (e.g., "WB", "VS code").

4.2 File Content Extraction

To generate the request, we need to extract the relevant COBOL code from the user’s selected
file.

 Action: Check if the COBOL areas are locked or unlocked and get the contents of the file based
on the areas.
 File Trimming: Confirm with the AI team whether we need to trim the COBOL code before
sending the request (i.e., remove sequence/identity area tags, comments, or any unnecessary
metadata). If no trimming is required, send the file as-is.

4.3 File Size Validation

If the COBOL file contains more than 20,000 lines, it may affect performance.

 Action: Consider adding a validation step to warn the user about large files. Display a message
asking if they still wish to proceed with the conversion.
5. API Response Handling
5.1 Response Classes

Once the request is sent, we will receive a response containing the converted Java code. We need
to define appropriate response classes to parse this data.

 Action: Create response classes that can handle the conversion output, and check for errors or
warnings.

5.2 Error Handling

Validate the response for correctness:

 Action: Check if the conversion was successful and if the returned Java code is valid.
 If the response is invalid, handle errors gracefully by displaying appropriate messages to the user
and allowing them to retry.

6. Generating the Java File


6.1 Creating Java File

Once the response contains the converted Java code:

 Action: Create a new Java file.


 Content: Populate this file with the converted code from the AI response.

The new Java file should be saved in the appropriate project directory for the user to access and
review.

7. Testing and Validation


7.1 Testing Conversion Accuracy

To ensure the accuracy of the conversion, the system will need thorough testing using various
COBOL code snippets of different complexities. This includes testing edge cases like large files,
legacy code, and non-standard COBOL constructs.

7.2 User Experience Feedback

Collect feedback from users on the conversion results, as well as the overall process, to identify
potential areas for improvement in the UI and conversion logic.

8. Future Considerations
 AI Model Updates: Ensure the AI model can be updated periodically to improve
conversion accuracy and handle newer versions of COBOL.
 Customization: Explore the possibility of allowing users to configure the conversion
logic or modify certain code patterns after conversion.

You might also like