# Com / Optage / Kopt / Bp

## Overview

The `com.optage.kopt.bp` module is a subpackage of `com.optage.kopt` that handles **Start of Day (SOD) processing coordination** for the batch system. It provides the core classes for initializing batch services, dispatching SOD operations, validating data, and formatting input. The code in this module currently exists as auto-generated test fixtures (marked with `SPEC-SCOPED-WIKI tests`), meaning the classes serve as scaffolds for test generation rather than production logic. The SOD domain context — including request/response DTOs — lives in the sibling `com.optage.kopt.dto` package, and cross-module validation references classes in `com.optage.kopt.batch`.

## Key Classes and Interfaces

### JKKBpServiceBase

**File:** [`src/main/java/com/optage/kopt/bp/JKKBpServiceBase.java`](src/main/java/com/optage/kopt/bp/JKKBpServiceBase.java)

The base class for batch processing services in this package. It provides a shared initialization hook via the `baseInit()` method, which is intended to be called by subclasses to perform common setup before processing begins.

| Method | Description |
|---|---|
| `baseInit()` | Protected initialization method containing shared setup logic for derived batch services. |

**Design role:** This class follows a template-method-style pattern where `baseInit()` serves as a common entry point that subclasses can call or override. It establishes the inheritance hierarchy root for batch services in the `bp` package.

---

### JKKHakkoSODCC

**File:** [`src/main/java/com/optage/kopt/bp/JKKHakkoSODCC.java`](src/main/java/com/optage/kopt/bp/JKKHakkoSODCC.java)

The central orchestrator in this module. "Hakko" (発光) in Japanese business software often refers to a production or issuance module, and SOD confirms the Start of Day context. This class coordinates the two primary operations: dispatching SOD processing and validating data before it is sent.

| Method | Description |
|---|---|
| `dispatch()` | Creates a new `JKKSodSendCC` instance and invokes its `send()` method. This is the primary entry point for triggering SOD dispatch operations. |
| `validate()` | Creates a new `KKPRC14901` instance (from the `com.optage.kopt.batch` package) and invokes its `check()` method. This validates data before dispatch. |

**Design role:** `JKKHakkoSODCC` acts as a facade or controller. It delegates to specialized classes for specific concerns — `JKKSodSendCC` for sending, `KKPRC14901` for validation — rather than implementing the logic itself. This keeps the class thin and single-responsibility.

**Relationship to parent:** `JKKBpServiceBase` is listed as the parent module, suggesting that `JKKHakkoSODCC` either extends or is conceptually anchored by `JKKBpServiceBase`.

---

### JKKHakkoSODHelper

**File:** [`src/main/java/com/optage/kopt/bp/JKKHakkoSODHelper.java`](src/main/java/com/optage/kopt/bp/JKKHakkoSODHelper.java)

A lightweight utility class providing helper methods for SOD data processing. Currently exposes a single method:

| Method | Parameters | Returns | Description |
|---|---|---|---|
| `format(String input)` | `input` — the string to format | `String` | Trims whitespace from the input string and returns the result. |

**Design role:** Utility helper that encapsulates common string transformations used during SOD processing. Its static-friendly design (single stateless method) makes it suitable for inline use wherever formatted input is needed.

---

### JKKSodSendCC

**File:** [`src/main/java/com/optage/kopt/bp/JKKSodSendCC.java`](src/main/java/com/optage/kopt/bp/JKKSodSendCC.java)

Handles the actual SOD dispatch logic. Instantiated by `JKKHakkoSODCC.dispatch()` and responsible for sending or publishing the Start of Day data.

| Method | Description |
|---|---|
| `send()` | Performs the SOD dispatch/sending operation. The implementation details are deferred (`/* SOD dispatch logic */`). |

**Design role:** Dedicated concern separation. While `JKKHakkoSODCC` orchestrates the flow, `JKKSodSendCC` owns the mechanics of actually sending the SOD data. This allows the sending logic to evolve independently.

---

