# Business Logic — WribSvcTrgtKeiMover.transform() [80 LOC]

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

## 1. Role

### WribSvcTrgtKeiMover.transform()

This method performs a **data dispatch and transformation** operation that maps input service-target key information from a `CAANMsg` message object into a structured `HashMap<String, String>` output. It acts as the central **mapper** (in the routing/dispatch design pattern) for the **Wrib (Wiring Reservation) Service Key** data model, enabling downstream consumers to receive uniformly formatted key-type service contract details regardless of whether the underlying service is a discount or reduction type.

The method discriminates between two business service categories based on the `keiKind` (key type) discriminator retrieved from the input message:

- **Discount services** (`keiKind = "1"`): Service key records where a pricing discount is applied. For these, the method applies special start date logic — if the recorded start date is the default "future" sentinel value (`"20991231"`), it resolves the actual start date by adding one day to the end date, ensuring the service period is correctly computed.
- **Reduction services** (`keiKind != "1"`): Service key records where a billing reduction (rather than a discount) applies. These follow the standard date mapping path, except for a special exception for the **Network Phone TV bundle** service code (`"DT0000002"`), where both start and end dates are explicitly cleared to empty strings. This exception exists because network phone TV bundle services do not have meaningful start/end date boundaries (corresponding to LT-2013-0000101 issue resolution).

The method's `kei_kind` output value is set to `"01"` (WRIB — original/discount) or `"02"` (HNSOKU — reduction) via the `KeiKind` enum, which downstream screens and batch processors use to determine which service category the record belongs to. This dispatch is critical for the v5.00.20 refactoring that consolidated discount and promotion data retrieval from multiple service interfaces into a single unified service interface, reducing processing steps and simplifying the data flow.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["transform method entry"])

    START --> INIT["Initialize HashMap out"]

    INIT --> GETKEI["Get keiKind from input message"]

    GETKEI --> COND1{keiKind equals 1?}

    COND1 -->|Yes: Discount| DISC1["Get sYmd and eYmd from input"]

    DISC1 --> CHECKFD{sYmd is future date?}

    CHECKFD -->|No| MAPDISC["Populate out map with discount fields"]

    CHECKFD -->|Yes| CHECKE{eYmd not blank and not future date?}

    CHECKE -->|No| MAPDISC
    CHECKE -->|Yes| ADJSD["sYmd equals eYmd plus one day"]

    ADJSD --> MAPDISC

    MAPDISC2["Set discount fields: kei_kind=01 WRIB, no, stat, type_cd, campaign_cd, staymd adjusted, endymd, wrib_svc_cd, aply_jun_nm"]

    COND1 -->|No: Reduction| REDC1["Populate out map with reduction fields"]

    REDC12["Set reduction fields: kei_kind=02 HNSOKU, no, stat, type_cd, campaign_cd, staymd, endymd, wrib_svc_cd, aply_jun_nm"]

    REDC1 --> REDC12

    REDC12 --> CHECKTB{Service code is DT0000002?}

    CHECKTB -->|No| RET["Return out map"]
    CHECKTB -->|Yes: Network TV bundle| CLEARDT["Clear staymd and endymd"]

    CLEARDT --> RET

    RET --> END(["transform method exit"])
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `in` | `CAANMsg` | An input message object carrying all service-target key data from the upstream service interface. Contains fields such as the key type discriminator (`WRIB_DCHS_HAMBET_CD`), service key no, status, type code, campaign code, service name, application order name, and start/end date fields for discount/reduction service periods. The specific data extracted depends on whether `keiKind` indicates a discount or reduction service. |

**Key extracted fields from `in` (business meaning):**

