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
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 -
Method Summary
Modifier and TypeMethodDescriptionlong
count()
Counts the total number of entities.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> Retrieves a paginated list of entities with optional filtering.Updates an existing entity.
-
Constructor Details
-
BaseService
public BaseService()
-
-
Method Details
-
findById
Finds an entity by its unique identifier.- Specified by:
findById
in interfaceBaseCrudOperation<T extends BaseModel>
- Parameters:
id
- The unique identifier of the entity- Returns:
- The found entity
- Throws:
OperationException
- if entity is not found
-
create
Creates a new entity.- Specified by:
create
in interfaceBaseCrudOperation<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 interfaceBaseCrudOperation<T extends BaseModel>
- Parameters:
restQuery
- RSQL query string for filtering and sortingpageable
- Pagination parameters- Returns:
- Page of entities matching the criteria
- Throws:
OperationException
- if retrieval fails
-
update
Updates an existing entity.- Specified by:
update
in interfaceBaseCrudOperation<T extends BaseModel>
- Parameters:
obj
- The entity with updated values- Returns:
- The updated entity
- Throws:
OperationException
- if update fails or entity not found
-
delete
Deletes an entity by its unique identifier.- Specified by:
delete
in interfaceBaseCrudOperation<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
-