# Com / Fujitsu / Futurity / Bp / Custom / Bpm / Kksv0730

## Overview

This module implements the **subscription new-registration confirmation screen restoration display** operation (`申込新規登録確認画面断面復元表示`). It handles the business process for restoring and displaying confirmation screen data when a user navigates back to a subscription application confirmation screen within the K-Opticom customer base system. The module acts as a BPM (Business Process Management) flow that orchestrates data retrieval from multiple common components (CC) and service components (SC) to reconstruct the state of a pending subscription registration form.

## Key Classes and Interfaces

### [KKSV0730Flow](source/koptBp/ejbModule/com/fujitsu/futurity/bp/custom/bpm/kksv0730/KKSV0730Flow.java)

A stateless EJB session bean that serves as the **entry point** for the KKSV0730 business process flow. It extends `AbstractService` and implements both `IBPM` and `IOperation` interfaces, meaning it can act as both a BPM flow orchestrator and a standalone operation.

The flow is responsible for the following lifecycle:

1. **Service start logging** — Logs the execution start with version metadata (template `3.2.0.a`, BPMXML `2.6`).
2. **Database configuration** — Sets up a `DefaultDBL` for database lookups and a `RandomDBSSelector` for database system selection.
3. **Operation dispatch** — Inspects the `operationId` from the request's control header. If the value is `"KKSV0730OP"`, it executes the operation pipeline; otherwise it returns an error (`EL988 — invalid operation ID`).
4. **Common pre-processing** — Runs `MappingInitializer.mappingInit` to set up common pre-process mappings.
5. **Core operation** — Delegates to `KKSV0730OPOperation` (configured via `OperationBroker` at class-level field `target3`).
6. **Common post-processing** — Runs `MappingInitializer.mappingDispose` to clean up common post-process mappings.
7. **Service end logging** — Runs in a `finally` block to guarantee logging.

#### Key methods

- **[KKSV0730Flow()](source/koptBp/ejbModule/com/fujitsu/futurity/bp/custom/bpm/kksv0730/KKSV0730Flow.java:115)** — Default constructor. No initialization logic beyond instance creation.
- **[run(RequestParameter param)](source/koptBp/ejbModule/com/fujitsu/futurity/bp/custom/bpm/kksv0730/KKSV0730Flow.java:129)** — The main entry point. Executes the business process as described above. Returns the modified `RequestParameter`. Throws `BPMFlowException`, `DBLookupException`, `DBSystemException`, and `ReqChkException` on errors.
- **[getID()](source/koptBp/ejbModule/com/fujitsu/futurity/bp/custom/bpm/kksv0730/KKSV0730Flow.java:204)** — Returns `"KKSV0730Flow"` for identification and logging.

#### Annotations

- **@Stateless(mappedName="KKSV0730")** — Declared as a stateless EJB, making it suitable for pooled, concurrent invocation under the EJB container.
- **@TransactionManagement(TransactionManagementType.BEAN)** — Transaction management is handled programmatically via the BPM framework rather than container-managed transactions.

### [KKSV0730OPOperation](source/koptBp/ejbModule/com/fujitsu/futurity/bp/custom/bpm/kksv0730/KKSV0730OPOperation.java)

The **core business logic handler** for the subscription confirmation screen restoration. It extends `AbstractOperation` and implements `IOperation`. This class performs the actual data retrieval work by invoking a sequence of common components and service components.

The operation retrieves four categories of data:

1. **Customer menu display data** (`JKKGetMskmDmenCC`) — Fetches menu-related display information for the customer.
2. **New registration initialization data** (`JKKGetMskmNewInitCC`) — Fetches data needed to initialize the new subscription registration form.
3. **Front-screen new application data** (`KKSV007925SC`) — *Conditional*: Only executed if the custom request-check condition (`ExeCondition`) evaluates to true. This condition checks against a custom request checker (`JKKSV073005ReqChk`) with a comparison against the `"カスタム"` (custom) field. Added in ticket IT2-2017-0000014.
4. **CX strategic WG data** (`KKSV007930SC`) — *Always executed*. Added in ticket ANK-4092-00-00 for the CX strategic working group initiative.

#### Key methods

- **[KKSV0730OPOperation()](source/koptBp/ejbModule/com/fujitsu/futurity/bp/custom/bpm/kksv0730/KKSV0730OPOperation.java:135)** — Default constructor. No initialization logic.
- **[run(RequestParameter param)](source/koptBp/ejbModule/com/fujitsu/futurity/bp/custom/bpm/kksv0730/KKSV0730OPOperation.java:152)** — Executes the four retrieval steps in sequence. Returns the modified `RequestParameter` with restored screen data. Throws the standard BPM exceptions.
  - Each step sets up the broker with `BeanFactory` and `BPMOperator` references, acquires a `DBCode` from the `FUDB` connection, retrieves the system-level DB code, and executes via the `BPMOperator` with a dedicated `DBConnectionInfo`.

