# Business Logic — JBSbatKKSyuKeiJudgeTran.setChTienList() [46 LOC]

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

## 1. Role

### JBSbatKKSyuKeiJudgeTran.setChTienList()

This method is a batch-level CSV file loader responsible for reading a course change delay confirmation service contract list file and populating the class-level `chTienList` field with service detail numbers extracted from that file. The business operation centers on the **course change delay confirmation** process (コール変更遅延確認定), which ensures that when a customer's service line is changed due to a delay, only valid, registered service contracts are tracked for subsequent judgment logic. The method acts as a **data ingestion utility** within the batch transaction processing pipeline — it does not route or branch by service type, but provides a prerequisite data structure used by downstream judgment operations (e.g., the `initial()` method at line 301 calls this to populate `chTienList` before evaluating whether each service number in the list is valid). The file is expected to be a comma-delimited CSV where the first column contains the service detail number (svcKeiNo), and double-quote characters are stripped from each line prior to parsing.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["setChTienList"])
    INIT["Initialize chTienList = new ArrayList<String>()"]
    CHECK_EMPTY{"filePath.length() == 0"}
    THROW_EMPTY["throw JBSbatBusinessException EKKB0130CE"]
    CREATE_READER["Create JBSbatInputFileUtil with SJIS, LF"]
    READ_LOOP{"Read next line"}
    STRIP_QUOTES["Remove quotes from line"]
    SPLIT_LINE["Split line by comma"]
    EXTRACT["Extract svcKeiNo from dataList[0]"]
    CHECK_SVCNO{"svcKeiNo != null"}
    ADD_TO_LIST["Add svcKeiNo to chTienList"]
    FINALLY_CHECK{"tmpReader != null"}
    CLOSE_READER["tmpReader.close()"]
    END_NODE(["Return / Next"])

    START --> INIT
    INIT --> CHECK_EMPTY
    CHECK_EMPTY -->|Yes| THROW_EMPTY
    THROW_EMPTY --> END_NODE
    CHECK_EMPTY -->|No| CREATE_READER
    CREATE_READER --> READ_LOOP
    READ_LOOP -->|Yes| STRIP_QUOTES
    STRIP_QUOTES --> SPLIT_LINE
    SPLIT_LINE --> EXTRACT
    EXTRACT --> CHECK_SVCNO
    CHECK_SVCNO -->|Yes| ADD_TO_LIST
    ADD_TO_LIST --> READ_LOOP
    CHECK_SVCNO -->|No| READ_LOOP
    READ_LOOP -->|No| FINALLY_CHECK
    FINALLY_CHECK -->|Yes| CLOSE_READER
    CLOSE_READER --> END_NODE
    FINALLY_CHECK -->|No| END_NODE
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `filePath` | `String` | The file path (including filename) of a CSV file containing the course change delay confirmation service contract list. Each line in the file is a comma-separated record; the first field of each record is the service detail number (svcKeiNo) to be collected into the `chTienList`. If this is an empty string, a business exception (`EKKB0130CE`) is thrown indicating the missing "filename" field. |

