# Business Logic — JBSbatTUBmpKojiFinTrn.terminal() [11 LOC]

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

## 1. Role

### JBSbatTUBmpKojiFinTrn.terminal()

This method serves as the **business service termination handler** (業務サービス終了処理) for the Banteho (番口 — telephone number portability) work completion batch process. The class `JBSbatTUBmpKojiFinTrn` is responsible for telephone number portability work procedures (電話番号割当手続き登録処理) within the eo Customer Base System (eo顧客基幹システム), specifically handling the finalization phase of the Banteho work process.

The `terminal()` method implements the **resource cleanup pattern** — it ensures that all database access connections opened during the batch lifecycle are properly closed to prevent resource leaks. This is a standard life-cycle callback method that follows the batch service template pattern inherited from `JBSbatBusinessService`, which defines three key phases: `initial()` (resource initialization), `execute()` (main business logic), and `terminal()` (resource cleanup).

This method is part of the **work completion phase item** (工事完了処理部品) within the batch processing workflow. In the context of the eo system's telephone number portability feature, it acts as a shared utility teardown method invoked at the end of the batch run, whether the batch completes successfully or encounters an error. The batch was originally created in May 2011 as v3.00.00 and has evolved to support bidirectional Banteho (双方向番口対応) as of v72.00.1 (2024).

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["terminal()"])
    STEP1["Close DB access: db_TU_T_BMP_KOJI"]
    STEP2["Close DB access: db_KK_T_ICJKN_SETTE"]
    STEP3["Close DB access: db_KK_T_KICJKN"]
    END(["Return / End"])

    START --> STEP1
    STEP1 --> STEP2
    STEP2 --> STEP3
    STEP3 --> END