### JKKHakkoSODCCTest (Test)

**File:** [`src/test/java/com/optage/kopt/bp/JKKHakkoSODCCTest.java`](src/test/java/com/optage/kopt/bp/JKKHakkoSODCCTest.java)

The JUnit test class for `JKKHakkoSODCC`. It is an auto-generated test fixture and currently contains a placeholder `testMain()` method that asserts `true`.

| Method | Description |
|---|---|
| `testMain()` | Placeholder test using JUnit 4 `@Test` annotation. Currently a no-op stub (`assertTrue(true)`). |

---

## How It Works

### SOD Processing Flow

Based on the structure of `JKKHakkoSODCC`, the typical SOD processing flow is:

1. **Entry** — A caller invokes `JKKHakkoSODCC.dispatch()` or `JKKHakkoSODCC.validate()`.
2. **Dispatch path** — `dispatch()` instantiates `JKKSodSendCC` and calls `send()`, which performs the SOD dispatch logic.
3. **Validation path** — `validate()` instantiates `KKPRC14901` from `com.optage.kopt.batch` and calls `check()`, which performs batch validation.
4. **Formatting** — Throughout the flow, `JKKHakkoSODHelper.format()` can be used to clean/trim input data before processing.

### Inheritance Pattern

Batch services in this package can extend `JKKBpServiceBase` and benefit from the shared `baseInit()` initialization hook. This ensures consistent setup across all batch services that inherit from it.

## Data Model

The `bp` package itself does not define data model classes. Data structures for SOD operations (such as `JKKSodRequestDTO` and `JKKSodResponseDTO`) reside in the sibling `com.optage.kopt.dto` package and are consumed by the classes in `bp` at runtime.

| DTO | Location | Purpose |
|---|---|---|
| `JKKSodRequestDTO` | `com.optage.kopt.dto` | Carries SOD request data including `tenantId` and `serviceId`. |
| `JKKSodResponseDTO` | `com.optage.kopt.dto` | Carries SOD response data. |

## Dependencies and Integration

| Dependency | Type | Description |
|---|---|---|
| `com.optage.kopt.batch` | Cross-module | `JKKHakkoSODCC.validate()` depends on `KKPRC14901` from the batch package for validation checks. |
| `com.optage.kopt.dto` | Sibling package | SOD request/response DTOs consumed by this module's classes. |
| JUnit 4 | Test | `JKKHakkoSODCCTest` uses JUnit 4 annotations (`@Test`, `Assert`). |

## Module Diagram

The following diagram shows the primary relationships between classes in this module:

```
flowchart LR
    HKK["JKKHakkoSODCC"] -->|"dispatch"| SOD["JKKSodSendCC"]
    HKK -->|"validate"| KKP["KKPRC14901 (batch)"]
    HKK -->|"uses"| HLP["JKKHakkoSODHelper"]
    BSP["JKKBpServiceBase"] -->|"base init"| HKK
```

## Notes for Developers

- **Auto-generated fixtures:** All classes in this package are currently auto-generated test scaffolds (`SPEC-SCOPED-WIKI tests`). Their methods contain minimal or placeholder implementations. If you are working on expanding this module's functionality, treat the current code as structure templates rather than production-ready logic.

- **Extensibility point:** `JKKBpServiceBase.baseInit()` is the recommended place to add shared initialization logic that all batch services should execute.

- **Thin delegators:** The `bp` package follows a delegation pattern — each class owns a single responsibility and delegates to others. When adding new capabilities, follow this pattern: create a new dedicated class rather than adding methods to `JKKHakkoSODCC`.

- **Test coverage:** The test class `JKKHakkoSODCCTest` is currently a stub (`assertTrue(true)`). Real test cases should be added to cover the dispatch, validate, and helper flows once production logic is implemented.

- **Japanese naming convention:** Class names follow Japanese banking/enterprise software conventions (JKK, SOD, Hakko). These map to business concepts like "Start of Day issuance" and are consistent across the broader `com.optage.kopt` package family.