| Input Field (from `EKK0451B011CBSMsg1List`) | Business Meaning |
|---------------------------------------------|-----------------|
| `WRIB_DCHS_HAMBET_CD` | Key type discriminator — determines whether this is a discount (`"1"`) or reduction service |
| `WRIBSVK_DCHSKMST_NO` | Service key number — unique identifier for the service key record |
| `WRIBSVK_DCHSKMST_STAT` | Service key status — current operational state |
| `WRIBSVK_DCHSKMST_STAT_NM` | Service key status name — human-readable status label |
| `WRIB_DCHS_TYPE_CD` | Service type code — classification of the service (e.g., FTTH, Mail, ENUM) |
| `WRIB_DCHS_TYPE_CD_NM` | Service type code name — human-readable service type label |
| `DSP_CAMPAIGN_DCHSKM_CD` | Campaign code for discount — promotional campaign identifier |
| `WRISVC_DCHSKM_NM` | Service key name — descriptive name of the service |
| `MSKM_YMD` | Subscription date — the date the customer subscribed |
| `SVC_CHRG_DCHSKMST_STAYMD` | Start date — when the chargeable service period begins |
| `SVC_CHRG_DCHSKMST_ENDYMD` | End date — when the chargeable service period ends |
| `WRISVC_DCHSKM_CD` | Service code — specific service identifier (e.g., `"DT0000002"` for network phone TV bundle) |
| `APLY_JUN_NM` | Application order name — the order in which this service was applied relative to other services |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `in.getString` (via `EKK0451B011CBSMsg1List`) | - | CAANMsg message fields | Reads service key data fields from the input message — key type, status, type code, campaign code, dates, service code, and application order name |
| C | `JPCDateUtil.addDay` | - | - | Adds one day to a date string (`eYmd`) to compute the adjusted start date when the recorded start date is the future sentinel value |
| - | `HashMap.put` | - | - | Populates the output map with 12 key-value pairs mapping field names to resolved values |
| - | `JKKWribSvcKeiOperateCC.KeiKind.getKeiKind()` | - | - | Enum accessor that resolves `"01"` (WRIB/discount) or `"02"` (HNSOKU/reduction) based on the service type |
| - | `String.equals` | - | - | String equality checks on `keiKind`, `sYmd`, `eYmd`, and service code to determine control flow |

**No direct database or SC (Service Component) calls** are made within this method. It is a pure **data transformation and mapping** method that reads from a `CAANMsg` object (which was populated by an upstream CBS/SC call) and writes to a `HashMap`. All date computation uses `JPCDateUtil.addDay()`, a utility class for date arithmetic.

## 5. Dependency Trace

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

No screen/batch entry points found within 8 hops. Direct callers found: 7 methods.

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | CBS: `JKKBatKKCashPostBase` | `JKKBatKKCashPostBase.execute()` -> `WribSvcTrgtKeiMover.transform()` | `getString [R] CAANMsg fields` |
| 2 | Utility: `Items` | `Items.map()` -> `WribSvcTrgtKeiMover.transform()` | `getString [R] CAANMsg fields` |
| 3 | CBS: `JECNA0040001TPMA` | `JECNA0040001TPMA.invoke()` -> `WribSvcTrgtKeiMover.transform()` | `getString [R] CAANMsg fields` |
| 4 | CBS: `JECNA0040002TPMA` | `JECNA0040002TPMA.invoke()` -> `WribSvcTrgtKeiMover.transform()` | `getString [R] CAANMsg fields` |
| 5 | CBS: `JECNA0150001TPMA` | `JECNA0150001TPMA.callPost()` -> `WribSvcTrgtKeiMover.transform()` | `getString [R] CAANMsg fields` |
| 6 | CBS: `JECNA0160001TPMA` | `JECNA0160001TPMA.callPost()` -> `WribSvcTrgtKeiMover.transform()` | `getString [R] CAANMsg fields` |
| 7 | CBS: `JKKejbKKA0010002SecProc` | `JKKejbKKA0010002SecProc.searchCredit()` -> `WribSvcTrgtKeiMover.transform()` | `getString [R] CAANMsg fields` |
| 8 | CBS: `JKKejbKKA001SecProc` | `JKKejbKKA001SecProc.shokaiOsrIrai()` -> `WribSvcTrgtKeiMover.transform()` | `getString [R] CAANMsg fields` |
| 9 | CBS: `JKKejbKKA0110001SecProc` | `JKKejbKKA0110001SecProc.execute()` -> `WribSvcTrgtKeiMover.transform()` | `getString [R] CAANMsg fields` |
| 10 | Controller: `JCKCtrlCisInfoImpl` | `JCKCtrlCisInfoImpl.call_CIS()` -> `WribSvcTrgtKeiMover.transform()` | `getString [R] CAANMsg fields` |
| 11 | Controller: `JCKCtrlCisInfoStubImpl` | `JCKCtrlCisInfoStubImpl.call_CIS()` -> `WribSvcTrgtKeiMover.transform()` | `getString [R] CAANMsg fields` |
| 12 | Controller: `JCRCtrlTnInfoImpl` | `JCRCtrlTnInfoImpl.ctrlTnInfo_CRA0001()` -> `WribSvcTrgtKeiMover.transform()` | `getString [R] CAANMsg fields` |
| 13 | Controller: `JKKCtrlMvnoSvcKeiInfoImpl` | `JKKCtrlMvnoSvcKeiInfoImpl.ctrlMvnoInfo_KKA0003()` -> `WribSvcTrgtKeiMover.transform()` | `getString [R] CAANMsg fields` |
| 14 | Controller: `JZMCtrlCisInfoImpl` | `JZMCtrlCisInfoImpl.ctrlCisInfo_ZMA0001()` -> `WribSvcTrgtKeiMover.transform()` | `getString [R] CAANMsg fields` |
| 15 | Controller: `JZMCtrlTrankInfoImpl` | `JZMCtrlTrankInfoImpl.call_TRANK()` -> `WribSvcTrgtKeiMover.transform()` | `getString [R] CAANMsg fields` |
| 16 | Utility: `JFUXPathManager` | `JFUXPathManager.getDomSize()` -> `WribSvcTrgtKeiMover.transform()` | `getString [R] CAANMsg fields` |

