# Business Logic — JBSbatKKOpsvkeiDelTrgtChsht.setDelTrgtDataEmail() [51 LOC]

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

## 1. Role

### JBSbatKKOpsvkeiDelTrgtChsht.setDelTrgtDataEmail()

This method is the **deletion target data configuration handler for email-related items** (消去対象データ設定処理(Eメール)). It is invoked as part of a batch job that processes deletion targets for service contracts — specifically, it identifies and prepares email-related data that needs to be flagged for deletion processing. The method implements a **routing/dispatch pattern**: it reads three optional email-related fields from the input map (email address, mail alias, and POP ID), and for each non-empty field, it initializes a dedicated output map with the appropriate deletion processing type and target classification, then adds it to the output bean's result list. Its role is to act as a **data pre-filter and classifier** within the larger deletion target selection batch (`JBSbatKKOpsvkeiDelTrgtChsht`), bridging the input command with the downstream deletion processing logic by setting flags (`setOutFlg(true)`) and routing keys (DEL_TRAN_SBT, DEL_TRGT_SBT) that dictate how each item is handled downstream.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["setDelTrgtDataEmail(inMap, outputBean)"])
    START --> GET1["Extract mlad, alias, popID from inMap"]
    GET1 --> COND_MLAD{mlad != null<br>&<br>mlad != ""}
    COND_MLAD -- true --> BLOCK_MLAD["Block: Email Address Processing<br>L217-L226"]
    BLOCK_MLAD --> GET_MLAD["initData(inMap)"]
    GET_MLAD --> SET_DT_MLAD["set DEL_TRAN_SBT = getDelTranSbt(inMap)"]
    SET_DT_MLAD --> SET_DST_MLAD["set DEL_TRGT_SBT = DEL_TRGT_SBT_MLAD = 03"]
    SET_DST_MLAD --> SET_MLAD["set MLAD = mlad"]
    SET_MLAD --> SET_FLG_MLAD["setOutFlg(true)"]
    SET_FLG_MLAD --> ADD_MLAD["outputBean.addOutMapList(outMap)"]
    ADD_MLAD --> COND_ALIAS{alias != null<br>&<br>alias != ""}
    COND_MLAD -- false --> COND_ALIAS
    COND_ALIAS -- true --> BLOCK_ALIAS["Block: Mail Alias Processing<br>L228-L237"]
    BLOCK_ALIAS --> INIT_ALIAS["initData(inMap)"]
    INIT_ALIAS --> SET_DT_ALIAS["set DEL_TRAN_SBT = DEL_TRAN_SBT_AGING_UPD = 2"]
    SET_DT_ALIAS --> SET_DST_ALIAS["set DEL_TRGT_SBT = DEL_TRGT_SBT_MAILALIAS = 04"]
    SET_DST_ALIAS --> SET_MAIL_ALIAS["set MAILALIAS = alias"]
    SET_MAIL_ALIAS --> SET_FLG_ALIAS["setOutFlg(true)"]
    SET_FLG_ALIAS --> ADD_ALIAS["outputBean.addOutMapList(outMap)"]
    ADD_ALIAS --> COND_POPID{popID != null<br>&<br>popID != ""}
    COND_ALIAS -- false --> COND_POPID
    COND_POPID -- true --> BLOCK_POPID["Block: POPID Processing<br>L248-L257"]
    BLOCK_POPID --> INIT_POPID["initData(inMap)"]
    INIT_POPID --> SET_DT_POPID["set DEL_TRAN_SBT = DEL_TRAN_SBT_AGING_UPD = 2"]
    SET_DT_POPID --> SET_DST_POPID["set DEL_TRGT_SBT = DEL_TRGT_SBT_POP_ID = 15"]
    SET_DST_POPID --> SET_POP_ID["set POP_ID = popID"]
    SET_POP_ID --> SET_FLG_POPID["setOutFlg(true)"]
    SET_FLG_POPID --> ADD_POPID["outputBean.addOutMapList(outMap)"]
    ADD_POPID --> END_NODE(["Return / Next"])
