# Business Logic — JBSbatTUBmpSwchSodTrn.terminal() [15 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.business.service.JBSbatTUBmpSwchSodTrn` |
| Layer | Service (Batch) |
| Module | `service` (Package: `eo.business.service`) |

## 1. Role

### JBSbatTUBmpSwchSodTrn.terminal()

This method serves as the **business service termination handler** (業務サービス終了処理 / Service Completion Processing) for the port number change Service Order (SOD) automatic processing batch — `JBSbatTUBmpSwchSodTrn`. It is an abstract lifecycle method inherited from `JBSbatBusinessService` and is invoked automatically by the batch framework after the main processing (`execute()`) completes, regardless of success or failure. Its sole business purpose is to **release all database access resources** (SQL connections, cursors, internal buffers) that were allocated during the batch run. Specifically, it closes four `JBSbatSQLAccess` objects: two for the port number work table (`TU_T_BMP_KOJI` — primary and lock variants), one for the eo光電話 service contract table (`KK_T_SVKEIUW_EOH_TEL`), and one for the telecommunications provider master table (`TU_M_TUSHIN_JGYOSHA`). The last two were added in change ticket ANK-4494-00-00 to support bidirectional port number handling. This method implements the standard **resource cleanup pattern** used across all batch services in the eo customer core system, ensuring no DB connection leaks occur even when exceptions abort the main processing flow.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["terminal()"])
    STEP1["Close db_TU_T_BMP_KOJI"]
    STEP2["Close db_TU_T_BMP_KOJI_L"]
    STEP3["Close db_KK_T_SVKEIUW_EOH_TEL"]
    STEP4["Close db_TU_M_TUSHIN_JGYOSHA"]
    END_NODE(["Return void"])

    START --> STEP1
    STEP1 --> STEP2
    STEP2 --> STEP3
    STEP3 --> STEP4
    STEP4 --> END_NODE
