# Business Logic — JBSbatKKSvkeiuwDelTgCst.terminal() [18 LOC]

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

## 1. Role

### JBSbatKKSvkeiuwDelTgCst.terminal()

This method serves as the **business service termination handler** (業務サービス終了処理) for the `JBSbatKKSvkeiuwDelTgCst` batch service, which specializes in extracting target records for deletion from service contract detail tables (サービス契約内相消対象抽出部品). In the telecom billing domain, the K-Opticom system manages customer service contracts — primarily FTTH (Fiber To The Home) internet and telephone subscriptions — and this batch class is responsible for identifying which contract lines should be deleted based on business rules.

The `terminal()` method implements the **cleanup / resource release pattern**. It is called at the end of the batch service lifecycle to systematically close all database access connections (DBアクセス) that were opened and used during the service's data extraction processing. This ensures proper resource management by releasing JDBC connections back to the pool, preventing connection leaks, and allowing the batch job to terminate cleanly.

The method is a **shared utility method** within the `JBSbatBusinessService` framework — it overrides the base class's `terminal()` contract. It is not called directly from screen-level code but is invoked by the batch runtime framework as part of the standard service execution flow. The method closes connections to eight DB tables involved in the service contract deletion extraction process, including tables for EO broadband (eo光ネット), EO telephone (eo光電話), pricing groups, work parameter management, order settings, machine-provided service contracts, and returnable equipment tracking.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["terminal()"])
    START --> CLOSE_NET["Close KK_T_SVKEIUW_EOH_NET connection"]
    CLOSE_NET --> CLOSE_TEL1["Close KK_T_SVKEIUW_EOH_TEL connection"]
    CLOSE_TEL1 --> CLOSE_PRG["Close KK_M_PRC_GRP connection"]
    CLOSE_PRG --> CLOSE_WPK["Close ZM_M_WORK_PARAM_KNRI connection"]
    CLOSE_WPK --> CLOSE_ODR["Close KK_T_ODR_SET connection"]
    CLOSE_ODR --> SKIP_OHJ["Skip KK_T_ODR_HAKKO_JOKEN (commented out)"]
    SKIP_OHJ --> CLOSE_KKTK["Close KK_T_KKTK_SVC_KEI connection"]
    CLOSE_KKTK --> CLOSE_HMPIN["Close DK_T_HMPIN_KIKI connection"]
    CLOSE_HMPIN --> END_NODE(["Return / Next"])