```

**Constant Resolution:**
- `DEL_TRGT_SBT_MLAD = "03"` (消去対象種類(メールアドレス) — Deletion target type: Email Address)
- `DEL_TRGT_SBT_MAILALIAS = "04"` (消去対象種類(メールエイリアス) — Deletion target type: Mail Alias)
- `DEL_TRGT_SBT_POP_ID = "15"` (消去対象種類(POPID) — Deletion target type: POP ID)
- `DEL_TRAN_SBT_AGING_UPD = "2"` (消去処理種類(エイジング更新) — Deletion processing type: Aging update)
- `JBSbatKKIFM160.DEL_TRAN_SBT = "DEL_TRAN_SBT"` (key name for deletion processing type)
- `JBSbatKKIFM160.DEL_TRGT_SBT = "DEL_TRGT_SBT"` (key name for deletion target type)

**Requirements:**
- The method processes three independent conditional branches (mlad, alias, popID), each evaluated in sequence.
- All three conditions are non-exclusive: if multiple fields are populated, all three blocks execute, generating multiple output map entries.
- Each block follows the same pattern: initialize via `initData(inMap)`, set deletion processing and target classification flags, set the actual data value, flag as output, and add to the result list.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `inMap` | `JBSbatServiceInterfaceMap` | Input command map carrying the service contract's email-related data. It contains keys for `MLAD` (email address), `ALIAS` (mail alias), and `POP_ID` (POP server ID), sourced from the ISP service contract data table (`KK_T_OPSVKEI_ISP`). These fields represent customer contact information that may need to be purged during contract deletion processing. |
| 2 | `outputBean` | `JBSbatOutputItem` | Output carrier that accumulates the prepared deletion target records. Each non-empty email field generates one entry added via `addOutMapList()`. The `outputBean` is shared across all deletion-target-handling methods in this class and is consumed by the caller (`execute()`) to drive downstream processing. |

| Source | Field | Business Meaning |
|--------|-------|-----------------|
| Instance | (none explicitly read as fields) | This method is private and reads all data from the `inMap` parameter; no instance fields are directly accessed within the method body. |

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JBSbatServiceInterfaceMap.getString` (inMap) | - | `KK_T_OPSVKEI_ISP` (MLAD field) | Reads the email address (メールアドレス取得) from the input map, sourced from the optional service ISP contract table. |
| R | `JBSbatServiceInterfaceMap.getString` (inMap) | - | `KK_T_SBOPSVKEI_ISP` (ALIAS field) | Reads the mail alias (メールエイリアス取得) from the input map, sourced from the shared optional service ISP table. |
| C | `JBSbatKKOpsvkeiDelTrgtChsht.initData` | - | - | Initializes a fresh output map from the input map context. Creates a new `JBSbatServiceInterfaceMap` with pre-populated base fields for the deletion target entry. |
| R | `JBSbatKKOpsvkeiDelTrgtChsht.getDelTranSbt` | - | - | Reads and returns the deletion processing type (消去処理種類) from the input map, used only in the email address (mlad) branch. |
| - | `JBSbatServiceInterfaceMap.setString` (outMap) | - | - | Sets the deletion processing type key (`DEL_TRAN_SBT`) in the output map. |
| - | `JBSbatServiceInterfaceMap.setString` (outMap) | - | - | Sets the deletion target type key (`DEL_TRGT_SBT`) in the output map, classifying the record by deletion target category. |
| - | `JBSbatServiceInterfaceMap.setString` (outMap) | - | - | Sets the actual data value (MLAD, MAILALIAS, or POP_ID) in the output map. |
| - | `JBSbatServiceInterfaceMap.setOutFlg` (outMap) | - | - | Flags this output map for inclusion in the result set (出力フラグON). |
| C | `JBSbatOutputItem.addOutMapList` | - | - | Adds the fully configured output map into the output bean's result list for downstream consumption. |

### How called methods are classified:

| Method | Classification | Rationale |
|--------|---------------|-----------|
| `inMap.getString()` | Read | Retrieves existing data values from the input map |
| `initData()` | Create | Creates and returns a new `JBSbatServiceInterfaceMap` instance |
| `getDelTranSbt()` | Read | Queries the deletion processing type from input data |
| `outMap.setString()` | Update | Sets/modifies key-value pairs in the output map |
| `outMap.setOutFlg(true)` | Update | Sets a boolean flag on the output map |
| `outputBean.addOutMapList()` | Create | Appends a new entry to the output result list |

## 5. Dependency Trace

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

