# Business Logic — JKKStbUcwkEoTvKktkSvcKeiCC.setKojiRenkeiKikiData() [99 LOC]

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

## 1. Role

### JKKStbUcwkEoTvKktkSvcKeiCC.setKojiRenkeiKikiData()

This method is responsible for constructing and registering construction coordination data (工事連携データ) for set-top box (STB) and other home device equipment used in the K-Opticom eo Optical TV subscription channel registration workflow. The method builds a detailed equipment profile map (`mp`) by extracting device-related fields from the `kikiInfo` message (terminal information) and enriches it with additional data such as the STB ID (resolved via a service component call) and, when applicable, "old" equipment fields for device swap processing. It follows a routing/dispatch pattern: if the service category code indicates an STB (`"C009"`), it calls the `EKKA0020003CBS` service component to look up the STB ID using the home device model code and serial number; if the operation is a device swap (`STB_IDO_DIV_CHG = "02"`), it captures the previous STB ID and equipment attributes as "old" fields for change tracking. Notably, when the service category is BCAS (`"C010"`) during a device swap, it overrides the installation type code to `"09"` (no change) to accommodate BCAS-specific constraints. The constructed equipment map is then appended to the `kktkSvcOutList` within the coordination output map for downstream processing by the broader service contract registration flow.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["setKojiRenkeiKikiData params"])

    START --> RETRIEVE["Retrieve inMap from param.getData fixedText"]
    RETRIEVE --> NESTED["Retrieve kktkSvcOutMap and kktkSvcOutList from inMap"]
    NESTED --> INITMP["Init mp HashMap"]
    INITMP --> POPULATE["Populate mp with kikiInfo fields: taknkiki_sbt_cd, kktk_svc_kei_no, taknkiki_model_cd, kiki_seizo_no, hdd_capa_cd, stb_kei_tv_course_cd"]

    POPULATE --> IS_STB{KKTK_SVC_CD is STB C009}

    IS_STB -->|Yes| SET_IDO["Set taknkiki_ido_cd to stbIdoDiv"]
    IS_STB -->|No| CHECK_CHG

    SET_IDO --> CALL_SC["callSC handle scCall param fixedText msgEKKA0020003"]
    CALL_SC --> HAS_RESULT{result length greater than 0}
    HAS_RESULT -->|Yes| GET_STB_ID["Extract stb_id from result"]
    HAS_RESULT -->|No| SET_EMPTY_STB["stb_id stays empty string"]
    GET_STB_ID --> PUT_STB["Put stb_id into mp"]
    SET_EMPTY_STB --> PUT_STB

    PUT_STB --> CHECK_CHG{stbIdoDiv is CHG 02}

    CHECK_CHG -->|Yes| PUT_OLD["Set old_stb_id, old_hdd_capa_cd, old_taknkiki_model_cd in mp"]
    CHECK_CHG -->|No| ADD_TO_LIST

    PUT_OLD --> CHECK_BCAS{KKTK_SVC_CD is BCAS C010}
    CHECK_BCAS -->|Yes| BCAS_FORCE["Set taknkiki_ido_cd to 09 No Change"]
    CHECK_BCAS -->|No| ADD_TO_LIST

    BCAS_FORCE --> ADD_TO_LIST["Add mp to kktkSvcOutList"]
    ADD_TO_LIST --> END(["Return"])
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | Database session handle for executing service component calls, used when calling `callSC` to invoke `EKKA0020003CBS` for STB ID resolution. |
| 2 | `param` | `IRequestParameterReadWrite` | Request parameter object that carries nested data maps. Used to retrieve the construction coordination output map via `param.getData(fixedText)` and then the `kktkSvcOutList` for appending equipment data. |
| 3 | `fixedText` | `String` | Map key used to retrieve the correct data map from `param`. Acts as a namespace identifier for the construction coordination data section. Resolves to the `kojifixtext` key within the returned map. |
| 4 | `scCall` | `ServiceComponentRequestInvoker` | Service component invocation bridge used to call downstream CBS (service component) methods like `EKKA0020003CBS` for external service lookups. |
| 5 | `kikiInfo` | `CAANMsg` | Terminal/equipment information message carrying device details such as model code, serial number, HDD capacity, service category code, and sub-category code. Fields are accessed via constants from `EKK0341A010CBSMsg1List`. |
| 6 | `stbIdoDiv` | `String` | STB installation/division code indicating the type of device operation. `"02"` means device swap (home device swap / 家庭機器異動コード：交換), `"01"` means device addition, `"03"` means partial removal. Controls whether "old" equipment fields are populated. |
| 7 | `tvCourceCd` | `String` | TV course/subscription plan code (石部TV課codes / STB type TV course code). Represents the TV subscription plan category associated with the STB equipment, stored as `stb_kei_tv_course_cd`. |

