# Business Logic — JFUDslOpSvcKeiCC.setInMapOpSvcKeiDsl() [49 LOC]

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

## 1. Role

### JFUDslOpSvcKeiCC.setInMapOpSvcKeiDsl()

This method performs **upstream data mapping for Option Service Contract Cancellation** (上りマッピング項目設定 - Option Service Contract Cancellation). It is a data assembly method that constructs the input request map (`inMap`) required by the EKK0351C240CBS service component — the CBS responsible for submitting option service contract cancellation requests.

The method acts as a **mapping/transformation utility** within the eo Optical Television Option Service Contract Cancellation component. It gathers operational data from multiple sources — the option service DSL map (which carries the contract details), the current request context (which holds temporary template data), and shared utility classes (which provide system dates and charge end dates) — and consolidates them into a single, flat HashMap that matches the CBS input parameter contract.

The method handles **two operational modes** based on the function code: when the function code is "1" (Check & Register), and when it is not (likely Display-only or other modes). For multi-item cancellations (template number > 1) under Check & Register mode, the method also resolves the previous update timestamp from the working map for optimistic concurrency control.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["setInMapOpSvcKeiDsl"])

    START --> S1["S1: Get user data from param.getData(fixedText)"]
    S1 --> S2["S2: Get svcEndDate via getEndDate(opSvcKeiDslMap)"]
    S2 --> S3["S3: Get idoDiv via getIdoDiv(opSvcKeiDslMap)"]
    S3 --> S4["S4: templateNo = index + 1"]
    S4 --> S5["S5: Get mskmNaiyoList via getTemplateList"]
    S5 --> S6["S6: mskmNaiyoMap = mskmNaiyoList.get(0)"]
    S6 --> S7["S7: Populate inMap"]
    S7 --> S7A["OP_SVC_KEI_NO from opSvcKeiDslMap"]
    S7 --> S7B["MSKM_DTL_NO from mskmNaiyoMap"]
    S7 --> S7C["RSV_TSTA_KIBO_YMD = svcEndDate"]
    S7 --> S7D["SVC_DLRE_CD = CD00879_01"]
    S7 --> S7E["IDO_DIV = idoDiv"]
    S7 --> S7F["SVC_CHRG_ENDYMD from JFUBPCommon.getSvcChrgEndYmdOpTv"]
    S7A --> S8["S8: lastUpdDtm = opSvcKeiDslMap CC_UPD_DTM"]
    S8 --> COND1{getFuncCode = FUNC_CD_1}
    COND1 -->|Yes| COND2{templateNo > 1}
    COND1 -->|No| FINAL
    COND2 -->|Yes| S9["lastUpdDtm = inMap.get(LAST_UPD_DTM)"]
    COND2 -->|No| FINAL
    S9 --> FINAL["Final: inMap.put(UPD_DTM_BF, lastUpdDtm)"]
    FINAL --> END(["Return / Next"])
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `param` | `IRequestParameterReadWrite` | The request parameter object carrying the full request context. Used to retrieve the temporary working map (`fixedText` key) which holds the admission-registered detail template data (申込登録明細情報). |
| 2 | `fixedText` | `String` | The service message key used as the map key to retrieve data from `param`. Typically identifies the current screen or processing block within the request context. |
| 3 | `opSvcKeiDslMap` | `HashMap` | The Option Service Contract Cancellation Information (オプションサービス契約解約情報) map carrying the contract details for the cancellation record at the given index — including the contract number, update timestamp, and operation status. |
| 4 | `index` | `int` | The Option Service Contract Processing Target Index (オプションサービス契約処理対象インデックス) — the zero-based position in the cancellation list. Used to derive the template number (index + 1) for multi-record handling. |

**Internal fields / external state read:**

| Field | Source | Description |
|-------|--------|-------------|
| `JFUBPCommon.getSvcChrgEndYmdOpTv(null)` | Utility class | Returns the service charge end date/year-month-day for option television services. |
| `getFuncCode(param, fixedText)` | Inherited from `JFUBaseCC` | Retrieves the current function code from the request parameters (e.g., "1" for Check & Register mode). |
| `CC_OP_SVC_KEI_NO` | `JFUDslOpSvcKeiCC` constant | Internal key `"cc_op_svc_kei_no"` — Option Service Contract Number. |
| `CC_UPD_DTM` | `JFUDslOpSvcKeiCC` constant | Internal key `"cc_upd_dtm"` — Update Date-Time. |
| `LAST_UPD_DTM` | `EKK0351A010CBSMsg1List` constant | DB column `"last_upd_dtm"` — Last Update Date-Time (for optimistic concurrency). |

