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

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

## 1. Role

### JBSbatKKSvkeiDelTgCst.terminal()

This method performs **business service termination processing** (業務サービス終了処理) — the cleanup phase executed at the end of a batch job that extracts service contract cancellation targets. The `JBSbatKKSvkeiDelTgCst` class is a batch service component for the **eo Customer Base System** (eo顧客基盤システム), responsible for extracting records from tables related to service contract cancellations across multiple telecom service types (EO Light Internet, EO ADSL, and EO Light Telephone).

The `terminal()` method specifically acts as a **resource cleanup handler**, following a common batch template pattern where a `terminal()` method is invoked as a post-processing hook to close all open database access handles that were initialized earlier in the batch lifecycle. It closes `JBSbatSQLAccess` objects for four database tables: two service detail tables (EO Light Internet and ADSL), one service contract table (EO Light Telephone), and one order settings table.

This method implements the **delegation pattern** — it does not perform any business logic itself but delegates to the `close()` methods of each database access object. It is the **cleanup entry point** called by the batch framework's lifecycle management after all primary processing steps (data extraction, transformation, and output) have completed.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["START: terminal()"])
    CLOSE1["Close db_KK_T_SVKEIUW_EOH_NET
(EO Light Internet service details)"]
    CLOSE2["Close db_KK_T_SVKEIUW_EOADSL
(EO ADSL service details)"]
    CLOSE3["Close db_KK_T_SVC_KEI_EOH_TEL
(EO Light Telephone service contract)"]
    CLOSE4["Close db_KK_T_ODR_SET
(Order settings)"]
    END_NODE(["END: Return / Next"])

    START --> CLOSE1
    CLOSE1 --> CLOSE2
    CLOSE2 --> CLOSE3
    CLOSE3 --> CLOSE4
    CLOSE4 --> END_NODE
```

**Processing description:**

1. **Close EO Light Internet service detail handle** — Calls `db_KK_T_SVKEIUW_EOH_NET.close()` to release the database access connection for the `KK_T_SVKEIUW_EOH_NET` table, which stores service detail records for EO Light Internet contracts.

2. **Close EO ADSL service detail handle** — Calls `db_KK_T_SVKEIUW_EOADSL.close()` to release the database access connection for the `KK_T_SVKEIUW_EOADSL` table, which stores service detail records for EO ADSL contracts.

3. **Close EO Light Telephone service contract handle** — Calls `db_KK_T_SVC_KEI_EOH_TEL.close()` to release the database access connection for the `KK_T_SVC_KEI_EOH_TEL` table, which stores service contract records for EO Light Telephone.

4. **Close Order Settings handle** — Calls `db_KK_T_ODR_SET.close()` to release the database access connection for the `KK_T_ODR_SET` table, which stores order settings data.

5. **Return** — The method returns `void`, completing the batch lifecycle cleanup. No conditional branches exist in this method.

**Note on historical change:** As of fix IT1-2013-0000285 (2013/02/13), the `db_KK_T_ODR_HAKKO_JOKEN` handle (Order Release Conditions table) was removed from this cleanup sequence. The corresponding table constant and SQL key definitions were also commented out, indicating the order release conditions table is no longer part of this batch's scope.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| - | (none) | - | This method takes no parameters. It is a parameterless cleanup handler invoked by the batch framework lifecycle. |

**Instance fields / external state read by this method:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `db_KK_T_SVKEIUW_EOH_NET` | `JBSbatSQLAccess` | Database access handle for the EO Light Internet service details table — used during batch data extraction |
| `db_KK_T_SVKEIUW_EOADSL` | `JBSbatSQLAccess` | Database access handle for the EO ADSL service details table — used during batch data extraction |
| `db_KK_T_SVC_KEI_EOH_TEL` | `JBSbatSQLAccess` | Database access handle for the EO Light Telephone service contract table — used during batch data extraction |
| `db_KK_T_ODR_SET` | `JBSbatSQLAccess` | Database access handle for the order settings table — used during batch data extraction |

## 4. CRUD Operations / Called Services

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

| SC / CBS | SC Code | Operation Type | Operation Description |
|----------|---------|----------------|----------------------|
| `JBSbatSQLAccess.close` | (framework) | Resource Cleanup | Closes a database access connection, releasing the DB resource allocated during batch processing |

**Method call analysis:**

| # | Type | SC / CBS | SC Code | Entity / DB | Operation |
|---|------|----------|---------|-------------|-----------|
| 1 | EXEC | `db_KK_T_SVKEIUW_EOH_NET.close` | Framework (DB Layer) | `KK_T_SVKEIUW_EOH_NET` | Closes the database access handle for EO Light Internet service details |
| 2 | EXEC | `db_KK_T_SVKEIUW_EOADSL.close` | Framework (DB Layer) | `KK_T_SVKEIUW_EOADSL` | Closes the database access handle for EO ADSL service details |
| 3 | EXEC | `db_KK_T_SVC_KEI_EOH_TEL.close` | Framework (DB Layer) | `KK_T_SVC_KEI_EOH_TEL` | Closes the database access handle for EO Light Telephone service contract |
| 4 | EXEC | `db_KK_T_ODR_SET.close` | Framework (DB Layer) | `KK_T_ODR_SET` | Closes the database access handle for order settings |

**Classification:** These are **resource cleanup operations** rather than CRUD operations on database records. They release `JBSbatSQLAccess` connections (database cursors/handles) that were acquired earlier in the batch processing lifecycle. No actual database records are read, created, updated, or deleted by this method.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: JBSbatKKSvkeiDelTgCst | `JBSbatBusinessService.execute()` -> `terminal()` | `close [Cleanup] KK_T_SVKEIUW_EOH_NET`<br>`close [Cleanup] KK_T_SVKEIUW_EOADSL`<br>`close [Cleanup] KK_T_SVC_KEI_EOH_TEL`<br>`close [Cleanup] KK_T_ODR_SET` |

**Caller analysis notes:**

- The `terminal()` method is not explicitly called by any other class in the codebase — it is a **framework-invoked lifecycle hook**. The class `JBSbatKKSvkeiDelTgCst` extends `JBSbatBusinessService`, which defines the batch execution lifecycle. The `execute()` method in the base class (or a batch orchestration framework) calls `terminal()` as the final step after all primary processing has completed.
- No screen classes (KKSV*) reference this method directly. This is a batch-only component.
- The `JBSbatBusinessService` abstract base class serves as the parent framework for all batch services in the eo Customer Base System.

## 6. Per-Branch Detail Blocks

**Block 1** — [PROCESS] (DB handle cleanup for EO Light Internet) `(L532)`

> Closes the database access handle for the EO Light Internet service details table (`KK_T_SVKEIUW_EOH_NET`). This table stores service detail records including work numbers, service codes, and status information for FTTH (Fiber To The Home) internet service contracts.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `db_KK_T_SVKEIUW_EOH_NET.close()` // Close DB access class (EO Light Internet service details) [-> Table: KK_T_SVKEIUW_EOH_NET] |

**Block 2** — [PROCESS] (DB handle cleanup for EO ADSL) `(L533)`

> Closes the database access handle for the EO ADSL service details table (`KK_T_SVKEIUW_EOADSL`). This table stores service detail records for ADSL (Asymmetric Digital Subscriber Line) broadband contracts.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `db_KK_T_SVKEIUW_EOADSL.close()` // Close DB access class (EO ADSL service details) [-> Table: KK_T_SVKEIUW_EOADSL] |

**Block 3** — [PROCESS] (DB handle cleanup for EO Light Telephone) `(L534)`

> Closes the database access handle for the EO Light Telephone service contract table (`KK_T_SVC_KEI_EOH_TEL`). This table stores service contract records for the EO Light Telephone (VOIP) service, including service detail work numbers and contract information.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `db_KK_T_SVC_KEI_EOH_TEL.close()` // Close DB access class (EO Light Telephone service contract) [-> Table: KK_T_SVC_KEI_EOH_TEL] |

**Block 4** — [PROCESS] (DB handle cleanup for Order Settings) `(L535)`

> Closes the database access handle for the order settings table (`KK_T_ODR_SET`). This table stores order configuration data used during batch processing, including order content codes, order sub-type codes, and service order information.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `db_KK_T_ODR_SET.close()` // Close DB access class (Order settings) [-> Table: KK_T_ODR_SET] |

**Block 5** — [COMMENTED OUT] (Historical: Order Release Conditions) `(L537–L539)`

> The cleanup for `db_KK_T_ODR_HAKKO_JOKEN` (Order Release Conditions) was removed in fix IT1-2013-0000285 on 2013/02/13. This table previously tracked the conditions under which orders are released/issued. Its removal indicates the batch scope was narrowed to exclude order release conditions from the cancellation target extraction process.

| # | Type | Code |
|---|------|------|
| 1 | COMMENT | `//db_KK_T_ODR_HAKKO_JOKEN.close()` // IT1-2013-0000285 2013/02/13 DEL — Removed from cleanup |

**Block 6** — [RETURN] (Method completion) `(L541)`

> The method returns `void`. All database access handles have been closed, completing the batch cleanup phase.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return;` // implicit void return |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `KK_T_SVKEIUW_EOH_NET` | DB Table | Service detail table (EO Light Internet) — Stores per-line service detail records for FTTH (Fiber To The Home) internet service contracts, including work tracking numbers and service codes |
| `KK_T_SVKEIUW_EOADSL` | DB Table | Service detail table (EO ADSL) — Stores per-line service detail records for ADSL broadband service contracts, analogous to the internet table but for DSL technology |
| `KK_T_SVC_KEI_EOH_TEL` | DB Table | Service contract table (EO Light Telephone) — Stores service contract records for EO Light Telephone (VOIP) service, including contract work numbers and service status information |
| `KK_T_ODR_SET` | DB Table | Order settings — Stores order configuration data used during batch processing, such as order content codes, order types, and service order parameters |
| `KK_T_ODR_HAKKO_JOKEN` | DB Table (Deprecated) | Order release conditions — Previously tracked conditions under which orders are issued/released. Removed from this batch's scope in fix IT1-2013-0000285 (2013/02/13) |
| `JBSbatSQLAccess` | Class | Database access class — Framework class providing database connection and query execution capabilities for batch services |
| `JBSbatBusinessService` | Class | Abstract base class for all batch business services — Defines the batch execution lifecycle including `terminal()` as a cleanup hook |
| `terminal()` | Method | Batch lifecycle cleanup method — Framework-invoke method executed at the end of batch processing to close resources |
| SOD | Acronym | Service Order Data — Service order entity used in the order release process (referenced in class constants `DEL_TRAN_SBT_SOD` and `DEL_TRAN_SBT_SOD_AGING_UPD`) |
| FTTH | Business term | Fiber To The Home — Fiber-optic broadband internet service (referred to as "EO Light Internet" in the system) |
| ADSL | Business term | Asymmetric Digital Subscriber Line — DSL-based broadband internet service (referred to as "EO ADSL" in the system) |
| EO Light (光) | Business term | K-Opticom's branded fiber-optic telecommunications service suite, encompassing Internet (FTTH), Telephone (VOIP), and ADSL offerings |
| 業務サービス終了処理 | Japanese | Business service termination processing — The Javadoc description for this method, indicating it is the cleanup phase of the batch service |
| ツールから生成した終了処理のソースです | Japanese | "This is the source code for termination processing generated from the tool" — Tool-generated comment indicating this method is scaffold code auto-generated by a code generator |
| IT1-2013-0000285 | Ticket | Change request ticket from 2013/02/13 that removed the `db_KK_T_ODR_HAKKO_JOKEN` handle from the cleanup sequence, narrowing the batch's scope |
| DEL_TRAN_SBT_SOD | Constant | Deletion processing type code "1" — Indicates "Delete SOD Issue" processing type (referenced in class, used by calling logic) |
| DEL_TRAN_SBT_SOD_AGING_UPD | Constant | Deletion processing type code "3" — Indicates "Delete SOD Issue · Aging Update" processing type (added in IT1-2013-0000285) |
| DEL_TRGT_SBT_ISP_NINSHO_ID | Constant | Deletion target type code "01" — ISP authentication ID (referenced in class, used by calling logic) |
| DEL_TRGT_SBT_PPP_NINSHO_ID | Constant | Deletion target type code "06" — PPP authentication ID (referenced in class, used by calling logic) |
| DEL_TRGT_SBT_ADSL_NINSHO_ID | Constant | Deletion target type code "16" — ADSL authentication ID (added in IT1-2013-0000285) |
| K-Opticom | Company | Japanese telecommunications company operating fiber-optic and DSL broadband services; the system owner |
