# Business Logic — JZMEnumSwitchCC.editResultRP() [83 LOC]

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

## 1. Role

### JZMSwitchCC.editResultRP()

This method is a **shared response-mapping utility** used across the telecom customer backbone system (eo Customer Backbone System) after a Service Component (SC) is invoked. Its primary business role is to **translate raw SC execution results (CAANMsg objects) into structured business data and error information** on the `IRequestParameterReadWrite` param object, making results available to downstream screen logic.

The method performs four distinct business operations: **(1) return-code validation and override** — if the SC layer returns a non-zero return code, the status is forcibly set to 9000 (SC error), then validated against the `RETURN_MESSAGE_XXXX` constant dictionary to ensure the status maps to a known message; **(2) status arbitration** — compares the template status against the BP (business process) control map status, and if the SC status is worse, overwrites the param's return code and message so the screen displays the SC-level error; **(3) error-ID mapping** — iterates through the service IF's item layout, identifies fields ending with `_err`, and maps their values from the template into the user data HashMap; **(4) detail-list (Msg1List) mapping** — handles multi-row detail data where the template contains a nested `templateId + "CBSMsg1List"` array, mapping error IDs into each row's HashMap.

The method implements the **delegation design pattern** — it does not directly interact with databases. Instead, it delegates template-to-content resolution to `getContents()` and error-ID mapping to `mappingErrId()`, while aggregating final error info via `TemplateErrorUtil.getErrorInfo()`. It serves as the **response-side counterpart** to `setSCInputCommonData()` (which maps request data into the SC input), forming the complete request-response round-trip for SC invocation in this codebase.

The method is called by `callSvcInter()` (within the same class) after `scCall.run()` returns the SC result map, and is also directly invoked by numerous other CC classes (e.g., `JKKAdchgVaChgCC`, `JKKSmtvlInfHktgiCC`, `KKUpdSvcKeiTelCC`).

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["editResultRP(msgList, param, fixedText)"])

    START --> EXTRACT["Extract CAANMsg[] templates = (CAANMsg[]) msgList.get(TEMPLATE_LIST_KEY)"]
    EXTRACT --> TPL0["template = templates[0]"]
    TPL0 --> RETCODE["Get returnCode = (Integer) msgList.get(RET_CD_INT_KEY)"]
    RETCODE --> TPLID["Get templateId = template.getString(TEMPLATE_ID_KEY)"]
    TPLID --> TPLSTAT["Get templateStatus = template.getInt(STATUS_INT_KEY)"]
    TPLSTAT --> CHECKCODE{"returnCode != 0?"}

    CHECKCODE -->|Yes| OVERWRITE["Set templateStatus = 9000"]
    CHECKCODE -->|No| VALIDATE["Validate status"]
    OVERWRITE --> VALIDATE

    VALIDATE --> CONSTCHECK{"RETURN_MESSAGE_<status> exists?"}
    CONSTCHECK -->|No| RESET["Set templateStatus = 0"]
    CONSTCHECK -->|Yes| GETBPSTATUS["Get bpStatus from param control map"]
    RESET --> GETBPSTATUS

    GETBPSTATUS --> OBJNULL{"bpStatus object is null?"}
    OBJNULL -->|Yes| SETNEG1["Set bpStatus = -1"]
    OBJNULL -->|No| PARSEINT["Parse bpStatus = Integer.parseInt(String)"]
    SETNEG1 --> COMPARE{"templateStatus > bpStatus?"}
    PARSEINT --> COMPARE

    COMPARE -->|Yes| SETCTRL["Set RETURN_CODE = <status> in param control map"]
    COMPARE -->|Yes| SETMSG["Set RETURN_MESSAGE in param control map"]
    COMPARE -->|No| GETUSERDATA["Get user data HashMap from param.getData(fixedText)"]
    SETCTRL --> GETUSERDATA
    SETMSG --> GETUSERDATA

    GETUSERDATA --> GCONTENTS["Call getContents(templateId)"]
    GCONTENTS --> MAPERR["Call mappingErrId(inMap, template, contents)"]
    MAPERR --> MSG1CHECK{"templateArray = template.getCAANMsgList(templateId + CBSMsg1List) != null?"}

    MSG1CHECK -->|No| ERRINFO["Get errList from param control map"]
    MSG1CHECK -->|Yes| LISTNULL{"inList is null?"}
    LISTNULL -->|Yes| INITLIST["Create new ArrayList, put into inMap with key templateId + CBSMsg1List"]
    LISTNULL -->|No| FORLOOP["For each childTemplate in templateArray"]
    INITLIST --> FORLOOP

    FORLOOP --> SIZENCHECK{"i >= inList.size()?"}
    SIZENCHECK -->|Yes| ADDMAP["Add new HashMap to inList"]
    SIZENCHECK -->|No| GETCHILD["Get childMap = inList.get(i)"]
    ADDMAP --> GETCHILD
    GETCHILD --> CHILDCONTENTS["Call getContents(msg1ListId)"]
    CHILDCONTENTS --> CHILDERR["Call mappingErrId(childMap, childTemplate, msg1ListContents)"]
    CHILDERR --> NEXTI["i++"]
    NEXTI --> FORLOOP

    ERRINFO --> ERRNULL2{"errList is null?"}
    ERRNULL2 -->|Yes| NEWERR["Create new ArrayList<Object>"]
    ERRNULL2 -->|No| USEXIST["Use existing errList"]
    NEWERR --> SETERROR["Set ERROR_INFO in param: TemplateErrorUtil.getErrorInfo(msgList, errList)"]
    USEXIST --> SETERROR

    SETERROR --> RETURN(["Return param"])

    START --> GETDATA2["Get bpStatus object from param"]
    CHECKCODE -.-> GETDATA2
