# Business Logic — JKKWrisvcAutoAplyGetSvcInfoCC.getSvkeiNo() [39 LOC]

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

## 1. Role

### JKKWrisvcAutoAplyGetSvcInfoCC.getSvkeiNo()

This method extracts and populates service contract numbers (`svc_kei_no`) for each service line item within a batch request context. It is a shared data-population utility that bridges the gap between template-based service information and the item-level data structures that downstream SC (Service Component) calls consume. The method operates on a list of addition request items (`add_inf_list`), iterates over each item, and looks up the corresponding service contract number from a template map associated with that item's `TemplateId`. The design follows a **data enrichment** pattern: it reads pre-existing template data and enriches each item map with the resolved `svc_kei_no` value so that subsequent processing (such as SC invocations in the caller's `for` loop) can use the enriched data without additional lookups. It plays a critical role in the **automatic discount service application entry** workflow, serving multiple callers including `getSvcInfo()`, `getInvokeCBS()`, `JKKUpdJdgInfoAfAddCC`, and `JKKJdgGetSvcInfoCC` — making it a shared backbone method across both screen-based and batch processing paths for telecom service contract order fulfillment.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["getSvkeiNo(param, fixedText)"])
    A1["Get dataMap from param.getData(fixedText)"]
    A2{"dataMap is null?"}
    A3["dataMap = new HashMap()"]
    A4["param.setData(fixedText, dataMap)"]
    A5["Get dataList from dataMap.get(add_inf_list)"]
    A6{"dataList is null?"}
    A7["Return param"]
    A8["Loop: i = 0 to dataList.size()"]
    A9["map = dataList.get(i)"]
    A10{"param.getData(map.get(TemplateId)) != null?"}
    A11["templateMap = param.getData(map.get(TemplateId))"]
    A12["svKeiNo = templateMap.get(map.get(SvKeiNoKmkNm))"]
    A13{"svKeiNo != null?"}
    A14["map.put(svc_kei_no, svKeiNo)"]
    A15["Increment i"]
    A16["Return param"]
    END(["End"])

    START --> A1
    A1 --> A2
    A2 -- Yes --> A3
    A3 --> A4
    A4 --> A5
    A2 -- No --> A5
    A5 --> A6
    A6 -- Yes --> A7
    A7 --> END
    A6 -- No --> A8
    A8 --> A9
    A9 --> A10
    A10 -- Yes --> A11
    A11 --> A12
    A12 --> A13
    A13 -- Yes --> A14
    A14 --> A15
    A15 --> A16
    A15 --> A9
    A13 -- No --> A15
    A10 -- No --> A15
    A16 --> END
