# Business Logic — JBSbatKKAdChgAddDataCst.setPrg() [64 LOC]

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

## 1. Role

### JBSbatKKAdChgAddDataCst.setPrg()

This method populates the progress output Map with the **progress service contract number** (progression contract ID) mapped to the correct output key based on the **service code** (svcCd). It acts as a **data routing transformer** in the batch address change processing pipeline (`KKAdChg` — Kyo-yaku Address Henkou, contract address modification). The method dispatches by service type: for **Internet services** (`SVC_CD_NET = "01"`), it writes both the primary contract number and the cancellation-side contract number (added in OM-2014-0001653) to the output Map; for **Telephone services** (`SVC_CD_TEL = "02"`), it writes only the primary contract number; for **Television services** (`SVC_CD_TV = "03"`), it writes both the primary contract number and the cancellation-side contract number (also added in OM-2014-0001653); and for **unknown service types**, it silently skips all contract number assignments (ignore block). In all cases, if the address change is **new** (`isNew = true`), it additionally sets the **contractor address change presence/absence flag** (`kshadChgUm`) into the output Map — this is used to track whether the contractor has moved or changed their registered address during service provisioning. The method implements a **routing/dispatch pattern** combined with a **null-safety guard** (isBlank checks) that normalizes empty or null values to empty strings before outputting. It is a shared utility called by `JBSbatKKAdChgAddDataCst.execute()` and its own recursive `setPrg()` overload, serving as a critical data-mapping step in the batch address change flow where service contract numbers must be correctly routed to downstream output files or interfaces.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["setPrg outMap svcCd prgSvcKeiNo prgSvcKeiNoDsl kshadChgUm isNew"])

    START --> SVC_CHECK{Check svcCd}

    SVC_CHECK --> NET_SVC{svcCd equals SVC_CD_NET}
    NET_SVC -->|True| NET_BLOCK[Handle Internet Service]
    NET_SVC -->|False| TEL_SVC{svcCd equals SVC_CD_TEL}
    TEL_SVC -->|True| TEL_BLOCK[Handle Telephone Service]
    TEL_SVC -->|False| TV_SVC{svcCd equals SVC_CD_TV}
    TV_SVC -->|True| TV_BLOCK[Handle Television Service]
    TV_SVC -->|False| IGNORE_BLOCK[Ignore unknown service type]

    NET_BLOCK --> NET_CHECK{isBlank prgSvcKeiNo}
    NET_CHECK -->|True| NET_SET_EMPTY1[setString PRG_SVC_KEI_NO_NET empty]
    NET_CHECK -->|False| NET_SET_VALUE1[setString PRG_SVC_KEI_NO_NET prgSvcKeiNo]
    NET_SET_EMPTY1 --> NET_DSL_CHECK{isBlank prgSvcKeiNoDsl}
    NET_SET_VALUE1 --> NET_DSL_CHECK
    NET_DSL_CHECK -->|True| NET_SET_EMPTY2[setString PRG_SVC_KEI_NO_NET_DSL empty]
    NET_DSL_CHECK -->|False| NET_SET_VALUE2[setString PRG_SVC_KEI_NO_NET_DSL prgSvcKeiNoDsl]
    NET_SET_EMPTY2 --> TEL_BLOCK
    NET_SET_VALUE2 --> TEL_BLOCK

    TEL_BLOCK --> TEL_CHECK{isBlank prgSvcKeiNo}
    TEL_CHECK -->|True| TEL_SET_EMPTY[setString PRG_SVC_KEI_NO_TEL empty]
    TEL_CHECK -->|False| TEL_SET_VALUE[setString PRG_SVC_KEI_NO_TEL prgSvcKeiNo]
    TEL_SET_EMPTY --> IGNORE_BLOCK
    TEL_SET_VALUE --> IGNORE_BLOCK

    TV_BLOCK --> TV_CHECK{isBlank prgSvcKeiNo}
    TV_CHECK -->|True| TV_SET_EMPTY1[setString PRG_SVC_KEI_NO_TV empty]
    TV_CHECK -->|False| TV_SET_VALUE1[setString PRG_SVC_KEI_NO_TV prgSvcKeiNo]
    TV_SET_EMPTY1 --> TV_DSL_CHECK{isBlank prgSvcKeiNoDsl}
    TV_SET_VALUE1 --> TV_DSL_CHECK
    TV_DSL_CHECK -->|True| TV_SET_EMPTY2[setString PRG_SVC_KEI_NO_TV_DSL empty]
    TV_DSL_CHECK -->|False| TV_SET_VALUE2[setString PRG_SVC_KEI_NO_TV_DSL prgSvcKeiNoDsl]
    TV_SET_EMPTY2 --> IGNORE_BLOCK
    TV_SET_VALUE2 --> IGNORE_BLOCK

    IGNORE_BLOCK --> ADDR_CHECK{isNew is true}
    ADDR_CHECK -->|True| ADDR_KSHAD_CHECK{kshadChgUm blank}
    ADDR_CHECK -->|False| END_NODE(["Return void"])

    ADDR_KSHAD_CHECK -->|True| ADDR_SET_EMPTY[setString KSHAD_CHG_UM empty]
    ADDR_KSHAD_CHECK -->|False| ADDR_SET_VALUE[setString KSHAD_CHG_UM kshadChgUm]
    ADDR_SET_EMPTY --> END_NODE
    ADDR_SET_VALUE --> END_NODE