```

**Processing Flow Summary:**

1. **Extract SC results**: Pull `CAANMsg[]` templates and return code from the SC result map.
2. **Override return code**: If the SC returned a non-zero return code, force `templateStatus` to `9000` (indicating an SC-level error).
3. **Validate status**: Check if `RETURN_MESSAGE_<status>` constant exists in the application constant manager. If not, reset `templateStatus` to `0` (normal end).
4. **Arbitrate status**: Compare the resolved template status against the BP control map status (`bpStatus`). If the template status is worse (higher), overwrite the param's return code and message with the SC-level status and message.
5. **Map error IDs**: Get the user data HashMap, fetch the item layout via `getContents(templateId)`, and map error fields (those ending with `_err`) from the template into the user data.
6. **Map detail list**: If a nested `CBSMsg1List` exists in the template, iterate over each child template, expanding the list as needed, and map error IDs into each row.
7. **Aggregate error info**: Call `TemplateErrorUtil.getErrorInfo()` to produce a consolidated error info list, and store it in the param's control map.
8. **Return param**: The updated param now contains all mapped business data and error information for the calling screen.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `msgList` | `Map<?, ?>` | The raw result map returned from a Service Component invocation. Contains `CAANMsg[]` templates (under `TEMPLATE_LIST_KEY`) and an integer return code (under `RET_CD_INT_KEY`). Represents the complete SC response payload including success/error status, mapped data fields, and nested detail lists. |
| 2 | `param` | `IRequestParameterReadWrite` | The business data read/write interface. Serves as the carrier object that accumulates mapped results (return codes, return messages, error IDs, error info list) so downstream screen logic can read them. Control map data uses keys like `RETURN_CODE`, `RETURN_MESSAGE`, `ERROR_INFO`. |
| 3 | `fixedText` | `String` | A user-defined arbitrary string used as a key to retrieve the user data HashMap from `param.getData(fixedText)`. In business terms, it acts as a namespace or section identifier — different service types or operation modes use different `fixedText` values to isolate their data in the param's data store. |

**External state / instance fields read:** None. This method is stateless and operates purely on its parameters.

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JZMEnumSwitchCC.getContents` | - | - | Resolves service IF item layout (field order/structure) for a given template ID. Returns `Object[][]` describing field names and their display order in the CBSMsg. |
| R | `JZMEnumSwitchCC.mappingErrId` | - | - | Maps error-ID fields (fields whose names end with `_err`) from a CAANMsg template into a HashMap. Used for both top-level and child (detail list) templates. |
| R | `TemplateErrorUtil.getErrorInfo` | - | - | Aggregates error information from the SC result map (`msgList`) into an `ArrayList<Object>`. Produces the consolidated error info list stored in `param.controlMapData(ERROR_INFO)`. |
| R | `param.getControlMapData` | - | - | Reads control map data (e.g., `RETURN_CODE`, `ERROR_INFO`) from the request parameter object. |
| R | `param.getData` | - | - | Retrieves user data HashMap identified by the `fixedText` key from the request parameter object. |
| R | `template.getString` | - | - | Reads a string field (template ID) from the CAANMsg template. |
| R | `template.getInt` | - | - | Reads an integer field (template status) from the CAANMsg template. |
| R | `template.getCAANMsgList` | - | - | Retrieves a nested list of CAANMsg objects for a given message list key (e.g., `templateId + "CBSMsg1List"`). |
| R | `template.isNull` | - | - | Checks whether a field in the CAANMsg template is null. |
| R | `JCMAPLConstMgr.getString` | - | - | Reads application constant values. Used to look up `RETURN_MESSAGE_<status>` message strings. |
| W | `param.setControlMapData` | - | - | Writes return code and return message into the control map of the request parameter object. |
| W | `inMap.put` | - | - | Stores the message list 1 data (detail list) into the user data HashMap under the key `templateId + "CBSMsg1List"`. |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | CC: JZMEnumSwitchCC | `callSvcInter(handle, param, siInMap, fixedText)` → `scCall.run(siInMap, handle)` → `editResultRP(rsltMap, param, fixedText)` | `getErrorInfo [R]`, `mappingErrId [-]`, `getContents [R]` |
| 2 | CC: JKKAdchgVaChgCC | (direct call after SC result) → `editResultRP(rsltMap, param, this.global_fixedText)` | `getErrorInfo [R]`, `mappingErrId [-]`, `getContents [R]` |
| 3 | CC: JKKSmtvlInfHktgiCC | (direct call after SC result) → `editResultRP(rsltMap, param, fixedText, contents)` | `getErrorInfo [R]`, `mappingErrId [-]`, `getContents [R]` |
| 4 | CC: JKKUpdSvcKeiTelCC | (direct call after SC result) → `editResultRP(rsltMap, param, fixedText)` | `getErrorInfo [R]`, `mappingErrId [-]`, `getContents [R]` |
| 5 | CC: JKKSodSendCC | (direct call after SC result) → `editResultRP(rsltMap, param, fixedText)` | `getErrorInfo [R]`, `mappingErrId [-]`, `getContents [R]` |
| 6 | CC: JKKAdchgFixTajgsKeiIdtCC | (direct call after SC result) → `editResultRP(rsltMap, param, fixedText, contents)` | `getErrorInfo [R]`, `mappingErrId [-]`, `getContents [R]` |
| 7 | CC: KKKTsysChoiceInitCC | (direct call after SC result) → `editResultRP(rsltMap, param, this.global_fixedText)` | `getErrorInfo [R]`, `mappingErrId [-]`, `getContents [R]` |
| 8 | CC: JKKChokiWribStkuCC | (direct call after SC result) → `editResultRP(rsltMap, param, this.global_fixedText)` | `getErrorInfo [R]`, `mappingErrId [-]`, `getContents [R]` |
| 9 | CC: JKKAddBmpTaiorrki | (direct call via mapper) → `this.mapper.editResultRP(rsltMap, param, fixedText, contents)` | `getErrorInfo [R]`, `mappingErrId [-]`, `getContents [R]` |
| 10 | CC: JKKHakkoSODCC | (direct call via this) → `this.editResultRP(rsltMap, param, contents)` | `getErrorInfo [R]`, `mappingErrId [-]`, `getContents [R]` |
| 11 | CC: JKKAgntUpdCC | (direct call via mapper) → `this.mapper.editResultRP(rsltMap, param, fixedText, contents)` | `getErrorInfo [R]`, `mappingErrId [-]`, `getContents [R]` |
| 12 | CC: JKKAdchgIdoRsvHaneiCC | (direct call after SC result) → `editResultRP(rsltMap, param, fixedText, contents)` | `getErrorInfo [R]`, `mappingErrId [-]`, `getContents [R]` |

