# Com / Optage / Kopt / Bp

## Overview

The `com.optage.kopt.bp` package is a subpackage under the KOPT (presumably a batch processing system) that handles SOD (Start-of-Day) dispatch and processing for JKK (an internal system or client). It provides the core coordination logic for dispatching SOD-related tasks, validating inputs, formatting data, and sending dispatch messages. This package sits at the top level of the module hierarchy and depends on the `com.optage.kopt.batch` package for underlying batch infrastructure.

## Key Classes

### [JKKHakkoSODCC](src/main/java/com/optage/kopt/bp/JKKHakkoSODCC.java) — SOD Dispatch Controller

The central orchestrator in this package. `JKKHakkoSODCC` coordinates the SOD dispatch workflow by delegating to other components.

**Key methods:**

- **`dispatch()`** — Initiates the SOD dispatch process. Internally it creates a new `JKKSodSendCC` instance and invokes `send()`, triggering the actual dispatch logic. This is the primary entry point for SOD operations.

- **`validate()`** — Performs validation before dispatch. It instantiates a `KKPRC14901` object and calls `check()` on it. This appears to be a cross-reference to a validation class in an adjacent module (`com.optage.kopt.batch`), suggesting validation rules are defined centrally.

**Design role:** Acts as the facade for the SOD dispatch flow — callers interact with this single class rather than reaching for the lower-level send and validate components directly.

### [JKKBpServiceBase](src/main/java/com/optage/kopt/bp/JKKBpServiceBase.java) — Base Service

A base class that provides shared initialization logic for related services.

**Key methods:**

- **`baseInit()`** — Performs common initialization steps shared across subclasses. Marked `protected`, so it is intended to be extended by other service classes in the broader system.

**Design role:** Follows the Template Method / common-bases pattern to eliminate duplication across service implementations that share SOD-related setup.

### [JKKSodSendCC](src/main/java/com/optage/kopt/bp/JKKSodSendCC.java) — SOD Send Component

Handles the actual SOD message dispatch.

**Key methods:**

- **`send()`** — Executes the SOD dispatch logic. Invoked by `JKKHakkoSODCC.dispatch()`. The implementation encapsulates the mechanics of transmitting or queuing the SOD dispatch request.

### [JKKHakkoSODHelper](src/main/java/com/optage/kopt/bp/JKKHakkoSODHelper.java) — Formatting Utility

A lightweight helper class providing string formatting capabilities for SOD-related data.

**Key methods:**

- **`format(String input)`** — Trims whitespace from the input string and returns the result. A simple, pure function used to clean input data before processing. This is a standard data hygiene step that prevents issues from leading/trailing whitespace.

## How It Works

### Typical Dispatch Flow

Here is the sequence when an SOD dispatch is triggered:

```mermaid
flowchart LR
    A["Caller"] -->|"dispatch()"| B["JKKHakkoSODCC"]
    B -->|"validate()"| C["KKPRC14901"]
    C -->|"check()"| D["Validation Rules"]
    B -->|"dispatch() - sends to"| E["JKKSodSendCC"]
    E -->|"send()"| F["SOD Dispatch Logic"]
    F --> G["Downstream System"]
```

1. A caller invokes `JKKHakkoSODCC.dispatch()`.
2. `dispatch()` creates a `JKKSodSendCC` instance and calls `send()`, which carries out the dispatch.
3. Separately, `JKKHakkoSODCC.validate()` ensures data integrity by delegating to `KKPRC14901.check()`.

The validation and dispatch paths may be called independently depending on the caller's needs — `dispatch()` does not necessarily invoke `validate()` within the same call (they are separate public methods).

## Data Model

This package does not define its own entity or DTO classes. Data flows through the system as:

- **String inputs** — handled by `JKKHakkoSODHelper.format()` for trimming.
- **SOD dispatch requests** — passed through `JKKSodSendCC` to downstream systems.

Any complex data structures are likely defined in parent modules (`com.optage.kopt.batch`) or external systems.

## Dependencies and Integration

| Dependency | Relationship |
|---|---|
| `com.optage.kopt.batch` | Parent package. `JKKHakkoSODCC.validate()` depends on `KKPRC14901`, which lives in the batch package. |

The module's only declared dependency is on the parent batch package. All other collaborators (`KKPRC14901`, downstream dispatch targets) are resolved at runtime.

## Notes for Developers

- **Validation is external.** The `validate()` method instantiates `KKPRC14901` from the batch package rather than embedding validation logic inline. If validation rules need to change, the work likely happens in that external class, not here.

- **Helper is minimal but could grow.** `JKKHakkoSODHelper.format()` currently only trims strings. If more formatting rules are needed for SOD data, this is the natural place to add them.

- **`JKKBpServiceBase` is a base class.** If you are creating a new service in this area, consider whether it should extend `JKKBpServiceBase` to inherit the shared `baseInit()` logic.

- **Tests are a placeholder.** The test class `JKKHakkoSODCCTest` contains a `testMain()` method that performs a no-op assertion. This is a known stub and may need substantive test coverage once the real dispatch logic is fully implemented.

- **No child subpackages.** The module currently contains no nested subpackages; all five source files live directly under `com.optage.kopt.bp`.