## 4. CRUD Operations / Called Services

This method performs **no direct database operations**. All operations are Read (R) calls through service helper/utility methods that extract or compute values for the input map. No Create, Update, or Delete operations are performed by this method itself.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `param.getData(fixedText)` | - | - | Retrieves the temporary working map from the request parameter context. |
| R | `getEndDate(opSvcKeiDslMap)` | - | - | Internal helper: reads contract status to compute service end date (online date or end of month). |
| R | `getIdoDiv(opSvcKeiDslMap)` | - | - | Internal helper: reads contract status to determine change category code (option cancellation or option setup). |
| R | `getTemplateList(...)` | Inherited from `JFUBaseCC` | - | Retrieves the admission-registered detail template list (申込内容承認登録テンプレートリスト) from the working map. |
| R | `JFUBPCommon.getSvcChrgEndYmdOpTv(null)` | JFUBPCommon | - | Returns the service charge end date/year-month/day for option television (サービス課金終了年月日). |
| R | `getFuncCode(param, fixedText)` | Inherited from `JFUBaseCC` | - | Retrieves the current function code from request parameters. |
| R | `opSvcKeiDslMap.get(CC_UPD_DTM)` | - | - | Reads the last update date-time from the DSL map for optimistic concurrency control. |
| R | `inMap.get(LAST_UPD_DTM)` | - | - | Reads the previous update timestamp from the working map for concurrency check (multi-item case). |

## 5. Dependency Trace

The pre-computed call graph shows no screen/batch entry points within 8 hops. This method is a private helper directly called by its enclosing class.

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Class: JFUDslOpSvcKeiCC | `JFUDslOpSvcKeiCC.dslOpSvcKei()` -> `setInMapOpSvcKeiDsl()` | `getFuncCode [R]`, `getSvcChrgEndYmdOpTv [R]`, `getTemplateList [R]`, `getEndDate [R]`, `getIdoDiv [R]`, `param.getData [R]` |

**Note:** All terminal operations are Read (R) operations — this method assembles data but does not execute any SC codes or perform database I/O directly. The actual CBS invocation (EKK0351C240CBS) occurs at a higher level in the call chain after this method returns.

## 6. Per-Branch Detail Blocks

**Block 1** — SET (data retrieval) (L423)

> Get the user data working map from the request parameter.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `param.getData(fixedText)` // Retrieves the temporary working map identified by fixedText key [-> GETS HashMap from param] |
| 2 | SET | `inMap = (HashMap) param.getData(fixedText)` // User data working map for cancellation input fields |

**Block 2** — SET (service end date acquisition) (L426)

> Gets the service end date/year-month-day. The logic is delegated to `getEndDate(opSvcKeiDslMap)`, which checks if the contract status (`CC_OP_SVC_KEI_STAT`) equals `"030"` (結末済 - completed). If so, it returns the online operation date; otherwise, it returns the end of the month of the online operation date.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `getEndDate(opSvcKeiDslMap)` // Service end date — returns today's date if status is "030" (結末済/Completed), else end of month |
| 2 | SET | `svcEndDate = getEndDate(opSvcKeiDslMap)` // Service end date (サービス終了年月日) |

**Block 3** — SET (change category acquisition) (L429)

> Gets the change category (異動区分). Delegated to `getIdoDiv(opSvcKeiDslMap)`, which checks if the contract status (`CC_OP_SVC_KEI_STAT`) equals `"030"` (結末済 - completed). If so, it sets `"00055"` (オプション予約取消 - option reservation cancellation); otherwise, it sets `"00031"` (オプション設定 - option setup).

| # | Type | Code |
|---|------|------|
| 1 | CALL | `getIdoDiv(opSvcKeiDslMap)` // Change category — "00055" (オプション予約取消/Option Reservation Cancellation) if status is "030" (結末済/Completed), else "00031" (オプション設定/Option Setup) |
| 2 | SET | `idoDiv = getIdoDiv(opSvcKeiDslMap)` // Change category (異動区分) |

