# Business Logic — KKW00128SFLogic.mapForDbUpd() [325 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.KKW00128SF.KKW00128SFLogic` |
| Layer | Service Logic (Controller-layer business logic within the web MVC framework) |
| Module | `KKW00128SF` (Package: `eo.web.webview.KKW00128SF`) |

## 1. Role

### KKW00128SFLogic.mapForDbUpd()

The `mapForDbUpd` method is the central dispatching hub for service contract data mapping and database update operations on the eo light service contract update screen (サービス契約更新画面). It receives screen bean data and an input map, then routes to one of **11 distinct mapper-based processing branches** based on the `ido_div` (operation type discriminator). Each branch instantiates a dedicated one-stop DataBean mapper (`KKSV0194` through `KKSV0787`) responsible for coordinating the set of Service Component (SC) calls that map screen data to the database update payload.

The method handles a comprehensive range of telecom service lifecycle operations on K-Opticom's FTTH (Fiber To The Home) network: recovery (restoring a suspended or cancelled service), contract cancellation (解約, full contract termination), cancel (user-initiated withdrawal), suspension receipt (accepting a suspension request), cancel suspension (rescinding a pending suspension), content correction / service information edit (editing service details), cancel reservation (cancelling a scheduled cancellation), course change (changing the subscriber's service plan), suspend (registering a service suspension), suspend change/reservation cancel (modifying suspension or cancelling reservation), and address change with start date adjustment.

It implements the **routing/dispatch design pattern**, where a single entry point delegates to specialized sub-handlers (mappers) based on the operation type. It also uses **delegation** to the `KKSV0194` through `KKSV0204` and `KKSV0787` mappers, each of which internally orchestrates a sequence of SC calls that perform the actual data transformation and database persistence.

A pre-processing guard checks the service flag (`svcFlg`). When the service type is home type (1), the method proceeds normally. When the service type is maintenance type (2) or maintenance type (private) (3), it sets a flag (`iyakFlg`) to true, which affects subsequent mapper calls that conditionally process contract transfer data.

