# Business Logic — JBSbatKKSodUpdInfCst.terminal() [21 LOC]

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

## 1. Role

### JBSbatKKSodUpdInfCst.terminal()

This method implements the **business service termination (cleanup) processing** for the SOD (Service Order Data) update information extraction component within the address change batch job pipeline. It is part of the standard `JBSbatBusinessService` lifecycle — every batch service class inherits the `initial()` → `execute()` → `terminal()` pattern, and `terminal()` is called last to release all database resources opened during processing.

The method performs a **sequential cleanup/dispose pattern**: it closes seven `JBSbatSQLAccess` database connection wrappers that were initialized in the `initial()` method. These connections hold open database cursors and file handles for tables used during address-change and service-contract-line order processing. Closing them in reverse initialization order ensures no resource leak during batch execution.

This method has **no conditional branches** — it is a linear sequence of resource cleanup calls, directly reflecting a **delegation pattern** where each `close()` call delegates to the underlying JDBC connection cleanup. Its role in the larger system is as a **shared lifecycle hook** called by the batch framework after the main processing (`execute()`) of `JBSbatKKAdChgCstScreenKidou` completes, ensuring database resources for the SOD update submodule are properly released.

**Design pattern**: Resource Management / Disposable lifecycle.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["terminal() Entry"])

    step1["Close db_KK_T_SVKEI_KAISEN_UW"]
    step2["Close db_KK_T_ADCHG"]
    step3["Close db_KK_T_ADCHG_DTL"]
    step4["Close db_KK_T_KJ_FIN_WK"]
    step5["Close db_KU_T_SVKEI_KOJIAK"]
    step6["Close db_KK_T_TK_HOSHIKI_KEI"]
    step7["Close db_KK_T_SVC_KEI"]

    END(["Return / Next"])

    START --> step1
    step1 --> step2
    step2 --> step3
    step3 --> step4
    step4 --> step5
    step5 --> step6
    step6 --> step7
    step7 --> END