```

**Processing flow description:**

1. **Service code dispatch:** The method compares `svcCd` against three known service type constants — `SVC_CD_NET = "01"` (Internet Service), `SVC_CD_TEL = "02"` (Telephone Service), and `SVC_CD_TV = "03"` (Television Service) — to determine the service category.

2. **Internet branch (`svcCd = "01"`):** Sets the progress service contract number (net) with null-safety, then sets the cancellation-side progress service contract number (net, DSL) with null-safety. Both fields are optional.

3. **Telephone branch (`svcCd = "02"`):** Sets the progress service contract number (telephone) with null-safety. No cancellation-side field is supported for telephone.

4. **Television branch (`svcCd = "03"`):** Sets the progress service contract number (TV) with null-safety, then sets the cancellation-side progress service contract number (TV, DSL) with null-safety. Both fields are optional.

5. **Ignore branch (unknown `svcCd`):** No contract number is set. Processing continues to the final block.

6. **Address change flag block:** Regardless of the service type branch taken, if `isNew` is `true` and `kshadChgUm` is provided, the contractor address change presence/absence flag is set in the output Map. If `isNew` is `false`, this block is entirely skipped — the flag is not set for existing (non-new) address changes.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `outMap` | `JBSbatServiceInterfaceMap` | The output data transfer object (Map) where the progress service contract numbers and address change flag are written. This Map serves as the interface between batch processing stages, carrying structured data from this service method to downstream processors or output file writers. |
| 2 | `svcCd` | `String` | Service code that determines the service type and which output key to use. Valid values are `"01"` (Internet Service), `"02"` (Telephone Service), and `"03"` (Television Service). If the value does not match any of these, the contract number block is skipped (silent ignore). |
| 3 | `prgSvcKeiNo` | `String` | Progress service contract number — the progression contract ID for the service line item. This is the primary contract identifier that tracks the service's status through the fulfillment pipeline. Used as the main service contract number for the determined service type (Net/Tel/TV). |
| 4 | `prgSvcKeiNoDsl` | `String` | Progress service contract number (cancellation side) — the contract number associated with the cancellation/dissolution side of the service. Only relevant for Internet and TV service types. Added in OM-2014-0001653 to support cancellation tracking. Empty or null when not applicable. |
| 5 | `kshadChgUm` | `String` | Contractor address change presence/absence indicator — a flag value that indicates whether the contractor has changed their registered address. Trimmed before comparison; if blank after trimming, an empty string is set in the output. |
| 6 | `isNew` | `boolean` | Flag indicating whether this is a new address change record (`true`) or an update to an existing one (`false`). When `true`, the `kshadChgUm` field is written to the output Map. When `false`, the address change flag is not set, effectively preserving the prior state. |

**External state / instance fields read:** None directly. The method relies on static constants (`JKKBatConst`), static utility methods (`isBlank`), and instance methods on the parameter object (`outMap.setString`).

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `JBSbatKKIFM101.PRG_SVC_KEI_NO_NET` | - | - | Output field key constant for progress service contract number (Net) |
| - | `JBSbatKKIFM101.PRG_SVC_KEI_NO_NET_DSL` | - | - | Output field key constant for progress service contract number (Net, cancellation side) |
| - | `JBSbatKKIFM101.PRG_SVC_KEI_NO_TEL` | - | - | Output field key constant for progress service contract number (Telephone) |
| - | `JBSbatKKIFM101.PRG_SVC_KEI_NO_TV` | - | - | Output field key constant for progress service contract number (TV) |
| - | `JBSbatKKIFM101.PRG_SVC_KEI_NO_TV_DSL` | - | - | Output field key constant for progress service contract number (TV, cancellation side) |
| - | `JBSbatKKIFM101.KSHAD_CHG_UM` | - | - | Output field key constant for contractor address change presence/absence |
| - | `JBSbatServiceInterfaceMap.setString` | - | - | Sets a key-value pair in the output Map interface — transforms in-memory data structure |
| - | `JBSbatKKAdChgAddDataCst.isBlank` | - | - | Null/safety check utility — validates whether a String is null or empty |
| - | `JBSbatKKAdChgAddDataCst.trim` (via `String.trim()`) | - | - | Trims whitespace from the contractor address change flag before blank comparison |

This method is purely a **data routing and mapping** method — it does not perform any Create/Read/Update/Delete operations on database tables or invoke service components (SC/CBS). All its operations are in-memory: reading constants, evaluating conditions, checking string blanks, and writing key-value pairs to the output `JBSbatServiceInterfaceMap`. The terminal operations are all `setString` calls on the `outMap` object and a `trim` call on the `kshadChgUm` string parameter.

## 5. Dependency Trace

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

No screen/batch entry points found within 8 hops. Direct callers found: 2 methods.
Terminal operations from this method: `setString` [-], `setString` [-], `setString` [-], `setString` [-], `setString` [-], `setString` [-], `setString` [-], `setString` [-], `setString` [-], `setString` [-], `trim` [-], `trim` [-], `trim` [-], `trim` [-], `trim` [-], `setString` [-], `setString` [-], `setString` [-], `setString` [-], `setString` [-]

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: JBSbatKKAdChgAddDataCst.execute() | `execute()` -> `setPrg(outMap, svcCd, prgSvcKeiNo, prgSvcKeiNoDsl, kshadChgUm, isNew)` | `setString [U] PRG_SVC_KEI_NO_NET`<br/>`setString [U] PRG_SVC_KEI_NO_NET_DSL`<br/>`setString [U] PRG_SVC_KEI_NO_TEL`<br/>`setString [U] PRG_SVC_KEI_NO_TV`<br/>`setString [U] PRG_SVC_KEI_NO_TV_DSL`<br/>`setString [U] KSHAD_CHG_UM` |
| 2 | Batch: JBSbatKKAdChgAddDataCst (recursive/self-call) | `setPrg()` -> `setPrg(...)` (overload resolution) | `setString [U] PRG_SVC_KEI_NO_NET`<br/>`setString [U] PRG_SVC_KEI_NO_NET_DSL`<br/>`setString [U] PRG_SVC_KEI_NO_TEL`<br/>`setString [U] PRG_SVC_KEI_NO_TV`<br/>`setString [U] PRG_SVC_KEI_NO_TV_DSL`<br/>`setString [U] KSHAD_CHG_UM` |

**Notes:**
- This method is called from within the same class (`JBSbatKKAdChgAddDataCst`) by its `execute()` method and by an overloaded `setPrg()` variant (recursive delegation).
- No screen entry points (KKSV*) were found within 8 hops — this is a batch-only internal method, not exposed to user screens.
- The terminal operations are all `setString` calls that populate the output `JBSbatServiceInterfaceMap` with progress service contract numbers and address change flags. These are in-memory mutations, not database operations.

## 6. Per-Branch Detail Blocks

**Block 1** — [IF] `(svcCd equals SVC_CD_NET = "01" — Internet Service)` (L1895)

> Determines whether the service is an Internet-type broadband service. If true, enters the Net-specific contract number assignment block, which writes both the primary contract number and the cancellation-side (DSL) contract number.

| # | Type | Code |
|---|------|------|
| 1 | COND | `JKKBatConst.SVC_CD_NET.equals(svcCd)` [-> `SVC_CD_NET = "01"`] |
| 2 | EXEC | Check if `prgSvcKeiNo` is blank (primary contract number) |

**Block 1.1** — [IF-ELSE-IF: isBlank(prgSvcKeiNo)] `(primary contract number null-safety)` (L1899)

> Null-safety guard for the primary progress service contract number (Net). Writes an empty string if the value is null or blank; otherwise writes the actual contract number.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `isBlank(prgSvcKeiNo)` [-> utility method, returns true if null or empty] |
| 2 | SET | `outMap.setString(JBSbatKKIFM101.PRG_SVC_KEI_NO_NET, "")` [if blank] |
| 3 | SET | `outMap.setString(JBSbatKKIFM101.PRG_SVC_KEI_NO_NET, prgSvcKeiNo)` [if not blank] |

**Block 1.2** — [IF-ELSE-IF: isBlank(prgSvcKeiNoDsl)] `(cancellation-side contract number null-safety)` (L1906)

> Null-safety guard for the cancellation-side (DSL) progress service contract number (Net). Only written for Internet services. Added in OM-2014-0001653.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `isBlank(prgSvcKeiNoDsl)` [-> utility method, returns true if null or empty] |
| 2 | SET | `outMap.setString(JBSbatKKIFM101.PRG_SVC_KEI_NO_NET_DSL, "")` [if blank] |
| 3 | SET | `outMap.setString(JBSbatKKIFM101.PRG_SVC_KEI_NO_NET_DSL, prgSvcKeiNoDsl)` [if not blank] |

**Block 2** — [ELSE-IF] `(svcCd equals SVC_CD_TEL = "02" — Telephone Service)` (L1913)

> Determines whether the service is a telephone-type service. If true, enters the Tel-specific block which writes only the primary contract number (no cancellation-side field for telephone).

| # | Type | Code |
|---|------|------|
| 1 | COND | `JKKBatConst.SVC_CD_TEL.equals(svcCd)` [-> `SVC_CD_TEL = "02"`] |
| 2 | EXEC | Check if `prgSvcKeiNo` is blank |

**Block 2.1** — [IF-ELSE-IF: isBlank(prgSvcKeiNo)] `(telephone contract number null-safety)` (L1918)

> Null-safety guard for the progress service contract number (Telephone). Writes an empty string or the actual value.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `isBlank(prgSvcKeiNo)` [-> utility method] |
| 2 | SET | `outMap.setString(JBSbatKKIFM101.PRG_SVC_KEI_NO_TEL, "")` [if blank] |
| 3 | SET | `outMap.setString(JBSbatKKIFM101.PRG_SVC_KEI_NO_TEL, prgSvcKeiNo)` [if not blank] |

**Block 3** — [ELSE-IF] `(svcCd equals SVC_CD_TV = "03" — Television Service)` (L1923)

> Determines whether the service is a television-type service. If true, enters the TV-specific block which writes both the primary contract number and the cancellation-side (DSL) contract number, mirroring the Net pattern.

| # | Type | Code |
|---|------|------|
| 1 | COND | `JKKBatConst.SVC_CD_TV.equals(svcCd)` [-> `SVC_CD_TV = "03"`] |
| 2 | EXEC | Check if `prgSvcKeiNo` is blank |

**Block 3.1** — [IF-ELSE-IF: isBlank(prgSvcKeiNo)] `(TV contract number null-safety)` (L1928)

> Null-safety guard for the progress service contract number (TV).

| # | Type | Code |
|---|------|------|
| 1 | CALL | `isBlank(prgSvcKeiNo)` [-> utility method] |
| 2 | SET | `outMap.setString(JBSbatKKIFM101.PRG_SVC_KEI_NO_TV, "")` [if blank] |
| 3 | SET | `outMap.setString(JBSbatKKIFM101.PRG_SVC_KEI_NO_TV, prgSvcKeiNo)` [if not blank] |

**Block 3.2** — [IF-ELSE-IF: isBlank(prgSvcKeiNoDsl)] `(TV cancellation-side contract number null-safety)` (L1936)

> Null-safety guard for the cancellation-side (DSL) progress service contract number (TV). Added in OM-2014-0001653.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `isBlank(prgSvcKeiNoDsl)` [-> utility method] |
| 2 | SET | `outMap.setString(JBSbatKKIFM101.PRG_SVC_KEI_NO_TV_DSL, "")` [if blank] |
| 3 | SET | `outMap.setString(JBSbatKKIFM101.PRG_SVC_KEI_NO_TV_DSL, prgSvcKeiNoDsl)` [if not blank] |

**Block 4** — [ELSE] `(ignore — unknown service type)` (L1942)

> When `svcCd` does not match any known service type (`"01"`, `"02"`, `"03"`), the contract number assignment is entirely skipped. This is an intentional no-op: unknown service codes are silently ignored without throwing an error, allowing the processing pipeline to continue to the address change flag block.

| # | Type | Code |
|---|------|------|
| 1 | COMMENT | `// ignore` — no operation for unknown service codes |