## 6. Per-Branch Detail Blocks

**Block 1** — [METHOD BODY] (L17038)

> Initialize the output HashMap and extract the key type discriminator from the input message.

| # | Type | Code |
|---|------|------|
| 1 | INIT | `out = new HashMap<String, String>(DEFAULT_HASH_SIZE)` |
| 2 | SET | `keiKind = in.getString(EKK0451B011CBSMsg1List.WRIB_DCHS_HAMBET_CD)` // [KEY_TYPE_DISCRIMINATOR] Key type code from input — determines discount (1) vs reduction (non-1) branch |

**Block 2** — [IF] `(keiKind equals "1")` `[WRIB_DCHS_HAMBET_CD_DISC="1"]` (L17042)

> **Discount branch** — Handles service keys where a pricing discount applies. Includes special logic to resolve the actual start date when it is set to the default future sentinel value (`"20991231"`).

**Block 2.1** — [IF nested] (`"20991231".equals(sYmd)`) `[DEFAULT_FUTURE_DATE="20991231"]` (L17047)

> When the recorded start date is the default future sentinel, compute the actual start date from the end date plus one day.

| # | Type | Code |
|---|------|------|
| 1 | SET | `sYmd = in.getString(EKK0451B011CBSMsg1List.SVC_CHRG_DCHSKMST_STAYMD)` // Start date from input |
| 2 | SET | `eYmd = in.getString(EKK0451B011CBSMsg1List.SVC_CHRG_DCHSKMST_ENDYMD)` // End date from input |
| 3 | IF | `if ("20991231".equals(sYmd))` `[DEFAULT_FUTURE_DATE="20991231"]` // Default future date sentinel |
| 3.1 | IF-AND | `&& (!JKKStringUtil.isNullBlank(eYmd) && !"20991231".equals(eYmd))` |
| 3.1.1 | SET | `sYmd = JPCDateUtil.addDay(eYmd, 1)` // Resolve actual start date as end date + 1 day |

**Block 2.2** — [FIELD MAPPING] Discount fields (L17051–17064)

> Map all 12 output fields for the discount service key type. The `kei_kind` is set to `"01"` (WRIB — Discount).

