# Business Logic — JBSbatKKAdHenkoHoyuDataUpdOtr.initial() [21 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.business.service.JBSbatKKAdHenkoHoyuDataUpdOtr` |
| Layer | Service (Batch service component, extends `JBSbatBusinessService`) |
| Module | `service` (Package: `eo.business.service`) |

## 1. Role

### JBSbatKKAdHenkoHoyuDataUpdOtr.initial()

This method is the **initialization hook** for a batch service responsible for updating records in the "change-target address list work table" (`KK_T_CHG_AD_JGRTWK`). It is part of the K-Opticom Customer Backbone System and handles address master update operations for telecom service contracts — specifically, it manages the workflow of identifying which address records need updating after a customer's address has been consolidated or modified.

The method follows the **template method pattern** common in batch frameworks: `JBSbatBusinessService` defines `initial()` as an abstract lifecycle hook that is invoked before the main `execute()` processing. This subclass implements it to wire up the five database access objects (`JBSbatSQLAccess` instances) that the batch will use for CRUD operations during its main processing phase, and initializes a working list (`adBfList`) used to cache pre-change address records.

It also calls `super.setCommonInfo(commonItem)` to propagate the batch common parameters to the parent class, ensuring the common batch metadata (such as batch ID, process date, and operator information) is properly set.

The method has **no conditional branches** — it performs a deterministic sequence of initialization steps. It does not read or write to any database tables directly; it only prepares the infrastructure (SQL access handles and cached data structures) that the subsequent `execute()` method will use to query `ZM_M_AD` (address master), update `KK_T_CHG_AD_JGRTWK`, and coordinate with related tables.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["initial(commonItem)"])
    STEP1["Create db_CHG_AD_JGRTWK access<br/>for KK_T_CHG_AD_JGRTWK table"]
    STEP2["Create db_CK_T_PROSCST access<br/>for CK_T_PROSCST table"]
    STEP3["Create db_DK_T_YBKIKI_HAISO access<br/>for DK_T_YBKIKI_HAISO table"]
    STEP4["Create db_KU_T_SENKO_DSGN access<br/>for KU_T_SENKO_DSGN table"]
    STEP5["Create db_ZM_M_AD access<br/>for ZM_M_AD table (OM-2019-0001393)"]
    STEP6["Call super.setCommonInfo(commonItem)<br/>Set common batch parameters"]
    STEP7["Initialize adBfList<br/>as empty HashMap (OM-2019-0001393)"]
    END_NODE(["Return / Next"])

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

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `commonItem` | `JBSbatCommonItem` | The batch common parameter document carrying shared batch execution metadata — including batch execution ID, process date/time, operator ID, and flags that govern batch behavior across all services. This object is passed to each `JBSbatSQLAccess` constructor to propagate batch context (such as connection pool selection and audit metadata) to all DB access handles created in this method. |

**Instance fields set by this method:**

| No | Field Name | Type | Business Description |
|----|-----------|------|---------------------|
| 1 | `db_CHG_AD_JGRTWK` | `JBSbatSQLAccess` | Database access handle for the change-target address list work table (`KK_T_CHG_AD_JGRTWK`) — used in `execute()` to update processing status flags. |
| 2 | `db_CK_T_PROSCST` | `JBSbatSQLAccess` | Database access handle for the proposal service contract table (`CK_T_PROSCST`, schema `CK0051`) — referenced for service contract coordination. |
| 3 | `db_DK_T_YBKIKI_HAISO` | `JBSbatSQLAccess` | Database access handle for the backup delivery table (`DK_T_YBKIKI_HAISO`, schema `DK0061`) — referenced for backup delivery coordination. |
| 4 | `db_KU_T_SENKO_DSGN` | `JBSbatSQLAccess` | Database access handle for the advance design table (`KU_T_SENKO_DSGN`, schema `KU0101`) — referenced for advance design coordination. |
| 5 | `db_ZM_M_AD` | `JBSbatSQLAccess` | Database access handle for the address master table (`ZM_M_AD`) — added in v45.00.00 (OM-2019-0001393) to support address consolidation handling; used in `execute()` to look up the previous generation of address records. |
| 6 | `adBfList` | `HashMap<String, JBSbatCommonDBInterface>` | Pre-change address list — a working cache that maps address codes (`AD_CD`) to their pre-change address records (`JBSbatCommonDBInterface`). Initialized as empty here and populated during `execute()` when the new and old address codes match. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `JBSbatBusinessService.setCommonInfo` | JBSbatBusinessService | - | Calls `setCommonInfo` in the parent batch service class to propagate common batch parameters |