```

**Processing overview**: The method executes a linear chain of seven `close()` calls on database access objects, in the exact reverse order of their initialization in `initial()`. Each `close()` releases a database cursor, file handle, or prepared statement associated with a specific batch work table. There are no conditional branches, loops, or exception handlers — the method is a pure sequential cleanup routine.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| - | (none) | - | This method takes no parameters. It operates on instance fields initialized during `initial(JBSbatCommonItem)`. |

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

| # | Field Name | Type | Business Description |
|---|-----------|------|---------------------|
| 1 | `db_KK_T_SVKEI_KAISEN_UW` | `JBSbatSQLAccess` | Database access wrapper for service contract line information table (`KK_T_SVKEI_KAISEN_UW`) — holds cursor for querying service detail work data. |
| 2 | `db_KK_T_ADCHG` | `JBSbatSQLAccess` | Database access wrapper for address change table (`KK_T_ADCHG`) — tracks address change requests. |
| 3 | `db_KK_T_ADCHG_DTL` | `JBSbatSQLAccess` | Database access wrapper for address change detail table (`KK_T_ADCHG_DTL`) — stores line-level address change details. |
| 4 | `db_KK_T_KJ_FIN_WK` | `JBSbatSQLAccess` | Database access wrapper for accounting completion work table (`KK_T_KJ_FIN_WK`) — temporary accounting completion tracking data. |
| 5 | `db_KU_T_SVKEI_KOJIAK` | `JBSbatSQLAccess` | Database access wrapper for service individual customer table (`KU_T_SVKEI_KOJIAK`) — customer-level service data. |
| 6 | `db_KK_T_TK_HOSHIKI_KEI` | `JBSbatSQLAccess` | Database access wrapper for TK contract line table (`KK_T_TK_HOSHIKI_KEI`) — TK (Telecom) contract line information. |
| 7 | `db_KK_T_SVC_KEI` | `JBSbatSQLAccess` | Database access wrapper for service contract line table (`KK_T_SVC_KEI`) — service contract line item data. |

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `db_KK_T_SVKEI_KAISEN_UW.close` | JBSbatSQLAccess | - | Closes database access for service contract line information work table |
| - | `db_KK_T_ADCHG.close` | JBSbatSQLAccess | - | Closes database access for address change table |
| - | `db_KK_T_ADCHG_DTL.close` | JBSbatSQLAccess | - | Closes database access for address change detail table |
| - | `db_KK_T_KJ_FIN_WK.close` | JBSbatSQLAccess | - | Closes database access for accounting completion work table |
| - | `db_KU_T_SVKEI_KOJIAK.close` | JBSbatSQLAccess | - | Closes database access for service individual customer table |
| - | `db_KK_T_TK_HOSHIKI_KEI.close` | JBSbatSQLAccess | - | Closes database access for TK contract line table |
| - | `db_KK_T_SVC_KEI.close` | JBSbatSQLAccess | - | Closes database access for service contract line table |

**Classification note**: All operations are resource cleanup calls (not CRUD operations against the database). The `close()` method on `JBSbatSQLAccess` releases JDBC resources (cursors, prepared statements, file handles) — it does not perform C/R/U/D against the database.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: `JBSbatKKAdChgCstScreenKidou` | `initial()` → `execObjSod.initial()` → `execute()` → `terminal()` | `db_KK_T_SVKEI_KAISEN_UW.close`, `db_KK_T_ADCHG.close`, `db_KK_T_ADCHG_DTL.close`, `db_KK_T_KJ_FIN_WK.close`, `db_KU_T_SVKEI_KOJIAK.close`, `db_KK_T_TK_HOSHIKI_KEI.close`, `db_KK_T_SVC_KEI.close` |

**Caller details**:
- `JBSbatKKAdChgCstScreenKidou` is the address change batch job that orchestrates multiple sub-processes. It instantiates `JBSbatKKSodUpdInfCst` as `execObjSod` and calls `initial(commonItem)` during initialization and `terminal()` during cleanup.
- The `terminal()` method is part of the standard `JBSbatBusinessService` lifecycle hook (abstract method `public abstract void terminal() throws Exception` defined in the parent class).

## 6. Per-Branch Detail Blocks

**Block 1** — LINEAR PROCESSING (L612)

> Close DB access for KK_T_SVKEI_KAISEN_UW (Service contract line information work table)
> DBアクセスクラスをクローズします (Close the DB access class)

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `db_KK_T_SVKEI_KAISEN_UW.close();` // Close DB access for service contract line info work table |

**Block 2** — LINEAR PROCESSING (L614)

> Close DB access for KK_T_ADCHG (Address change table)
> ST2-2013-0001434対応 20130316 星野 ADD

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `db_KK_T_ADCHG.close();` // Close DB access for address change table |

**Block 3** — LINEAR PROCESSING (L616)

> Close DB access for KK_T_ADCHG_DTL (Address change detail table)
> ST2-2013-0001008対応 20130301 OKITA ADD

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `db_KK_T_ADCHG_DTL.close();` // Close DB access for address change detail table |

**Block 4** — LINEAR PROCESSING (L617)

> Close DB access for KK_T_KJ_FIN_WK (Accounting completion work table)

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `db_KK_T_KJ_FIN_WK.close();` // Close DB access for accounting completion work table |

**Block 5** — LINEAR PROCESSING (L618)

> Close DB access for KU_T_SVKEI_KOJIAK (Service individual customer table)

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `db_KU_T_SVKEI_KOJIAK.close();` // Close DB access for service individual customer table |

**Block 6** — LINEAR PROCESSING (L619)

> Close DB access for KK_T_TK_HOSHIKI_KEI (TK contract line table)

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `db_KK_T_TK_HOSHIKI_KEI.close();` // Close DB access for TK contract line table |

**Block 7** — LINEAR PROCESSING (L621)

> Close DB access for KK_T_SVC_KEI (Service contract line table)
> ANK-1429-00-00 2013.03.21 T.TORIKAI ADD

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `db_KK_T_SVC_KEI.close();` // Close DB access for service contract line table |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `terminal()` | Method | Business service termination processing — cleanup method called at end of batch service lifecycle |
| SOD | Acronym | Service Order Data — telecom order fulfillment data for service updates and changes |
| KKSodUpdInf | Module name | KK SOD Update Information — SOD update information extraction component (KK prefix indicates K-Opticom customer domain) |
| AdChg | Abbreviation | Address Change — customer address modification processing |
| `db_KK_T_SVKEI_KAISEN_UW` | Field | Database access object for KK_T_SVKEI_KAISEN_UW table — service contract line information work table (UW = update work) |
| `db_KK_T_ADCHG` | Field | Database access object for KK_T_ADCHG table — address change header table |
| `db_KK_T_ADCHG_DTL` | Field | Database access object for KK_T_ADCHG_DTL table — address change detail (line-item) table |
| `db_KK_T_KJ_FIN_WK` | Field | Database access object for KK_T_KJ_FIN_WK table — accounting (KJ = Kaikei) completion work table |
| `db_KU_T_SVKEI_KOJIAK` | Field | Database access object for KU_T_SVKEI_KOJIAK table — service individual customer table (KU = universal table namespace) |
| `db_KK_T_TK_HOSHIKI_KEI` | Field | Database access object for KK_T_TK_HOSHIKI_KEI table — TK (Telecom) contract line table |
| `db_KK_T_SVC_KEI` | Field | Database access object for KK_T_SVC_KEI table — service contract line table |
| KK_T_* | Naming convention | K-Opticom internal temporary work tables (T prefix) |
| KU_T_* | Naming convention | K-Opticom universal namespace temporary tables |
| JBSbatSQLAccess | Class | SQL access utility class providing database cursor and prepared statement management |
| JBSbatBusinessService | Class | Abstract base class defining the batch service lifecycle: `initial()` → `execute()` → `terminal()` |
| JBSbatKKAdChgCstScreenKidou | Class | Address change batch job class — orchestrates multiple sub-services including SOD update extraction |
| SC Code | Term | Service Component Code — naming convention for service/business component identifiers |
| CBS | Abbreviation | Component Business Service — batch processing business logic component |