**Note:** Multiple callers use a different method signature (`editResultRP(rsltMap, param, fixedText, contents)`) with an additional `Object[][] contents` parameter — this is a separate overloaded method not documented here. The signature documented is `editResultRP(Map<?, ?> msgList, IRequestParameterReadWrite param, String fixedText)` with 3 parameters.

## 6. Per-Branch Detail Blocks

### Block 1 — Extract SC results (L1288–L1293)

> Extract templates, return code, template ID, and template status from the SC result map.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | EXEC | `CAANMsg[] templates = (CAANMsg[]) msgList.get(JCMConstants.TEMPLATE_LIST_KEY)` | Extract CAANMsg array from SC result map [-> `TEMPLATE_LIST_KEY`] |
| 2 | SET | `CAANMsg template = templates[0]` | Take the first (parent) template from the array |
| 3 | EXEC | `Integer returnCode = (Integer) msgList.get(JCMConstants.RET_CD_INT_KEY)` | Get SC return code [-> `RET_CD_INT_KEY`] |
| 4 | EXEC | `String templateId = template.getString(JCMConstants.TEMPLATE_ID_KEY)` | Read template ID [-> `TEMPLATE_ID_KEY`] |
| 5 | EXEC | `int templateStatus = template.getInt(JCMConstants.STATUS_INT_KEY)` | Read template status [-> `STATUS_INT_KEY`] |

