# Com / Optage / Kopt / Bp

## Overview

The `com.optage.kopt.bp` package is a subpackage under the `com.optage.kopt` module that provides batch-processing infrastructure related to SOD (Segregation of Duties) operations. It contains a base service class, a core coordination controller, a helper utility, and a send/dispatch component. The package is designed as a minimal fixture layer that integrates with the broader `com.optage.kopt.batch` package for validation and with DTOs in `com.optage.kopt.dto` for request/response data exchange.

## Key Classes

### JKKBpServiceBase

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

A base class that provides shared initialization logic for other classes in the `bp` package. The `baseInit()` method acts as a common entry point for setup routines that subclasses or related components can invoke.

**Key method:**

| Method | Return Type | Description |
|--------|-------------|-------------|
| `baseInit()` | `void` | Performs shared initialization. Called by dependent components to ensure common setup is completed before SOD operations proceed. |

### JKKHakkoSODCC

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

The core coordination and control class for the SOD (Segregation of Duties) workflow. This class acts as an orchestrator, bridging between validation, sending, and helper logic. Its two public methods handle the two main branches of the SOD process.

**Key methods:**

| Method | Return Type | Description |
|--------|-------------|-------------|
| `dispatch()` | `void` | Triggers the SOD send operation by instantiating a `JKKSodSendCC` and calling its `send()` method. This is the entry point for the dispatch flow. |
| `validate()` | `void` | Performs validation by creating a `KKPRC14901` instance (from `com.optage.kopt.batch`) and invoking its `check()` method. Delegates batch-level validation to the parent package. |

This class is the central hub of the `bp` package. A typical SOD workflow flows through `validate()` first (to ensure data integrity) and then `dispatch()` (to execute the send operation).

### JKKSodSendCC

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

The send/submit component responsible for executing the actual SOD dispatch logic. It is instantiated by `JKKHakkoSODCC.dispatch()` and carries out the outbound operation.

**Key method:**

| Method | Return Type | Description |
|--------|-------------|-------------|
| `send()` | `void` | Executes the SOD dispatch logic. This method encapsulates the sending mechanism and is called by `JKKHakkoSODCC.dispatch()`. |

### JKKHakkoSODHelper

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

A utility helper class that provides formatting support for SOD-related string processing. Currently it offers a single formatting method.

**Key method:**

| Method | Return Type | Description |
|--------|-------------|-------------|
| `format(String input)` | `String` | Trims whitespace from the input string and returns the result. Useful for normalizing input values before validation or dispatch. |

### JKKHakkoSODCCTest (Test)

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

The JUnit test class for this package. It provides a basic smoke test to verify that the module loads and can be exercised.

**Key method:**

| Method | Return Type | Description |
|--------|-------------|-------------|
| `testMain()` | `void` | A placeholder test that asserts `true`. Serves as a baseline to confirm the test infrastructure and fixtures are correctly set up. |

## Class Diagram

```mermaid
flowchart LR
    HAKKO["JKKHakkoSODCC
Core orchestrator"]
    HAKKO --> dispatch["dispatch()"]
    HAKKO --> validate["validate()"]
    dispatch --> SEND["JKKSodSendCC"]
    SEND --> send["send()"]
    validate --> VALID["KKPRC14901
batch.KKPRC14901"]
    VALID --> check["check()"]
    HAKKO --> HELPER["JKKHakkoSODHelper"]
    HELPER --> format["format(String)
whitespace trim"]
    BASE["JKKBpServiceBase
Shared init"]
    BASE --> baseInit["baseInit()"]
```

## How It Works

### Typical SOD Dispatch Flow

1. `JKKHakkoSODCC.validate()` is called first to validate the SOD request. It delegates to `KKPRC14901.check()` from the `com.optage.kopt.batch` package, which performs the batch-level validation checks.
2. Once validation passes, `JKKHakkoSODCC.dispatch()` is called. It creates a new `JKKSodSendCC` instance and invokes `send()`, which executes the actual SOD dispatch.
3. Throughout the process, `JKKHakkoSODHelper.format()` can be used to normalize any string inputs (e.g., trimming whitespace).
4. `JKKBpServiceBase.baseInit()` provides a common initialization hook that can be invoked by any component needing shared setup.

### Data Flow

The `bp` package interacts with DTOs from `com.optage.kopt.dto`:
- `JKKSodRequestDTO` — carries request data (`tenantId`, `serviceId`) into the SOD pipeline.
- `JKKSodResponseDTO` — holds the response status and message after the dispatch completes.

These DTOs are consumed by the downstream classes in the `batch` package (such as `KKPRC14901`) which this `bp` package delegates to.

## Dependencies and Integration

| Dependency | Package | Relationship |
|------------|---------|--------------|
| `com.optage.kopt.batch` | Parent module | `JKKHakkoSODCC.validate()` creates a `KKPRC14901` instance and calls `check()` on it. This is the primary cross-package integration point. |
| `com.optage.kopt.dto` | Sibling package | SOD operations use `JKKSodRequestDTO` and `JKKSodResponseDTO` for data exchange. |

The `bp` package itself is a leaf subpackage — it has no child subpackages, making it a focused, single-layer component.

## Notes for Developers

- **Minimal stub classes.** These classes are currently minimal fixture implementations (auto-generated for `SPEC-SCOPED-WIKI` tests). The bodies of methods contain placeholder comments like `/* SOD dispatch logic */` and `/* shared init */`. As the implementation matures, these method bodies will be expanded with real logic.
- **Validation delegation.** The `validate()` method in `JKKHakkoSODCC` delegates to `KKPRC14901` in the `batch` package. Any validation logic changes should be made in that parent-class, not here.
- **No deep hierarchy.** `JKKBpServiceBase` is provided as a potential extension point but is not currently extended by any class in this package. If you plan to create subclasses, call `baseInit()` before proceeding with SOD operations.
- **Helper utility.** `JKKHakkoSODHelper.format()` currently only trims strings. If more formatting capabilities are needed, extend this class rather than scattering format logic throughout the dispatch code.
- **Test coverage.** The current test (`JKKHakkoSODCCTest.testMain()`) is a placeholder assertion. As real implementation logic is added, expand this test class with meaningful unit and integration tests.
