# Business Logic — JBSbatKKFmtcelSodUpdInfCst.terminal() [17 LOC]

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

## 1. Role

### JBSbatKKFmtcelSodUpdInfCst.terminal()

This method implements the **business service termination (cleanup) processing** for the Format Cell Service Order Update Information Extraction component. It is invoked as part of the standard batch service lifecycle — specifically as the `terminal()` callback — after the main business processing (`execute()`) completes, regardless of whether the processing succeeded or failed. Its sole responsibility is to release all database access resources held by `JBSbatSQLAccess` objects, ensuring that no DB connections, cursors, or statement handles remain open after the batch job finishes. This follows a standard template-generated cleanup pattern in the K-Opticom batch framework where each service component is responsible for closing its own SQL access handles. The method performs deterministic, unconditional cleanup: there are no conditional branches, no data mutations, and no business logic beyond sequential resource deallocation.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["terminal()"])
    STEP1["Close db_KK_T_SVKEI_KAISEN_UW
(DB Access: Service Contract Line Items)"]
    STEP2["Close db_KK_T_ADCHG_DTL
(DB Access: Address Change Details)"]
    STEP3["Close db_KK_T_KJ_FIN_WK
(DB Access: Work Completion Work)"]
    STEP4["Close db_KU_T_SVKEI_KOJIAK
(DB Access: Service Contract / Work Project)"]
    STEP5["Close db_KK_T_SVC_KEI
(DB Access: Service Contract)"]
    END_NODE(["Return / Next"])

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

**Processing Flow:**

1. The method is invoked by the batch framework after `execute()` completes.
2. It closes 5 `JBSbatSQLAccess` instances in sequence, each responsible for a distinct database table access.
3. After all close operations complete, the method returns `void`, signaling completion to the parent `JBSbatBusinessService` lifecycle.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| - | (none) | - | This method takes no parameters. It operates entirely on instance-level `JBSbatSQLAccess` fields that were initialized during the service lifecycle. |

**Instance Fields Used:**

| Field Name | Type | Business Description |
|-----------|------|---------------------|
| `db_KK_T_SVKEI_KAISEN_UW` | `JBSbatSQLAccess` | DB access handle for the service contract line items work table (`KK_T_SVKEI_KAISEN_UW`) |
| `db_KK_T_ADCHG_DTL` | `JBSbatSQLAccess` | DB access handle for the address change details work table (`KK_T_ADCHG_DTL`) |
| `db_KK_T_KJ_FIN_WK` | `JBSbatSQLAccess` | DB access handle for the work completion work table (`KK_T_KJ_FIN_WK`) |
| `db_KU_T_SVKEI_KOJIAK` | `JBSbatSQLAccess` | DB access handle for the service contract / work project master table (`KU_T_SVKEI_KOJIAK`) |
| `db_KK_T_SVC_KEI` | `JBSbatSQLAccess` | DB access handle for the service contract table (`KK_T_SVC_KEI`) |

## 4. CRUD Operations / Called Services

### Pre-computed evidence from code analysis:

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| D | `db_KK_T_SVKEI_KAISEN_UW.close` | - | `KK_T_SVKEI_KAISEN_UW` | Closes DB access handle for Service Contract Line Items work table |
| D | `db_KK_T_ADCHG_DTL.close` | - | `KK_T_ADCHG_DTL` | Closes DB access handle for Address Change Details work table |
| D | `db_KK_T_KJ_FIN_WK.close` | - | `KK_T_KJ_FIN_WK` | Closes DB access handle for Work Completion Work table |
| D | `db_KU_T_SVKEI_KOJIAK.close` | - | `KU_T_SVKEI_KOJIAK` | Closes DB access handle for Service Contract / Work Project master table |
| D | `db_KK_T_SVC_KEI.close` | - | `KK_T_SVC_KEI` | Closes DB access handle for Service Contract table |

**Classification:** All 5 operations are **D** (Delete / Release) — not database deletions, but deletion of in-memory database access handles (connection/context cleanup). Each `close()` call releases the underlying SQL connection, cursor, and statement resources associated with the respective table access.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: `JBSbatKKFmtcelSodUpdInfCst` (self-lifecycle) | `JBSbatBusinessService.terminate()` [framework] → `JBSbatKKFmtcelSodUpdInfCst.terminal()` | `close [D] KK_T_SVKEI_KAISEN_UW`, `close [D] KK_T_ADCHG_DTL`, `close [D] KK_T_KJ_FIN_WK`, `close [D] KU_T_SVKEI_KOJIAK`, `close [D] KK_T_SVC_KEI` |
| 2 | Batch: `JBSbatKKAdChgCstScreenKidou` (commented-out reference) | `execObjFmtcel.terminal()` — reference exists but is commented out in the caller class | `close [D] KK_T_SVKEI_KAISEN_UW`, `close [D] KK_T_ADCHG_DTL`, `close [D] KK_T_KJ_FIN_WK`, `close [D] KU_T_SVKEI_KOJIAK`, `close [D] KK_T_SVC_KEI` |

**Notes on callers:**
- **Primary caller:** The batch framework (`JBSbatBusinessService.terminate()`) automatically invokes `terminal()` as part of the service lifecycle callback chain. This is a template-generated pattern — the parent class orchestrates the lifecycle (`initial` → `execute` → `terminal`).
- **Secondary reference:** `JBSbatKKAdChgCstScreenKidou` contains commented-out code that would instantiate and call this class's methods. This represents a deprecated or removed integration path.

## 6. Per-Branch Detail Blocks

### Block 1 — SEQUENCE `(resource cleanup)` (L359)

> This block contains the entire method body — a linear sequence of `close()` calls on database access handles. There are no conditional branches, loops, or nested control structures. Each step closes one `JBSbatSQLAccess` object associated with a specific database table.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `db_KK_T_SVKEI_KAISEN_UW.close()` | Close DB access handle for Service Contract Line Items work table (`KK_T_SVKEI_KAISEN_UW`) |
| 2 | EXEC | `db_KK_T_ADCHG_DTL.close()` | Close DB access handle for Address Change Details work table (`KK_T_ADCHG_DTL`) — Added per ST2-2013-0001008 (2013/03/01 OKITA) |
| 3 | EXEC | `db_KK_T_KJ_FIN_WK.close()` | Close DB access handle for Work Completion Work table (`KK_T_KJ_FIN_WK`) |
| 4 | EXEC | `db_KU_T_SVKEI_KOJIAK.close()` | Close DB access handle for Service Contract / Work Project master table (`KU_T_SVKEI_KOJIAK`) |
| 5 | EXEC | `db_KK_T_SVC_KEI.close()` | Close DB access handle for Service Contract table (`KK_T_SVC_KEI`) — Added per ANK-1429-00-00 (2013/03/21 T.TORIKAI) |
| 6 | RETURN | `return;` | Method returns `void` — cleanup complete, control returns to the batch framework |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `KK_T_SVKEI_KAISEN_UW` | Table | Service Contract Line Items Work Table — temporary work table holding detailed line-item data for service contracts (e.g., FTTH, Mail, ENUM service lines). "SVKEI" = Service Detail, "KAISEN" = Extraction, "UW" = Work. |
| `KK_T_ADCHG_DTL` | Table | Address Change Details Work Table — work table storing details of address change operations. Added per ST2-2013-0001008 to support address change processing. "ADCHG" = Address Change. |
| `KK_T_KJ_FIN_WK` | Table | Work Completion Work Table — work table tracking construction/installation work completion status. "KJ" = Koushi (工事, construction/work), "FIN" = Finish, "WK" = Work. |
| `KU_T_SVKEI_KOJIAK` | Table | Service Contract / Work Project Master Table — master/work table linking service contracts to work/project numbers. "KOJIAK" = Kojika-ban (工事番号, work/project number). |
| `KK_T_SVC_KEI` | Table | Service Contract Table — core table storing service contract records. "SVC" = Service, "KEI" = Kei (契約, contract). |
| `SOD` | Acronym | Service Order Data — telecom service order entity in the K-Opticom system. |
| `Fmtcel` | Abbreviation | Format Cell — refers to formatted cell data extraction component in the batch processing pipeline. |
| `JBSbatBusinessService` | Class | Base batch business service class — provides the lifecycle template (`initial`, `execute`, `terminal`) for all batch service components. |
| `JBSbatSQLAccess` | Class | Database access abstraction class — wraps JDBC operations and provides `close()` for resource cleanup. |
| `terminal` | Method | Service termination callback — lifecycle method called after main processing to perform cleanup. |
| 工事完了 | Japanese term | Work Completion — status indicating construction/installation work has been finished. |
| 住所変更 | Japanese term | Address Change — customer address modification operation. |
| サービス契約 | Japanese term | Service Contract — agreement record for telecom services (FTTH, Mail, etc.). |
| サービス契約回線内訳 | Japanese term | Service Contract Line Items — breakdown of individual service lines under a contract. |
| 抽出 | Japanese term | Extraction — data retrieval/process in batch context. |
| ST2 | Change ID | Change ticket prefix: ST2-2013-0001008 — responsible for adding `KK_T_ADCHG_DTL` resource management. |
| ANK | Change ID | Change ticket prefix: ANK-1429-00-00 — responsible for adding `KK_T_SVC_KEI` resource management. |