### Method calls within `initial()`:

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `super.setCommonInfo(commonItem)` | JBSbatBusinessService | - | Sets common batch parameters on the parent class from `commonItem` — establishes batch execution context for downstream processing |

### DB access objects created (no CRUD performed here — infrastructure only):

| DB Handle | Entity / Table | Business Description |
|-----------|---------------|---------------------|
| `db_CHG_AD_JGRTWK` | `KK_T_CHG_AD_JGRTWK` | Change-target address list work table — stores address records flagged for processing during the address update batch. |
| `db_CK_T_PROSCST` | `CK_T_PROSCST` | Proposal service contract table — service contract data linked by schema ID `CK0051`. |
| `db_DK_T_YBKIKI_HAISO` | `DK_T_YBKIKI_HAISO` | Backup delivery table — backup delivery scheduling data linked by schema ID `DK0061`. |
| `db_KU_T_SENKO_DSGN` | `KU_T_SENKO_DSGN` | Advance design table — advance installation design data linked by schema ID `KU0101`. |
| `db_ZM_M_AD` | `ZM_M_AD` | Address master table — contains current and historical address records; queried via SQL key `KK_SELECT_012` in `execute()` to retrieve the previous generation of address records when the new and old address codes match. |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: `JBSbatBusinessService` (abstract framework) | `JBSbatBusinessService.executeBatch()` -> `initial(commonItem)` [abstract lifecycle hook] | `setCommonInfo [U] common batch params` |

**Notes on caller chain:**
- `initial()` is an **abstract method** declared in the parent class `JBSbatBusinessService` (line 85: `public abstract void initial(JBSbatCommonItem commonItem) throws Exception`).
- It is invoked by the batch execution framework after the batch job loads and validates the common parameters, and before the main `execute()` processing begins.
- The batch framework orchestrates: `load commonItem` -> `initial(commonItem)` -> `execute(inMap)` -> `post-process`.
- This method is not called directly by any screen or external batch entry point — it is a **framework lifecycle callback** invoked by the K-Opticom batch processing engine.

## 6. Per-Branch Detail Blocks

> This method has no conditional branches. It executes a fixed, sequential initialization sequence.

**Block 1** — [SEQUENTIAL STEPS] (L76)

> Create database access handles for the five tables this batch service will operate on during its main processing phase.

| # | Type | Code |
|---|------|------|
| 1 | SET | `db_CHG_AD_JGRTWK = new JBSbatSQLAccess(commonItem, "KK_T_CHG_AD_JGRTWK")` // Create DB access handle for the change-target address list work table |
| 2 | SET | `db_CK_T_PROSCST = new JBSbatSQLAccess(commonItem, "CK_T_PROSCST")` // Create DB access handle for proposal service contract table [-> PROSCST_SKEMA_ID="CK0051"] |
| 3 | SET | `db_DK_T_YBKIKI_HAISO = new JBSbatSQLAccess(commonItem, "DK_T_YBKIKI_HAISO")` // Create DB access handle for backup delivery table [-> YBKIKI_HAISO_SKEMA_ID="DK0061"] |
| 4 | SET | `db_KU_T_SENKO_DSGN = new JBSbatSQLAccess(commonItem, "KU_T_SENKO_DSGN")` // Create DB access handle for advance design table [-> SENKO_DSGN_SKEMA_ID="KU0101"] |
| 5 | SET | `db_ZM_M_AD = new JBSbatSQLAccess(commonItem, "ZM_M_AD")` // Create DB access handle for address master table (Added in v45.00.00, OM-2019-0001393) |