**Block 4** — SET (template number derivation) (L431)

| # | Type | Code |
|---|------|------|
| 1 | SET | `templateNo = index + 1` // Derives 1-based template number from 0-based index |

**Block 5** — SET (registration detail information retrieval) (L434-L437)

> Retrieves the admission-registered detail information (申込登録明細情報) from the temporary template list. Uses the template key `"TEMP_" + "EKK0011D020" + "_" + templateNo` with detail template ID `"EKK0011D020CBSMSG1LIST"`. Extracts the first element as the detail map.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `param.getData(fixedText)` // Gets the temporary working map for template access |
| 2 | CALL | `getTemplateList(...)` // Retrieves admission-registered detail template list (申込内容承認登録明細) |
| 3 | SET | `mskmNaiyoList = getTemplateList((HashMap)param.getData(fixedText), TEMP_TEMPLATE_KEY_MSKM_NAIYO_SHONIN_ADD + templateNo, TEMPLATE_ID_DETAIL_MSKM_NAIYO_SHONIN_ADD)` // Template list for registration details |
| 4 | SET | `mskmNaiyoMap = mskmNaiyoList.get(0)` // First (and typically only) detail entry |

**Block 6** — SET (input map population) (L440-L448)

> Populates the `inMap` with the six core cancellation request fields that map to the EKK0351C240CBS service component's input schema.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `inMap.put(OP_SVC_KEI_NO, opSvcKeiDslMap.get(CC_OP_SVC_KEI_NO))` | Option Service Contract Number (オプションサービス契約番号) — carries the contract number from the DSL map |
| 2 | SET | `inMap.put(MSKM_DTL_NO, mskmNaiyoMap.get(MSKM_DTL_NO))` | Registration Detail Number (申込明細番号) — taken from the admission-registered detail template |
| 3 | SET | `inMap.put(RSV_TSTA_KIBO_YMD, svcEndDate)` | Reservation Effective Start Desired Date (予約適用開始希望年月日) — the computed service end date |
| 4 | SET | `inMap.put(SVC_DLRE_CD, CD00879_01)` | Service Cancellation Reason Code (サービス解約理由コード) — hardcoded to `"01"` (service cancellation reason 1) [-> JFUStrConst.CD00879_01 = "01"] |
| 5 | SET | `inMap.put(IDO_DIV, idoDiv)` | Change Category (異動区分) — determined by contract status (結末済 vs. other) |
| 6 | SET | `inMap.put(SVC_CHRG_ENDYMD, JFUBPCommon.getSvcChrgEndYmdOpTv(null))` | Service Charge End Date/Year-Month-Day (サービス課金終了年月日) — obtained from the BP common utility for option television charge termination |

**Block 7** — SET (last update date-time initialization) (L450)

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `lastUpdDtm = String.valueOf(opSvcKeiDslMap.get(CC_UPD_DTM))` // Converts update date-time from DSL map to String — default value for optimistic concurrency check |

**Block 8** — IF (function code check) (L453)

> Condition: `JPCModelConstant.FUNC_CD_1` (function code `"1"` — チェック＆登録/Check and Register) equals `getFuncCode(param, fixedText)`. When the function code indicates Check & Register mode, additional processing is performed.

**Block 8.1** — IF (multi-item cancellation check) (L456) (CONST: FUNC_CD_1 = "1" - Check and Register)

> Condition: `templateNo > 1`. When the cancellation record is not the first item (i.e., this is the 2nd or subsequent cancellation in a batch), the last update timestamp is retrieved from the working map instead of the DSL map. This is for optimistic concurrency control — comparing against the previous state of the specific record.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `lastUpdDtm = String.valueOf(inMap.get(LAST_UPD_DTM))` // For multi-item cancellations, retrieves the previous update timestamp from the working map for optimistic concurrency verification [-> LAST_UPD_DTM = "last_upd_dtm" (EKK0351A010CBSMsg1List)] |

**Block 9** — SET (update timestamp before update) (L463)

