# Business Logic — JKKKikiKaifukuWrisvcCC.setMessageInfo() [24 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.fujitsu.futurity.bp.custom.common.JKKKikiKaifukuWrisvcCC` |
| Layer | CC / Common Component (Package: `com.fujitsu.futurity.bp.custom.common`) |
| Module | `common` (Package: `com.fujitsu.futurity.bp.custom.common`) |

## 1. Role

### JKKKikiKaifukuWrisvcCC.setMessageInfo()

This method is a message accumulation utility within the system's Common Component layer. Its business purpose is to construct structured message metadata objects and append them to a shared message list carried inside the request/response context map (`ccMsg`). It serves the **system notification and error handling** domain — every business screen in this application that needs to surface validation errors, warnings, or informational messages to the end-user funnel's message data through this method.

The method implements a **message builder** pattern: it accepts discrete message metadata parameters (message ID, replacement characters, and error flag) and assembles them into a structured `HashMap<String, Object>` that is then appended to a running `ArrayList` of message objects stored under the `"message_list"` key. This allows callers to accumulate multiple messages across the lifecycle of a single request before displaying them to the user.

The method also handles **warning-flag inheritance**: if the current context map already contains an empty-string or warning-type error flag (`err_flg`), it inherits and propagates the new `pErrFlg` value into the map. This ensures that a warning-level flag is never silently downgraded to an "OK" state by a subsequent non-error message. This conditional logic ensures message severity escalates rather than degrades as the processing chain accumulates messages.

The method has no conditional branches that alter its core accumulation behavior — both the flag-update and skip paths converge to the same message-building and appending sequence. Its role in the larger system is that of a **shared utility** called by the primary business method `execKikiKaifukuWrisvc()` and potentially by other service components that participate in the recovery/damage-assistance workflow.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["setMessageInfo params"])
    READ_ERR_FLG["Read err_flg from ccMsg"]
    CHECK_ERR_FLG{err_flg is empty
OR err_flg is Warning W}
    UPDATE_ERR_FLG["Set ccMsg err_flg to pErrFlg"]
    SKIP_UPDATE["Skip update"]
    CREATE_MESSAGE_MAP["Create new messageMap HashMap"]
    PUT_MESSAGE_ID["Put messageId into messageMap"]
    PUT_REPLACE_CHA["Put replaceCha into messageMap"]
    PUT_ERR_ITEM["Put errItem into messageMap"]
    GET_MESSAGE_LIST["Get message_list ArrayList from ccMsg"]
    ADD_MESSAGE["Add messageMap to message_list"]
    END_NODE(["Return void"])

    START --> READ_ERR_FLG
    READ_ERR_FLG --> CHECK_ERR_FLG
    CHECK_ERR_FLG -->|true| UPDATE_ERR_FLG
    CHECK_ERR_FLG -->|false| SKIP_UPDATE
    UPDATE_ERR_FLG --> CREATE_MESSAGE_MAP
    SKIP_UPDATE --> CREATE_MESSAGE_MAP
    CREATE_MESSAGE_MAP --> PUT_MESSAGE_ID
    PUT_MESSAGE_ID --> PUT_REPLACE_CHA
    PUT_REPLACE_CHA --> PUT_ERR_ITEM
    PUT_ERR_ITEM --> GET_MESSAGE_LIST
    GET_MESSAGE_LIST --> ADD_MESSAGE
    ADD_MESSAGE --> END_NODE
