# Eo / Web / Webview / Kkw00191sf

## Overview

The **KKW00191SF** module is the web-layer component for the **Review Cancellation** feature (照査取消部品) within the contract management system. Its purpose is to allow operators to cancel or withdraw a service contract that has previously passed (or failed) a review check. When a user accesses this screen, the module retrieves the inherited screen data (system ID, service contract number, locations, customer name, and contract party address), displays the review details on the form, and then dispatches the appropriate backend service — a normal review cancellation (`KKSV0408`) if the review passed, or a review-NG cancellation (`KKSV0742`) if the review had flagged an issue. The module is built on top of the Fujitsu Futurity X31/X33 web framework and follows a standard three-layer pattern: form bean, logic class, and checker stub.

## Architecture at a Glance

```mermaid
flowchart TD
    A["KKW00191SFLogic
Business Logic"] -->|"actionInit"| B["KKW00191SFBean
Main Form Bean"]
    A -->|"initServiceFormBean"| C["KKW00191SF04DBean
Inherited Data
KKW00191SF01DBean
Service Contract
KKW00191SF02DBean
Application
KKW00191SF03DBean
Common Info"]
    A -->|"invokeService"| D["KKSV0408_DBMapper
Service Layer"]
    A -->|"editServiceFormBean"| E["KKW00191SF01DBean
Service Contract Details"]
    A -->|"editServiceFormBean"| F["KKW00191SF02DBean
Application Details"]
    A -->|"editServiceFormBean"| G["KKW00191SF03DBean
Common Info"]
    A -->|"shosaNgCl"| H["KKSV0742
ShosaNG Service"]
    B -->|"svc_kei_list_list"| E
    B -->|"mskm_dtl_list_list"| F
    B -->|"svc_kei_com_list_list"| G
    B -->|"cust_kei_hktgi_list_list"| C
    I["KKW00191SFChecker
Validation (stub)"] -->|"checkMethod"| B
    J["KKW00191SFConst
Constants"] -->|"field keys"| A
    J -->|"field keys"| B
    J -->|"field keys"| E
    J -->|"field keys"| F
    J -->|"field keys"| G
    J -->|"field keys"| C
```

## Key Classes

### KKW00191SFLogic — Primary Business Logic

**File:** [`KKW00191SFLogic.java`](source/koptWebB/src/eo/web/webview/KKW00191SF/KKW00191SFLogic.java)

This is the central orchestrator for the review cancellation screen. It extends `JCCWebBusinessLogic` and implements the following entry-point methods:

#### `actionInit()` — Screen Initialization

This is the main entry method invoked when the user first opens the screen. The flow is:

1. **Acquires the common-info bean** via `super.getCommonInfoBean()` to access shared screen state.
2. **Calls `initServiceFormBean()`** to populate the form bean with inherited data (system ID, service contract number, cancellation location address, customer details, etc.) pulled from a `CUST_KEI_HKTGI_LIST` list element in the service form bean.
3. **Branches based on `shosa_dsl_fin_cd`** (照査解除完了コード / review cancellation completion code):
   - If the value equals `CD00469_1` (review OK), it invokes the standard review cancellation service `invokeService()` using use case `UCID_KKSV0408` / operation `OPID_KKSV0408OP`.
   - If the value equals `CD00469_2` (review NG), it calls the private `shosaNgCl()` method to invoke the NG cancellation service `KKSV0742` instead.
4. **Calls `executeAxMRnkSjisho()`** (via `JKKSvkeiUpdScreenUtil`) to handle additional inheritance logic (version 5.00.00 change).
5. **Displays the confirmation message** `EKB4390__I` ("Review cancellation of service contract") via `JCCWebCommon.setMessageInfo()`.

#### `invokeService()` — Normal Review Cancellation (KKSV0408)

When the review passed (code `CD00469_1`), this method:

- Sets the `RSV_APLY_YMD` field to the current operator date via `JCCWebCommon.getOpeDate()`.
- Creates a `KKSV0408_KKSV0408OPDBMapper` to map form fields to the service-layer input map.
- Configures the mapper with:
  - `setKKSV040802SC` / `setKKSV040803SC` / `setKKSV040805SC` — core service contract fields.
  - `setJKKSvkeiShosaClCC` — review check context, pulling organization code and name from the common-info bean (added in OM-2013-0002656).
  - `setJKKButuryuCtrlCC`, `setJKKHakkoSODCC`, `setJKKTchishoAddCC` — supplementary control and registration mappers.