**Block 2** — [SEQUENTIAL STEP] (L86)

> Set common batch parameters on the parent class.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `super.setCommonInfo(commonItem)` // Set common batch parameters — propagates batch execution context to parent framework |

**Block 3** — [SEQUENTIAL STEP] (L89)

> Initialize the pre-change address list cache. Added in v45.00.00 (OM-2019-0001393) for address consolidation handling.

| # | Type | Code |
|---|------|------|
| 1 | SET | `adBfList = new HashMap<String, JBSbatCommonDBInterface>()` // Initialize empty map to cache pre-change address records keyed by address code [-> adBfList] |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `KK_T_CHG_AD_JGRTWK` | Table | Change-target address list work table — a batch working table that holds address records identified for processing during the address update batch workflow. |
| `CK_T_PROSCST` | Table | Proposal service contract table — stores service contract proposals, linked by schema ID `CK0051`. |
| `DK_T_YBKIKI_HAISO` | Table | Backup delivery table — stores backup delivery scheduling information, linked by schema ID `DK0061`. |
| `KU_T_SENKO_DSGN` | Table | Advance design table — stores advance installation design records, linked by schema ID `KU0101`. |
| `ZM_M_AD` | Table | Address master table — the definitive address reference table containing current and historical address records (city, ward, town,大字, chome, etc.). |
| `adBfList` | Field | Pre-change address list — a HashMap that caches address records retrieved from `ZM_M_AD` before they are updated, keyed by address code (`AD_CD`). Used during address consolidation processing. |
| `CHG_AD_JGRTWK_NO` | Field | Change-target address list work number — the primary key used to identify a batch of address records to be processed. |
| `AD_CD` | Field | Address code — a unique identifier for an address record in the address master. |
| `NEW_AD_CD` | Field | New address code — the address code after address consolidation (post-update). |
| `PCD` | Field | Postal code — Japanese postal code for an address. |
| `STATE_NM` | Field | Prefecture name — the prefecture portion of a Japanese address (e.g., 東京都). |
| `CITY_NM` | Field | City name — the city/ward portion of a Japanese address. |
| `OAZTSU_NM` | Field | Oaza/cho name — the大字 (oaza) or town name portion of a Japanese address (rural/suburban addressing). |
| `AZCHO_NM` | Field | Chome/block name — the丁目 (chome) and block portion of a Japanese address (urban addressing). |
| `JBSbatBusinessService` | Class | Abstract batch service base class — defines the batch processing lifecycle including `initial()`, `execute()`, and `setCommonInfo()` methods. |
| `JBSbatSQLAccess` | Class | Database access abstraction class — wraps SQL execution, providing `selectNext()`, `updateByPrimaryKeys()`, and other CRUD operations for batch processing. |
| `JBSbatCommonItem` | Class | Batch common parameter object — carries shared batch metadata including batch ID, process date, operator info, and system flags. |
| `JBSbatCommonDBInterface` | Interface | Common database record interface — represents a row of data retrieved from or prepared for a database table, accessible via `getString()` and `setValue()`. |
| `JBSbatServiceInterfaceMap` | Class | Service interface map — a key-value map carrying input data between batch service methods. |
| `setCommonInfo` | Method | Sets common batch parameters on the parent service class from `commonItem`, establishing shared execution context. |
| K-Opticom | System | K-Opticom Customer Backbone System — the enterprise telecom customer management system serving as the core platform. |
| v45.00.00 | Version | Release v45.00.00 (2019/09/02) — added address consolidation processing (ANK-3689-00-00) and address master lookup via `ZM_M_AD` (OM-2019-0001393). |
| OM-2019-0001393 | Change ID | Change request OM-2019-0001393 — disaster response update adding address master table access for address consolidation support. |
| ANK-3689-00-00 | Change ID | Change request ANK-3689-00-00 — address consolidation handling improvement (v45.00.00). |
