# Business Logic — KKW00804SFLogic.setInitBean() [36 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.KKW00804SF.KKW00804SFLogic` |
| Layer | Controller (Web Service Logic — `eo.web.webview.*` package houses screen-level business logic classes) |
| Module | `KKW00804SF` (Package: `eo.web.webview.KKW00804SF`) |

## 1. Role

### KKW00804SFLogic.setInitBean()

This method performs **initial value setup for the Home Page Information Registration access screen** (ホームページ情報登録). It is a private initialization helper invoked at the end of the `actionInit()` entry point flow, responsible for populating default values into the form DataBeans that are rendered to the user's browser on screen load. Specifically, it handles three distinct initialization concerns: (1) setting initial capacity-related data structures (homepage capacity information and access analysis lists) with default index values of `"0"`, (2) resolving the homepage access domain — if no domain is pre-populated from business parameters, it falls back to deriving the domain from a URL configuration value, and (3) populating the service end date (利用終了日) year, month, and day fields by extracting the components from the system's operational date obtained via `JCCWebCommon.getOpeDate()`. The method implements a **data bean initialization pattern** common in the X31 framework, where arrays of `X31SDataBeanAccess` objects serve as the bridge between controller logic and view rendering. It plays a supporting role in the larger Home Page Information Registration screen lifecycle — it does not make any database or service component calls beyond reading the operational date, making it a pure presentation-layer initializer.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["setInitBean paramBean"])
    START --> GET_HP_CAPA["Get HP capacity DataBean array from paramBean[0]"]
    GET_HP_CAPA --> GET_HP_SUBBEAN["Get first sub-bean index 0"]
    GET_HP_SUBBEAN --> SET_HP_INIT["Set INDEX_01 to 0 for HP capacity"]
    SET_HP_INIT --> GET_ACCSS["Get access analysis DataBean array"]
    GET_ACCSS --> GET_ACCSS_SUBBEAN["Get first sub-bean index 0"]
    GET_ACCSS_SUBBEAN --> SET_ACCSS_INIT["Set INDEX_01 to 0 for access analysis"]
    SET_ACCSS_INIT --> GET_HPAD_DOMAIN["Get hpad_domain from paramBean[0]"]
    GET_HPAD_DOMAIN --> CHECK_EMPTY{Is hpad_domain empty?}
    CHECK_EMPTY -->|Yes| GET_URL_DOMAIN["Get URL domain from paramBean[0]"]
    GET_URL_DOMAIN --> SET_HPAD_DOMAIN["Set HPAD_DOMAIN to url_domain"]
    GET_URL_DOMAIN --> LOG_DATABEAN["Log DataBean dump via JSYwebLog.println"]
    SET_HPAD_DOMAIN --> LOG_DATABEAN
    CHECK_EMPTY -->|No| LOG_DATABEAN
    LOG_DATABEAN --> GET_OPE_DATE["Call JCCWebCommon.getOpeDate"]
    GET_OPE_DATE --> SET_USE_STAYMD_YEAR["Set USE_STAYMD_YEAR from use_ymd substring 0-4"]
    SET_USE_STAYMD_YEAR --> SET_USE_STAYMD_MON["Set USE_STAYMD_MON from use_ymd substring 4-6"]
    SET_USE_STAYMD_MON --> SET_USE_STAYMD_DAY["Set USE_STAYMD_DAY from use_ymd substring 6-8"]
    SET_USE_STAYMD_DAY --> END_NODE(["Return to caller"])
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `paramBean` | `X31SDataBeanAccess[]` | An array of DataBean access objects representing the screen form's data model. `paramBean[0]` is the primary form bean containing sub-bean arrays for homepage capacity information (`HP_CAPA_INFO`) and access analysis information (`ACCSS_BNSK_INFO`), as well as fields for the homepage access domain (`HPAD_DOMAIN`) and URL domain (`URL_DOMAIN`). This is the standard X31 framework pattern where all screen data flows through a single DataBean array entry point. |
| — | `this` (instance) | `KKW00804SFLogic` | The logic class instance used as the first argument to `JCCWebCommon.getOpeDate()` to retrieve the operational date from session/context. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JCCWebCommon.getOpeDate` | JCCWebCommon | - | Retrieves the system operational date (YYYYMMDD format string) from the X31 operational date context/utilities |
| - | `paramBean[0].getDataBeanArray` | - | - | Accesses a nested DataBean array for homepage capacity info or access analysis info from the primary form bean |
| - | `hp_capa_list.getDataBean` | - | - | Retrieves the first row (index 0) of the homepage capacity sub-bean list |
| - | `bnsk_subbean.sendMessageString` (SET) | - | - | Sets initial default values (index "0", set-value flag) in sub-bean fields |
| - | `paramBean[0].sendMessageString` (GET) | - | - | Reads current field values from the form bean (hpad_domain, url_domain) |
| - | `paramBean[0].sendMessageString` (SET) | - | - | Writes initial/default field values into the form bean |
| - | `dumpDatabean()` | - | - | Dumps the current state of the DataBean for logging/debugging |
| - | `JSYwebLog.println` | - | - | Logs the DataBean dump output using the X31 logging utility |

**Classification rationale:** This method performs **no data creation, update, or deletion operations** on persistent storage. All operations are purely **in-memory DataBean manipulation** and **operational date retrieval**. The method is a presentation-layer initializer — it prepares default values for the screen's view model but does not interact with any database tables or service components that perform CRUD.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Screen:KKW00804SF | `KKW00804SFLogic.actionInit()` -> `setInitBean(paramBean)` | `JCCWebCommon.getOpeDate [R] operational_date_context`, `sendMessageString [SET] form_bean_fields` |

**Call chain detail:** The method is called exclusively from `KKW00804SFLogic.actionInit()` (line 155 of `KKW00804SFLogic.java`). The `actionInit()` method serves as the screen initialization entry point for the Home Page Information Registration screen. The full chain is: screen request → `actionInit()` (performs screen info retrieval, service form bean acquisition, customer contract list setup, and initial service invocation) → `setInitBean(paramBean)` (final initialization of form field defaults) → return `true` to proceed with screen rendering.

Terminal operations from this method reach only the operational date context (via `JCCWebCommon.getOpeDate`) and in-memory DataBean field mutations (`sendMessageString` with `DATABEAN_SET_VALUE` flag). No database entities or service component endpoints are directly accessed.

## 6. Per-Branch Detail Blocks

**Block 1** — [SET] Initialize homepage capacity DataBean (L528-L530)

> Sets up the homepage capacity information DataBean with a default index value. The homepage capacity info is a nested array structure; this block retrieves the array and initializes the first row's index field to "0".

| # | Type | Code |
|---|------|------|
| 1 | SET | `hp_capa_list = paramBean[0].getDataBeanArray(KKW00804SFConst.HP_CAPA_INFO)` // Get homepage capacity info DataBean array [-> HP_CAPA_INFO="ホームページ容量情報"] |
| 2 | SET | `hp_subbean = hp_capa_list.getDataBean(0)` // Get first sub-bean from the capacity list (index 0) |
| 3 | EXEC | `hp_subbean.sendMessageString(KKW00804SFConst.INDEX_01, X31CWebConst.DATABEAN_SET_VALUE, "0")` // Set index field to "0" [-> INDEX_01="添え字"] |

**Block 2** — [SET] Initialize access analysis DataBean (L532-L535)

> Sets up the access analysis information DataBean with a default index value, parallel to the homepage capacity initialization. This prepares the analysis list table shown on the screen.

| # | Type | Code |
|---|------|------|
| 1 | SET | `accss_bnsk_list = paramBean[0].getDataBeanArray(KKW00804SFConst.ACCSS_BNSK_INFO)` // Get access analysis info DataBean array [-> ACCSS_BNSK_INFO="アクセス解析情報"] |
| 2 | SET | `bnsk_subbean = accss_bnsk_list.getDataBean(0)` // Get first sub-bean from the analysis list (index 0) |
| 3 | EXEC | `bnsk_subbean.sendMessageString(KKW00804SFConst.INDEX_01, X31CWebConst.DATABEAN_SET_VALUE, "0")` // Set index field to "0" [-> INDEX_01="添え字"] |

**Block 3** — [IF] Domain resolution — fallback from URL domain (L537-L541)

> Reads the homepage access domain field. If it is empty (not pre-populated from business parameters), the code falls back to reading the URL domain value and assigns it to the homepage access domain field. This implements a parameter-overrides-URL fallback pattern for domain configuration.

| # | Type | Code |
|---|------|------|
| 1 | SET | `hpad_domain = paramBean[0].sendMessageString(KKW00804SFConst.HPAD_DOMAIN, X31CWebConst.DATABEAN_GET_VALUE)` // Get current homepage access domain [-> HPAD_DOMAIN="ホームページアドレスドメイン"] |
| 2 | IF | `"".equals(hpad_domain)` // Branch: is the domain empty? |

**Block 3.1** — [nested IF-TRUE] Domain fallback from URL (L539-L540)

> When the homepage access domain is empty, derive it from the URL domain configuration. This handles cases where the domain is configured at the system/URL level rather than passed in as a business parameter.

| # | Type | Code |
|---|------|------|
| 1 | SET | `url_domain = paramBean[0].sendMessageString(KKW00804SFConst.URL_DOMAIN, X31CWebConst.DATABEAN_GET_VALUE)` // Get URL domain value [-> URL_DOMAIN="URLドメイン"] |
| 2 | SET | `paramBean[0].sendMessageString(KKW00804SFConst.HPAD_DOMAIN, X31CWebConst.DATABEAN_SET_VALUE, url_domain)` // Set homepage access domain to the URL domain value |

**Block 4** — [EXEC] DataBean logging (L543)

> Dumps the current state of all DataBeans to the log for debugging purposes. This is a diagnostic logging step that outputs the full DataBean tree structure.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `JSYwebLog.println(JSYwebLog.DataBean_Dump, getClass(), dumpDatabean(), null, null, null)` // Log full DataBean dump [-> JSYwebLog.DataBean_Dump debug log level] |

**Block 5** — [SET] Set operational date as service end date (L544-L558)

> Adds date initialization support (v3.00.00). Retrieves the current operational date from the system context and splits it into year, month, and day components, setting each into the corresponding use start date fields (利用開始日) on the form bean. Despite the Japanese comment saying "利用終了日" (service end date), the constant name is `USE_STAYMD_*` which translates to "use start date" (利用開始日).

| # | Type | Code |
|---|------|------|
| 1 | SET | `use_ymd = JCCWebCommon.getOpeDate(this, null)` // Get operational date string in YYYYMMDD format [-> JCCWebCommon.getOpeDate] |
| 2 | SET | `paramBean[0].sendMessageString(KKW00804SFConst.USE_STAYMD_YEAR, X31CWebConst.DATABEAN_SET_VALUE, use_ymd.substring(0, 4))` // Extract year from YYYYMMDD [-> USE_STAYMD_YEAR="利用開始日（年）"] |
| 3 | SET | `paramBean[0].sendMessageString(KKW00804SFConst.USE_STAYMD_MON, X31CWebConst.DATABEAN_SET_VALUE, use_ymd.substring(4, 6))` // Extract month from YYYYMMDD [-> USE_STAYMD_MON="利用開始日（月）"] |
| 4 | SET | `paramBean[0].sendMessageString(KKW00804SFConst.USE_STAYMD_DAY, X31CWebConst.DATABEAN_SET_VALUE, use_ymd.substring(6, 8))` // Extract day from YYYYMMDD [-> USE_STAYMD_DAY="利用開始日（日）"] |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `HP_CAPA_INFO` | Field | Homepage capacity information — DataBean array key for the homepage capacity data structure, containing rows for capacity-related display fields |
| `ACCSS_BNSK_INFO` | Field | Access analysis information — DataBean array key for the access analysis data structure, containing rows for web analytics data |
| `HPAD_DOMAIN` | Field | Homepage address domain — the URL/domain of the registered homepage (e.g., "www.example.com") |
| `URL_DOMAIN` | Field | URL domain — the system-level URL domain configured as a fallback when no business parameter provides the homepage domain |
| `INDEX_01` | Field | Index / Row key — used as a sub-bean array row identifier (添え字 = "subscript/index") to reference specific rows in DataBean lists |
| `USE_STAYMD_YEAR` | Field | Service start date (year) — the year component of the service start/end date, extracted from operational date |
| `USE_STAYMD_MON` | Field | Service start date (month) — the month component of the service start/end date |
| `USE_STAYMD_DAY` | Field | Service start date (day) — the day component of the service start/end date |
| `X31SDataBeanAccess` | Class | X31 framework DataBean access object — the standard view-model object used across all X31 screens to pass data between controller logic and JSP views |
| `X31SDataBeanAccessArray` | Class | X31 framework DataBean array — a list/collection wrapper for sub-beans within a DataBean, used for tabular or repeatable data sections |
| `X31CWebConst.DATABEAN_SET_VALUE` | Constant | X31 framework flag indicating a write/set operation on a DataBean field |
| `X31CWebConst.DATABEAN_GET_VALUE` | Constant | X31 framework flag indicating a read/get operation on a DataBean field |
| `JCCWebCommon` | Class | Common web utility class — provides shared functionality for web screens including operational date retrieval, screen info management |
| `getOpeDate` | Method | Retrieves the current system operational date (YYYYMMDD string) from the X31 operational date context; represents the "current date" for business processing |
| `JSYwebLog` | Class | X31 framework web logging utility — used for debug and diagnostic logging on web screens |
| `dumpDatabean` | Method | Dumps the full current state of all DataBeans into a string representation for logging |
| `actionInit` | Method | Screen initialization entry point — the method that orchestrates the complete screen startup flow including contract data loading and form initialization |
| ホームページ情報登録 | Japanese | Home Page Information Registration — the business screen for registering and managing homepage URL/capacity information for customer accounts |
| アクセス解析 | Japanese | Access analysis — web traffic analytics data associated with the registered homepage |
| 利用開始日 | Japanese | Service start date — the date on which the service begins; used here as the default initial value populated from the current operational date |
| 添え字 | Japanese | Index / subscript — used as a row identifier in DataBean list structures |
| X31 framework | Technical | K-Opticom's proprietary web application framework providing the DataBean model, screen lifecycle, logging, and common utility infrastructure |