**Instance fields read by this method:**
| Field | Type | Business Description |
|-------|------|---------------------|
| `chTienList` | `ArrayList<String>` | Class-level field that stores the extracted list of service detail numbers (svcKeiNo) from the CSV. This field is overwritten (re-initialized) each time this method is called. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JBSbatInputFileUtil` (constructor) | JBSbatInputFile | - | Opens and creates file input stream from `filePath` |
| - | `JBSbatInputFileUtil.setEncode` | JBSbatInputFile | - | Sets character encoding to SJIS (`JKKBatConst.SJIS`) |
| - | `JBSbatInputFileUtil.setLine` | JBSbatInputFile | - | Sets line ending code to LF (`JKKStrConst.LINE_LF`) |
| - | `JBSbatInputFileUtil.createReader` | JBSbatInputFile | - | Initializes the BufferedReader for reading |
| R | `JBSbatInputFileUtil.readLine` | JBSbatInputFile | - | Reads one line from the CSV file per iteration |
| - | `JBSbatDKHmpinAdd.split` | JBSbatDKHmpinAdd | - | Calls `split` with comma separator (`JKKBatConst.S_SEP_CAM = ","`) |
| - | `JACbatDataBnktUtil.close` | JACbatDataBnkt | - | Calls `close` on tmpReader in finally block |

**How to classify:**
- **R** (Read): All file I/O operations are read-only. The method reads lines from a CSV file and extracts service detail numbers — no create, update, or delete operations against any database or entity.

## 5. Dependency Trace

Trace who calls this method and what this method ultimately calls.

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: JBSbatKKSyuKeiJudgeTran | `initial()` (line 301) -> `setChTienList(filePath)` | `readLine` [R] CSV file, `close` [-] |

**Instructions:**
- `initial()` at line 301 calls `setChTienList(filePath)` to populate `chTienList` during batch initialization.
- This is a private method — it has no screen, CBS, or external caller. It is called internally by the same class's `initial()` method.
- The method is part of a batch processing workflow; `filePath` is passed from the class's own context (set via another method prior to `initial()` invocation).

## 6. Per-Branch Detail Blocks

**Block 1** — [SET] `(Initialize chTienList)` (L2110)

> Initializes the course change delay confirmation service contract list (コール変更遅延確認定サービス契約リスト) as a fresh ArrayList, clearing any previous contents.

| # | Type | Code |
|---|------|------|
| 1 | SET | `chTienList = new ArrayList<String>()` // コース変更遅延確認定サービス契約リスト (Course change delay confirmation service contract list) |

**Block 2** — [IF] `(filePath is empty)` (L2113)

> Validates that the provided file path is not an empty string. If empty, throws a business exception (`EKKB0130CE`) with the field label "filename".

| # | Type | Code |
|---|------|------|
| 1 | COND | `0 == filePath.length()` // 取得出来なかった場合、エラーとします (If data cannot be retrieved, treat as error) |
| 2 | THROWS | `throw new JBSbatBusinessException(JPCBatchMessageConstant.EKKB0130CE, new String[]{"ファイル項目：ファイル名"})` // File field: filename |

**Block 3** — [ELSE/CONTINUE] `(filePath is valid)` (L2118-2122)

> Creates a file reader utility instance with proper encoding (SJIS) and line ending (LF) settings, then prepares the reader for processing.

| # | Type | Code |
|---|------|------|
| 1 | SET | `tmpReader = null` // KKIFM462ファイルを読み込みしてサービス契約番号を保持 (Read KKIFM462 file and hold service contract number) |
| 2 | SET | `tmpReader = new JBSbatInputFileUtil(filePath)` // Create file input handler |
| 3 | EXEC | `tmpReader.setEncode(JKKBatConst.SJIS)` // 文字コード (Character code) [-> SJIS] |
| 4 | EXEC | `tmpReader.setLine(JKKStrConst.LINE_LF)` // 改行コード (Line code) [-> LINE_LF="LF"] |
| 5 | EXEC | `tmpReader.createReader()` // Initialize the reader |

**Block 4** — [WHILE LOOP] `(read lines until EOF)` (L2124-2137)

> Iterates over each line of the CSV file, strips double-quote characters, splits by comma, extracts the first column (service detail number), and adds it to `chTienList` if non-null.

| # | Type | Code |
|---|------|------|
| 1 | SET | `line = null` // Initialize line buffer |
| 2 | SET | `svcKeiNo = null` // Initialize service detail number variable |
| 3 | COND | `null != (line = tmpReader.readLine())` // Loop condition: while there are lines to read |
| 4 | EXEC | `line = line.replaceAll("\"", "")` // Strip double-quote characters from the line |
| 5 | SET | `dataList = line.split(JKKBatConst.S_SEP_CAM)` // Split by comma [-> S_SEP_CAM=","] |
| 6 | SET | `svcKeiNo = dataList[0]` // Extract first column as service detail number |
| 7 | IF | `null != svcKeiNo` // Block 4.1 |
| 8 | SET | `chTienList.add(svcKeiNo)` // Add the service detail number to the list |

**Block 4.1** — [nested IF] `(svcKeiNo is not null)` (L2134)

> Only adds the extracted service detail number to the list if it is not null, filtering out any blank or malformed rows.

| # | Type | Code |
|---|------|------|
| 1 | COND | `null != svcKeiNo` |
| 2 | SET | `chTienList.add(svcKeiNo)` // コース変更遅延確认定サービス契約リストに追加 (Add to course change delay confirmation service contract list) |

**Block 5** — [CATCH] `(IOException)` (L2139-2141)

> Catches any I/O exception during file reading and re-throws it as a business exception (`EKKB0020CE`) with the file path as context.

| # | Type | Code |
|---|------|------|
| 1 | CATCH | `catch (IOException e)` |
| 2 | THROWS | `throw new JBSbatBusinessException("EKKB0020CE", new String[]{filePath})` // Re-throw with file path context |

**Block 6** — [FINALLY] `(Cleanup)` (L2143-2148)

> Ensures the file reader is closed in all cases to prevent resource leaks. Checks `tmpReader` is not null before closing.

| # | Type | Code |
|---|------|------|
| 1 | COND | `null != tmpReader` |
| 2 | EXEC | `tmpReader.close()` // Release file input stream resource |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `chTienList` | Field | Course Change Delay Confirmation Service Contract List — a class-level ArrayList holding service detail numbers extracted from a CSV file, used for subsequent batch judgment processing |
| `svcKeiNo` | Field | Service Detail Number — the primary identifier for a service contract line item, extracted as the first column of each CSV row |
| `filePath` | Field | File Path (including filename) — the full path to a CSV file containing service contract records |
| S_SEP_CAM | Constant | Comma separator — value `","`, used as the CSV delimiter character |
| SJIS | Technical | Shift JIS — a Japanese character encoding standard used for reading the input file |
| LINE_LF | Constant | Line feed code — value `"LF"`, used as the line ending convention for the input file |
| KKIFM462 | Internal | An internal file naming convention — the input CSV file is expected to follow the KKIFM462 naming pattern |
| JBSbatInputFileUtil | Component | Batch Service Input File Utility — a utility class for reading input files with configurable encoding and line endings |
| JBSbatBusinessException | Component | Business Exception — a custom exception class used to signal business-level errors in batch processing, including error codes and parameterized messages |
| EKKB0130CE | Error Code | Missing field error — thrown when the filename parameter is empty |
| EKKB0020CE | Error Code | File I/O error — thrown when an IOException occurs during file reading |
| JPCBatchMessageConstant | Component | Batch Message Constants — a central class holding localized error message codes for batch processing |
| コール変更遅延確認定 | Japanese term | Course Change Delay Confirmation — a business process that validates and tracks service contract line items when a customer's line has been changed due to a delay |
| 文字コード | Japanese term | Character encoding — specifies the character set used to interpret the file contents |
| 改行コード | Japanese term | Line ending code — specifies the newline character convention (LF, CRLF, CR) used in the input file |
