# Business Logic — JKKPrcSimulationCC.chkGetAplyInfo() [39 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.fujitsu.futurity.bp.custom.common.JKKPrcSimulationCC` |
| Layer | Common Component / CC (Shared utility within EJB business layer) |
| Module | `common` (Package: `com.fujitsu.futurity.bp.custom.common`) |

## 1. Role

### JKKPrcSimulationCC.chkGetAplyInfo()

This method performs **subscription form code validation** (申込形態コードチェック) within the K-Opticom billing price simulation subsystem. Its core business responsibility is to determine whether a given discount service (割引サービス) has a valid, matching subscription form code (申込形態コード) that authorizes it to be applied to the current order context.

The method follows a **retrieve-filter-validate** pattern: it first fetches all discount service application conditions (割引サービス適用条件一覧) via a mapper call, then removes any unnecessary conditions through `editAplyInfo`, and finally iterates over the remaining conditions to check if any condition's form code matches the current form code stored in the work area. This implements a shared utility pattern — the method is called from `chkMainWribSvc()` as part of the broader validation chain before executing discount service operations.

The method supports a **Masuta (マスタ) setting mechanism**: when application conditions exist, the method verifies that at least one condition's form code matches the order's current form code. If no application conditions are returned (empty list), it is treated as a pass (no Masuta setting required, OK). If conditions exist but none match, the method fails the check. This behavior ensures that discount services are only applied to orders of compatible subscription forms.