This method serves as the **primary data transformation entry point** for the KKW00128SF screen. It is called by `actionFix` and `actionUpdcfm`, which are the screen's confirmation and update confirmation actions. As a shared dispatch method, it is a critical integration point that bridges the presentation layer (screen beans) with the service persistence layer (SCs via mappers).

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START([mapForDbUpd])
    START --> GET_SVC_FLG[GET svcFlg from paramBean SVC_FLG]
    GET_SVC_FLG --> CHECK_SVC_TYPE{svcFlg == 2 or 3?}
    CHECK_SVC_TYPE -->|Yes| SET_IYAK[iyakFlg = true]
    CHECK_SVC_TYPE -->|No| SET_IYAK2[iyakFlg = true default]
    SET_IYAK --> CHECK_IDO{CHECK ido_div}
    SET_IYAK2 --> CHECK_IDO

    CHECK_IDO -->|00004 Recovery| BR_RECOVERY[BR Recovery KKSV0194]
    CHECK_IDO -->|00005 Cancellation| BR_CANCELLATION[BR Contract Cancellation KKSV0195]
    CHECK_IDO -->|00008 Cancel| BR_CANCEL[BR Cancel KKSV0196]
    CHECK_IDO -->|00010 Suspend Receipt| BR_SUSPEND_RECV[BR Suspend Receipt KKSV0197]
    CHECK_IDO -->|00011 Cancel Suspension| BR_CANCEL_SUSPEND[BR Cancel Suspension KKSV0198]
    CHECK_IDO -->|00032 00033 EditInfo| BR_EDIT_INFO[BR Edit Content Info KKSV0200]
    CHECK_IDO -->|00053 Cancel Reservation| BR_CANCEL_RES[BR Cancel Reservation KKSV0195]
    CHECK_IDO -->|00009 Course Change| BR_COURSE[BR Course Change KKSV0202]
    CHECK_IDO -->|00024 Suspend| BR_SUSPEND[BR Suspend KKSV0203]
    CHECK_IDO -->|00025 Suspend Change| BR_SUSPEND_CHANGE[BR Suspend Change KKSV0204]
    CHECK_IDO -->|00084 Address| BR_ADDRESS[BR Address KKSV0787]
    CHECK_IDO -->|None Match| END([Return void])

    BR_RECOVERY --> RECOVERY_CALLS[28 mapper.setKKSV0194*SC calls]
    RECOVERY_CALLS --> END

    BR_CANCELLATION --> CANCELLATION_CALLS[2 mapper.setKKSV0195*SC calls]
    CANCELLATION_CALLS --> END

    BR_CANCEL --> CANCEL_CALLS[2 mapper.settrgt_data + setKKSV0196*SC calls]
    CANCEL_CALLS --> END

    BR_SUSPEND_RECV --> SUSPEND_RECV_CALLS[6 mapper.setKKSV0197*SC calls]
    SUSPEND_RECV_CALLS --> END

    BR_CANCEL_SUSPEND --> CANCEL_SUSPEND_CALLS[6 mapper.setKKSV0198*SC calls]
    CANCEL_SUSPEND_CALLS --> END

    BR_EDIT_INFO --> EDIT_CHECK_SVC_STAT[GET svc_kei_stat]
    EDIT_CHECK_SVC_STAT --> EDIT_STAT_CHECK{svc_kei_stat == 920?}
    EDIT_STAT_CHECK -->|No| EDIT_NORMAL[Call setKKSV020013SC]
    EDIT_STAT_CHECK -->|Yes| SKIP_13[Skip setKKSV020013SC]
    EDIT_NORMAL --> EDIT_MORE_CALLS[12+ mapper.setKKSV0200*SC CC calls]
    EDIT_MORE_CALLS --> EDIT_PAY_CHECK{Pay method 001 or 003 or 004?}
    EDIT_PAY_CHECK -->|Yes| EDIT_PAY_CALL[Call setKKSV020031SC]
    EDIT_PAY_CHECK -->|No| EDIT_IP_CHECK
    EDIT_PAY_CALL --> EDIT_IP_CHECK{Fixed IP AD8 changed?}
    EDIT_IP_CHECK -->|Yes| EDIT_IP_CALL[Call setKKSV020032CC]
    EDIT_IP_CHECK -->|No| EDIT_DNS_CHECK{DNS changed?}
    EDIT_IP_CALL --> EDIT_DNS_CHECK
    EDIT_DNS_CHECK -->|Yes| EDIT_DNS_CALL[Call setKKSV020035CC]
    EDIT_DNS_CHECK -->|No| EDIT_END
    EDIT_DNS_CALL --> EDIT_END
    SKIP_13 --> EDIT_PAY_CHECK

    BR_COURSE --> COURSE_CALLS[24 mapper.setKKSV0202*SC CC calls]
    COURSE_CALLS --> COURSE_FUNC_CHECK{func_code == FUNC_CD_2?}
    COURSE_FUNC_CHECK -->|Yes| COURSE_CHECK_CALLS[setKKSV020267SC 68SC]
    COURSE_FUNC_CHECK -->|No| COURSE_STAT_CHECK{svc_kei_stat >= 100?}
    COURSE_STAT_CHECK -->|Yes| COURSE_STAT_CALLS[setKKSV020270SC 71SC]
    COURSE_STAT_CHECK -->|No| COURSE_2631_CHECK{func_code == FUNC_CD_2?}
    COURSE_2631_CHECK -->|Yes| COURSE_2631_CALL[setKKSV020278CC FUNC_CD_3]
    COURSE_2631_CHECK -->|No FUNC_CD_1| COURSE_2631_CALL2[setKKSV020278CC func_code]
    COURSE_STAT_CALLS --> COURSE_2631_CHECK
    COURSE_CHECK_CALLS --> COURSE_2631_CHECK
    COURSE_2631_CALL --> COURSE_FINAL[setKKSV020296-99CC calls]
    COURSE_2631_CALL2 --> COURSE_FINAL
    COURSE_FINAL --> END

    BR_SUSPEND --> SUSPEND_CALLS[3 mapper.setKKSV0203*SC CC calls]
    SUSPEND_CALLS --> END

    BR_SUSPEND_CHANGE --> SUSPEND_CHANGE_CALLS[1 mapper.setKKSV020401CC call]
    SUSPEND_CHANGE_CALLS --> END

    BR_ADDRESS --> ADDRESS_CALLS[1 mapper.setKKSV078701CC call]
    ADDRESS_CALLS --> END
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `paramBean` | `X31SDataBeanAccess[]` | Array of DataBeans carrying screen input data — each element holds the user-submitted values for service contract fields (service type, course code, suspension date, address, billing details, DNS settings, fixed IP address, etc.). The first element (`paramBean[0]`) is the primary DataBean used for all `sendMessageString` and `getString` extractions. |
| 2 | `inputMap` | `HashMap<String, Object>` | Uptilt data map carrying request-scoped parameters from the presentation layer, including the `func_code` discriminator, screen attributes, and transient state data passed through the confirmation/update flow. |
| 3 | `func_code` | `String` | Function code identifying the operation mode: **FUNC_CD_1 (1)** = registration/insert mode, **FUNC_CD_2 (2)** = check-only mode (validation without persistence), **FUNC_CD_3 (3)** = course change mode. This code determines which SC calls are invoked and with which function code variant. |

**Instance fields read by this method:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `ido_div` | `String` | Operation type discriminator — classifies the type of service contract modification being performed (recovery, cancellation, cancel, suspend, course change, etc.). Values are resolved from `JKKCommonConst.IDO_DIV_VALUE_*` constants. |
| `iyakFlg` | `boolean` | Contract transfer flag — set to true when svcFlg indicates maintenance type (2 or 3); passed to mappers that conditionally process contract transfer data. |
| `isWaornkiflg` | `boolean` | NTT add-on removal flag — introduced in ANK-4640-00-00; passed to cancellation and course change mappers to control NTT service removal processing. |
| `svc_kei_dataMap` | `HashMap` | Service contract data map — provides access to service detail common fields including settlement service number (`SVCKEICOMMON_ID_SEIKY_KEI_NO`). |
