Interface BaseCrudOperation<T>

Type Parameters:
T - The type of entity to manage
All Known Implementing Classes:
BaseService, FunctionLibraryService, FunctionLibraryServiceImpl, RuleHelperService, RuleHelperServiceImpl, RuleLibraryService, RuleLibraryServiceImpl

public interface BaseCrudOperation<T>
Base interface for CRUD operations in service layer.

This interface defines the standard contract for CRUD (Create, Read, Update, Delete) operations in the Beas Rule Engine service layer. It provides a consistent API structure for all entity services.

The interface includes:

  • Entity creation
  • Entity retrieval by ID
  • Paginated entity retrieval with filtering
  • Entity updates
  • Entity deletion
Since:
1.0
Version:
1.0
Author:
Beas Solution Team
  • Method Summary

    Modifier and Type
    Method
    Description
    create(T obj)
    Creates a new entity.
    void
    delete(UUID obj)
    Deletes an entity by its unique identifier.
    Finds an entity by its unique identifier.
    org.springframework.data.domain.Page<T>
    read(String rsql, org.springframework.data.domain.Pageable pageable)
    Retrieves a paginated list of entities with optional filtering.
    update(T obj)
    Updates an existing entity.
  • Method Details

    • findById

      T findById(UUID id)
      Finds an entity by its unique identifier.

      This method retrieves a single entity from the database using its UUID. If the entity is not found, an OperationException is thrown.

      Parameters:
      id - The unique identifier of the entity
      Returns:
      The found entity
      Throws:
      OperationException - if entity is not found
    • create

      T create(T obj) throws OperationException
      Creates a new entity.

      This method persists a new entity to the database. The entity is validated before persistence and audit fields are automatically populated.

      Parameters:
      obj - The entity to create
      Returns:
      The created entity with generated ID and audit fields
      Throws:
      OperationException - if creation fails
    • read

      org.springframework.data.domain.Page<T> read(String rsql, @PageableDefault org.springframework.data.domain.Pageable pageable) throws OperationException
      Retrieves a paginated list of entities with optional filtering.

      This method retrieves entities from the database with support for pagination and RSQL query filtering. The RSQL query allows for complex filtering, sorting, and selection operations.

      Parameters:
      rsql - RSQL query string for filtering and sorting
      pageable - Pagination parameters
      Returns:
      Page of entities matching the criteria
      Throws:
      OperationException - if retrieval fails
    • update

      T update(T obj) throws OperationException
      Updates an existing entity.

      This method updates an existing entity in the database. Only the provided fields are updated, maintaining existing values for non-specified fields. The entity must exist in the database.

      Parameters:
      obj - The entity with updated values
      Returns:
      The updated entity
      Throws:
      OperationException - if update fails or entity not found
    • delete

      void delete(UUID obj) throws OperationException
      Deletes an entity by its unique identifier.

      This method permanently removes an entity from the database using its UUID. The entity must exist in the database.

      Parameters:
      obj - The unique identifier of the entity to delete
      Throws:
      OperationException - if deletion fails or entity not found