Class StorageBinService
StorageBin domain operations.
This class provides a clear separation between external API methods (returning DTOs to controllers) and internal domain methods (returning entities to other services or the Timefold solver). This dual-boundary pattern ensures that external clients receive decoupled response objects, while internal consumers have full access to the domain model for complex operations like constraint-based optimisation.
All public methods are @Transactional to guarantee data consistency.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateStorageBin(StorageBinRequest request) Creates a new storage bin and returns its DTO representation.org.springframework.data.domain.Page<StorageBinResponse> findAll(org.springframework.data.domain.Pageable pageable) Retrieves a paginated list of all storage bins, mapped to their DTO representations.Retrieves allStorageBinentities without pagination.org.springframework.data.domain.Page<StorageBin> findAllEntities(org.springframework.data.domain.Pageable pageable) Retrieves a paginated list of allStorageBinentities.Retrieves allStorageBinentities without pagination.Retrieves a storage bin by its unique identifier and returns its DTO representation.findEntityById(Long id) Finds aStorageBinentity by its identifier.
-
Constructor Details
-
StorageBinService
public StorageBinService()
-
-
Method Details
-
createStorageBin
Creates a new storage bin and returns its DTO representation.Before persisting, this method validates that the supplied
binCodeis unique. If a storage bin with the same code already exists, aStorageBinCodeExistsExceptionis thrown.- Parameters:
request- the input data containing the bin code and its spatial coordinates- Returns:
- a
StorageBinResponserepresenting the newly persisted storage bin - Throws:
StorageBinCodeExistsException- if a storage bin with the givenbinCodealready exists in the database
-
findById
Retrieves a storage bin by its unique identifier and returns its DTO representation.If no storage bin exists with the given
id, aStorageBinNotFoundExceptionis thrown.- Parameters:
id- the storage bin's primary key- Returns:
- a
StorageBinResponsefor the matching storage bin - Throws:
StorageBinNotFoundException- if no storage bin is found for the givenid- See Also:
-
findAll
@Transactional(readOnly=true) public org.springframework.data.domain.Page<StorageBinResponse> findAll(org.springframework.data.domain.Pageable pageable) Retrieves a paginated list of all storage bins, mapped to their DTO representations.- Parameters:
pageable- pagination and sorting parameters- Returns:
- a
PageofStorageBinResponseobjects - See Also:
-
findEntityById
Finds aStorageBinentity by its identifier.This is an internal method intended for use by other services or the Timefold solver that require access to the full domain model. It throws a
StorageBinNotFoundExceptionwhen the entity is not found.- Parameters:
id- the storage bin's primary key- Returns:
- the
StorageBinentity - Throws:
StorageBinNotFoundException- if no storage bin exists for the givenid
-
findAllEntities
@Transactional(readOnly=true) public org.springframework.data.domain.Page<StorageBin> findAllEntities(org.springframework.data.domain.Pageable pageable) Retrieves a paginated list of allStorageBinentities.This is an internal method that returns full domain objects, suitable for batch processing or solver input.
- Parameters:
pageable- pagination and sorting parameters- Returns:
- a
PageofStorageBinentities
-
findAllEntities
Retrieves allStorageBinentities without pagination.This is an internal method that should be used with care when the total number of bins is expected to be small, or when the caller intentionally loads the full collection (e.g., seeding the Timefold solver).
- Returns:
- an unmodifiable-style
Listof allStorageBinentities
-
findAllEntitiesForPlanning
Retrieves allStorageBinentities without pagination.This is an internal method that should be used with care when the total number of bins is expected to be small, or when the caller intentionally loads the full collection, for example when building the Timefold planning problem.
Do not use this method for normal paginated REST API access.
- Returns:
- an unmodifiable list of all
StorageBinentities
-