| # | Type | Code |
|---|------|------|
| 1 | SET | `out.put("no", in.getString(EKK0451B011CBSMsg1List.WRIBSVK_DCHSKMST_NO))` // Service key number |
| 2 | SET | `out.put("kei_kind", JKKWribSvcKeiOperateCC.KeiKind.WRIB.getKeiKind())` // [-> "01"] WRIB (discount) key type |
| 3 | SET | `out.put("stat", in.getString(EKK0451B011CBSMsg1List.WRIBSVK_DCHSKMST_STAT))` // Service key status |
| 4 | SET | `out.put("stat_nm", in.getString(EKK0451B011CBSMsg1List.WRIBSVK_DCHSKMST_STAT_NM))` // Status name |
| 5 | SET | `out.put("type_cd", in.getString(EKK0451B011CBSMsg1List.WRIB_DCHS_TYPE_CD))` // Service type code |
| 6 | SET | `out.put("type_cd_nm", in.getString(EKK0451B011CBSMsg1List.WRIB_DCHS_TYPE_CD_NM))` // Service type name |
| 7 | SET | `out.put("campaign_cd", in.getString(EKK0451B011CBSMsg1List.DSP_CAMPAIGN_DCHSKM_CD))` // Campaign code |
| 8 | SET | `out.put("campaign_nm", in.getString(EKK0451B011CBSMsg1List.WRISVC_DCHSKM_NM))` // Campaign/service name |
| 9 | SET | `out.put("mskm_ymd", in.getString(EKK0451B011CBSMsg1List.MSKM_YMD))` // Subscription date |
| 10 | SET | `out.put("staymd", sYmd)` // [v5.00.24 MOD] Adjusted start date (computed from end date if future sentinel) |
| 11 | SET | `out.put("endymd", in.getString(EKK0451B011CBSMsg1List.SVC_CHRG_DCHSKMST_ENDYMD))` // End date |
| 12 | SET | `out.put("wrib_svc_cd", in.getString(EKK0451B011CBSMsg1List.WRISVC_DCHSKM_CD))` // Service code |
| 13 | SET | `out.put("aply_jun_nm", in.getString(EKK0451B011CBSMsg1List.APLY_JUN_NM))` // Application order name |

**Block 3** — [ELSE] `keiKind != "1"` (L17065)

> **Reduction branch** — Handles service keys where a billing reduction (rather than discount) applies. Uses `kei_kind = "02"` (HNSOKU). After mapping all standard fields, checks for the special Network Phone TV bundle exception.

**Block 3.1** — [FIELD MAPPING] Reduction fields (L17066–17078)

> Map all 12 output fields for the reduction service key type.

| # | Type | Code |
|---|------|------|
| 1 | SET | `out.put("no", in.getString(EKK0451B011CBSMsg1List.WRIBSVK_DCHSKMST_NO))` // Service key number |
| 2 | SET | `out.put("kei_kind", JKKWribSvcKeiOperateCC.KeiKind.HNSOKU.getKeiKind())` // [-> "02"] HNSOKU (reduction) key type |
| 3 | SET | `out.put("stat", in.getString(EKK0451B011CBSMsg1List.WRIBSVK_DCHSKMST_STAT))` // Service key status |
| 4 | SET | `out.put("stat_nm", in.getString(EKK0451B011CBSMsg1List.WRIBSVK_DCHSKMST_STAT_NM))` // Status name |
| 5 | SET | `out.put("type_cd", in.getString(EKK0451B011CBSMsg1List.WRIB_DCHS_TYPE_CD))` // Service type code |
| 6 | SET | `out.put("type_cd_nm", in.getString(EKK0451B011CBSMsg1List.WRIB_DCHS_TYPE_CD_NM))` // Service type name |
| 7 | SET | `out.put("campaign_cd", in.getString(EKK0451B011CBSMsg1List.DSP_CAMPAIGN_DCHSKM_CD))` // Campaign code |
| 8 | SET | `out.put("campaign_nm", in.getString(EKK0451B011CBSMsg1List.WRISVC_DCHSKM_NM))` // Campaign/service name |
| 9 | SET | `out.put("mskm_ymd", in.getString(EKK0451B011CBSMsg1List.MSKM_YMD))` // Subscription date |
| 10 | SET | `out.put("staymd", in.getString(EKK0451B011CBSMsg1List.SVC_CHRG_DCHSKMST_STAYMD))` // Start date (no adjustment in reduction branch) |
| 11 | SET | `out.put("endymd", in.getString(EKK0451B011CBSMsg1List.SVC_CHRG_DCHSKMST_ENDYMD))` // End date |
| 12 | SET | `out.put("wrib_svc_cd", in.getString(EKK0451B011CBSMsg1List.WRISVC_DCHSKM_CD))` // Service code |
| 13 | SET | `out.put("aply_jun_nm", in.getString(EKK0451B011CBSMsg1List.APLY_JUN_NM))` // Application order name |