```

**Processing Flow:**

The `terminal()` method executes a strictly linear sequence of eight DB connection close operations. There are no conditional branches, loops, or error-handling blocks. Each `close()` call releases a database access handle previously acquired by the service during its read operations.

- **Step 1**: Close the EO broadband (eo光ネット) service contract detail connection (`KK_T_SVKEIUW_EOH_NET`)
- **Step 2**: Close the EO telephone (eo光電話) service contract detail connection (`KK_T_SVKEIUW_EOH_TEL`)
- **Step 3**: Close the pricing group master connection (`KK_M_PRC_GRP`)
- **Step 4**: Close the work parameter management connection (`ZM_M_WORK_PARAM_KNRI`)
- **Step 5**: Close the order settings connection (`KK_T_ODR_SET`)
- **Step 6**: Skip the order release conditions table (`KK_T_ODR_HAKKO_JOKEN`) — this was removed by IT1-2013-0000285 on 2013/02/13 and is commented out
- **Step 7**: Close the machine-provided service contract connection (`KK_T_KKTK_SVC_KEI`)
- **Step 8**: Close the returnable equipment (返品機器) connection (`DK_T_HMPIN_KIKI`)

After all connections are released, the method returns void, completing the service termination process.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| - | (none) | - | This method takes no parameters. It operates on instance-level DB access fields inherited from `JBSbatBusinessService`, which manage connections to the tables listed in the processing flow above. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `db_KK_T_SVKEIUW_EOH_NET.close` | JBSbatKK_T_SVKEIUW_EOH_NET | `KK_T_SVKEIUW_EOH_NET` | Calls `close` on the EO broadband (Fiber To The Home) service contract detail table connection |
| - | `db_KK_T_SVKEIUW_EOH_TEL.close` | JBSbatKK_T_SVKEIUW_EOH_TEL | `KK_T_SVKEIUW_EOH_TEL` | Calls `close` on the EO telephone (optical telephone) service contract detail table connection |
| - | `db_KK_M_PRC_GRP.close` | JBSbatKK_M_PRC_GRP | `KK_M_PRC_GRP` | Calls `close` on the pricing group (料金グループ) master table connection |
| - | `db_ZM_M_WORK_PARAM_KNRI.close` | JBSbatZM_M_WORK_PARAM_KNRI | `ZM_M_WORK_PARAM_KNRI` | Calls `close` on the work parameter management (業務パラメータ管理) table connection |
| - | `db_KK_T_ODR_SET.close` | JBSbatKK_T_ODR_SET | `KK_T_ODR_SET` | Calls `close` on the order settings (オーダ設定) table connection |
| - | `db_KK_T_KKTK_SVC_KEI.close` | JBSbatKK_T_KKTK_SVC_KEI | `KK_T_KKTK_SVC_KEI` | Calls `close` on the machine-provided service contract (機器提供サービス契約) table connection |
| - | `db_DK_T_HMPIN_KIKI.close` | JBSbatDK_T_HMPIN_KIKI | `DK_T_HMPIN_KIKI` | Calls `close` on the returnable equipment (返品機器) table connection |

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `db_KK_T_ODR_HAKKO_JOKEN.close` | JBSbatKK_T_ODR_HAKKO_JOKEN | `KK_T_ODR_HAKKO_JOKEN` | Calls `close` on the order release conditions (オーダ発行条件) table — **commented out** (removed by IT1-2013-0000285) |

**Note**: The `close()` operation is a **resource release** (not a CRUD data operation). These connections were previously opened for **Read (R)** operations during the main batch processing — `KK_SELECT_006`, `KK_SELECT_018`, `KK_SELECT_008`, `KK_SELECT_017`, `KK_SELECT_011`, `KK_SELECT_036`, `KK_SELECT_129`, and `KK_SELECT_003` SQL keys were used to query data from the respective tables before this termination method runs.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch:JBSbatKKSvkeiuwDelTgCst | `JBSbatBusinessService.execute` -> `JBSbatKKSvkeiuwDelTgCst.terminal` | `close [R-release] KK_T_SVKEIUW_EOH_NET`, `close [R-release] KK_T_SVKEIUW_EOH_TEL`, `close [R-release] KK_M_PRC_GRP`, `close [R-release] ZM_M_WORK_PARAM_KNRI`, `close [R-release] KK_T_ODR_SET`, `close [R-release] KK_T_KKTK_SVC_KEI`, `close [R-release] DK_T_HMPIN_KIKI` |

**Notes:**
- This method is defined on a batch service class (`JBSbatKKSvkeiuwDelTgCst extends JBSbatBusinessService`) and is called by the batch framework's standard execution flow, not by external screens or CBS components.
- No external callers reference this method directly — it is part of the internal batch lifecycle.
- The `KK_T_ODR_HAKKO_JOKEN` close call was removed by change ticket IT1-2013-0000285 (2013/02/13) and is now commented out.

## 6. Per-Branch Detail Blocks

> This method contains no conditional branches, loops, or switch statements. It is a pure linear sequence of DB connection close operations. The entire body is documented as a single block below.

**Block 1** — [LINEAR SEQUENCE] `(none)` (L520)

> The business service termination process. This block closes all DB access connections (DBアクセス) opened during the service's data extraction processing. The close operations follow the exact order of the table declarations in the class header.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `db_KK_T_SVKEIUW_EOH_NET.close()` | Close the EO broadband (Fiber To The Home) service contract detail table connection |
| 2 | EXEC | `db_KK_T_SVKEIUW_EOH_TEL.close()` | Close the EO telephone (optical telephone) service contract detail table connection |
| 3 | EXEC | `db_KK_M_PRC_GRP.close()` | Close the pricing group master table connection |
| 4 | EXEC | `db_ZM_M_WORK_PARAM_KNRI.close()` | Close the work parameter management table connection |
| 5 | EXEC | `db_KK_T_ODR_SET.close()` | Close the order settings table connection |
| 6 | EXEC (COMMENTED OUT) | `// db_KK_T_ODR_HAKKO_JOKEN.close()` | Skip — removed by IT1-2013-0000285 on 2013/02/13 |
| 7 | EXEC | `db_KK_T_KKTK_SVC_KEI.close()` | Close the machine-provided service contract table connection |
| 8 | EXEC | `db_DK_T_HMPIN_KIKI.close()` | Close the returnable equipment table connection |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `KK_T_SVKEIUW_EOH_NET` | Table | Service Contract Detail (eo Optical Network) — stores contract line items for fiber-optic internet (eo光ネット) services |
| `KK_T_SVKEIUW_EOH_TEL` | Table | Service Contract Detail (eo Optical Telephone) — stores contract line items for optical telephone (eo光電話) services |
| `KK_M_PRC_GRP` | Table | Pricing Group Master (料金グループ) — master data defining pricing groupings for telecom services |
| `ZM_M_WORK_PARAM_KNRI` | Table | Work Parameter Management (業務パラメータ管理) — system configuration parameters controlling batch processing behavior |
| `KK_T_ODR_SET` | Table | Order Settings (オーダ設定) — order configuration data for service orders |
| `KK_T_ODR_HAKKO_JOKEN` | Table | Order Release Conditions (オーダ発行条件) — conditions governing when service orders are issued — **removed by IT1-2013-0000285** |
| `KK_T_KKTK_SVC_KEI` | Table | Machine-Provided Service Contract (機器提供サービス契約) — contracts for hardware/equipment provided with telecom services |
| `DK_T_HMPIN_KIKI` | Table | Returnable Equipment (返品機器) — tracks equipment returned by customers (e.g., modems, ONTs) |
| SVKEIUW | Abbreviation | Service Withdrawal (サービス取消) — business domain for service cancellation/termination processing |
| EOH | Abbreviation | EO Optical (エフオーライト光) — the brand name for K-Opticom's fiber-optic broadband and telephone services |
| KKTK | Abbreviation | Kit Teiki (機器定額) — equipment regular charge / hardware subscription model |
| HMPIN | Abbreviation |ihan Kin (返品機器) — returnable equipment / customer-returned hardware |
| FTTH | Business term | Fiber To The Home — fiber-optic broadband internet service delivery |
| DBアクセス | Japanese term | DB Access — database access connection/handle managed by the framework |
| 業務サービス終了処理 | Japanese term | Business Service Termination Processing — cleanup operation executed at the end of a batch service |
| サービス契約内相消対象抽出部品 | Japanese term | Service Contract Netting Target Extraction Component — the batch class purpose: identifying which service contract lines should be deleted |