### Block 2 — Return code override (L1295–L1297)

> If the SC layer returned a non-zero return code, the status is forcibly set to 9000 (SC error condition).

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | IF | `returnCode.intValue() != 0` | [SC returned non-zero return code] |
| 2 | SET | `templateStatus = 9000` | Force template status to SC error code |

### Block 3 — Status validation (L1298–L1300)

> Check if a message constant exists for the current template status. If not (meaning the status is not a recognized/registered message code), reset the status to 0 (normal end).

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | IF | `JCMAPLConstMgr.getString("RETURN_MESSAGE_" + String.format("%1$04d", templateStatus)) == null` | [RETURN_MESSAGE_<status> does not exist in constant manager] |
| 2 | SET | `templateStatus = 0` | Reset to normal end (status 0000) |

### Block 4 — BP status arbitration (L1302–L1311)

> Compare the SC template status against the BP control map status. If the SC status is worse (higher value), overwrite the param's return code and message so the screen displays the SC-level error rather than the BP status.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `Object obj = param.getControlMapData(SCControlMapKeys.RETURN_CODE)` | Read BP's current return code from control map |
| 2 | IF | `obj == null` | [BP return code not set] |
| 3 | SET | `bpStatus = -1` | Default to -1 when BP has no status |
| 4 | ELSE | `bpStatus = Integer.parseInt((String) obj)` | Parse BP's status code |
| 5 | IF | `templateStatus > bpStatus` | [SC status is worse than BP status] |
| 6 | SET | `String formatStatus = String.format("%1$04d", templateStatus)` | Format status as zero-padded 4-digit string (e.g., "0000", "9000") |
| 7 | EXEC | `String message = JCMAPLConstMgr.getString("RETURN_MESSAGE_" + formatStatus)` | Look up business message for this status |
| 8 | EXEC | `param.setControlMapData(SCControlMapKeys.RETURN_CODE, formatStatus)` | Overwrite BP return code with SC status [-> `RETURN_CODE`] |
| 9 | EXEC | `param.setControlMapData(SCControlMapKeys.RETURN_MESSAGE, message)` | Overwrite BP return message [-> `RETURN_MESSAGE`] |