```

This method performs sequential resource cleanup. There are no conditional branches, loops, or decision points. Each `close()` call on a `JBSbatSQLAccess` instance releases the underlying database cursor and connection handle, returning it to the pool.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| - | (none) | - | This method takes no parameters. It operates entirely on instance fields (DB access objects) that were initialized in the `initial()` method. |

**Instance fields read by this method:**

| Field Name | Type | Business Description |
|-----------|------|---------------------|
| `db_TU_T_BMP_KOJI` | `JBSbatSQLAccess` | Database access handle for the port number work table (`TU_T_BMP_KOJI`) — holds active records for port number change processing |
| `db_TU_T_BMP_KOJI_L` | `JBSbatSQLAccess` | Database access handle for the port number work table lock variant (`TU_T_BMP_KOJI` — lock record) — used to prevent concurrent access conflicts |
| `db_KK_T_SVKEIUW_EOH_TEL` | `JBSbatSQLAccess` | Database access handle for the eo光電話 service contract table (`KK_T_SVKEIUW_EOH_TEL`) — added in ANK-4494-00-00 for bidirectional port number support |
| `db_TU_M_TUSHIN_JGYOSHA` | `JBSbatSQLAccess` | Database access handle for the telecommunications provider master table (`TU_M_TUSHIN_JGYOSHA`) — added in ANK-4494-00-00 for provider code lookups |

## 4. CRUD Operations / Called Services

### Pre-computed evidence from code analysis graph:

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `JACbatDataBnktUtil.close` | JACbatDataBnkt | - | Calls `close` in `JACbatDataBnktUtil` |
| - | `JACbatParamUtil.close` | JACbatParam | - | Calls `close` in `JACbatParamUtil` |
| - | `JACbatSchdlUtil.close` | JACbatSchdl | - | Calls `close` in `JACbatSchdlUtil` |
| - | `JBSbatCHChangeGroupKei.close` | JBSbatCHChangeGroupKei | - | Calls `close` in `JBSbatCHChangeGroupKei` |
| - | `JBSbatKKPrcIfCommon.close` | JBSbatKKPrcIfCommon | - | Calls `close` in `JBSbatKKPrcIfCommon` |

### Method call analysis for `terminal()`:

This method contains only `close()` calls on `JBSbatSQLAccess` instances. These are framework-level resource release operations, not CRUD data operations.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `db_TU_T_BMP_KOJI.close` | - | `TU_T_BMP_KOJI` (Port Number Work Table) | Releases the SQL access cursor and connection for the port number work table |
| - | `db_TU_T_BMP_KOJI_L.close` | - | `TU_T_BMP_KOJI` (Port Number Work Table — Lock Record) | Releases the SQL access cursor and connection for the port number work table lock variant |
| - | `db_KK_T_SVKEIUW_EOH_TEL.close` | - | `KK_T_SVKEIUW_EOH_TEL` (eo光電話 Service Contract Table) | Releases the SQL access cursor and connection for the eo光電話 service contract table (added in ANK-4494-00-00) |
| - | `db_TU_M_TUSHIN_JGYOSHA.close` | - | `TU_M_TUSHIN_JGYOSHA` (Telecommunications Provider Master Table) | Releases the SQL access cursor and connection for the telecommunications provider master table (added in ANK-4494-00-00) |

## 5. Dependency Trace

The `terminal()` method is inherited as an abstract method from `JBSbatBusinessService`. It is called by the batch framework's lifecycle manager after `execute()` completes. No explicit callers reference this method in the codebase — it is invoked implicitly.

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: `JBSbatTUBmpSwchSodTrn` (framework) | `JBSbatBusinessBase.executeBatch()` → `initial(commonItem)` → `execute()` → `terminal()` | `db_TU_T_BMP_KOJI.close [R] TU_T_BMP_KOJI` |
| 2 | Batch: `JBSbatTUBmpSwchSodTrn` (framework) | `JBSbatBusinessBase.executeBatch()` → `initial(commonItem)` → `execute()` → `terminal()` | `db_TU_T_BMP_KOJI_L.close [R] TU_T_BMP_KOJI` |
| 3 | Batch: `JBSbatTUBmpSwchSodTrn` (framework) | `JBSbatBusinessBase.executeBatch()` → `initial(commonItem)` → `execute()` → `terminal()` | `db_KK_T_SVKEIUW_EOH_TEL.close [R] KK_T_SVKEIUW_EOH_TEL` |
| 4 | Batch: `JBSbatTUBmpSwchSodTrn` (framework) | `JBSbatBusinessBase.executeBatch()` → `initial(commonItem)` → `execute()` → `terminal()` | `db_TU_M_TUSHIN_JGYOSHA.close [R] TU_M_TUSHIN_JGYOSHA` |

## 6. Per-Branch Detail Blocks

### Block 1 — EXEC (Resource Cleanup) (L467)

> This is the only processing block. It is a linear sequence of `close()` calls with no conditional branches. The method contains tool-generated cleanup code (marked by comments indicating the source was auto-generated by a code generator tool).

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `db_TU_T_BMP_KOJI.close()` // Release DB access cursor — Port Number Work Table (TU_T_BMP_KOJI) [L468] |
| 2 | EXEC | `db_TU_T_BMP_KOJI_L.close()` // Release DB access cursor — Port Number Work Table Lock (TU_T_BMP_KOJI_L) [L472] |
| 3 | EXEC | `db_KK_T_SVKEIUW_EOH_TEL.close()` // Release DB access cursor — eo光電話 Service Contract Table (added in ANK-4494-00-00) [L474] |
| 4 | EXEC | `db_TU_M_TUSHIN_JGYOSHA.close()` // Release DB access cursor — Telecommunications Provider Master Table (added in ANK-4494-00-00) [L475] |

### Block 1.1 — RETURN (L477)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return;` // void method — implicit return after cleanup completes [L477] |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `TU_T_BMP_KOJI` | Table | Port Number Work Table — temporary work table holding records for port number change (番号変更) processing. "BMP" = "Banpō", "KOJI" = "Kōji" (工事/work). |
| `TU_T_BMP_KOJI_L` | Table (Variant) | Port Number Work Table Lock Record — lock table variant used to prevent concurrent access to the same port number work records during batch processing. |
| `KK_T_SVKEIUW_EOH_TEL` | Table | eo光電話 Service Contract Table — holds service contract details for eo Hikari Phone (eo光電話) lines. Added in ANK-4494-00-00 for bidirectional port number support. "SVKEIUW" = Service Contents (サービス内容). |
| `TU_M_TUSHIN_JGYOSHA` | Table | Telecommunications Provider Master Table — master data for telecommunications operators (通信事業者). Used for provider code lookups during port number change processing. |
| `terminal()` | Method | Business service termination handler — lifecycle callback invoked after main batch processing (`execute()`) completes. Responsible for resource cleanup. |
| `initial()` | Method | Business service initialization handler — lifecycle callback invoked at the start of batch processing. Initializes DB access objects and common parameters. |
| `execute()` | Method | Business service main processing handler — lifecycle callback containing the core batch logic. |
| `JBSbatBusinessService` | Class | Abstract base class for all batch business services. Defines the `initial → execute → terminal` lifecycle pattern and provides shared utility methods. |
| `JBSbatSQLAccess` | Class | Database access abstraction class wrapping SQL operations. Manages cursor lifecycle and connection pool handling. |
| `JBSbatBusinessBase` | Class | Framework-level base class that orchestrates the batch execution lifecycle. Invokes `initial()`, `execute()`, and `terminal()` in sequence. |
| ANK-4494-00-00 | Change ticket | Change ticket for bidirectional port number support in eo定期 (eo Regular) services. Added new DB access objects to `initial()` and corresponding `close()` calls in `terminal()`. |
| BMP | Abbreviation | Banpō (番号) — Port Number / Phone number |
| KOJI | Abbreviation | Kōji (工事) — Construction / Installation work |
| SOD | Acronym | Service Order Data — telecom order fulfillment data entity used to track service changes (registrations, modifications, cancellations) |
| SBT | Abbreviation | Service (サービス) — Service type/category |
| EOH | Abbreviation | eo Hikari (eo光) — NTT West's fiber-optic internet service brand |
| SVKEIUW | Abbreviation | Service Contents (サービス内容) — Service detail/contract line items |
| TSJGS | Abbreviation | Telecommunications Service Provider (通信事業者) — Telecommunications operator |
| TUSHIN | Abbreviation | Tsūshin (通信) — Telecommunications |
| TUBmp | Abbreviation | Type — Update Batch for Port Number (番号変更) — indicates this is an update-type batch handling port number changes |
| Swch | Abbreviation | Switch — Port number switch/porting |
| SodTrn | Abbreviation | Service Order Transaction — SOD processing transaction |