**Instance fields / external state read:**
- `STB_IDO_DIV_CHG` — constant `"02"` used to check if the operation is a device swap.

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JBSbatDKNyukaFinAdd.getData` | JBSbatDKNyukaFinAdd | - | Calls `getData` in `JBSbatDKNyukaFinAdd` |
| R | `JBSbatFUCaseFileRnkData.getString` | JBSbatFUCaseFileRnkData | - | Calls `getString` in `JBSbatFUCaseFileRnkData` |
| R | `JBSbatFUMoveNaviData.getString` | JBSbatFUMoveNaviData | - | Calls `getString` in `JBSbatFUMoveNaviData` |
| R | `JBSbatZMAdDataSet.getString` | JBSbatZMAdDataSet | - | Calls `getString` in `JBSbatZMAdDataSet` |
| R | `JFUeoTelOpTransferCC.getData` | JFUeoTelOpTransferCC | - | Calls `getData` in `JFUeoTelOpTransferCC` |
| R | `JFUTransferCC.getData` | JFUTransferCC | - | Calls `getData` in `JFUTransferCC` |
| R | `JFUTransferListToListCC.getData` | JFUTransferListToListCC | - | Calls `getData` in `JFUTransferListToListCC` |
| R | `JKKStbUcwkEoTvKktkSvcKeiCC.callSC` | EKKA0020003CBS | - | Calls `callSC` to invoke `EKKA0020003CBS` for STB ID lookup by model code and serial number. Returns the STB ID from the response list. |
| R | `JESC0101B010TPMA.getString` | JESC0101B010TPMA | - | Calls `getString` in `JESC0101B010TPMA` |
| R | `JESC0101B020TPMA.getString` | JESC0101B020TPMA | - | Calls `getString` in `JESC0101B020TPMA` |
| R | `KKW12701SFLogic.getData` | KKW12701SFLogic | - | Calls `getData` in `KKW12701SFLogic` |
| R | `SCW00701SFLogic.getName` | SCW00701SFLogic | - | Calls `getName` in `SCW00701SFLogic` |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | JKKStbUcwkEoTvKktkSvcKeiCC.stbUcwkEoTvKktkSvcKei() | `stbUcwkEoTvKktkSvcKei` → `setKojiRenkeiKikiData` | `getString [R] EKK0341A010CBSMsg1List fields`, `callSC EKKA0020003CBS [R] STBID lookup` |

**Terminal operations reached from this method:**

| # | Terminal Operation | Type | Description |
|---|-------------------|------|-------------|
| 1 | `kikiInfo.getString(EKK0341A010CBSMsg1List.TAKNKIKI_SBT_CD)` | R | Read terminal sub-category code |
| 2 | `kikiInfo.getString(EKK0341A010CBSMsg1List.KKTK_SVC_KEI_NO)` | R | Read service detail work number |
| 3 | `kikiInfo.getString(EKK0341A010CBSMsg1List.TAKNKIKI_MODEL_CD)` | R | Read home device model code |
| 4 | `kikiInfo.getString(EKK0341A010CBSMsg1List.KIKI_SEIZO_NO)` | R | Read device serial number |
| 5 | `kikiInfo.getString(EKK0341A010CBSMsg1List.HDD_CAPA_CD)` | R | Read HDD capacity code |
| 6 | `kikiInfo.getString(EKK0341A010CBSMsg1List.KKTK_SVC_CD)` | R | Read service category code (used in branching) |
| 7 | `callSC(handle, scCall, param, fixedText, msgEKKA0020003)` | R | Call EKKA0020003CBS for STB ID resolution |
| 8 | `resltMsgList[0].getString(EKKA0020003CBSMsg2List.STBID)` | R | Read resolved STB ID from response |
| 9 | `kktkSvcOutList.add(mp)` | C | Append equipment data map to coordination output list |

## 6. Per-Branch Detail Blocks

**Block 1** — [SET] `param.getData` retrieval (L620)

The method begins by retrieving nested data structures from the parameter object. It extracts a map using `fixedText` as the key, then derives the construction coordination output map and list from a sub-key `"kojifixtext"`.

> (Optional: brief business description of what this block does)
> Retrieves the construction coordination data map and output list from the request parameter. This is the shared map key infrastructure for inter-construction coordination.

| # | Type | Code |
|---|------|------|
| 1 | SET | `inMap = param.getData(fixedText)` // Retrieve work coordination data map key [-> FIXED_TEXT_KEY] |
| 2 | SET | `kktkSvcOutMap = param.getData(inMap.get("kojifixtext"))` // Retrieve work coordination CC usage map [-> KOJIFIXTEXT] |
| 3 | SET | `kktkSvcOutList = kktkSvcOutMap.get("kktkSvcOutList")` // Retrieve output list for construction coordination data |
| 4 | SET | `mp = new HashMap<String, Object>()` // Initialize equipment profile map |

**Block 2** — [SET] Populate mp with kikiInfo fields (L625–631)

Populates the equipment profile map with terminal/equipment information extracted from the `kikiInfo` message. These fields represent the core device attributes for the service contract.

| # | Type | Code |
|---|------|------|
| 1 | SET | `mp.put("taknkiki_sbt_cd", kikiInfo.getString(EKK0341A010CBSMsg1List.TAKNKIKI_SBT_CD))` // Set terminal sub-category code |
| 2 | SET | `mp.put("kktk_svc_kei_no", kikiInfo.getString(EKK0341A010CBSMsg1List.KKTK_SVC_KEI_NO))` // Set service detail work number |
| 3 | SET | `mp.put("taknkiki_model_cd", kikiInfo.getString(EKK0341A010CBSMsg1List.TAKNKIKI_MODEL_CD))` // Set home device model code |
| 4 | SET | `mp.put("kiki_seizo_no", kikiInfo.getString(EKK0341A010CBSMsg1List.KIKI_SEIZO_NO))` // Set device serial number |
| 5 | SET | `mp.put("hdd_capa_cd", kikiInfo.getString(EKK0341A010CBSMsg1List.HDD_CAPA_CD))` // Set HDD capacity code |
| 6 | SET | `mp.put("stb_kei_tv_course_cd", tvCourceCd)` // Set STB type TV course code |
| 7 | SET | `stb_id = ""` // Initialize STB ID (empty; only set if device is STB) |

**Block 3** — [IF] STB service category check: `KKTK_SVC_CD == "C009"` (L633)

> If the terminal service category code is `"C009"` (STB), this block resolves the STB ID by calling the `EKKA0020003CBS` service component. The STB ID lookup uses the home device model code and serial number to find the matching STB.

**Block 3.1** — [SET] Set taknkiki_ido_cd (L641)

| # | Type | Code |
|---|------|------|
| 1 | SET | `mp.put("taknkiki_ido_cd", stbIdoDiv)` // Set device installation/division code |

**Block 3.2** — [SET] Prepare EKKA0020003CBS message (L644–651)

Constructs the CBS message for STB ID lookup with function code `"1"` (inquiry).

| # | Type | Code |
|---|------|------|
| 1 | SET | `msgEKKA0020003 = new CAANMsg(EKKA0020003CBSMsg.class.getName())` // Create CBS message for STB lookup |
| 2 | SET | `msgEKKA0020003List1 = new CAANMsg(EKKA0020003CBSMsg1List.class.getName())` // Create request list message |
| 3 | SET | `msglist = new CAANMsg[1]` // Allocate single-element response array |
| 4 | SET | `msgEKKA0020003.set(EKKA0020003CBSMsg.FUNC_CODE, "1")` // Set function code to 1 (inquiry) |
| 5 | SET | `msgEKKA0020003List1.set(EKKA0020003CBSMsg1List.KEY_TK_MDL_CD, kikiInfo.getString(EKK0341A010CBSMsg1List.TAKNKIKI_MODEL_CD))` // Set home device model code |
| 6 | SET | `msgEKKA0020003List1.set(EKKA0020003CBSMsg1List.KEY_KK_SEIZO_NO, kikiInfo.getString(EKK0341A010CBSMsg1List.KIKI_SEIZO_NO))` // Set device serial number |
| 7 | SET | `msglist[0] = msgEKKA0020003List1` // Set request list element |
| 8 | SET | `msgEKKA0020003.set(EKKA0020003CBSMsg.EKKA0020003CBSMSG1LIST, msglist)` // Attach request list to message |

**Block 3.3** — [CALL] Call EKKA0020003CBS (L653–654)

Invokes the service component to resolve the STB ID from model code and serial number.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `resltMsgList = callSC(handle, scCall, param, fixedText, msgEKKA0020003).getCAANMsgList(EKKA0020003CBSMsg.EKKA0020003CBSMSG2LIST)` // Call EKKA0020003CBS for STB ID lookup [-> EKKA0020003CBS] |

**Block 3.4** — [IF] Result validation (L656–659)

Checks if the result message array has elements before extracting the STB ID.

| # | Type | Code |
|---|------|------|
| 1 | SET | `stb_id = resltMsgList[0].getString(EKKA0020003CBSMsg2List.STBID)` // Extract STB ID from first result |
| 2 | SET | `mp.put("stb_id", resltMsgList[0].getString(EKKA0020003CBSMsg2List.STBID))` // Put STB ID into equipment map |

**Block 4** — [IF] Device swap check: `stbIdoDiv == STB_IDO_DIV_CHG` (L663)

> When the installation/division code is `"02"` (Device Swap / 交換), this block populates "old" equipment fields to preserve the previous device's STB ID, HDD capacity, and model code for change tracking. This enables downstream audit trails and billing adjustments for swapped equipment.

**Block 4.1** — [SET] Set old equipment fields (L665–667)

| # | Type | Code |
|---|------|------|
| 1 | SET | `mp.put("old_stb_id", stb_id)` // Set previous STB ID |
| 2 | SET | `mp.put("old_hdd_capa_cd", kikiInfo.getString(EKK0341A010CBSMsg1List.HDD_CAPA_CD))` // Set previous HDD capacity code |
| 3 | SET | `mp.put("old_taknkiki_model_cd", kikiInfo.getString(EKK0341A010CBSMsg1List.TAKNKIKI_MODEL_CD))` // Set previous home device model code |

**Block 4.2** — [IF] BCAS override: `KKTK_SVC_CD == "C010"` (ANK-1191-00-00, L671)

> For BCAS services (BCAS is a broadcast encryption/conditional access system), when a device swap occurs, the installation type code is forcibly set to `"09"` (No Change / 異動なし). This BCAS-specific override ensures the encryption system is not triggered by a device change when the same service is maintained.

| # | Type | Code |
|---|------|------|
| 1 | SET | `mp.put("taknkiki_ido_cd", "09")` // Force installation type to "09" (No Change) for BCAS [-> ANK-1191-00-00 override] |

**Block 5** — [EXEC] Append to coordination list (L682)

Adds the fully constructed equipment profile map to the construction coordination output list.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `kktkSvcOutList.add(mp)` // Append equipment data map to coordination output list |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `setKojiRenkeiKikiData` | Method | Construction coordination terminal data registration — registers terminal/equipment data to the construction coordination map for STB and home device service contract processing |
| `kikiInfo` | Parameter | Terminal information message — carries device attributes (model code, serial number, HDD capacity, service category) for the equipment being registered or swapped |
| `stbIdoDiv` | Parameter | STB installation/division code — indicates the type of device operation: `"01"` (Addition / 追加), `"02"` (Swap / 交換), `"03"` (Partial Removal / 一部撤去) |
| `tvCourceCd` | Parameter | TV course code — the subscription plan code associated with the STB equipment |
| `fixedText` | Parameter | Fixed text map key — namespace identifier used to retrieve the correct data map from the request parameter for construction coordination |
| `kktkSvcOutList` | Field | Construction coordination service output list — the shared list where equipment data maps are appended for downstream processing |
| `kojifixtext` | Constant Key | Work coordination fixed text — the key within the data map that references the construction coordination CC usage map |
| `taknkiki_sbt_cd` | Field | Terminal sub-category code — identifies the type/sub-category of the home device |
| `kktk_svc_kei_no` | Field | Construction coordination service detail work number — internal tracking ID for the service contract line item |
| `taknkiki_model_cd` | Field | Terminal model code — the hardware model identifier for the home device |
| `kiki_seizo_no` | Field | Terminal serial number — unique manufacturing serial number of the device |
| `hdd_capa_cd` | Field | HDD capacity code — identifies the hard drive capacity tier of the STB/device |
| `stb_kei_tv_course_cd` | Field | STB type TV course code — the TV subscription plan category specific to STB equipment |
| `stb_id` | Field | STB ID — the unique identifier for the set-top box, resolved via `EKKA0020003CBS` lookup |
| `old_stb_id` | Field | Previous STB ID — the STB identifier before a device swap, preserved for audit/billing |
| `old_hdd_capa_cd` | Field | Previous HDD capacity code — HDD capacity before device swap |
| `old_taknkiki_model_cd` | Field | Previous terminal model code — device model before swap |
| `taknkiki_ido_cd` | Field | Terminal installation/division code — indicates what type of device operation was performed |
| `STB_IDO_DIV_ADD` | Constant | `"01"` — Home device addition code (家庭機器異動コード：追加) |
| `STB_IDO_DIV_CHG` | Constant | `"02"` — Home device swap code (家庭機器異動コード：交換) |
| `STB_IDO_DIV_RMV` | Constant | `"03"` — Home device partial removal code (家庭機器異動コード：一部撤去) |
| `KKTK_SVC_CD_STB` | Constant | `"C009"` — STB service category code (STBサービス) |
| `KKTK_SVC_CD_BCAS` | Constant | `"C010"` — BCAS service category code (BCASサービス) |
| `KKTK_SVC_CD_CCAS` | Constant | `"C011"` — CCAS service category code (CCASサービス) |
| `KKTK_SVC_CD_VONU` | Constant | `"C013"` — VoONU service category code (VoONUサービス) |
| BCAS | Business term | Broadband CA system — a Japanese broadcast conditional access system for encryption and content protection |
| CCAS | Business term | Common Conditional Access System — a standards-based CAS used in Japanese digital broadcasting |
| VoONU | Business term | Voice over Ethernet over Passive Optical Network — VoIP service delivered via fiber-to-the-home ONT equipment |
| `EKK0341A010CBSMsg1List` | Class | Terminal information message list — CBS message class containing terminal equipment fields for STB subscription contract registration |
| `EKKA0020003CBS` | CBS | STB ID lookup service — service component that resolves the STB ID from model code and serial number |
| `STBID` | Field | STB identifier field in the response message of EKKA0020003CBS |
| 工事連携データ | Japanese term | Construction coordination data — shared data map between construction/registration components for SOD order processing |
| 家庭機器異動 | Japanese term | Home device movement/change — the operation type for STB device changes (addition, swap, removal) |
| K-Opticom | Organization | K-Opticom — a Japanese internet and optical TV service provider (now part of KDDI) |
| eo Optical TV | Product | eoヒカリエ — K-Opticom's cable TV/internet subscription service |
| SOD | Acronym | Service Order Data — telecom order fulfillment entity |
| STB | Acronym | Set-Top Box — cable/iptv decoder equipment |
| CBS | Acronym | Component Business Service — service component layer for business logic execution |
| SC Code | Acronym | Service Component Code — standardized code identifying a service component (pattern: `[A-Z]{3}\d{4}[A-Z]\d{3}`) |
| ANK-1191-00-00 | Change ticket | BCAS device swap override — change ticket that added the BCAS "09" (no change) forced installation code for device swaps |