As a private method, it acts as an internal gate within the price simulation flow, preventing invalid discount service applications from proceeding further in the processing pipeline.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START([\"chkGetAplyInfo\"])

    START --> GET_SVC_CD[\"Get WRIB_SVC_CD from wribSvcMap\"]

    GET_SVC_CD --> CALL_M[\"callWribAplyInfo(commonInfo, wribSvcCd, FUNC_1=\\\"1\\\", serial)\"]

    CALL_M --> EDIT_APLY[\"editAplyInfo(wrisvcDchskmAplyJknList)\"]

    EDIT_APLY --> CHECK_EMPTY{\"wrisvcDchskmAplyJknList.isEmpty()?\"}

    CHECK_EMPTY -->|Yes| LOG_NO_MASA[\"Log: Masuta setting none - OK\"]

    LOG_NO_MASA --> RET_TRUE_1([\"return true\"])

    CHECK_EMPTY -->|No| FOR_LOOP[\"for each mapWrisvcDchskmAplyJkn in wrisvcDchskmAplyJknList\"]

    FOR_LOOP --> GET_APLY_CND[\"Get WRSV_APLY_JKN_VALUE_1 from map\"]

    GET_APLY_CND --> GET_MSKM[\"Get MSKM_FORM_CD from commonInfo\"]

    GET_MSKM --> COMPARE{\"commonInfo.MSKM_FORM_CD equals aplyCndMksmFormCd?\"}

    COMPARE -->|Yes| LOG_MATCH[\"Log: Masuta setting yes - Match found\"]

    LOG_MATCH --> RET_TRUE_2([\"return true\"])

    COMPARE -->|No| FOR_NEXT{\"More items?\"}

    FOR_NEXT -->|Yes| FOR_LOOP

    FOR_NEXT -->|No| LOG_NOMATCH[\"Log: Masuta setting yes - No match\"]

    LOG_NOMATCH --> RET_FALSE([\"return false\"])
```

**Processing summary:**

1. **Extract service code** — Retrieve the discount service code (`WRIB_SVC_CD`) from the `wribSvcMap` input map.
2. **Fetch application conditions** — Call `callWribAplyInfo()` via the mapper with the constant `FUNC_1 = "1"` and the serial number to retrieve a list of discount service application conditions. This is an SC (Service Component) call that queries the system for relevant conditions.
3. **Filter unnecessary conditions** — Pass the result list to `editAplyInfo()`, which removes unnecessary (unnecessary/unwanted) discount service application conditions from the list. This modification was introduced in v4.00.00 to handle discount application logic.
4. **Check for empty list** — If the filtered list is empty, no Masuta (マスタ/master data) setting is required, so the check passes and returns `true`.
5. **Iterate and match** — If the list is non-empty, iterate through each application condition record. For each record, extract the application condition value 1 (`WRSV_APLY_JKN_VALUE_1`) and compare it against the subscription form code (`MSKM_FORM_CD`) from `commonInfo`.
6. **Match found** — If a match is found, log the result and return `true` (check OK, processing ends).
7. **No match** — If the loop completes without finding a match, log the failure and return `false`.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `commonInfo` | `HashMap<String, Object>` | Work area (作業領域) containing the current order's operational context. Specifically holds the subscription form code (`MSKM_FORM_CD`) which represents the form/pattern of the order being processed. This code determines what types of discount services can be applied. |
| 2 | `wribSvcMap` | `HashMap<String, Object>` | Service information map (サービス情報). Contains the discount service code (`WRIB_SVC_CD`) identifying which discount service the application conditions should be retrieved for. Also holds discount type code and service name data used elsewhere in the simulation flow. |
| 3 | `serial` | `String` | Serial number (SCマップ連番) — a unique iteration/index identifier used to distinguish between multiple concurrent or sequential service processing instances. Acts as a correlation key for the mapper call. |

### External State Read

| Field | Source | Description |
|-------|--------|-------------|
| `getMapper()` return value | Instance method | Returns a `JKKPrcSimulationCCMapper` instance used to call the `callWribAplyInfo` data access method. The mapper instance is obtained from the parent class or injected dependency. |

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `callWribAplyInfo` | — | — | Reads discount service application conditions from the data layer. Called via the mapper with the service code, `FUNC_1="1"`, and serial. |
| U | `editAplyInfo` | — | — | Updates the application conditions list in-place by removing unnecessary conditions. Introduces filtering logic added in v4.00.00. |
| - | `getMapper` | — | — | Returns the mapper instance; no direct data operation. |
| - | `printlnEjbLog` | — | — | Logging utility call; writes diagnostic log messages for audit/debug purposes. |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | — | `JKKPrcSimulationCC.chkMainWribSvc()` -> `chkGetAplyInfo(commonInfo, wribSvcMap, serial)` | `callWribAplyInfo [R]`, `editAplyInfo [U]`, `printlnEjbLog [-]`, `getMapper [R]` |

**Note:** `chkMainWribSvc()` in `JKKPrcSimulationCC` is the direct caller. This method operates within the EJB business tier as a private validation utility. No screen or batch entry points were found within 8 hops in the call graph.

## 6. Per-Branch Detail Blocks

### Block 1 — GET `(condition)` [WRIB_SVC_CD="wrib_svc_cd"] (L728)

> Extracts the discount service code from the service info map. This code identifies which discount service's application conditions should be fetched.

| # | Type | Code |
|---|------|------|
| 1 | SET | `wribSvcCd = (String) wribSvcMap.get(KKSV0553_KKSV0553OP_WORK_WRISVC.WRIB_SVC_CD)` // Retrieves discount service code (割引サービスコード) from wribSvcMap [-> "wrib_svc_cd"] |

---

### Block 2 — CALL `(no condition)` [FUNC_1="1"] (L732)

> Calls the mapper to fetch the discount service application conditions list. Uses `FUNC_1 = "1"` as the service IF call identifier and the serial number for correlation. The result is an ArrayList of maps, each representing one application condition record.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `wrisvcDchskmAplyJknList = getMapper().callWribAplyInfo(commonInfo, wribSvcCd, FUNC_1, serial)` // Invokes SC to fetch discount service application conditions (割引サービス適用条件一覧) [-> FUNC_1="1"] |

---

### Block 3 — CALL `(no condition)` (L737)

> Removes unnecessary discount service application conditions from the list. This filtering was introduced in v4.00.00 as part of the discount application logic. The comment indicates that conditions with types other than "01: Subscription Form" (01: 申込形態) are excluded.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `editAplyInfo(wrisvcDchskmAplyJknList)` // Filters out unnecessary discount service application conditions (不必要な割引サービス適用条件一覧を除外) |

---

### Block 4 — IF `[isEmpty()]` (L740)

> Checks if the (now filtered) application conditions list is empty. If empty, it means no Masuta (master data) setting is required for this discount service, so the check passes.

| # | Type | Code |
|---|------|------|
| 1 | SET | `wrisvcDchskmAplyJknList.isEmpty()` // Tests if the list has no entries |

**Block 4.1 — IF-BRANCH: Yes (empty)** (L742)

> No application conditions exist — the discount service has no Masuta settings configured. Treated as OK since there's no conflicting condition.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `printlnEjbLog("申込形態コードチェック結果【マスタ設定無し－OK】【" + wribSvcCd + "】")` // Logs: Subscription form code check result [No Masuta setting - OK] [service code] |
| 2 | RETURN | `return true` // Check passes — no Masuta setting required, no conflict to resolve |

**Block 4.2 — IF-BRANCH: No (non-empty)** (L740)

> Application conditions exist — must validate that at least one matches the order's current form code. Proceeds to iteration (Block 5).

---

### Block 5 — FOR `(iterating wrisvcDchskmAplyJknList)` (L746)

> Iterates through each discount service application condition record in the list. For each record, the method checks whether the condition's form code matches the order's current form code. If a match is found, the check passes and returns immediately. This implements a find-first-match strategy.

| # | Type | Code |
|---|------|------|
| 1 | SET | `mapWrisvcDchskmAplyJkn` // Iterator variable for each application condition record in the filtered list |

---

### Block 5.1 — GET `[WRSV_APLY_JKN_VALUE_1]` (L751)

> Extracts the application condition value 1 from the current map entry. This field (`WRSV_APLY_JKN_VALUE_1`) stores the subscription form code that the condition applies to.

| # | Type | Code |
|---|------|------|
| 1 | SET | `aplyCndMksmFormCd = (String) mapWrisvcDchskmAplyJkn.get(KKSV0553_KKSV0553OP_KKSV055303SC_EKK2311B002CBSMsg1List.WRSV_APLY_JKN_VALUE_1)` // Retrieves application condition form code value [-> "wrsv_aply_jkn_value_1"] |

---

### Block 5.2 — IF `[equals()]` (L752)

> Compares the subscription form code from `commonInfo` with the application condition's form code extracted from the list. If they are equal, the discount service is valid for this order's form, and the check succeeds.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `commonInfo.get(KKSV0553_KKSV0553OP_WORK.MSKM_FORM_CD).equals(aplyCndMksmFormCd)` // Compares order form code with condition form code [-> MSKM_FORM_CD="mskm_form_cd"] |

**Block 5.2.1 — IF-BRANCH: Yes (match)** (L753)

> The subscription form codes match — this application condition is valid for the current order. Logs the match result and terminates checking with success.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `printlnEjbLog("申込形態コードチェック結果【マスタ設定有り－該当有り】【" + wribSvcCd + "】")` // Logs: Subscription form code check result [Masuta setting yes - Match found] [service code] |
| 2 | RETURN | `return true` // Check passes — valid match found, processing ends |

**Block 5.2.2 — IF-BRANCH: No (no match)** (L752)

> The form codes do not match. The loop continues to the next application condition record. If no records match after iterating through all, the method returns `false` at the end.

| # | Type | Code |
|---|------|------|
| 1 | — | (implicit: loop continues to next iteration) |

---

### Block 6 — LOG/RETURN `(post-loop, no match)` (L761)

> All application conditions have been checked and none matched the order's current form code. The discount service cannot be applied because there is no compatible subscription form code. Logs the failure and returns `false` to indicate a failed check.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `printlnEjbLog("申込形態コードチェック結果【マスタ設定有り－該当無し】【" + wribSvcCd + "】")` // Logs: Subscription form code check result [Masuta setting yes - No match] [service code] |
| 2 | RETURN | `return false` // Check fails — Masuta settings exist but no matching condition found |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `chkGetAplyInfo` | Method | Check Get Application Info — validates subscription form codes for discount service applicability |
| 申込形態コード (Shinnyokeitai koodo) | Field | Subscription form code — identifies the type/format of the customer's subscription or contract form |
| 割引サービス (Waribiki saabisu) | Business term | Discount service — promotional or pricing services applied to orders that reduce costs |
| 割引サービス適用条件 (Waribiki saabisu tekiyou joken) | Field | Discount service application condition — rules that define when and how a discount service can be applied |
| 作業領域 (Sagyoryouiki) | Field | Work area — temporary data storage holding the current processing context and order state |
| サービス情報 (Saabisu jouhou) | Field | Service information — data structure containing details about a specific discount service being processed |
| SCマップ連番 (SC map renban) | Field | SC (Service Component) map serial number — unique iteration index used to correlate mapper calls with specific service processing instances |
| Masuta (マスタ) | Business term | Master data — configuration settings derived from master/reference tables that govern service application rules |
| MSKM_FORM_CD | Field | Masu (subscription) form code — key field in `commonInfo` holding the order's current subscription form code for validation |
| WRIB_SVC_CD | Field | WRIB (Waribiki — discount) service code — identifier for the specific discount service being validated |
| WRSV_APLY_JKN_VALUE_1 | Field | WRIB SVice Application Condition VALUE 1 — the first application condition value, representing the subscription form code that the condition applies to |
| FUNC_1 | Constant | Function code "1" — used as an identifier parameter for the service IF (mapper) call to specify the type of operation |
| callWribAplyInfo | SC Method | Call WRIB (discount) Application Info — SC method that retrieves discount service application conditions from the data layer |
| editAplyInfo | CC Method | Edit Application Info — utility method that filters/removes unnecessary application conditions from the list |
| JKKPrcSimulationCC | Class | JKK (K-Opticom internal code) Price Simulation Common Component — shared component class for price simulation business logic |
| wrisvcDchskmAplyJknList | Variable | WRIB SVC DeChi (detail) SKM Application JOKEN (condition) List — ArrayList of application condition records returned from the SC call |
