Class StorageBinService

java.lang.Object
com.v1rex.liftnexus.storagebin.service.StorageBinService

@Service public class StorageBinService extends Object
Service layer for 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 Details

    • StorageBinService

      public StorageBinService()
  • Method Details

    • createStorageBin

      @Transactional public StorageBinResponse createStorageBin(StorageBinRequest request)
      Creates a new storage bin and returns its DTO representation.

      Before persisting, this method validates that the supplied binCode is unique. If a storage bin with the same code already exists, a StorageBinCodeExistsException is thrown.

      Parameters:
      request - the input data containing the bin code and its spatial coordinates
      Returns:
      a StorageBinResponse representing the newly persisted storage bin
      Throws:
      StorageBinCodeExistsException - if a storage bin with the given binCode already exists in the database
    • findById

      @Transactional(readOnly=true) public StorageBinResponse findById(Long id)
      Retrieves a storage bin by its unique identifier and returns its DTO representation.

      If no storage bin exists with the given id, a StorageBinNotFoundException is thrown.

      Parameters:
      id - the storage bin's primary key
      Returns:
      a StorageBinResponse for the matching storage bin
      Throws:
      StorageBinNotFoundException - if no storage bin is found for the given id
      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 Page of StorageBinResponse objects
      See Also:
    • findEntityById

      @Transactional(readOnly=true) public StorageBin findEntityById(Long id)
      Finds a StorageBin entity 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 StorageBinNotFoundException when the entity is not found.

      Parameters:
      id - the storage bin's primary key
      Returns:
      the StorageBin entity
      Throws:
      StorageBinNotFoundException - if no storage bin exists for the given id
    • findAllEntities

      @Transactional(readOnly=true) public org.springframework.data.domain.Page<StorageBin> findAllEntities(org.springframework.data.domain.Pageable pageable)
      Retrieves a paginated list of all StorageBin entities.

      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 Page of StorageBin entities
    • findAllEntities

      @Transactional(readOnly=true) public List<StorageBin> findAllEntities()
      Retrieves all StorageBin entities 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 List of all StorageBin entities
    • findAllEntitiesForPlanning

      @Transactional(readOnly=true) public List<StorageBin> findAllEntitiesForPlanning()
      Retrieves all StorageBin entities 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 StorageBin entities