> Sets the "update date-time before update" (更新年月日時分秒(更新前)) field into the input map. This is the optimistic concurrency check timestamp that the CBS will compare against the database value to detect concurrent modifications.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `inMap.put(UPD_DTM_BF, lastUpdDtm)` // Update Date-Time Before Update (更新年月日時分秒(更新前)) — optimistic concurrency control value for the CBS |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `setInMapOpSvcKeiDsl` | Method | Set Input Map - Option Service Contract (DSL); upstream data mapping for option service contract cancellation |
| DSL | Acronym | DSL (Design/Description Language) — in this codebase, refers to the DSL map pattern used for structured data passing between processing stages |
| `opSvcKeiDslMap` | Field | Option Service Contract DSL Map — carries option service contract details for a single cancellation record |
| `inMap` | Field | Input Map — the HashMap being built for the CBS service component input parameters |
| `svcEndDate` | Field | Service End Date — the calculated date when the service should be terminated |
| `idoDiv` | Field | Change Category (異動区分) — classifies the type of contract change (option reservation cancellation "00055" or option setup "00031") |
| `templateNo` | Field | Template Number — 1-based index for selecting the correct temporary template entry |
| `mskmNaiyoList` | Field | Admission-Registered Detail List (申込登録明細リスト) — list of admission-registered content detail templates |
| `mskmNaiyoMap` | Field | Admission-Registered Detail Map (申込登録明細マップ) — single detail entry from the template list |
| `OP_SVC_KEI_NO` | CBS Field | Option Service Contract Number (オプションサービス契約番号) |
| `MSKM_DTL_NO` | CBS Field | Registration Detail Number (申込明細番号) |
| `RSV_TSTA_KIBO_YMD` | CBS Field | Reservation Effective Start Desired Date (予約適用開始希望年月日) |
| `SVC_DLRE_CD` | CBS Field | Service Cancellation Reason Code (サービス解約理由コード) |
| `IDO_DIV` | CBS Field | Change Category (異動区分) |
| `SVC_CHRG_ENDYMD` | CBS Field | Service Charge End Date (サービス課金終了年月日) |
| `UPD_DTM_BF` | CBS Field | Update Date-Time Before Update (更新年月日時分秒(更新前)) — optimistic concurrency timestamp |
| `CC_OP_SVC_KEI_NO` | Constant | `"cc_op_svc_kei_no"` — internal key for option service contract number |
| `CC_UPD_DTM` | Constant | `"cc_upd_dtm"` — internal key for update date-time |
| `LAST_UPD_DTM` | Constant | `"last_upd_dtm"` — database column for last update date-time (from EKK0351A010CBSMsg1List) |
| `TEMP_TEMPLATE_KEY_MSKM_NAIYO_SHONIN_ADD` | Constant | `"TEMP_" + "EKK0011D020" + "_"` — prefix for temporary template keys of admission content approval registration |
| `FUNC_CD_1` | Constant | `"1"` — function code for Check & Register (チェック＆登録) mode |
| `CD00879_01` | Constant | `"01"` — service cancellation reason code 1 |
| `CD00576_00055` | Constant | `"00055"` — option reservation cancellation category (オプション予約取消) |
| `CD00576_00031` | Constant | `"00031"` — option setup category (オプション設定) |
| `CD00037_030` | Constant | `"030"` — contract status code for "completed" (結末済) |
| EKK0351C240CBS | CBS | Option Service Contract Cancellation CBS — handles cancellation of option service contracts |
| EKK0011D020 | Template ID | Admission Content Approval Registration template ID (申込内容承認登録) |
| Option Service (オプションサービス) | Business term | Optional add-on services (e.g., extra channels, premium content) that subscribers can attach to their base TV package |
| Option Service Contract (オプションサービス契約) | Business term | The contractual agreement governing an option service — its creation, modification, and cancellation |
| Option Service Contract Cancellation (オプションサービス契約解約) | Business term | The business operation of terminating an existing option service contract |
| eo Optical Television (eo光テレビ) | Business term | NTT Plala's fiber-optic bundled television service — the core product domain |
| Check & Register (チェック＆登録) | Business term | Function mode where the system validates data and registers it in a single operation (function code "1") |
| Optimistic Concurrency Control | Concept | A database concurrency strategy using timestamp comparison (last_upd_dtm) to detect conflicting updates |
| 上りマッピング (upstream mapping) | Japanese term | Data flow direction: mapping from internal data structures to the CBS input request parameters |
| 下りマッピング (downstream mapping) | Japanese term | Data flow direction: mapping from CBS output data back to internal/field data structures |