**Block 5** — [IF] `(isNew == true — new address change record)` (L1946)

> Determines whether this is a new address change record. Only when `isNew` is `true` does the method write the contractor address change presence/absence flag (`kshadChgUm`) to the output Map. This ensures that the flag is only set for new records, not when re-processing existing ones. The Japanese comment reads: `住所変更有無を設定` (set address change presence/absence).

| # | Type | Code |
|---|------|------|
| 1 | COND | `isNew` [boolean flag — true means new record] |
| 2 | EXEC | Check if `kshadChgUm` is blank after trimming |

**Block 5.1** — [IF-ELSE-IF: kshadChgUm is blank after trim] `(contractor address change flag null-safety)` (L1947)

> Null-safety guard for the contractor address change presence/absence indicator. Trims whitespace from `kshadChgUm` before comparison, then writes an empty string if blank; otherwise writes the actual value.

| # | Type | Code |
|---|------|------|
| 1 | COND | `kshadChgUm == null` [null check] |
| 2 | COND | `"\".equals(kshadChgUm.trim())"` [empty string check after trim] |
| 3 | SET | `outMap.setString(JBSbatKKIFM101.KSHAD_CHG_UM, "")` [if null or blank after trim] |
| 4 | SET | `outMap.setString(JBSbatKKIFM101.KSHAD_CHG_UM, kshadChgUm)` [if non-blank] |

