# Business Logic — Mover.getBeanMapFromDataBean() [63 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.KKW01021SF.Mover.getBeanMapFromDataBean` |
| Layer | CC/Common Component (intra-class static utility within `KKW01021SFLogic`) |
| Module | `KKW01021SF` (Package: `eo.web.webview.KKW01021SF`) |

## 1. Role

### Mover.getBeanMapFromDataBean()

This method acts as a **data-structure converter** that transforms data held in an `X31SDataBeanAccess` object into a `BeanMap` (a `HashMap<String, Object>` with fluent `pair` insertion). It serves as a core deserialization utility within the KKW01021SF screen logic, bridging the gap between the framework's data bean abstraction and the plain map-based representation consumed by downstream processing (view rendering, API responses, or further business logic).

The method implements a **dispatch/router pattern** driven by a type-resolution mechanism. It receives a `structure` parameter — an array of key-value pairs where each pair declares a field name and its expected type — and iterates over this structure to determine how to extract and convert each field from the source data bean. For simple scalar types (String, Long, Boolean) it performs direct extraction; for array types (String[], Long[], Boolean[]) it extracts the full array; and for the special `DATABEAN` type, it recursively invokes `getBeanMapListFromDataBeanArray` to produce a nested `ArrayList<BeanMap>`.

The method is a **shared utility** (static method within the `Mover` inner class) called from a wide variety of callers across the codebase — including screen mappers (KKSV0231 through KKSV0240, KKSV0781) and the KKW01021SF logic action handlers (actionAdd, actionBulkDelete, actionCash, actionDelete, actionDetail, actionHistory, actionInitKKW01021, actionInitKKW01022, actionIntr, actionUpdate, editWribCampaignList). Its role is to flatten a structured data bean into a navigable map, enabling screen code to access data by simple key lookups rather than through the data bean API.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["getBeanMapFromDataBean(bean, structure)"])
    INIT["result = new BeanMap()"]
    LOOP_START["for (Object node : structure)"]
    CAST_NODE["Object[] pair = (Object[])node"]
    CAST_ITEM["String item = (String)pair[0]"]
    CAST_VALUE["Object value = pair[1]"]
    RESOLVE["StructureType type = StructureType.resolve(value)"]
    SWITCH["switch (type)"]
    CASE_DATABEAN["case DATABEAN: Object[].class"]
    CASE_STRING["case STRING: String.class"]
    CASE_LONG["case LONG: Long.class"]
    CASE_BOOLEAN["case BOOLEAN: Boolean.class"]
    CASE_STRINGS["case STRINGS: String[].class"]
    CASE_LONGS["case LONGS: Long[].class"]
    CASE_BOOLEANS["case BOOLEANS: Boolean[].class"]
    CALL_BEAN_ARRAY["Mover.getBeanArray(bean, item)"]
    CALL_GET_LIST["getBeanMapListFromDataBeanArray(beanArray, value)"]
    CALL_PAIR_BEAN["result.pair(item, content)"]
    CALL_GET_STRING["Mover.getString(bean, item)"]
    CALL_GET_LONG["Mover.getLong(bean, item)"]
    CALL_GET_BOOLEAN["Mover.getBoolean(bean, item)"]
    CALL_GET_STRING_ARRAY["Mover.getStringArray(bean, item)"]
    CALL_GET_LONG_ARRAY["Mover.getLongArray(bean, item)"]
    CALL_GET_BOOLEAN_ARRAY["Mover.getBooleanArray(bean, item)"]
    DEFAULT["default: break"]
    END_LOOP["end for"]
    RETURN["return result"]

    START --> INIT
    INIT --> LOOP_START
    LOOP_START --> CAST_NODE
    CAST_NODE --> CAST_ITEM
    CAST_ITEM --> CAST_VALUE
    CAST_VALUE --> RESOLVE
    RESOLVE --> SWITCH

    SWITCH --> CASE_DATABEAN
    SWITCH --> CASE_STRING
    SWITCH --> CASE_LONG
    SWITCH --> CASE_BOOLEAN
    SWITCH --> CASE_STRINGS
    SWITCH --> CASE_LONGS
    SWITCH --> CASE_BOOLEANS
    SWITCH --> DEFAULT

    CASE_DATABEAN --> CALL_BEAN_ARRAY
    CALL_BEAN_ARRAY --> CALL_GET_LIST
    CALL_GET_LIST --> CALL_PAIR_BEAN

    CASE_STRING --> CALL_GET_STRING
    CASE_LONG --> CALL_GET_LONG
    CASE_BOOLEAN --> CALL_GET_BOOLEAN
    CASE_STRINGS --> CALL_GET_STRING_ARRAY
    CASE_LONGS --> CALL_GET_LONG_ARRAY
    CASE_BOOLEANS --> CALL_GET_BOOLEAN_ARRAY

    CALL_PAIR_BEAN --> END_LOOP
    CALL_GET_STRING --> END_LOOP
    CALL_GET_LONG --> END_LOOP
    CALL_GET_BOOLEAN --> END_LOOP
    CALL_GET_STRING_ARRAY --> END_LOOP
    CALL_GET_LONG_ARRAY --> END_LOOP
    CALL_GET_BOOLEAN_ARRAY --> END_LOOP
    DEFAULT --> END_LOOP

    END_LOOP --> RETURN