```

**Description:** This method follows a linear, sequential resource teardown pattern with no conditional branches. It closes three database access connections in the reverse order of their creation in the `initial()` method. Each `close()` call releases the underlying JDBC connection and related resources back to the connection pool, ensuring clean session termination.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| - | (none) | - | This method takes no parameters. It operates entirely on instance fields initialized during the `initial()` phase of the batch service lifecycle. |

**Instance Fields Used:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `db_TU_T_BMP_KOJI` | `JBSbatSQLAccess` | Database access object for the `TU_T_BMP_KOJI` table (Banteho work records — 番口工事). Tracks portability work status. |
| `db_KK_T_ICJKN_SETTE` | `JBSbatSQLAccess` | Database access object for the `KK_T_ICJKN_SETTE` table (Temporary financial institution settings — 一時金設設定). Manages provisional financial institution configuration data. |
| `db_KK_T_KICJKN` | `JBSbatSQLAccess` | Database access object for the `KK_T_KICJKN` table (Contract temporary financial institution — 契約一時金). Handles contract-related provisional financial institution records. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `JBSbatSQLAccess.close` | - | TU_T_BMP_KOJI | Closes database access connection for Banteho work table |
| - | `JBSbatSQLAccess.close` | - | KK_T_ICJKN_SETTE | Closes database access connection for temporary financial institution settings table |
| - | `JBSbatSQLAccess.close` | - | KK_T_KICJKN | Closes database access connection for contract temporary financial institution table |

### Complete CRUD classification:

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `db_TU_T_BMP_KOJI.close` | - | TU_T_BMP_KOJI | Releases database access connection for the Banteho work (番口工事) table. No SQL operation — merely closes the connection. |
| - | `db_KK_T_ICJKN_SETTE.close` | - | KK_T_ICJKN_SETTE | Releases database access connection for the temporary financial institution settings (一時金設設定) table. |
| - | `db_KK_T_KICJKN.close` | - | KK_T_KICJKN | Releases database access connection for the contract temporary financial institution (契約一時金) table. |

**Note:** This method performs no data operations (no C/R/U/D). It only closes previously opened database access connections. The actual CRUD operations on these tables occur in other methods such as `execute()` and `insertBmpKoji()`.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: JBSbatTUBmpKojiFinTrn (lifecycle callback) | `JBSbatBusinessService.executeBatch` -> `JBSbatTUBmpKojiFinTrn.terminal` | `db_TU_T_BMP_KOJI.close [CLOSE] TU_T_BMP_KOJI`<br>`db_KK_T_ICJKN_SETTE.close [CLOSE] KK_T_ICJKN_SETTE`<br>`db_KK_T_KICJKN.close [CLOSE] KK_T_KICJKN` |

**Caller Details:**
- `terminal()` is a lifecycle callback invoked by the batch framework (`JBSbatBusinessService` parent class) at the end of the batch execution. The framework calls `initial()`, then `execute()`, then `terminal()` in sequence as part of the standard batch service lifecycle.
- No external screen or CBS caller directly invokes `terminal()` — it is called internally by the batch processing framework.

## 6. Per-Branch Detail Blocks

**Block 1** — [PROCEDURAL] `(linear teardown, no conditions)` (L153)

> The method executes a straightforward sequential teardown of three database access connections. No conditional logic, exception handling overrides, or branching is present within this method body. All cleanup is unconditional.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | CALL | `db_TU_T_BMP_KOJI.close()` | Closes database access for the Banteho work (番口工事) table. Releases the JDBC connection held by `db_TU_T_BMP_KOJI`. [-> `D_TBL_NAME_TU_T_BMP_KOJI = "TU_T_BMP_KOJI"`] |
| 2 | CALL | `db_KK_T_ICJKN_SETTE.close()` | Closes database access for the temporary financial institution settings (一時金設設定) table. Releases the JDBC connection held by `db_KK_T_ICJKN_SETTE`. [-> `D_TBL_NAME_KK_T_ICJKN_SETTE = "KK_T_ICJKN_SETTE"`] |
| 3 | CALL | `db_KK_T_KICJKN.close()` | Closes database access for the contract temporary financial institution (契約一時金) table. Releases the JDBC connection held by `db_KK_T_KICJKN`. [-> `D_TBL_NAME_KK_T_KICJKN = "KK_T_KICJKN"`] |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| Banteho (番口) | Business term | Telephone number portability — the process by which a subscriber retains their phone number when switching mobile/carrier service providers. A core telecommunications regulatory feature in Japan. |
| 工事完了 (Kousou Kanryou) | Japanese term | Work completion — the finalization of installation/construction work for service activation. In this system, the Banteho work completion status. |
| 一時金 (Ichijikin) | Japanese term | Temporary/provisional financial institution — a temporary registration of financial institution information, typically during transition periods. Used for interim financial data before final settlement. |
| 契約 (Yakusyoku) | Japanese term | Contract — refers to the contractual relationship with the customer or service provider. In `KK_T_KICJKN`, represents contract-level provisional financial institution records. |
| 設設定 (Settei) | Japanese term | Settings/configuration — refers to configuration or setup records. In `KK_T_ICJKN_SETTE`, represents temporary financial institution configuration settings. |
| 番口工事 (Banteho Kousou) | Japanese term | Telephone number portability work/installation — the complete workflow of processing a number portability request, from application through installation to finalization. |
| TU_T_BMP_KOJI | Table | Work completion table for Banteho records — tracks the status and completion of telephone number portability installation work. |
| KK_T_ICJKN_SETTE | Table | Temporary financial institution settings table — stores configuration data for provisional financial institution registrations. |
| KK_T_KICJKN | Table | Contract temporary financial institution table — stores contract-level temporary financial institution records. |
| JBSbatSQLAccess | Technical | SQL access utility class — a framework class providing database connection management, SQL execution, and result set handling for batch services. |
| JBSbatBusinessService | Technical | Base batch business service class — provides the standard batch lifecycle template with `initial()`, `execute()`, and `terminal()` hooks. |
| JBSbatTUBmpKojiFinTrn | Technical | Telephone number portability work completion transaction — the batch business service handling the finalization phase of Banteho work processing. |
| BMP_KOJI_FIN | Constant | Banteho work completion status code — a string constant (`JTUStrConst.BMP_KOJI_FIN`) representing the "work completed" status value written to the Banteho work table during the `execute()` phase. |
| eo 顧客基幹システム | Business term | eo Customer Base System — the core customer management system for K-Opticom's eo telecom services, handling customer data, orders, and service activations. |
| K-Opticom | Business term | K-Opticom — the telecommunications company whose eo brand provides fiber-optic internet and phone services in Japan. |