### Block 5 — Get user data HashMap (L1313–L1315)

> Retrieve the user data HashMap identified by `fixedText`. This HashMap holds business data fields for the current operation.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `HashMap inMap = (HashMap) param.getData(fixedText)` | Get user data section identified by fixedText key |

### Block 6 — Error ID mapping (top-level) (L1317–L1320)

> Fetch the item layout for the template and map error fields (those ending with `_err`) from the template into the user data HashMap.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | EXEC | `Object[][] contents = getContents(templateId)` | [CALL] Resolve field layout for this template ID. Handles 13 different template IDs: `EKK0081B033`, `EKK0191A010`, `EKK0191B001`, `EKK0191B040`, `EZM0111A010`, `EZM0111C010`, `EZM0111C020`, `EZM0111C030`, `EZM0111D010`, `EZM0111E010`, `EZM0121C010`, `EZM0121E011`, `ETU0151C010` |
| 2 | EXEC | `mappingErrId(inMap, template, contents)` | [CALL] Map error-ID fields into inMap. Iterates through contents, checks if element ends with `_err`, and copies value from template if not null. |

### Block 7 — Detail list (Msg1List) processing (L1322–L1339)

> Handle nested multi-row detail data. The template may contain a nested `templateId + "CBSMsg1List"` message list array. Each row in the detail list gets its own error-ID mapping.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `String msg1ListId = templateId + "CBSMsg1List"` | Construct nested message list key |
| 2 | EXEC | `CAANMsg[] templateArray = template.getCAANMsgList(msg1ListId)` | Retrieve child template array (detail rows) |
| 3 | IF | `templateArray != null` | [Nested detail list exists] |
| 4 | SET | `ArrayList inList = (ArrayList) inMap.get(msg1ListId)` | Get existing detail list from user data |
| 5 | IF | `inList == null` | [No detail list yet] |
| 6 | SET | `inList = new ArrayList()` | Create new ArrayList |
| 7 | EXEC | `inMap.put(msg1ListId, inList)` | Store new list into user data |
| 8 | FOR | `for (int i = 0; i < templateArray.length; i++)` | Iterate over each child template row |
| 9 | IF | `i >= inList.size()` | [Need to expand detail list] |
| 10 | EXEC | `inList.add(new HashMap())` | Add empty HashMap for new row |
| 11 | SET | `HashMap childMap = (HashMap) inList.get(i)` | Get the row's HashMap |
| 12 | SET | `CAANMsg childTemplate = templateArray[i]` | Get the child template |
| 13 | EXEC | `Object[][] msg1ListContents = getContents(msg1ListId)` | [CALL] Resolve field layout for nested list template |
| 14 | EXEC | `mappingErrId(childMap, childTemplate, msg1ListContents)` | [CALL] Map error IDs for this detail row |

### Block 8 — Error info aggregation (L1341–L1351)

> Retrieve any existing error info list (or create a new one), then call `TemplateErrorUtil.getErrorInfo()` to produce a consolidated error info list from the SC result map, and store it in the param's control map.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | EXEC | `ArrayList<Object> errList = (ArrayList<Object>) param.getControlMapData(SCControlMapKeys.ERROR_INFO)` | Get existing error info list [-> `ERROR_INFO`] |
| 2 | IF | `errList == null` | [No existing error info list] |
| 3 | SET | `errList = new ArrayList<Object>()` | Create new error info list |
| 4 | EXEC | `param.setControlMapData(SCControlMapKeys.ERROR_INFO, TemplateErrorUtil.getErrorInfo(msgList, errList))` | [CALL] Aggregate and set consolidated error info |