No screen/batch entry points found within 8 hops. Direct callers found: 1 methods.
Terminal operations from this method: `addOutMapList` [C], `setOutFlg` [-], `setOutFlg` [-], `setOutFlg` [-], `setString` [-], `setString` [-], `setString` [-], `setString` [-], `setString` [-], `setString` [-], `setString` [-], `setString` [-], `initData` [-], `initData` [-], `initData` [-], `getDelTranSbt` [-], `getString` [-], `getString` [-], `getString` [-], `getString` [-]  # NOSONAR

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: JBSbatKKOpsvkeiDelTrgtChsht | `JBSbatKKOpsvkeiDelTrgtChsht.execute()` -> `setDelTrgtDataEmail(inMap, outputBean)` | `addOutMapList [C] -`, `setOutFlg [-]`, `setString [-]`, `initData [-]`, `getDelTranSbt [-]`, `getString [-]` |

## 6. Per-Branch Detail Blocks

### Block 1 — [data extraction] (L212-L213)

> Extracts email address and mail alias from the input map. These values are sourced from the ISP service contract tables (`KK_T_OPSVKEI_ISP`, `KK_T_SBOPSVKEI_ISP`).

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `mlad = inMap.getString(JBSbatKK_T_OPSVKEI_ISP.MLAD)` // メールアドレス取得 (email address retrieval) |
| 2 | EXEC | `alias = inMap.getString(JBSbatKK_T_SBOPSVKEI_ISP.ALIAS)` // メールエイリアス取得 (mail alias retrieval) |

### Block 2 — [IF] `mlad != null && !"".equals(mlad)` (L215-L226)

> **Email Address Branch** — If the email address is present and non-empty, prepares a deletion target entry for email address purging. The deletion processing type is determined dynamically via `getDelTranSbt()`.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `outMap = initData(inMap)` // 初期化 (initialization) [-> `initData(inMap)`] |
| 2 | SET | `outMap.setString(JBSbatKKIFM160.DEL_TRAN_SBT, getDelTranSbt(inMap))` // 消去処理種類 (deletion processing type) [-> `getDelTranSbt(inMap)`] |
| 3 | SET | `outMap.setString(JBSbatKKIFM160.DEL_TRGT_SBT, DEL_TRGT_SBT_MLAD)` // 消去対象種類(メールアドレス) (deletion target type: Email Address) [-> `JKKBatDelRunConst.DEL_TRGT_SBT_MLAD = "03"`] |
| 4 | SET | `outMap.setString(JBSbatKKIFM160.MLAD, mlad)` // メールアドレス (email address) |
| 5 | EXEC | `outMap.setOutFlg(true)` // 消去対象データの設定 — set output flag ON |
| 6 | CALL | `outputBean.addOutMapList(outMap)` // Add configured entry to output result list |

### Block 3 — [IF] `alias != null && !"".equals(alias)` (L228-L237)

> **Mail Alias Branch** — If a mail alias is present and non-empty, prepares a deletion target entry with the processing type set to "aging update" (エイジング更新). This is used when mail aliases need to be retired as part of contract termination.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `outMap = initData(inMap)` // 初期化 (initialization) [-> `initData(inMap)`] |
| 2 | SET | `outMap.setString(JBSbatKKIFM160.DEL_TRAN_SBT, DEL_TRAN_SBT_AGING_UPD)` // 消去処理種類(エイジング更新) (deletion processing type: Aging update) [-> `JKKBatDelRunConst.DEL_TRAN_SBT_AGING_UPD = "2"`] |
| 3 | SET | `outMap.setString(JBSbatKKIFM160.DEL_TRGT_SBT, DEL_TRGT_SBT_MAILALIAS)` // 消去対象種類(メールエイリアス) (deletion target type: Mail Alias) [-> `JKKBatDelRunConst.DEL_TRGT_SBT_MAILALIAS = "04"`] |
| 4 | SET | `outMap.setString(JBSbatKKIFM160.MAILALIAS, alias)` // メールエイリアス (mail alias) |
| 5 | EXEC | `outMap.setOutFlg(true)` // 消去対象データの設定 — set output flag ON |
| 6 | CALL | `outputBean.addOutMapList(outMap)` // Add configured entry to output result list |

### Block 4 — [IF] `popID != null && !"".equals(popID)` (L245-L257)