#### Fields (target brokers)

| Field | Type | Component | Purpose |
|---|---|---|---|
| `target3` | `CCRequestBroker` | `JKKGetMskmDmenCC.getMskmDmen` | Customer menu display data |
| `target4` | `CCRequestBroker` | `JKKGetMskmNewInitCC.getMskmNewInit` | New registration init data |
| `target5` | `ServiceComponentBroker` | `KKSV007925SC` | Front-screen new application data (conditional) |
| `target6` | `ServiceComponentBroker` | `KKSV007930SC` | CX strategic WG data (always) |

#### Dependency injection

- `@Inject private ExeConditionReqChk ecrc` — An injected condition checker used to gate the execution of `target5` (the `KKSV007925SC` service component). This was added in ticket IT2-2017-0000014.

## How It Works

Here is a trace of a typical request through this module:

```mermaid
flowchart TD
    subgraph KKSV0730["KKSV0730 Flow"]
        Flow["KKSV0730Flow
BPM Flow Entry
@Stateless EJB"]
        Flow -->|"invokes via BPMOperator"\| Operation["KKSV0730OPOperation
Business Logic Handler"]
        Flow -->|"common pre-process"\| PreProcess["MappingInitializer
mappingInit"]
        Flow -->|"common post-process"\| PostProcess["MappingInitializer
mappingDispose"]
        Operation -->|"target3"\| Target3["JKKGetMskmDmenCC
getMskmDmen
Customer menu display data"]
        Operation -->|"target4"\| Target4["JKKGetMskmNewInitCC
getMskmNewInit
New registration init data"]
        Operation -->|"target5 [conditional]"\| Target5["KKSV007925SC
Front-screen new application data"]
        Operation -->|"target6 [always]"\| Target6["KKSV007930SC
CX strategic WG data"]
    end
```

**Step-by-step flow:**

1. **Flow entry** — The BPM engine invokes `KKSV0730Flow.run(param)`. The flow logs the service start and sets up database lookup and selection infrastructure.
2. **Operation ID check** — The flow reads `operationId` from the request control header. If it is not `"KKSV0730OP"`, the flow immediately returns an `EL988` error and terminates.
3. **Common pre-processing** — The flow runs `MappingInitializer.mappingInit` on the parameter using a `CCRequestBroker`. This establishes common pre-processing mappings with a `DefaultCCExceptionJudge`.
4. **Core operation** — The flow configures and executes `KKSV0730OPOperation` via `target3` (`OperationBroker`). This step uses a DB connection to code `"3"`.
5. **Core operation internals** — `KKSV0730OPOperation.run()`:
   - Logs the operation start.
   - Initializes `execondition5` on first call (the condition for executing `target5`).
   - **Step 1 (target3):** Invokes `JKKGetMskmDmenCC.getMskmDmen` to retrieve customer menu display data. Uses DB code `"3"`.
   - **Step 2 (target4):** Invokes `JKKGetMskmNewInitCC.getMskmNewInit` to retrieve new registration initialization data. Uses DB code `"4"`.
   - **Step 3 (target5):** *Conditional.* If `ecrc.isExecuteCheck(param, execondition5)` returns true, invokes `KKSV007925SC` to retrieve front-screen new application data. Uses DB code `"5"`.
   - **Step 4 (target6):** *Always.* Invokes `KKSV007930SC` to retrieve CX strategic WG data. Uses DB code `"6"` with explicit `useDBCode=false` flags.
   - Logs the operation end and returns the parameter.
6. **Common post-processing** — The flow runs `MappingInitializer.mappingDispose` to clean up post-process mappings.
7. **Service end logging** — The `finally` block logs the service end, ensuring logging occurs regardless of success or failure.

## Data Model

This module does not define its own data model classes. Instead, it operates on the framework's `RequestParameter` object, which carries:

- **ControlHeader** — Contains metadata like the `operationId` used for routing.
- **StatusArea** — Holds error and status information (`StatusInfo`, `ErrorLevel`, `OUTBREAK_AREA`).
- **Data area** — Carries the retrieved screen data from the various CC/SC components back to the caller.

