Class BaseService<T extends BaseModel>

java.lang.Object
com.beassolution.rule.service.base.BaseService<T>
Type Parameters:
T - The type of entity to manage
All Implemented Interfaces:
BaseCrudOperation<T>
Direct Known Subclasses:
FunctionLibraryService, RuleHelperService, RuleLibraryService

public class BaseService<T extends BaseModel> extends Object implements BaseCrudOperation<T>
Base service implementation for CRUD operations.

This class provides a concrete implementation of the BaseCrudOperation interface for all entity services in the Beas Rule Engine. It handles common CRUD operations using MongoDB and includes support for RSQL querying.

Key features include:

  • Standard CRUD operations
  • RSQL query parsing and execution
  • Object mapping with ModelMapper
  • Pagination support
  • Exception handling
Since:
1.0
Version:
1.0
Author:
Beas Solution Team
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • BaseService

      public BaseService()
  • Method Details

    • findById

      public T findById(UUID id)
      Finds an entity by its unique identifier.
      Specified by:
      findById in interface BaseCrudOperation<T extends BaseModel>
      Parameters:
      id - The unique identifier of the entity
      Returns:
      The found entity
      Throws:
      OperationException - if entity is not found
    • create

      public T create(T obj) throws OperationException
      Creates a new entity.
      Specified by:
      create in interface BaseCrudOperation<T extends BaseModel>
      Parameters:
      obj - The entity to create
      Returns:
      The created entity
      Throws:
      OperationException - if creation fails
    • read

      public org.springframework.data.domain.Page<T> read(String restQuery, org.springframework.data.domain.Pageable pageable) throws OperationException
      Retrieves a paginated list of entities with optional filtering.
      Specified by:
      read in interface BaseCrudOperation<T extends BaseModel>
      Parameters:
      restQuery - RSQL query string for filtering and sorting
      pageable - Pagination parameters
      Returns:
      Page of entities matching the criteria
      Throws:
      OperationException - if retrieval fails
    • update

      public T update(T obj) throws OperationException
      Updates an existing entity.
      Specified by:
      update in interface BaseCrudOperation<T extends BaseModel>
      Parameters:
      obj - The entity with updated values
      Returns:
      The updated entity
      Throws:
      OperationException - if update fails or entity not found
    • delete

      public void delete(UUID id) throws OperationException
      Deletes an entity by its unique identifier.
      Specified by:
      delete in interface BaseCrudOperation<T extends BaseModel>
      Parameters:
      id - The unique identifier of the entity to delete
      Throws:
      OperationException - if deletion fails or entity not found
    • count

      public long count()
      Counts the total number of entities.
      Returns:
      The total count of entities