> **POP ID Branch** (IT1-2013-0000285 2013/02/13 ADD) — If a POP ID is present and non-empty, prepares a deletion target entry with the processing type set to "aging update" (エイジング更新). This was added to support aging scheme POP state transition settings during contract transfer. POP ID identifies the Point of Presence server used for ISP authentication.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `popID = inMap.getString(JBSbatKK_T_OPSVKEI_ISP.POP_ID)` // POPID取得 (POP ID retrieval) |
| 2 | EXEC | `outMap = initData(inMap)` // 初期化 (initialization) [-> `initData(inMap)`] |
| 3 | SET | `outMap.setString(JBSbatKKIFM160.DEL_TRAN_SBT, DEL_TRAN_SBT_AGING_UPD)` // 消去処理種類(エイジング更新) (deletion processing type: Aging update) [-> `JKKBatDelRunConst.DEL_TRAN_SBT_AGING_UPD = "2"`] |
| 4 | SET | `outMap.setString(JBSbatKKIFM160.DEL_TRGT_SBT, DEL_TRGT_SBT_POP_ID)` // 消去対象種類(POPID) (deletion target type: POP ID) [-> `JKKBatDelRunConst.DEL_TRGT_SBT_POP_ID = "15"`] |
| 5 | SET | `outMap.setString(JBSbatKKIFM160.POP_ID, popID)` // POPID |
| 6 | EXEC | `outMap.setOutFlg(true)` // 消去対象データの設定 — set output flag ON |
| 7 | CALL | `outputBean.addOutMapList(outMap)` // Add configured entry to output result list |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `mlad` | Field | Mail Address — the customer's email address registered in the ISP service contract (KK_T_OPSVKEI_ISP.MLAD). Used for notification and contact purposes. |
| `alias` | Field | Mail Alias — an alternate email alias associated with the ISP service, stored in the shared optional service ISP table (KK_T_SBOPSVKEI_ISP.ALIAS). |
| `popID` | Field | POP ID — Point of Presence server identifier. Identifies which POP server the customer's ISP connection authenticates through. |
| `DEL_TRAN_SBT` | Field | Deletion Processing Type — a classification key that determines the deletion handling strategy (e.g., delete-only, SOD issuance, aging update). Mapped to `JBSbatKKIFM160.DEL_TRAN_SBT`. |
| `DEL_TRGT_SBT` | Field | Deletion Target Type — a classification key that categorizes which specific data field is being deleted (e.g., email address = "03", mail alias = "04", POP ID = "15"). |
| `DEL_TRGT_SBT_MLAD` | Constant | Deletion target type code "03" — Email Address. |
| `DEL_TRGT_SBT_MAILALIAS` | Constant | Deletion target type code "04" — Mail Alias. |
| `DEL_TRGT_SBT_POP_ID` | Constant | Deletion target type code "15" — POP ID. |
| `DEL_TRAN_SBT_AGING_UPD` | Constant | Deletion processing type code "2" — Aging Update. Used when the deletion involves aging scheme transitions (e.g., during contract transfers). |
| `DEL_TRAN_SBT_DEL_ONLY` | Constant | Deletion processing type code "0" — Delete Only. |
| `DEL_TRAN_SBT_DEL_SOD_HAKKO` | Constant | Deletion processing type code "1" — Delete SOD Issuance. Triggers deletion Service Order Data issuance. |
| KK_T_OPSVKEI_ISP | Entity/DB | Optional Service ISP Contract Table — stores ISP-related service contract data including email address (MLAD) and POP ID (POP_ID). |
| KK_T_SBOPSVKEI_ISP | Entity/DB | Shared Optional Service ISP Table — stores shared ISP service data including mail alias (ALIAS). |
| `setOutFlg(true)` | Field/Operation | Output flag — when set to true, marks this record for inclusion in the output result set for downstream processing. |
| `initData` | Method | Initialize Data — creates a fresh `JBSbatServiceInterfaceMap` output map pre-populated with base context fields from the input map. |
| `getDelTranSbt` | Method | Get Deletion Processing Type — retrieves the appropriate deletion processing classification code from the input map. |
| `addOutMapList` | Method | Add Output Map List — appends a configured output map to the output bean's result list. |
| `SOD` | Acronym | Service Order Data — the order fulfillment document generated during service contract changes (registration, deletion, modification). |
| `エイジング更新` | Business term | Aging Update — a deletion processing type used when retiring data as part of aging scheme transitions, typically during contract transfers or service reassignments. |
| POP | Business term | Point of Presence — a network access point/server where customers authenticate their ISP connection. |
| `execute()` | Method | The caller method in `JBSbatKKOpsvkeiDelTrgtChsht` that orchestrates the full deletion target selection process, invoking this method as one of several email-specific handlers. |
| `inMap` | Field | Input command map — the interface map carrying all input data for the deletion target selection batch. |
| `outputBean` | Field | Output carrier — the output item bean that accumulates all prepared deletion target records across all email-related branches. |
