# Business Logic — JBSbatKKKDDIAnkenIktTrkm.isCheckKDDIAnken() [53 LOC]

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

## 1. Role

### JBSbatKKKDDIAnkenIktTrkm.isCheckKDDIAnken()

This method performs an **extension validation check** for KDDI intermediary (reseller) case files during a batch import process. In the Japanese telecom ordering ecosystem, KDDI intermediary cases are orders routed through a dealer channel (代理店, *dairitensha*) where external files (such as CSV data dumps) must conform to strict naming conventions before being ingested by the batch system. The method ensures that the file linked to the current delivery transaction record has a `.csv` extension.

The method acts as a **gatekeeper validation step** within the KDDI order intake batch workflow. It reads delivery transaction metadata to locate the associated file record, retrieves the file name, and verifies that its extension is exactly "csv" (case-insensitive). If the file record does not exist, or if the file lacks an extension, or if the extension is anything other than "csv", the validation fails and an error result is recorded.

The design follows a **sequential validation pattern**: first fetching the file metadata, then performing nested conditional checks (existence check, dot-position check, extension comparison), and finally recording the result. It uses the `executeZM_T_DATAIKTTRK_KNRI_KK_SELECT_001` query to fetch the file management record, applies string manipulation to extract the extension, and delegates error message lookup and result data construction to utility methods.