```

**Processing Summary:**
1. Retrieve (or create) the data map keyed by `fixedText` from `param`. This map is a shared request-level data container.
2. Extract the `add_inf_list` (addition information list) from the data map. If the list is absent, the method returns early — no service line items to process.
3. Iterate over each item in the addition list. For each item:
   - Look up a template map using the item's `TemplateId` key.
   - If the template map exists, extract the `SvKeiNoKmkNm` (service contract number key name) from the item and use it to retrieve the actual service contract number from the template map.
   - If the service contract number is found, write it into the item's `svc_kei_no` field for downstream use.
4. Return the enriched `param` object.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `param` | `IRequestParameterReadWrite` | Request parameter container carrying the full request context, including data maps keyed by `fixedText` (the service message identifier), template maps, and item-level lists. This is the primary data carrier through which service contract numbers flow to downstream processing. |
| 2 | `fixedText` | `String` | Service message identifier used as the key to retrieve the correct data map from `param`. This corresponds to the service message name (e.g., a screen-specific message key) and determines which request-scoped data context this method operates on. |

**Data map keys used (literal strings in source):**

| Key Literal | Business Meaning |
|-------------|-----------------|
| `add_inf_list` | Addition information list — contains the list of service line items to process (items being added to a service contract) |
| `TemplateId` | Template identifier — the key name pointing to a template map that contains template-level service information |
| `SvKeiNoKmkNm` | Service contract number key name — the key name used within each item map to look up the corresponding template-level contract number |

## 4. CRUD Operations / Called Services

This method performs **no external CRUD operations**. It is a pure data-population utility that operates entirely on in-memory data structures (HashMap and ArrayList) within the request parameter object. All data accessed comes from `param` via `getData()` and `setData()`, which are request-scoped internal data stores, not database accesses.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `IRequestParameterReadWrite.getData(fixedText)` | - | - (in-memory data map) | Reads the shared data map keyed by `fixedText` from the request parameter |
| - | `IRequestParameterReadWrite.setData(fixedText, dataMap)` | - | - (in-memory data map) | Writes the data map into the request parameter under the `fixedText` key |
| - | `param.getData(map.get(TemplateId))` | - | - (in-memory template map) | Reads a template map from the request parameter using the item's TemplateId key |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | CC:JKKWrisvcAutoAplyGetSvcInfoCC.getSvcInfo() | `getSvcInfo()` -> `getSvkeiNo()` | No terminal CRUD — calls SC via `scCall.run()` after enrichment (`EKK0081A010` SC) |
| 2 | CC:JKKWrisvcAutoAplyGetSvcInfoCC.getInvokeCBS() | `getInvokeCBS()` -> `getSvkeiNo()` | No terminal CRUD — CBS invocation entry point for common data |
| 3 | CC:JKKUpdJdgInfoAfAddCC.getInvokeCBS() | `getInvokeCBS()` -> `getSvkeiNo()` | No terminal CRUD — judgment update post-addition common data population |
| 4 | CC:JKKJdgGetSvcInfoCC.getSvkeiNo() | `getSvkeiNo()` -> `getSvkeiNo()` | No terminal CRUD — recursive-style call from judgment-specific service info CC |

**Caller Notes:**
- `JKKWrisvcAutoAplyGetSvcInfoCC.getSvcInfo()` (line 118): Invoked before the cancellation and addition processing loops. It enriches item maps with `svc_kei_no` so that the subsequent `scCall.run(putParamMap(paramMap, template), handle)` calls in the `for` loop can use the service contract number.
- `JKKWrisvcAutoAplyGetSvcInfoCC.getInvokeCBS()` (line 102): Called from a CBS (common business service) invocation path that requires service contract number population before further data processing.
- `JKKUpdJdgInfoAfAddCC.getInvokeCBS()` (lines 96, 138): Called twice in the post-addition judgment update workflow — once before cancellation processing and once before addition processing, ensuring `svc_kei_no` is populated in both paths.
- `JKKJdgGetSvcInfoCC.getSvkeiNo()` (line 102): A similarly named method in the judgment-specific CC class that delegates to the same population logic, indicating a shared utility design.

**Terminal operations from this method:** None directly. The method only performs in-memory data enrichment. The callers chain to actual SC calls (e.g., EKK0081A010) after this method returns.

## 6. Per-Branch Detail Blocks

**Block 1** — [IF] `dataMap == null` (L273)

Retrieve the data map from the request parameter. If null, create a new empty map and store it.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `dataMap = (HashMap)param.getData(fixedText)` // Retrieve data map from param keyed by fixedText [-> "fixedText" key in param] |
| 2 | IF | `if (dataMap == null)` [L273] — Check if data map already exists |

**Block 1.1** — [nested IF-true: dataMap is null] `(dataMap == null)` (L274)

Create and initialize the data map if it was not present in the parameter.

| # | Type | Code |
|---|------|------|
| 1 | SET | `dataMap = new HashMap()` // Create new empty HashMap |
| 2 | EXEC | `param.setData(fixedText, dataMap)` // Store new dataMap back into param [-> "fixedText" key] |

**Block 1.2** — [nested IF-false: dataMap exists] `(dataMap != null)` (L276)

Data map already exists; proceed to extract the addition list from it.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `dataList = (ArrayList)dataMap.get("add_inf_list")` // Get addition info list [-> "add_inf_list" key] |

**Block 2** — [IF] `dataList == null` (L279)

Check if there are any addition request items to process. If the list is null or empty, there is nothing to do.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if (dataList == null)` [L279] — No addition items to process |

**Block 2.1** — [nested IF-true: dataList is null] `(dataList == null)` (L281)