- Invokes the service via `invokeService(paramMap, inputMap, outputMap)`.
- Maps results back via `getKKSV040803SC`, `getKKSV040804SC`, `getKKSV040805SC`.
- Calls `editServiceFormBean()` to transform backend results into displayable format.

#### `shosaNgCl()` — Review-NG Cancellation (KKSV0742)

A private method called when the review failed. It:

- Sets use case `UCID_KKSV0742` / operation `OPID_KKSV0742OP`.
- Builds an input map containing the target cancellation list element with the `svc_kei_no` (service contract number).
- Invokes the `KKSV0742` service via `invokeService()`.

#### `initServiceFormBean()` — Data Population

Populates the form bean with inherited screen data. It:

- Fetches screen info via `JCCWebCommon.getScreenInfo()`.
- Reads the `CUST_KEI_HKTGI_LIST` list element (index 0) and copies out:
  - System ID, service contract number, cancellation location address parts (state, city, district, block, lot number).
  - Customer name, customer kana, contract party address parts.
- Concatenates the cancellation location address parts into `KAISEN_ADDR` and the contract party address parts into `KEISHA_ADDR`.
- Copies the review cancellation completion code (`SHOSA_DSL_FIN_CD_04`) into the main bean.

#### `editServiceFormBean()` — Result Transformation

Transforms service-layer output into display-ready format:

- Extracts `MSKM_DTL_LIST` (application details list) and reformats the application date (`MSKM_YMD_02`) from YYYYMMDD to YYYY/MM/DD format.
- Copies application number (`MSKMSHO_NO`), review date, service code name, and price plan code name into the main form bean.
- Extracts `SVC_KEI_COM_LIST` (service contract common info list) and copies mansion ID and mansion name.

#### `actionComp()` — Complete Button Handler

Sets the next screen ID and name to `KKW01101` (service contract agreement list screen) in the common-info bean. The original implementation redirected to KKW00191, but this was removed in IT2-2012-0001905 because KKW01101 was already the correct destination.

### KKW00191SFBean — Main Form Bean

**File:** [`KKW00191SFBean.java`](source/koptWebB/src/eo/web/webview/KKW00191SF/KKW00191SFBean.java)

The main form bean that holds all display fields for the review cancellation screen. It extends `X33VViewBaseBean` and implements `X33VListedBeanInterface` and `X31CBaseBean`.

**Key design role:** It acts as the data bridge between the JSP view layer and the `KKW00191SFLogic` business logic. Every displayable field on the screen is represented here as three parallel properties: `xxx_update` (update flag), `xxx_value` (current value), and `xxx_state` (state/status).

**List-type fields (X33VDataTypeList):**

| Field | Content | DBean Class |
|---|---|---|
| `svc_kei_list_list` | Service contract agreement details | `KKW00191SF01DBean` |
| `mskm_dtl_list_list` | Application details agreement info | `KKW00191SF02DBean` |
| `svc_kei_com_list_list` | Service contract common info list | `KKW00191SF03DBean` |
| `cust_kei_hktgi_list_list` | Customer contract inheritance list | `KKW00191SF04DBean` |

The constructor initializes each list with exactly one element of the corresponding DBean type, ensuring the screen has a single row to display.

**Select-item generators:** Each list type has a corresponding `getJsflist_typelist_xxx()` method that iterates over the list and builds an `ArrayList<SelectItem>` for JSF dropdown rendering. The display value comes from the `loadModelData()` call on each row's DBean.

**Key scalar fields** (not exhaustive — the bean has 50+ getter/setter pairs):

- **Identifiers:** `sysid`, `svc_kei_no`
- **Cancellation location address:** `kaisen_place_state_nm`, `kaisen_place_city_nm`, `kaisen_place_oaztsu_nm`, `kaisen_place_azcho_nm`, `kaisen_place_bnchigo`, and the concatenated `kaisen_addr`
- **Customer info:** `cust_nm`, `cust_kana`
- **Contract party address:** `keisha_state_nm`, `keisha_city_nm`, `keisha_oaztsu_nm`, `keisha_azcho_nm`, `keisha_bnchigo`, `keisha_telno`, and the concatenated `keisha_addr`
- **Application data:** `mskmsho_no`, `mskm_ymd`, `mskm_dtl_no`
- **Review data:** `shosa_ymd`, `svc_cd`, `svc_cd_nm`, `pplan_cd`, `pplan_cd_nm`
- **Common info:** `mansion_id`, `mansion_nm`, `gene_add_dtm`, `rsv_aply_ymd`
- **Review cancellation completion code:** `shosa_dsl_fin_cd` (added in IT1-2013-0000148)