The method is called by `JBSbatKKKDDIAnkenIktTrkm.execute()`, which runs the main batch loop over multiple processing items (identified by `shoriCnt`). The boolean return value controls whether the batch continues processing this item or marks it as errored.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["Start: isCheckKDDIAnken(shoriCnt)"])
    A["isCheckFlg = true"]
    B["Build whereParamDlFile
[dlydTrnReqNo, efileKanriNo]"]
    C["executeZM_T_DATAIKTTRK_KNRI_KK_SELECT_001(whereParamDlFile)"]
    D["selectNext() -> mapDataikttrkKanri"]
    E{"mapDataikttrkKanri
== null?"}
    F["isCheckFlg = false"]
    G["fileNm = getString(FILE_NM)"]
    H["point = fileNm.lastIndexOf('.')"]
    I{"point != -1
(has dot)"}
    J["extension = fileNm.substring(point + 1)"]
    K{"!EXTENSION_CSV.equals(
extension.toLowerCase())"}
    L["isCheckFlg = false"]
    M["isCheckFlg = false"]
    N{"!isCheckFlg"}
    O["msg = getMessage(EKKB0650KE)"]
    P["add setKDDITrkmRsltDataList(err, null, null, msg, null)"]
    Q["return isCheckFlg"]
    R(["Return"])

    START --> A --> B --> C --> D --> E
    E -->|true| F --> N
    E -->|false| G --> H --> I
    I -->|true| J --> K
    K -->|true| L --> N
    K -->|false| N
    I -->|false| M --> N
    N -->|true| O --> P --> Q
    N -->|false| Q
    Q --> R
```

**Constant Resolution:**
- `EXTENSION_CSV = "csv"` — the only allowed file extension for KDDI intermediary case files

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `shoriCnt` | `int` | Processing count / item index — the zero-based (or one-based) index into the batch processing list. It identifies which delivery transaction record and data management record to validate in the current iteration of the batch loop. Used to index into `dlydTrnMapList` to retrieve the delivery transaction number and electronic file management number. |

**Instance fields accessed:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `dlydTrnMapList` | `List<Map<...>>` | Delivery transaction map list — a list of maps where each entry corresponds to a batch processing item, keyed by column constants such as `DLYD_TRN_REQ_NO` and `INPUT_EFILE_KANRI_NO` |
| `dataMapList` | `List<Map<...>>` | Data map list — used to record validation results (including error details) via `setKDDITrkmRsltDataList` |

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `executeZM_T_DATAIKTTRK_KNRI_KK_SELECT_001` | (internal query method) | `ZM_T_DATAIKTTRK_KNRI_KK` (Data One-Time Registration Management Table) | Executes a SELECT query to retrieve the file management record associated with the delivery transaction and electronic file management number |
| R | `JBSbatCommonDBInterface.selectNext` | (DB interface) | `ZM_T_DATAIKTTRK_KNRI_KK` | Retrieves the next row from the query result set returned by the above SELECT |
| R | `JBSbatZM_T_DL_FILE_KANRI.getString` | (entity accessor) | `ZM_T_DL_FILE_KANRI` (Download File Management Table — via `FILE_NM` column) | Gets the file name string from the retrieved data management record |
| R | `JBSbatLogPrintControl.getMessage` | JPCBatchMessageConstant | - | Looks up error message text for message code `EKKB0650KE` |
| - | `setKDDITrkmRsltDataList` | (internal builder) | - | Constructs an error result data map containing the error value, error message, and null fields; added to `dataMapList` |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: JBSbatKKKDDIAnkenIktTrkm.execute() | `execute()` -> `isCheckKDDIAnken(shoriCnt)` | `executeZM_T_DATAIKTTRK_KNRI_KK_SELECT_001 [R] ZM_T_DATAIKTTRK_KNRI_KK`, `setKDDITrkmRsltDataList [-]`, `getMessage [R] EKKB0650KE` |

**Analysis:** This method has a single direct caller — the `execute()` method of the same class `JBSbatKKKDDIAnkenIktTrkm`, which is a **batch processing entry point** for KDDI intermediary order intake. The batch loop iterates over items identified by `shoriCnt`, calling this validation method for each item. Terminal operations from this method include a database read from the data registration management table, a message lookup for the error code `EKKB0650KE`, and error result data construction.

## 6. Per-Branch Detail Blocks

**Block 1** — INIT `(initialization)` (L1766)

> Sets up the validation flag and builds the WHERE clause parameters to query the file management record.

| # | Type | Code |
|---|------|------|
| 1 | SET | `isCheckFlg = true` // Validation flag starts as "no error" |
| 2 | SET | `whereParamDlFile = new Object[2]` // WHERE clause parameter array |
| 3 | SET | `whereParamDlFile[0] = dlydTrnMapList.get(shoriCnt).get(JBSbatCC_T_DLYD_TRN_REQ.DLYD_TRN_REQ_NO).toString()` // [-> DLYD_TRN_REQ_NO: Delivery Transaction Request Number] — Gets the delivery transaction number for the current processing item |
| 4 | SET | `whereParamDlFile[1] = dlydTrnMapList.get(shoriCnt).get(JBSbatCC_T_DLYD_TRN_REQ.INPUT_EFILE_KANRI_NO).toString()` // [-> INPUT_EFILE_KANRI_NO: Input Electronic File Management Number] — Gets the electronic file management number for the current processing item |

**Block 2** — EXEC `(query execution)` (L1774)

> Executes the database query to fetch the data one-time registration management record.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `executeZM_T_DATAIKTTRK_KNRI_KK_SELECT_001(whereParamDlFile)` // [-> Executes SELECT on ZM_T_DATAIKTTRK_KNRI_KK using whereParamDlFile as WHERE clause] |
| 2 | CALL | `mapDataikttrkKanri = db_ZM_T_DATAIKTTRK_KNRI.selectNext()` // [-> Retrieves next row from query result set] |

**Block 3** — IF `(null existence check: mapDataikttrkKanri == null)` (L1777)

> Checks if the file management record exists in the database. If the record is null (not found), the validation fails immediately.
>
> Japanese comment: 存在チェックを行います(SQLKEY=KK_SELECT_001) — "Performs existence check (SQLKEY=KK_SELECT_001)"

| # | Type | Code |
|---|------|------|
| 1 | SET | `isCheckFlg = false` // Validation fails — no file record found |

**Block 4** — ELSE `(record exists)` (L1779)

> The file management record was found. Proceeds to extract and validate the file extension.
>
> Japanese comment: 拡張子チェック — "Extension check"

| # | Type | Code |
|---|------|------|
| 1 | SET | `fileNm = mapDataikttrkKanri.getString(JBSbatZM_T_DL_FILE_KANRI.FILE_NM)` // [-> FILE_NM: File Name] — Gets the file name from the record |
| 2 | SET | `point = fileNm.lastIndexOf('.')` // Finds the last dot position in the file name |
| 3 | IF | (see Block 4.1) |
| 4 | ELSE | (see Block 4.2) |

**Block 4.1** — IF `(point != -1, file has a dot)` (L1781)

> The file name contains at least one dot, so an extension can potentially be extracted.

| # | Type | Code |
|---|------|------|
| 1 | SET | `extension = fileNm.substring(point + 1)` // Extracts the substring after the last dot as the extension |
| 2 | IF | (see Block 4.1.1) |
| 3 | ELSE | (see Block 4.1.2) |

**Block 4.1.1** — IF `(extension does NOT match "csv")` (L1790)

> The extracted extension (lowercased) is not equal to "csv". This is a validation failure.
>
> Japanese comment: 拡張子がcsv以外の場合 — "When extension is not csv"

| # | Type | Code |
|---|------|------|
| 1 | SET | `isCheckFlg = false` // Validation fails — file extension is not csv |

**Block 4.1.2** — ELSE `(extension matches "csv")` (L1792)

> The extracted extension matches "csv" (case-insensitive). Validation passes; `isCheckFlg` remains `true`.
>
> No action needed — the flag was already initialized to `true`.

**Block 4.2** — ELSE `(point == -1, no dot in file name)` (L1794)

> The file name does not contain any dot character, meaning there is no extension. This is a validation failure.

| # | Type | Code |
|---|------|------|
| 1 | SET | `isCheckFlg = false` // Validation fails — file has no extension |

**Block 5** — IF `(!isCheckFlg, validation failed)` (L1800)

> When validation fails (either no record found, wrong extension, or no extension), records an error result.
>
> Japanese comment: メッセージ設定 — "Message setup"
> Japanese comment: エラーリスト設定 — "Error list setup"

| # | Type | Code |
|---|------|------|
| 1 | CALL | `msg = JBSbatLogPrintControl.getMessage(JPCBatchMessageConstant.EKKB0650KE)` // [-> EKKB0650KE: Error message code for KDDI case file extension mismatch] |
| 2 | CALL | `dataMapList.add(setKDDITrkmRsltDataList(JKKStrConst.KDDI_TRKM_RSLT_VAL_ERR, null, null, msg, null))` // [-> KDDI_TRKM_RSLT_VAL_ERR: KDDI intermediary result validation error value] — Constructs and adds an error result data row to the data map list |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `isCheckFlg` | Field | Check flag — boolean indicator of whether the KDDI case file extension validation passed (`true` = no error, `false` = error occurred) |
| `shoriCnt` | Parameter | Processing count — the index identifying which batch processing item is currently being validated |
| `dlydTrnMapList` | Field | Delivery Transaction Map List — a list of maps holding delivery transaction data for each batch item, indexed by processing count |
| `dataMapList` | Field | Data Map List — a list of maps holding processing results (including validation results and error details) |
| `dlydTrnReqNo` | Field | Delivery Transaction Request Number — an internal identifier for a delivery transaction request |
| `inputEfileKanriNo` | Field | Input Electronic File Management Number — the management ID for an electronic file associated with a delivery transaction |
| `ZM_T_DATAIKTTRK_KNRI_KK` | DB Table | Data One-Time Registration Management Table — stores records of one-time data registrations including linked file references |
| `ZM_T_DL_FILE_KANRI` | DB Table | Download File Management Table — stores file metadata including file names (`FILE_NM` column) |
| `fileNm` | Field | File Name — the name of the file (e.g., "report_20240115.csv") |
| `extension` | Field | File Extension — the substring after the last dot in the file name, lowercased for comparison |
| EXTENSION_CSV | Constant | `"csv"` — the only allowed file extension for KDDI intermediary case files |
| EKKB0650KE | Constant | Error message code — the key used to look up the error message text when a file extension mismatch is detected |
| KDDI_TRKM_RSLT_VAL_ERR | Constant | KDDI Intermediary Result Validation Error — a sentinel value indicating a validation error in the KDDI tracking result data |
| `isCheckKDDIAnken` | Method | KDDI Intermediary Case File Extension Check — validates that the KDDI case file has a `.csv` extension |
| KDDI | Business term | K.K. Data Communications — a major Japanese telecommunications carrier; orders routed through KDDI use this intermediary channel |
| 代理店 (dairitensha) | Business term | Dealer / Reseller / Agent — a business partner that places orders on behalf of end customers in the telecom ordering system |
| 拡張子 (kakuchoshi) | Business term | File extension — the suffix of a file name (e.g., ".csv") indicating file format |
| 案件 (anken) | Business term | Case / Order — a business order or transaction record in the ordering system |
| 処理件数 (shoriKensuu) | Business term | Processing Count — the number of items or the current item index being processed in a batch job |
| EKK0650KE | SC Code | Error message component code for KDDI case file validation failures |
| CSV | Business term | Comma-Separated Values — a plain-text file format used for data interchange; the required format for KDDI intermediary case files |