The `DBCode` and `DBConnectionInfo` objects are used to configure database connections for each step. Different DB codes (`"3"`, `"4"`, `"5"`, `"6"`, `"1"`) are used for different stages, allowing the system to route database queries appropriately.

## Dependencies and Integration

### External dependencies

| Dependency | Purpose |
|---|---|
| `eo.business.service` | Framework layer services used by the BPM engine |
| `com.fujitsu.futurity.bp.custom.common` | Shared common components (CC) like `JKKGetMskmDmenCC`, `JKKGetMskmNewInitCC` |
| `eo.business.common` | Common business utilities |

### Internal integration points

The module integrates with several other components across the broader KKSV/KKSV0079 family:

| Component | Package | Purpose |
|---|---|---|
| `JKKGetMskmDmenCC` | `com.fujitsu.futurity.bp.custom.common` | Retrieves customer menu display data |
| `JKKGetMskmNewInitCC` | `com.fujitsu.futurity.bp.custom.common` | Initializes new registration form data |
| `KKSV007925SC` | (via mapper) | Retrieves front-screen new application data |
| `KKSV007930SC` | (via mapper) | Retrieves CX strategic WG data |
| `KKSV073005ReqChk` | (mapped) | Custom request-check condition for gating `target5` |
| `BpOperationMapping` | `com.fujitsu.futurity.bp.custom.mapping` | Maps `OperationBroker` invocations |
| `KKSV0730_KKSV0730OP_EKK0711B001BSMapper` | (mapped) | Maps `KKSV007925SC` service component calls |
| `KKSV0079_KKSV0079OP_EKK3281B010BSMapper` | (mapped) | Maps `KKSV007930SC` service component calls |

### BPM framework infrastructure

Both classes rely heavily on the futurity BPM framework (`com.fujitsu.futurity.bp.x21.bpm`):

- **`AbstractService` / `AbstractOperation`** — Base classes providing `getBPMOperator()`, `getBeanFactory()`, and lifecycle methods.
- **`BPMOperator`** — The central orchestrator that actually runs the brokers (CC/SC).
- **`CCRequestBroker` / `ServiceComponentBroker` / `OperationBroker`** — Delegates to common components, service components, and operations respectively.
- **`CCRequestBroker` (pre/post)** — Common pre/post-process hooks using `MappingInitializer`.

## Notes for Developers

### Versioning
- Template version: `3.2.0.a`
- BPMXML version: `2.6`
- The classes are generated by a template — do not hand-edit the boilerplate (imports, class structure). Only the logic between the generation markers should be modified.

### Change history (tracked in source)
- **IT2-2017-0000014** (2017/06/01): Added conditional execution support (`KKSV007925SC`, `ExeConditionReqChk`, custom request checker) to fix incorrect data handling for front-screen new applications.
- **ANK-4092-00-00** (2021/08/06): Added `KKSV007930SC` invocation for the CX strategic WG initiative.

### Conditional execution
The `KKSV007925SC` target (`target5`) is gated by a custom execution condition. The condition checks whether a field named `"カスタム"` (custom) equals an empty string, using a `ConditionValueCustom` comparator. This pattern was introduced to support front-screen screen data retrieval only for specific application types. Be careful when adding new conditional logic — follow the `ExeCondition` pattern already in place.

### DB connection strategy
Each step in the operation uses a separate `DBConnectionInfo` with its own DB code and system code. The `RandomDBSSelector` at the flow level provides round-robin load balancing across available database servers. Target6 (`KKSV007930SC`) is configured with `useDBCode=false` in both the DB code and system code positions, meaning it may use a different database routing strategy.

### Thread safety
`KKSV0730Flow` is a `@Stateless` EJB, so the EJB container handles thread safety automatically. Instance fields (like the `CCRequestBroker` objects) are not mutable after construction — they hold immutable references to `OperationBroker` and `CCRequestBroker` instances configured at class load time.

### Error handling
- The flow catches no exceptions itself; they propagate up to the BPM engine.
- All CC/SC calls use `DefaultCCExceptionJudge` or `DefaultSCExceptionJudge` for exception classification.
- Unknown operation IDs result in `EL988` error level with `OUTBREAK_AREA.UNKNOWN`, wrapped in a `BPMFlowException` with a Japanese error message.

### Extension points
- To add a new data retrieval step, configure a new `CCRequestBroker` or `ServiceComponentBroker` field and invoke it in `KKSV0730OPOperation.run()` following the established pattern (set bean factory, set BPM operator, get DB code, get DB system, create DB connection info, run).
- To add a new conditional step, follow the `execondition5` / `ecrc.isExecuteCheck()` pattern from IT2-2017-0000014.