```

**CRITICAL — Constant Resolution:**

| Constant | Resolved Value | Business Meaning |
|----------|---------------|-----------------|
| `ERR_FLG_WARNING` | `"W"` | Warning-level error flag — indicates a non-blocking issue that should be surfaced to the user |

**Processing summary:**
1. **Error flag evaluation** (L388-390): Reads the current `err_flg` from the context map. If it is empty or already a warning (`"W"`), overwrites it with the passed-in `pErrFlg` value. This preserves or escalates warning severity.
2. **Message map construction** (L392-398): Creates a fresh `HashMap` and populates it with three key-value pairs: the message ID, replacement character string, and error item identifier.
3. **Message accumulation** (L399-401): Retrieves the `message_list` ArrayList from the context map and appends the newly built message map to it.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `ccMsg` | `HashMap<String, Object>` | The shared request/response context map that carries application-wide data across the processing chain. Contains the existing `err_flg` status, the `message_list` accumulator, and other contextual fields. Modified in-place by this method (mutated on keys `err_flg` and `message_list`). |
| 2 | `pMessageId` | `String` | The message identifier string. References a specific error/info message code defined in the application's message resource bundle (e.g., `"EKB4950--Q"`). Used as the lookup key that the frontend screen resolves to a localized display message. |
| 3 | `pReplaceCha` | `String` | The replacement character string or value. Contains data that should be substituted into the message template referenced by `pMessageId`. For example, if the message template mentions a field name, this might contain the actual field value that failed validation. |
| 4 | `pErrItem` | `String` | The error target item identifier. Specifies which UI field or form element the message pertains to (e.g., `"telTelArea1"`, `"changeAddress"`). The frontend uses this to highlight or scroll to the relevant input control. |
| 5 | `pErrFlg` | `String` | The error flag value being set. Typically `"E"` for error or `"W"` for warning. If the current context's `err_flg` is empty or already a warning, this value overwrites it. Otherwise, it is ignored. |

**External state read:**
| Field | Type | Business Description |
|-------|------|---------------------|
| `ERR_FLG_WARNING` | `private static final String` | Constant defining the warning-level flag value `"W"`. |

## 4. CRUD Operations / Called Services

This method does not call any service components, CBS, or database operations. It operates purely in-memory on the context map (`ccMsg`) and builds message data structures.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| — | — | — | — | No CRUD operations. This is a pure in-memory message builder utility. |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | CBS: JKKKikiKaifukuWrisvcCC | `JKKKikiKaifukuWrisvcCC.execKikiKaifukuWrisvc()` -> `JKKKikiKaifukuWrisvcCC.setMessageInfo()` | No terminal CRUD (pure in-memory) |

**Call chain explanation:**
- `execKikiKaifukuWrisvc()` is the primary entry point method in the same class. It is a public business method (returning `IRequestParameterReadWrite`) that orchestrates the recovery/damage-assistance workflow. During this workflow, it calls `setMessageInfo()` to accumulate error and warning messages into the `ccMsg` context map before returning the result to the caller.

## 6. Per-Branch Detail Blocks

**Block 1** — IF `(err_flg is empty OR err_flg == ERR_FLG_WARNING)` `(ERR_FLG_WARNING="W")` (L388)

> If the current error flag in the context map is either blank or already a warning, update it with the new `pErrFlg` value. This ensures that warning severity is preserved or escalated.

| # | Type | Code |
|---|------|------|
| 1 | SET | `String errFlg = (String) ccMsg.get("err_flg");` // Read current error flag from context map |
| 2 | IF | `if ("".equals(errFlg) || ERR_FLG_WARNING.equals(errFlg))` `[ERR_FLG_WARNING="W"]` — Condition: current flag is empty string or warning |

**Block 1.1** — IF-BRANCH (true) (L390)

> The context's error flag is empty or a warning. Overwrite it with the passed-in `pErrFlg`.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ccMsg.put("err_flg", pErrFlg);` // Overwrite err_flg with the passed-in flag value — severity is preserved or escalated [-> pErrFlg value] |

**Block 1.2** — ELSE (false) (L391)

> The context's error flag is neither empty nor a warning (e.g., it is already `"E"` for error). Skip the update — existing severity takes precedence. No action taken.

**Block 2** — Processing step (L392-398)

> Build a new message metadata HashMap. This creates the structured message object that will be appended to the message list. The message map uses standard key names (`messageId`, `replaceCha`, `errItem`) that the frontend message renderer expects.

| # | Type | Code |
|---|------|------|
| 1 | SET | `HashMap<String, Object> messageMap = new HashMap<String, Object>();` // Create fresh message container |
| 2 | EXEC | `messageMap.put("messageId", pMessageId);` // Set the message ID — references a localized message template in the resource bundle. `// メッセージIDを設定` — Set message ID |
| 3 | EXEC | `messageMap.put("replaceCha", pReplaceCha);` // Set the replacement character string — data to be inserted into the message template. `// 置換文字列` — Replacement character string |
| 4 | EXEC | `messageMap.put("errItem", pErrItem);` // Set the error target item — which UI field this message belongs to. `// エラー設定項目` — Error setting item |

**Block 3** — Processing step (L399-401)

> Retrieve the running message list from the context map and append the newly built message map. This is the accumulation step that allows multiple messages to be collected across the processing chain.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ArrayList<HashMap<String, Object>> messageInfo = (ArrayList<HashMap<String, Object>>) ccMsg.get("message_list");` // Retrieve the message list accumulator from context map |
| 2 | EXEC | `messageInfo.add(messageMap);` // Append the constructed message map to the list |
| 3 | RETURN | `return;` // void method — no return value |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `ccMsg` | Field | Context map — the shared HashMap that carries application-wide data (error flags, message lists, parameters) across the processing chain of a single request. |
| `err_flg` | Field | Error flag — a string field in the context map indicating the current error/warning status. Values: `""` (empty/none), `"W"` (Warning), `"E"` (Error). |
| `message_list` | Field | Message accumulator — the key in `ccMsg` that holds an `ArrayList` of message metadata HashMaps, built up incrementally during processing. |
| `messageId` | Field | Message identifier — the key within each message map that references a localized message code (e.g., `"EKB4950--Q"`) in the application's message resource bundle. |
| `replaceCha` | Field | Replacement character string — the value to be substituted into the message template. Often contains field names or values related to the error. |
| `errItem` | Field | Error target item — the key identifying which UI form element the message relates to, used by the frontend to highlight the relevant input field. |
| `ERR_FLG_WARNING` | Constant | Warning flag constant — value `"W"`, indicates a non-blocking warning that should be surfaced to the user but does not prevent processing from continuing. |
| `setMessageInfo` | Method | Message info setter — accumulates structured message data into the context map's message list. |
| `execKikiKaifukuWrisvc` | Method | Recovery/damage-assistance service orchestrator — the primary business entry point that calls `setMessageInfo` during error handling. |
| `*CC` (suffix) | Naming convention | Common Component — suffix indicating a shared utility class in the `com.fujitsu.futurity.bp.custom.common` package. |
| `ccMsg` (prefix) | Naming convention | Common Context — convention indicating the shared context map passed through the processing chain. |
| Fujitsu Futurity | Product | The application framework/platform — Fujitsu's telecom BSS (Business Support System) platform for order management and service provisioning. |
