---

# Business Logic — JKKDslRunCC.init() [12 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.fujitsu.futurity.bp.custom.common.JKKDslRunCC` |
| Layer | CC / Common Component (business logic shared component within the `com.fujitsu.futurity.bp.custom.common` package) |
| Module | `common` (Package: `com.fujitsu.futurity.bp.custom.common`) |

## 1. Role

### JKKDslRunCC.init()

This method serves as the **initialization entry point for contract cancellation execution (解約実行)** within the K-Opticom customer base system (eo customer base system). It prepares the runtime state before any cancellation processing logic runs, ensuring two critical preconditions are met: the internal DSL mapper object exists, and the error handling buffer is available in the request parameter map. The method follows a **lazy initialization pattern** for the mapper — creating the `JKKDslRunMapperCC` instance only if it has not already been set — and an **error-sink pattern** for the control map, where it clears any residual error entries by assigning a fresh, empty `ArrayList<Object>` under the `ERROR_INFO` key. Its role in the larger system is that of a **shared setup utility** consumed internally by other methods on `JKKDslRunCC` (`checkHteldel`, `getInvokeCBS`, `runDsl`, `runDslPreChk`), which each invoke `init()` as their first step before performing domain-specific cancellation checks, CBS invocations, or DSL (Domain Specific Language) rule processing. This centralizes error-state preparation and avoids duplication across the cancellation execution flow.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["init(params, fixedText)"])
    CHECK_MAPPER{"mapper is null?"}
    INIT_MAPPER["Set this.mapper = new JKKDslRunMapperCC()"]
    CLEAR_ERROR["Set ERROR_INFO to new empty ArrayList<Object>()"]
    END_NODE(["Return / Next"])

    START --> CHECK_MAPPER
    CHECK_MAPPER -->|Yes| INIT_MAPPER
    CHECK_MAPPER -->|No| CLEAR_ERROR
    INIT_MAPPER --> CLEAR_ERROR
    CLEAR_ERROR --> END_NODE
```

**Processing description:**

1. **Mapper lazy initialization check:** The method first checks whether the instance field `this.mapper` is `null`. If the mapper has not yet been instantiated, it creates a new `JKKDslRunMapperCC` object and assigns it to `this.mapper`. This follows the lazy initialization pattern — the mapper may have been created by a prior caller or setter, so the method avoids redundant instantiation.

2. **Error info buffer initialization:** Regardless of whether the mapper was created, the method always proceeds to initialize the error information buffer in the control map. It clears any existing error entries by writing a new, empty `ArrayList<Object>` to the key `ERROR_INFO` (constant `SCControlMapKeys.ERROR_INFO`) inside the `param` object. This ensures that downstream processing methods have a clean, fresh collection to append error messages to during cancellation execution.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `param` | `IRequestParameterReadWrite` | The request parameter object that carries the model group data and the control map for the current business operation. The control map is a `Map<String, Object>` used to share state between processing stages. Its `ERROR_INFO` key holds a list of error objects that downstream methods append error messages to during contract cancellation execution. |
| 2 | `fixedText` | `String` | A user-supplied arbitrary text string, intended for logging or audit trail purposes. It is accepted as a parameter but not used within this `init` method itself; it is forwarded to downstream methods that perform actual cancellation checks or DSL execution. |

**Instance fields read by this method:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `this.mapper` | `JKKDslRunMapperCC` | The internal DSL mapping object that handles data transformation and key mapping between the request parameter model and the service components called during cancellation execution. |

## 4. CRUD Operations / Called Services

This method performs **no CRUD operations** and invokes **no external services or CBS (Business Service) methods**. It is a pure initialization routine that only assigns in-memory objects.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| (none) | — | — | — | No database or service calls — this method only initializes in-memory state (mapper instance and error buffer). |

**Note:** The actual CRUD operations for contract cancellation (reads, creates, updates, deletes on service order and contract entities) are delegated to methods called *after* `init()`, such as `executeOdrHakkoJokenAdd`, `runDsl`, and other CBS invocation methods that this method prepares the state for.

## 5. Dependency Trace

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

No screen/batch entry points found within 8 hops. Direct callers found: 4 methods.
Terminal operations from this method: -

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | CBS: `JKKDslRunCC.checkHteldel` | `checkHteldel(handle, param, fixedText)` → `this.init(param, fixedText)` | No direct CRUD — delegates to downstream methods |
| 2 | CBS: `JKKDslRunCC.getInvokeCBS` | `getInvokeCBS(handle, param, fixedText)` → `this.init(param, fixedText)` | Invokes CBS service calls; terminal operations depend on service type |
| 3 | CBS: `JKKDslRunCC.runDsl` | `runDsl(handle, param, fixedText)` → `this.init(param, fixedText)` | DSL-driven processing; may trigger create/update/delete on order entities |
| 4 | CBS: `JKKDslRunCC.runDslPreChk` | `runDslPreChk(handle, param, fixedText)` → `this.init(param, fixedText)` | Pre-check processing; reads contract/order data |

## 6. Per-Branch Detail Blocks

**Block 1** — [IF] `(null == this.mapper)` [L54]

> Lazy initialization of the DSL mapper. The mapper is created only if it has not already been instantiated (by a prior caller or setter).

| # | Type | Code |
|---|------|------|
| 1 | SET | `this.mapper = new JKKDslRunMapperCC()` // Create new DSL mapper instance [-> LAZY INITIALIZATION] |

**Block 2** — [EXEC] (L59)

> Error info buffer initialization. Irrespective of whether the mapper was created, always clear the error information collection in the control map to provide a clean slate for downstream error reporting.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `param.setControlMapData(SCControlMapKeys.ERROR_INFO, new ArrayList<Object>())` // Clear error list for this operation [-> SCControlMapKeys.ERROR_INFO] |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| 解約 (kaiya) | Business term | Contract cancellation — the business operation of terminating a customer's service subscription (e.g., FTTH, telephone, mail services) |
| 初期処理 (shoki shori) | Business term | Initialization processing — the setup phase that prepares objects and data structures before main business logic executes |
| マッパー (mapper) | Technical term | An object that maps data between the request parameter model and the service component layer, handling key/value transformations |
| コントロールマップ (control map) | Technical term | A shared `Map<String, Object>` stored within the request parameter that carries state (errors, flags, model data) across processing stages |
| ERROR_INFO | Constant | Control map key (`SCControlMapKeys.ERROR_INFO`) — holds an `ArrayList<Object>` of error messages generated during processing |
| JKKDslRunCC | Class | DSL (Domain Specific Language) Run Common Component — a shared business component that orchestrates contract cancellation processing |
| JKKDslRunMapperCC | Class | DSL Run Mapper Common Component — handles data mapping for the cancellation DSL execution, including service type routing and parameter translation |
| IRequestParameterReadWrite | Interface | Request parameter interface that provides read/write access to the model group data and control map for the current business transaction |
| DSL | Acronym | Domain Specific Language — a rule-based processing framework that configures cancellation behavior via declarative mappings rather than hard-coded logic |
| CBS | Acronym | Business Service — an external service component (called via `call*SC*` or `call*CBS*` methods) that performs data access or integration operations |
| SC | Acronym | Service Component — a service-layer class (typically named `EKKxxxxxxSC`) that exposes methods for database and CBS interactions |
| SessionHandle | Class | Context object carrying session management information such as transaction context, user identification, and message handling |

---