**Block 6** — [ELSE] `(isNew == false — existing record)` (implicit)

> When `isNew` is `false`, the address change flag block is entirely skipped. The method proceeds to return without writing the `KSHAD_CHG_UM` field.

| # | Type | Code |
|---|------|------|
| 1 | COMMENT | `// isNew is false — skip KSHAD_CHG_UM setting` |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `svcCd` | Field | Service Code — a string identifier that determines the service type: "01" for Internet, "02" for Telephone, "03" for Television |
| `prgSvcKeiNo` | Field | Progress Service Contract Number — the progression contract ID (contract line item number) for the service being processed. Tracks the service through the fulfillment pipeline. |
| `prgSvcKeiNoDsl` | Field | Progress Service Contract Number (Cancellation Side) — the contract number associated with service cancellation/dissolution. Used for Internet and TV services. Introduced in OM-2014-0001653 (2014/04/25). |
| `kshadChgUm` | Field | Contractor Address Change Presence/Absence — a flag indicating whether the contractor has changed their registered address. "Um" comes from Japanese "有無" (uun / um) meaning "presence or absence". |
| `isNew` | Field | New Record Flag — boolean indicating whether this is a new address change (`true`) or a re-processing of an existing record (`false`). |
| `outMap` | Field | Output Service Interface Map — a Map-based data transfer object that carries structured data between batch processing stages. Serves as the contract number output container. |
| `JBSbatKKAdChgAddDataCst` | Class | Batch Address Change Add Data Constant — a batch service class responsible for adding and setting contract-related data during the address change processing flow. "KK" = 契約 (contract), "AdChg" = Address Change, "AddDataCst" = Add Data Constant. |
| `JKKBatConst` | Class | Batch Constants — a central constant definition class for the contract management batch system, defining service codes, price group codes, and other batch configuration values. |
| `JBSbatKKIFM101` | Class | Batch Address Change Interface Map 101 — a field key constant class defining output Map keys for address change batch processing, including all progress service contract number field identifiers. |
| `SVC_CD_NET = "01"` | Constant | Internet Service Code — identifies broadband/Internet-type services (eo Hikari Net). |
| `SVC_CD_TEL = "02"` | Constant | Telephone Service Code — identifies telephone-type services. |
| `SVC_CD_TV = "03"` | Constant | Television Service Code — identifies television-type services. |
| `PRG_SVC_KEI_NO_NET` | Constant | Output Map key for progress service contract number (Internet/Net). |
| `PRG_SVC_KEI_NO_NET_DSL` | Constant | Output Map key for progress service contract number (Internet/Net, cancellation side). Added in OM-2014-0001653. |
| `PRG_SVC_KEI_NO_TEL` | Constant | Output Map key for progress service contract number (Telephone). |
| `PRG_SVC_KEI_NO_TV` | Constant | Output Map key for progress service contract number (Television). |
| `PRG_SVC_KEI_NO_TV_DSL` | Constant | Output Map key for progress service contract number (Television, cancellation side). Added in OM-2014-0001653. |
| `KSHAD_CHG_UM` | Constant | Output Map key for contractor address change presence/absence. |
| `isBlank` | Method | Utility method that checks whether a String is null or has zero length (blank). |
| Net | Business term | Internet broadband service — specifically eo Hikari (Fiber To The Home) internet service. |
| TEL | Business term | Telephone service — traditional voice telephone service line. |
| TV | Business term | Television service — cable/satellite television broadcasting service. |
| DSL | Business term | Cancellation side (dissolution) — in this context, refers to the contract number for the cancellation/dissolution side of a service, used when a customer cancels a service. |
| 進捗サービス契約番号 | Japanese term | Progress Service Contract Number — the contract line item ID that tracks a service's status through the order fulfillment and provisioning pipeline. |
| 住所変更有無 | Japanese term | Address Change Presence/Absence — a flag indicating whether the contractor has moved or changed their registered address. |
| OM-2014-0001653 | Change ticket | Change request ticket for adding cancellation-side (DSL) contract number support for Internet and TV services. Implemented 2014/04/25 by Hoshino (星野). |
| JBSbatServiceInterfaceMap | Class | Service batch interface Map — a Map-based data transfer interface used to pass structured data between batch processing components. |