**Block 3.2** — [IF] `TgHansoku.equals(in.getString(...))` `[TgHansoku="DT0000002"]` (L17081–17084)

> **Network Phone TV Bundle exception** — For the network phone TV bundle service (`"DT0000002"`), both start and end dates are cleared to empty strings. This is because network phone TV bundle services do not have meaningful start/end date boundaries. This logic corresponds to the resolution of LT-2013-0000101.

| # | Type | Code |
|---|------|------|
| 1 | SET | `TgHansoku = "DT0000002"` // [TgHansoku="DT0000002"] Network phone TV bundle target inspection constant |
| 2 | IF | `if (TgHansoku.equals(in.getString(EKK0451B011CBSMsg1List.WRISVC_DCHSKM_CD)))` // Checks if service code matches network phone TV bundle |
| 2.1 | SET | `out.put("staymd", "")` // [NET_TV_BUNDLE] Clear start date — N/A for this service |
| 2.2 | SET | `out.put("endymd", "")` // [NET_TV_BUNDLE] Clear end date — N/A for this service |

**Block 4** — [RETURN] (L17087)

> Returns the fully populated output HashMap.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return out` // 12-field HashMap mapping Wrib service key fields to string values |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| Wrib | Business term | Wiring Reservation — NTT Western's infrastructure reservation system for service line wiring |
| SvcKei | Field abbreviation | Service Key — the contractual unit representing a subscribed service with associated charges and status |
| Mover | Design pattern | A transformer/mapper component that converts input data from one format to another |
| transform() | Design pattern | Data transformation method that maps input message fields into a structured output HashMap |
| kei_kind | Field | Key type discriminator — distinguishes between discount (`"01"`/WRIB) and reduction (`"02"`/HNSOKU) service types |
| WRIB | Field value | `"01"` — Discount service key type (from `KeiKind.WRIB` enum) |
| HNSOKU | Field value | `"02"` — Reduction service key type (from `KeiKind.HNSOKU` enum) |
| discount | Business term | A pricing reduction applied to a service; higher priority billing adjustment than reduction |
| reduction | Business term | A billing reduction (price adjustment) applied to a service, distinct from discount |
| WRIB_DCHS_HAMBET_CD | Field | Discount/handling type code — the discriminator field in the input message that determines which branch to take |
| WRIBSVK_DCHSKMST_NO | Field | Service key number — unique identifier for a service key record |
| WRIBSVK_DCHSKMST_STAT | Field | Service key status — current operational state code |
| WRIBSVK_DCHSKMST_STAT_NM | Field | Service key status name — human-readable status description |
| WRIB_DCHS_TYPE_CD | Field | Service type code — classification code for the service (e.g., FTTH, Mail, ENUM) |
| WRIB_DCHS_TYPE_CD_NM | Field | Service type code name — human-readable service type description |
| DSP_CAMPAIGN_DCHSKM_CD | Field | Discount campaign code — promotional campaign identifier associated with the service |
| WRISVC_DCHSKM_NM | Field | Service key name — descriptive name of the service |
| mskm_ymd | Field | Subscription date (Moshikomi date) — the date the customer subscribed to the service |
| staymd | Field | Start date (Start YYYYMMDD) — when the chargeable service period begins |
| endymd | Field | End date (End YYYYMMDD) — when the chargeable service period ends |
| wrib_svc_cd | Field | Service code — specific service identifier |
| aply_jun_nm | Field | Application order name — the order in which this service was applied relative to other services |
| DT0000002 | Constant | Network Phone TV Bundle — a bundled service combining internet phone, TV, and internet; excluded from date tracking |
| 20991231 | Constant | Default future date sentinel — a placeholder value used when no actual start date is set; the method resolves this by computing from the end date |
| JPCDateUtil.addDay() | Utility | Date arithmetic utility — adds a specified number of days to a date string in YYYYMMDD format |
| CAANMsg | Type | Common Application Abstraction Network Message — the standardized message container used across the system for passing structured data between components |
| v5.00.20 MOD | Change note | Code modification for consolidating discount/promotion information into a single service interface, removing redundant processing |
| LT-2013-0000101 | JIRA/Issue | Internal issue ticket for the network phone TV bundle date handling exception |
| DEFAULT_HASH_SIZE | Constant | Default initial capacity for the output HashMap |