Early return when no addition items exist.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return param` // Return param unchanged — no items to enrich |

**Block 2.2** — [nested IF-false: dataList exists] `(dataList != null)` (L284)

Process each addition request item, enriching it with the service contract number.

| # | Type | Code |
|---|------|------|
| 1 | FOR | `for (int i = 0; i < dataList.size(); i++)` [L284] — Iterate over each addition item |

**Block 2.2.1** — [nested FOR body] `(loop iteration)` (L287)

For each item in the addition list, retrieve the item's map and attempt to enrich it with the service contract number from the template.

| # | Type | Code |
|---|------|------|
| 1 | SET | `map = (HashMap)dataList.get(i)` // Get current item map from list |

**Block 2.2.2** — [IF] `param.getData(map.get("TemplateId")) != null` (L290)

Check if a template map exists for this item's TemplateId. Only proceed if the template data is present.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if (param.getData(map.get("TemplateId")) != null)` [L290] — Template map exists for this item |

**Block 2.2.2.1** — [nested IF-true: TemplateId exists] `(TemplateId found)` (L293)

Retrieve the template map and extract the service contract number, placing it into the item's `svc_kei_no` field.

| # | Type | Code |
|---|------|------|
| 1 | SET | `templateMap = (HashMap)param.getData(map.get("TemplateId"))` // Get template map using TemplateId key [-> "TemplateId" key] |
| 2 | SET | `svKeiNo = (String)templateMap.get(map.get("SvKeiNoKmkNm"))` // Resolve service contract number from template [-> "SvKeiNoKmkNm" key lookup] |

**Block 2.2.2.2** — [IF] `svKeiNo != null` (L296)

If the service contract number was found in the template, write it into the item map for downstream consumers.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if (svKeiNo != null)` [L296] — Service contract number resolved from template |

**Block 2.2.2.2.1** — [nested IF-true: svKeiNo found] `(svKeiNo != null)` (L297)

Populate the service contract number into the item map.

| # | Type | Code |
|---|------|------|
| 1 | SET | `map.put("svc_kei_no", svKeiNo)` // Enrich item with resolved service contract number |

**Block 2.2.2.2.2** — [nested IF-false: svKeiNo is null] `(svKeiNo == null)` (L300)

Service contract number not found in template; skip this item and continue to the next iteration.

| # | Type | Code |
|---|------|------|
| 1 | (implicit) | Continue loop — item map unchanged, no svc_kei_no set |

**Block 3** — [RETURN] (L306)

Return the enriched parameter object to the caller. All items that had template mappings now carry their `svc_kei_no` values.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return param` // Return param with all enrichment applied |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|-----------------|
| `svc_kei_no` | Field | Service contract number — the unique identifier assigned to a service contract line item, used to correlate order data across the system |
| `add_inf_list` | Field (map key) | Addition information list — contains service line items being added to a service contract (new service registrations) |
| `ccl_list` / `cancel_inf_list` | Field (map key) | Cancellation information list — contains service line items being cancelled (from the caller's context; not accessed directly by this method) |
| `TemplateId` | Field (map key) | Template identifier — the key name used to locate a template map containing template-level service data for a given item |
| `SvKeiNoKmkNm` | Field (map key) | Service contract number key name — the dynamic key name that indicates where to find the service contract number within a template map |
| `fixedText` | Parameter | Service message identifier — the business message key that determines which request-scoped data context to operate on |
| `param` | Parameter | Request parameter container — the central data carrier object (`IRequestParameterReadWrite`) holding all request-level data including maps, templates, and item lists |
| `param.getData(key)` | Method | Reads a value from the request parameter's internal data store by key |
| `param.setData(key, value)` | Method | Writes a value into the request parameter's internal data store under the given key |
| CC | Acronym | Common Component — a shared reusable Java class that provides cross-cutting business logic across multiple screens and CBS paths |
| SC | Acronym | Service Component — a remote service (typically EJB-based) that performs business logic and database operations; called via `ServiceComponentRequestInvoker` |
| `IRequestParameterReadWrite` | Interface | Interface for request parameter objects that support both reading and writing of data maps, control maps, and metadata |
| HashMap | Type | Java HashMap — the in-memory key-value map structure used throughout the request data model |
| ArrayList | Type | Java ArrayList — the in-memory ordered list structure used for item collections like `add_inf_list` |
| `getSvcInfo` | Method | The public entry point of `JKKWrisvcAutoAplyGetSvcInfoCC` that orchestrates automatic discount service application information retrieval, including calling `getSvkeiNo()` for data enrichment |
| `getInvokeCBS` | Method | CBS invocation entry point that prepares common data before invoking downstream service components |
| EKK0081A010 | SC Code | Service Component for automatic discount service application processing — invoked by the caller after this method enriches item data |