```

**Processing description:**

The method performs a **type-driven dispatch** over a schema-like `structure` array. Each entry in `structure` is a two-element pair: `[fieldKey, fieldType]` where `fieldKey` is a String identifier and `fieldType` is either a Class object (e.g., `String.class`) or an actual instance whose runtime class determines the type. The `StructureType.resolve(value)` method walks through the enum values `NULL → DATABEAN → STRING → LONG → BOOLEAN → STRINGS → LONGS → BOOLEANS` and returns the first matching type.

- **DATABEAN**: The value is an `Object[]` representing a nested data bean array. The method extracts the array from the data bean via `Mover.getBeanArray()`, then recursively converts each element into a `BeanMap` via `getBeanMapListFromDataBeanArray()`, and stores the resulting list under the field key.
- **STRING**: Extracts a single `String` value from the data bean via `Mover.getString()`.
- **LONG**: Extracts a single `Long` value via `Mover.getLong()`.
- **BOOLEAN**: Extracts a single `Boolean` value via `Mover.getBoolean()`.
- **STRINGS**: Extracts a `String[]` array via `Mover.getStringArray()`.
- **LONGS**: Extracts a `Long[]` array via `Mover.getLongArray()`.
- **BOOLEANS**: Extracts a `Boolean[]` array via `Mover.getBooleanArray()`.
- **NULL/DEFAULT**: No extraction occurs; the field is silently skipped.

All extracted values are stored into the result `BeanMap` using the fluent `pair(key, value)` method (which internally calls `super.put(key, value)` and returns `this` for chaining).

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `bean` | `X31SDataBeanAccess` | The source data bean holding structured screen data. This is the framework's data access object that encapsulates form/input data for a web screen. It carries typed fields (String, Long, Boolean, arrays, nested data beans) that represent business entities in the KKW01021SF screen context (campaign management, wriggle campaign list editing, etc.). |
| 2 | `structure` | `Object[]` | A schema definition array that describes which fields to extract and how to interpret them. Each element is an `Object[]` pair: `[fieldKey (String), fieldType (Object)]`. The field key is the data bean field name, and the field type dictates the dispatch path (e.g., `String.class` → scalar string extraction, `Object[].class` → nested bean array). This is the "contract" that maps data bean fields to the output map keys. |

**Additional notes on parameters:**

- The `structure` parameter is typically constructed by the caller to define a **view model** — the exact set of fields and types the caller needs from the data bean. Different callers (action handlers, screen mappers) supply different structures depending on what data they need for their specific operation.
- For the `DATABEAN` case, the value in the pair is an `Object[]` representing a **nested structure definition** — it is passed through to `getBeanMapListFromDataBeanArray()` to define the schema for each element in the nested bean array.

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `BeanMap.pair` | BeanMap | - | Puts a key-value entry into the result `BeanMap` (inherited from `HashMap`). This is the fundamental write operation, invoked once per iteration. |
| R | `Mover.getBeanArray` | Mover | - | Retrieves a `X31SDataBeanAccessArray` from the data bean by field name. Used in the DATABEAN dispatch path. |
| R | `Mover.getBeanMapListFromDataBeanArray` | Mover | - | Recursively converts an array of data beans into an `ArrayList<BeanMap>`. Used for nested DATABEAN fields. |
| R | `Mover.getBoolean` | Mover | - | Reads a single Boolean value from the data bean by field name. Used in the BOOLEAN dispatch path. |
| R | `Mover.getBooleanArray` | Mover | - | Reads a `Boolean[]` array from the data bean by field name. Used in the BOOLEANS dispatch path. |
| R | `Mover.getLong` | Mover | - | Reads a single Long value from the data bean by field name. Used in the LONG dispatch path. |
| R | `Mover.getLongArray` | Mover | - | Reads a `Long[]` array from the data bean by field name. Used in the LONGS dispatch path. |
| R | `Mover.getString` | Mover | - | Reads a single String value from the data bean by field name. Used in the STRING dispatch path. |
| R | `Mover.getStringArray` | Mover | - | Reads a `String[]` array from the data bean by field name. Used in the STRINGS dispatch path. |

**Classification rationale:**

All methods called by `getBeanMapFromDataBean` are **Read (R)** operations — they extract data from the `X31SDataBeanAccess` object. There are no Create, Update, or Delete operations in this method. The `BeanMap.pair` call is a local `put` operation that mutates the in-memory result map; it does not touch any database or persistent store. No SC (Service Component) or CBS (Common Business Service) methods are invoked, and no Entity/DB table access occurs. This method is a pure **data transformation** utility — it reads from the data bean, dispatches by type, and writes into an in-memory map.

## 5. Dependency Trace

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

No screen/batch entry points found within 8 hops. Direct callers found: 21 methods.
Terminal operations from this method: `pair` [-], `pair` [-], `pair` [-], `pair` [-], `pair` [-], `getBooleanArray` [R], `pair` [-], `pair` [-], `pair` [-], `pair` [-], `pair` [-], `getLongArray` [R], `pair` [-], `pair` [-], `pair` [-], `pair` [-], `pair` [-], `getStringArray` [R], `pair` [-], `pair` [-]

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Screen:KKSV0231 | `setKKSV023101CC()` → `getBeanMapFromDataBean` | `pair` [R], `getBooleanArray` [R], `getStringArray` [R], `getLongArray` [R] |
| 2 | Screen:KKSV0233 | `setKKSV023301CC()` → `getBeanMapFromDataBean` | `pair` [R], `getBooleanArray` [R], `getStringArray` [R], `getLongArray` [R] |
| 3 | Screen:KKSV0234 | `getKKSV023401CC()` → `getBeanMapFromDataBean` | `pair` [R], `getBooleanArray` [R], `getStringArray` [R], `getLongArray` [R] |
| 4 | Screen:KKSV0234 | `setKKSV023402CC()` → `getBeanMapFromDataBean` | `pair` [R], `getBooleanArray` [R], `getStringArray` [R], `getLongArray` [R] |
| 5 | Screen:KKSV0238 | `setKKSV023803CC()` → `getBeanMapFromDataBean` | `pair` [R], `getBooleanArray` [R], `getStringArray` [R], `getLongArray` [R] |
| 6 | Screen:KKSV0239 | `setKKSV023901CC()` → `getBeanMapFromDataBean` | `pair` [R], `getBooleanArray` [R], `getStringArray` [R], `getLongArray` [R] |
| 7 | Screen:KKSV0240 | `getKKSV024001CC()` → `getBeanMapFromDataBean` | `pair` [R], `getBooleanArray` [R], `getStringArray` [R], `getLongArray` [R] |
| 8 | Screen:KKSV0240 | `setKKSV024002CC()` → `getBeanMapFromDataBean` | `pair` [R], `getBooleanArray` [R], `getStringArray` [R], `getLongArray` [R] |
| 9 | Screen:KKSV0781 | `setKKSV022901CCKKW01033()` → `getBeanMapFromDataBean` | `pair` [R], `getBooleanArray` [R], `getStringArray` [R], `getLongArray` [R] |
| 10 | KKW01021SFLogic | `actionAdd()` → `getBeanMapFromDataBean` | `pair` [R], `getBooleanArray` [R], `getStringArray` [R], `getLongArray` [R] |
| 11 | KKW01021SFLogic | `actionBulkDelete()` → `getBeanMapFromDataBean` | `pair` [R], `getBooleanArray` [R], `getStringArray` [R], `getLongArray` [R] |
| 12 | KKW01021SFLogic | `actionCash()` → `getBeanMapFromDataBean` | `pair` [R], `getBooleanArray` [R], `getStringArray` [R], `getLongArray` [R] |
| 13 | KKW01021SFLogic | `actionDelete()` → `getBeanMapFromDataBean` | `pair` [R], `getBooleanArray` [R], `getStringArray` [R], `getLongArray` [R] |
| 14 | KKW01021SFLogic | `actionDetail()` → `getBeanMapFromDataBean` | `pair` [R], `getBooleanArray` [R], `getStringArray` [R], `getLongArray` [R] |
| 15 | KKW01021SFLogic | `actionHistory()` → `getBeanMapFromDataBean` | `pair` [R], `getBooleanArray` [R], `getStringArray` [R], `getLongArray` [R] |

**Additional callers:**

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 16 | KKW01021SFLogic | `actionInitKKW01021()` → `getBeanMapFromDataBean` | `pair` [R], `getBooleanArray` [R], `getStringArray` [R], `getLongArray` [R] |
| 17 | KKW01021SFLogic | `actionInitKKW01022()` → `getBeanMapFromDataBean` | `pair` [R], `getBooleanArray` [R], `getStringArray` [R], `getLongArray` [R] |
| 18 | KKW01021SFLogic | `actionIntr()` → `getBeanMapFromDataBean` | `pair` [R], `getBooleanArray` [R], `getStringArray` [R], `getLongArray` [R] |
| 19 | KKW01021SFLogic | `actionUpdate()` → `getBeanMapFromDataBean` | `pair` [R], `getBooleanArray` [R], `getStringArray` [R], `getLongArray` [R] |
| 20 | KKW01021SFLogic | `editWribCampaignList()` → `getBeanMapFromDataBean` | `pair` [R], `getBooleanArray` [R], `getStringArray` [R], `getLongArray` [R] |
| 21 | Mover | `getBeanMapListFromDataBeanArray()` → `getBeanMapFromDataBean` | `pair` [R], `getBooleanArray` [R], `getStringArray` [R], `getLongArray` [R] |

**Trace summary:**

- The method is called from **9 screen mapper classes** (KKSV0231, KKSV0233, KKSV0234, KKSV0238, KKSV0239, KKSV0240, KKSV0781) that process screen operation data, and **8 KKW01021SFLogic action handlers** that manage campaign lifecycle operations (add, delete, update, cash, bulk delete, detail, history, initialization).
- It is also called **recursively** by its sibling method `getBeanMapListFromDataBeanArray()` for nested DATABEAN fields.
- All terminal operations are local read (R) operations on the data bean via Mover utility methods and in-memory `BeanMap.pair` writes. No database or SC/CBS calls are reached through this method's execution path.

## 6. Per-Branch Detail Blocks

**Block 1** — [INITIALIZATION] (L1316)

> Creates the result container map.

| # | Type | Code |
|---|------|------|
| 1 | SET | `BeanMap result = new BeanMap()` // Instantiate a HashMap<String, Object> with default capacity 50 |

**Block 2** — [FOR LOOP] `for (Object node : structure)` (L1317)

> Iterates over each key-type pair in the structure definition array.

| # | Type | Code |
|---|------|------|
| 1 | SET | `Object[] pair = (Object[])node` // Cast loop element to Object array |
| 2 | SET | `String item = (String)pair[0]` // Extract the field name/key (e.g., "fieldName") |
| 3 | SET | `Object value = pair[1]` // Extract the type specifier (e.g., String.class, or actual value) |
| 4 | SET | `StructureType type = StructureType.resolve(value)` // Resolve the enum type for the value |

**Block 3** — [SWITCH on StructureType] (L1323)

> Dispatches extraction logic based on the resolved type. Seven branches handle distinct data types.

### Block 3.1 — [SWITCH CASE] `DATABEAN` — `Object[].class` (L1325)

> Nested data bean array branch. Extracts a data bean array and recursively converts each element into a `BeanMap`.

| # | Type | Code |
|---|------|------|
| 1 | SET | `X31SDataBeanAccessArray beanArray = Mover.getBeanArray(bean, item)` // Read nested bean array from source |
| 2 | SET | `ArrayList<BeanMap> content = getBeanMapListFromDataBeanArray(beanArray, (Object[])value)` // Recursive conversion |
| 3 | CALL | `result.pair(item, content)` // Store the nested list under the field key |

### Block 3.2 — [SWITCH CASE] `STRING` — `String.class` (L1332)

> Scalar string field branch.

| # | Type | Code |
|---|------|------|
| 1 | SET | `String content = Mover.getString(bean, item)` // Extract single String value |
| 2 | CALL | `result.pair(item, content)` // Store in result map |

### Block 3.3 — [SWITCH CASE] `LONG` — `Long.class` (L1337)

> Scalar Long field branch.

| # | Type | Code |
|---|------|------|
| 1 | SET | `Long content = Mover.getLong(bean, item)` // Extract single Long value |
| 2 | CALL | `result.pair(item, content)` // Store in result map |

### Block 3.4 — [SWITCH CASE] `BOOLEAN` — `Boolean.class` (L1342)

> Scalar Boolean field branch.

| # | Type | Code |
|---|------|------|
| 1 | SET | `Boolean content = Mover.getBoolean(bean, item)` // Extract single Boolean value |
| 2 | CALL | `result.pair(item, content)` // Store in result map |

### Block 3.5 — [SWITCH CASE] `STRINGS` — `String[].class` (L1347)

> String array field branch.

| # | Type | Code |
|---|------|------|
| 1 | SET | `String[] content = Mover.getStringArray(bean, item)` // Extract String array |
| 2 | CALL | `result.pair(item, content)` // Store in result map |

### Block 3.6 — [SWITCH CASE] `LONGS` — `Long[].class` (L1352)

> Long array field branch.

| # | Type | Code |
|---|------|------|
| 1 | SET | `Long[] content = Mover.getLongArray(bean, item)` // Extract Long array |
| 2 | CALL | `result.pair(item, content)` // Store in result map |

### Block 3.7 — [SWITCH CASE] `BOOLEANS` — `Boolean[].class` (L1357)

> Boolean array field branch.

| # | Type | Code |
|---|------|------|
| 1 | SET | `Boolean[] content = Mover.getBooleanArray(bean, item)` // Extract Boolean array |
| 2 | CALL | `result.pair(item, content)` // Store in result map |

### Block 3.8 — [SWITCH DEFAULT] (L1361)

> Fallback for unresolved types (NULL or unrecognized). No extraction occurs; silently skipped.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `break` // Exit switch, continue to next iteration |

**Block 4** — [LOOP END / RETURN] (L1363–1365)

> Returns the fully populated result map.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return result` // Return the converted BeanMap |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `X31SDataBeanAccess` | Class | Framework data bean access object — holds screen-level form/input data. Provides typed field access methods (getString, setString, etc.) for the web application's MVC data flow. |
| `X31SDataBeanAccessArray` | Class | Array container for multiple `X31SDataBeanAccess` instances — represents a collection of data bean rows (e.g., repeated line items in a campaign). |
| `BeanMap` | Class | A `HashMap<String, Object>` with a fluent `pair(key, value)` method for map insertion. Used as an intermediate representation between data beans and business logic. |
| `BeanMap.pair()` | Method | Puts a key-value pair into the map and returns `this` for method chaining. Equivalent to `HashMap.put()` with a fluent return. |
| `BeanMapListFilter` | Class | Implements predicate-based filtering over `BeanMap` lists (used in downstream processing, not directly by this method). |
| `StructureType` | Enum | Internal type-resolution enum that classifies values into one of: `NULL`, `DATABEAN`, `STRING`, `LONG`, `BOOLEAN`, `STRINGS`, `LONGS`, `BOOLEANS`. Used to dispatch extraction logic. |
| `StructureType.resolve()` | Method | Walks through all `StructureType` enum values and returns the first one whose `type` matches the given value's runtime class. |
| `Mover` | Class | Static utility class (inner class of `KKW01021SFLogic`) providing helper methods for data bean access — get/set operations for all primitive types and arrays. |
| `structure` | Parameter | A schema definition array describing which fields to extract from a data bean and their expected types. Each entry is `[fieldName, typeSpecifier]`. |
| DATABEAN | StructureType | A nested data bean array field — triggers recursive `BeanMap` conversion of each element. |
| STRING | StructureType | A single String-typed field. |
| LONG | StructureType | A single Long-typed field. |
| BOOLEAN | StructureType | A single Boolean-typed field. |
| STRINGS | StructureType | A String array field. |
| LONGS | StructureType | A Long array field. |
| BOOLEANS | StructureType | A Boolean array field. |
| NULL | StructureType | Null or unresolvable type — no extraction occurs for this field. |
| KKW01021SF | Module | Web screen module for campaign management operations (add, delete, update, cash, bulk delete, history, etc.). |
| KKSV0xxx | Class | Screen mapper classes (e.g., KKSV0231, KKSV0233) — data mapping layer between screens and business logic. The `KKSV` prefix identifies screen-related components. |
| X31CWebConst.DATABEAN_SET_VALUE | Constant | Framework constant used by Mover setter methods (not used in this read-only method). |