### Block 9 — Return (L1353)

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | RETURN | `return param` | Return the updated param with all mapped data and error info |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `msgList` | Parameter | SC result map — contains CAANMsg templates and return code from a Service Component invocation |
| `param` | Parameter | IRequestParameterReadWrite — the business data carrier that holds both input parameters for SC calls and output results for screen display |
| `fixedText` | Parameter | User-defined arbitrary string — used as a namespace key to isolate user data sections within the param object |
| `templateId` | Local variable | Service IF identifier (e.g., `EKK0081B033`) — determines which CBSMsg class's field layout to use for item mapping |
| `templateStatus` | Local variable | SC-level status code from the template (0 = normal, 9000 = error, others = warning/specific conditions) |
| `returnCode` | Local variable | Integer return code from the SC invocation (0 = success, non-zero = error) |
| `bpStatus` | Local variable | BP (business process) control map return code — the status previously set by the business process layer |
| CAANMsg | Class | Communication ANswer Message — a message class used to exchange data between the BP layer and Service Components |
| SC | Acronym | Service Component — an autonomous business logic module (e.g., EKK0081B033CBS) that performs specific data operations |
| BP | Acronym | Business Process — the higher-level orchestration layer that coordinates multiple SCs to fulfill a business operation |
| `RETURN_MESSAGE_XXXX` | Constant | Application constant key pattern — maps a 4-digit status code to its human-readable Japanese error/success message string |
| `CBSMsg1List` | Constant suffix | Suffix appended to a template ID to reference a nested list of child CAANMsg objects (detail/line items) |
| `ERROR_INFO` | Control map key | Key in the param's control map for storing the consolidated error info list |
| `RETURN_CODE` | Control map key | Key in the param's control map for storing the return code as a zero-padded 4-digit string (e.g., "0000", "9000") |
| `RETURN_MESSAGE` | Control map key | Key in the param's control map for storing the human-readable message string corresponding to the return code |
| `TEMPLATE_LIST_KEY` | Constant | Key to retrieve `CAANMsg[]` templates from the SC result map |
| `RET_CD_INT_KEY` | Constant | Key to retrieve the integer return code from the SC result map |
| `TEMPLATE_ID_KEY` | Constant | Key to retrieve the template ID string from a CAANMsg |
| `STATUS_INT_KEY` | Constant | Key to retrieve the integer status code from a CAANMsg |
| `_err` | Suffix | Field name suffix convention — any field ending with `_err` is treated as an error identifier field |
| TemplateErrorUtil | Class | Utility class providing `getErrorInfo()` to aggregate error information from SC result maps into a structured list |
| JCMAPLConstMgr | Class | Application constant manager — retrieves string constants from the application's constant configuration |
| JZMEnumSwitchCC | Class | ENUM switching common component — handles routing and result mapping for ENUM (service type) switching operations in the telecom customer system |
| `EKK0081B033` | Template ID | Service contract details display (telephone number) |
| `EKK0191A010` | Template ID | Service contract details — eo Fiber Optic Phone > Consent display |
| `EKK0191B001` | Template ID | Service contract details <eo Fiber> consent display (service contract number) |
| `EKK0191B040` | Template ID | Service contract details — eo Fiber Optic Phone > Consent display (telephone number) |
| `EZM0111A010` | Template ID | Telephone number change |
| `EZM0111C010` | Template ID | (Template ID — see source for Japanese comment) |
| `EZM0121C010` | Template ID | Telephone number change |
| `EZM0121E011` | Template ID | Telephone number physical deletion |
| `ETU0151C010` | Template ID | Port reception information change |
| eo | Business term | eo — NTT Docomo's fiber optic broadband brand (eo Hikari / eo Telegraph) |