### KKW00191SF01DBean — Service Contract Details Data Bean

**File:** [`KKW00191SF01DBean.java`](source/koptWebB/src/eo/web/webview/KKW00191SF/KKW00191SF01DBean.java)

Holds the fields for the "Service Contract Agreement Details" section (サービス契約照会明细). These are fields related to the service contract itself:

| Field (Japanese) | Purpose |
|---|---|
| `shosa_ymd` | Review date (照査年月日) |
| `svc_kei_no` | Service contract number (サービス契約番号) |
| `svc_cd` | Service code (サービスコード) |
| `svc_cd_nm` | Service code name (サービスコード名称) |
| `pplan_cd` | Price plan code (料金プランコード) |
| `pplan_cd_nm` | Price plan code name (料金プランコード名称) |
| `mskm_dtl_no` | Application detail number (申請明細番号) |

Each field has the standard `update`/`value`/`state` triple. The bean implements `X33VDataTypeBeanInterface`, providing `loadModelData()`, `storeModelData()`, `listKoumokuIds()`, and `typeModelData()` for framework-driven data binding.

### KKW00191SF02DBean — Application Details Data Bean

**File:** [`KKW00191SF02DBean.java`](source/koptWebB/src/eo/web/webview/KKW00191SF/KKW00191SF02DBean.java)

Holds the fields for the "Application Agreement Details" section (申請照会明细照会明细):

| Field (Japanese) | Purpose |
|---|---|
| `mskmsho_no` | Application number (申請書番号) |
| `mskm_ymd` | Application date (申請年月日) |

This is the smallest DBean in the module with just two data fields, each with update/value/state triples.

### KKW00191SF03DBean — Common Info Data Bean

**File:** [`KKW00191SF03DBean.java`](source/koptWebB/src/eo/web/webview/KKW00191SF/KKW00191SF03DBean.java)

Holds the fields for the "Service Contract Common Info List" section (サービス契約共通情報照会明細):

| Field (Japanese) | Purpose |
|---|---|
| `mansion_id` | Mansion ID (マンションID) |
| `mansion_nm` | Mansion name (マンション名) |

Like `KKW00191SF02DBean`, this is a minimal bean with just two fields.

### KKW00191SF04DBean — Inherited Data Data Bean

**File:** [`KKW00191SF04DBean.java`](source/koptWebB/src/eo/web/webview/KKW00191SF/KKW00191SF04DBean.java)

This is the largest DBean in the module, holding all fields that are inherited from a previous screen and need to be passed through to the service cancellation logic. It contains:

- **System and contract identifiers:** `sysid`, `svc_kei_no`
- **Cancellation location address:** `kaisen_place_state_nm`, `kaisen_place_city_nm`, `kaisen_place_oaztsu_nm`, `kaisen_place_azcho_nm`, `kaisen_place_bnchigo`
- **Customer info:** `cust_nm`, `cust_kana`
- **Contract party address:** `keisha_state_nm`, `keisha_city_nm`, `keisha_oaztsu_nm`, `keisha_azcho_nm`, `keisha_bnchigo`, `keisha_telno`
- **Review cancellation completion code:** `shosa_dsl_fin_cd` (added in IT1-2013-0000148)

The `loadModelData()` method in this bean maps Japanese field names to the corresponding getter/setter pairs, supporting both "value" and "state" subkeys.

### KKW00191SFChecker — Validation Stub

**File:** [`KKW00191SFChecker.java`](source/koptWebB/src/eo/web/webview/KKW00191SF/KKW00191SFChecker.java)

Implements `X31SGuiCheckBase`. The constructor receives a reference to the `KKW00191SFLogic` business logic class. The `checkMethod()` implementation is a no-op — it always returns `true` — indicating that no GUI-level validation is currently performed at this screen. This is likely a placeholder for future validation requirements.

### KKW00191SFConst — Constants

**File:** [`KKW00191SFConst.java`](source/koptWebB/src/eo/web/webview/KKW00191SF/KKW00191SFConst.java)

A utility class holding `public static final String` constants used across the module. Each constant serves as the key for accessing a specific field in the data beans via the `sendMessageString()` / `loadModelData()` API. The constants define the Japanese display labels for all screen fields:

- **Identifiers:** `SYSID` (システムID), `SVC_KEI_NO` (サービス契約番号)
- **Cancellation location:** `KAISEN_PLACE_STATE_NM`, `KAISEN_PLACE_CITY_NM`, `KAISEN_PLACE_OAZTSU_NM`, `KAISEN_PLACE_AZCHO_NM`, `KAISEN_PLACE_BNCHIGO`
- **Customer:** `CUST_NM`, `CUST_KANA`
- **Contract party:** `KEISHA_STATE_NM`, `KEISHA_CITY_NM`, `KEISHA_OAZTSU_NM`, `KEISHA_AZCHO_NM`, `KEISHA_BNCHIGO`, `KEISHA_TELNO`
- **Application:** `MSKMSHO_NO`, `MSKM_DTL_NO`, `MSKM_YMD`
- **Review info:** `SHOSA_YMD`, `SVC_CD`, `SVC_CD_NM`, `PPLAN_CD`, `PPLAN_CD_NM`
- **List keys:** `SVC_KEI_LIST` (サービス契約照会明細), `MSKM_DTL_LIST` (申請明細照会明細), `SVC_KEI_COM_LIST` (サービス契約共通情報一覧照会明細)
- **Derived fields:** `KAISEN_ADDR` (回線場所住所), `KEISHA_ADDR` (契約者住所)
- **Common info:** `MANSION_ID`, `MANSION_NM`, `GENE_ADD_DTM`, `RSV_APLY_YMD`
- **Other:** `CUST_KEI_HKTGI_LIST`, `SHOSA_YMD_01`

The class has a private constructor, making it a pure constant holder.

## How It Works — End-to-End Flow

```mermaid
sequenceDiagram
    participant User
    participant Logic as KKW00191SFLogic
    participant Bean as KKW00191SFBean
    participant Common as CommonInfoCF
    participant SVC as Service (KKSV0408/KKSV0742)

    User->>Logic: actionInit()
    Logic->>Bean: getCommonInfoBean()
    Logic->>Bean: initServiceFormBean()
    Bean-->>Logic: inherits data from CUST_KEI_HKTGI_LIST
    Logic->>Bean: get shosa_dsl_fin_cd
    alt review passed (CD00469_1)
        Logic->>Logic: invokeService()
        Logic->>SVC: KKSV0408 (review cancellation)
        SVC-->>Logic: output map
        Logic->>Bean: editServiceFormBean()
    else review NG (CD00469_2)
        Logic->>Logic: shosaNgCl()
        Logic->>SVC: KKSV0742 (NG cancellation)
        SVC-->>Logic: output map
    end
    Logic->>Common: set nextScreenId = KKW01101
    Logic-->>User: true (display success message)

    User->>Logic: actionComp()
    Logic->>Common: set next screen = KKW01101
    Logic-->>User: true
```

1. **Screen load (`actionInit`):** The user navigates to the review cancellation screen. The logic class initializes the form by pulling inherited screen data from the `CUST_KEI_HKTGI_LIST` list element. This data includes the system ID, service contract number, cancellation location, customer details, and the review cancellation completion code.

2. **Branch on review result:** The `shosa_dsl_fin_cd` field determines the cancellation path:
   - **Review OK (`CD00469_1`):** Calls `invokeService()` which maps all form fields to a `KKSV0408_KKSV0408OPDBMapper` and invokes the `KKSV0408` service. This is the standard review cancellation flow.
   - **Review NG (`CD00469_2`):** Calls `shosaNgCl()` which builds a minimal input map with just the service contract number and invokes the `KKSV0742` service for NG-specific cancellation.

3. **Post-processing:** Results are mapped back to the form bean via `editServiceFormBean()`, which reformats dates (YYYYMMDD -> YYYY/MM/DD) and transfers display-ready values from nested list beans to the main bean.

4. **Completion (`actionComp`):** When the user presses the complete button, the logic sets the next screen ID to `KKW01101` (the service contract agreement list screen) and redirects the user there.

## Data Model

The module uses a hierarchical bean structure. The main `KKW00191SFBean` contains both scalar fields and four `X33VDataTypeList` fields, each holding zero or more instances of a specific DBean:

```
KKW00191SFBean (main form)
├── scalar fields (sysid, svc_kei_no, shosa_ymd, etc.)
├── svc_kei_list_list [X33VDataTypeList]
│   └── [0] KKW00191SF01DBean (service contract agreement details)
├── mskm_dtl_list_list [X33VDataTypeList]
│   └── [0] KKW00191SF02DBean (application details)
├── svc_kei_com_list_list [X33VDataTypeList]
│   └── [0] KKW00191SF03DBean (common info: mansion)
└── cust_kei_hktgi_list_list [X33VDataTypeList]
    └── [0] KKW00191SF04DBean (inherited data: full context)
```

Each list is initialized with exactly one element in the bean constructor, reflecting the fact that the screen displays a single contract's details at a time. The DBeans implement `X33VDataTypeBeanInterface`, enabling the X33 framework to perform reflection-free data access via `loadModelData(key, subkey)` and `storeModelData(key, subkey, value)`.

## Dependencies and Integration

### Outbound Dependencies

The module depends on the following packages and classes:

| Dependency | Purpose |
|---|---|
| `eo.web.webview.KKA17201SF` | Referenced (likely for shared screen infrastructure) |
| `eo.web.webview.KKW00127SF` | Referenced |
| `eo.web.webview.KKA17101SF`, `KKA17401SF` | Screen infrastructure |
| `eo.web.webview.commonOneStop` | One-stop screen utilities |
| `eo.web.webview.common` | Common utilities (`JCCWebCommon`, `JKKCommonConst`, `JKKScreenConst`) |
| `eo.web.webview.CommonInfoCF` | Common info bean constants (`CommonInfoCFConst`) |
| `eo.web.webview.FUW00162SF`, `FUW09905SF` | External screen modules |
| `eo.web.webview.mapping.KKSV0408_KKSV0408OPDBMapper` | Service mapping for KKSV0408 |
| `eo.common.constant` | String constants, model constants, online message constants |
| `eo.common.util` | Common utilities |
| `eo.ejb.common`, `eo.ejb.common.edit` | EJB-layer dependencies |
| `com.fujitsu.futurity.bp.custom.common` | Futurity BP custom extensions |

### Inbound Dependencies (XML Configs)

| Config File | References |
|---|---|
| `WEBGAMEN_KKW001910PJP.xml` | `KKW00191SFBean`, `KKW00191SFLogic` |
| `x31business_logic_KKW00191SF.xml` | `KKW00191SFLogic` |

### Service Integration

The module integrates with two backend services via the service invocation framework:

1. **KKSV0408** (`UCID_KKSV0408` / `OPID_KKSV0408OP`) — Standard review cancellation service. Handles the full mapping of service contract, application, and common info data.
2. **KKSV0742** (`UCID_KKSV0742` / `OPID_KKSV0742OP`) — Review-NG cancellation service. Handles cases where the review check failed and the user needs to cancel the failed review state.

## Notes for Developers

- **Review completion code is the primary branching factor.** The `shosa_dsl_fin_cd` field determines whether `KKSV0408` or `KKSV0742` is invoked. This was introduced in IT1-2013-0000148 (2013-02-09). Check for `CD00469_1` (OK) or `CD00469_2` (NG).
- **Address concatenation is done server-side.** The `initServiceFormBean()` method manually concatenates state/city/district/block/lot fields into `kaisen_addr` and `keisha_addr` string buffers. These concatenated values are display-only; the individual address parts remain the authoritative source.
- **The checker is a no-op.** `KKW00191SFChecker.checkMethod()` returns `true` unconditionally. Any client-side validation logic is handled at the JSP layer or in the framework.
- **All data beans use Japanese strings as field keys.** The `loadModelData()` and `storeModelData()` methods in each DBean match against Japanese literals (e.g., "照査年月日", "サービス契約番号"). This is consistent with the X31/X33 framework convention where the Japanese label serves as the primary key for data access.
- **Date format conversion.** The `editServiceFormBean()` method converts dates from the YYYYMMDD format (YYYYMMDD_02 suffixed variants) from the service layer into the display format YYYY/MM/DD. The original data comes from `KKW00191SFConst.MSKM_YMD_02` and `KKW00191SFConst.SHOSA_YMD_01`.
- **Common info organization context.** Since version 8.00.00 (OM-2013-0002656, 2014-03-27), the review cancellation mapping includes the current user's organization code and name from the common-info bean. This replaced the original `setJKKSvkeiShosaClCC(paramBean, inputMap, JPCModelConstant.FUNC_CD_1)` call that did not pass organization details.
- **List beans always have exactly one element.** The constructor initializes each `X33VDataTypeList` with a single DBean instance. If multi-row display is ever needed, this initialization pattern will need to change.
