Interface MappableCrudEntityService<P>
- Type Parameters:
P
- Business domain type
- All Known Subinterfaces:
RsqlMappableCrudEntityService<P>
- All Known Implementing Classes:
BaseMappableCrudEntityService
,BaseRsqlMappableCrudEntityService
Repository
instance. Instances are intended to manage domain that
is NOT Trackable
, but still require mapping between projection and repository domain.
Instances generally perform mapping between a projection object and repository domain object via
the DomainMapperManager
.- Author:
- Jeff Fischer
-
Method Summary
Modifier and TypeMethodDescription<D,
R extends org.springframework.data.repository.CrudRepository<D, String> & com.broadleafcommerce.common.extension.DomainTypeAware>
PCreate an instance of an entity based on a business instance containing relevant property values.<D,
R extends org.springframework.data.repository.CrudRepository<D, String> & com.broadleafcommerce.common.extension.DomainTypeAware>
List<P>Create multiple instances of an entity at once based on the business instances containing relevant property values.<D,
R extends org.springframework.data.repository.CrudRepository<D, String> & com.broadleafcommerce.common.extension.DomainTypeAware>
BulkPersistenceResponse<P>createAllAllowingPartialSuccess
(List<P> businessInstances) Creates multiple instances of an entity at once based on the business instances containing relevant property values.void
Perform a delete operation on the entity identified by the id.readAll()
Read a list of instances in the form of the business instance.org.springframework.data.domain.Page<P>
readAll
(org.springframework.data.domain.Pageable pageable) Read a page of entity instances in the form of business instances.readAll
(org.springframework.data.domain.Sort sort) Read a list of instances in the form of the business instance.readAllByIds
(Iterable<String> ids) Reads all entity instances matching the provided ids.Read a single instance of an entity in the form of a business domain.Replace a single instance of an entity based on a business instance containing relavant property values.replaceAll
(List<Update<P>> replacements) Replace multiple instances of an entity at once based on the business instance containing relevant property values.replaceAllAllowingPartialSuccess
(List<Update<P>> replacements) Replace multiple instances of an entity at once based on the business instances containing relevant property values.Update a single instance of an entity based on a business instance containing relevant property values.A bulk operation that updates all of the items managed by the backing repository in the form of the business entity containing property values.updateAllAllowingPartialSuccess
(List<Update<P>> updates) Updates all of the items managed by the backing repository in the form of the business instances containing property values.
-
Method Details
-
readById
Read a single instance of an entity in the form of a business domain.- Parameters:
id
- The id for the entity.- Returns:
- The entity instance in the form of a business instance
- Throws:
EntityMissingException
- if not found
-
readAll
org.springframework.data.domain.Page<P> readAll(@NonNull org.springframework.data.domain.Pageable pageable) Read a page of entity instances in the form of business instances.- Parameters:
pageable
- information about which page of results to return. May bePageable.unpaged()
, may not benull
.- Returns:
- the requested page of entity instances in the form of business instances
-
readAllByIds
Reads all entity instances matching the provided ids. -
readAll
Read a list of instances in the form of the business instance.- Returns:
- The list of data in the form of business instances
-
readAll
Read a list of instances in the form of the business instance. Also apply the given sort.- Parameters:
sort
- The sort to be performed on the results- Returns:
- The list of sorted data in the form of business instances
-
update
Update a single instance of an entity based on a business instance containing relevant property values.- Parameters:
id
- The id for the entity.businessInstance
- The payload type that domain class should be converted to. In general, the payload is what the rest API responds with.- Returns:
- The updated entity instance in the form of a payload instance, or
EntityMissingException
if not available. - Throws:
com.broadleafcommerce.common.error.validation.ValidationException
- if the businessInstance failed validationEntityMissingException
- if a managed instance corresponding to the given id could not be found- See Also:
-
updateAll
A bulk operation that updates all of the items managed by the backing repository in the form of the business entity containing property values.All items contained within
updates
must exist in the backing repository and pass validation, else the entire batch will failFor an alternative that allows partial success, see
updateAllAllowingPartialSuccess(List)
.- Parameters:
updates
- each update to the repository domain- Returns:
- all of the updated entity instance in the form of a payload instance, or
EntityMissingException
if not available. - Throws:
UnsupportedOperationException
- if the persisted entity type from the repository is notIdentifiable
com.broadleafcommerce.common.error.validation.BulkValidationException
- if any of the instances within theupdates
fail validationEntityMissingException
- if any managed instances corresponding to the givenUpdate.getId()
could not be found- See Also:
-
updateAllAllowingPartialSuccess
Updates all of the items managed by the backing repository in the form of the business instances containing property values.Each item contained within
updates
must exist in the backing repository and pass validation, or it will be added to the failed list in the response and not persisted. All successfully found and validated items will be persisted.For an alternative that does not allow partial success, see
updateAll(List)
.- Parameters:
updates
- each update to the repository domain- Returns:
- a response containing a list of any entities which failed, and a list of the successfully updated entity instances in the form of a payload instance
- Throws:
UnsupportedOperationException
- if the persisted entity type from the repository is notIdentifiable
- See Also:
-
replace
Replace a single instance of an entity based on a business instance containing relavant property values.- Parameters:
id
- The id for the entity.businessInstance
- The payload type that domain class should be converted to. In general, the payload is what the rest API responds with.- Returns:
- The replaced entity instance in the form of a payload instance, or
EntityMissingException
if not available. - Throws:
com.broadleafcommerce.common.error.validation.ValidationException
- if the given businessInstance failed validation on replacementEntityMissingException
- if a managed instance corresponding to the given id could not be found- See Also:
-
replaceAll
Replace multiple instances of an entity at once based on the business instance containing relevant property values.All items contained within
replacements
must exist in the backing repository and pass validation, else the entire batch will failSee
replaceAllAllowingPartialSuccess(List)
for an alternative that allows partial success.- Parameters:
replacements
- all replacements to the repository domain- Returns:
- all of the replaced entity instances in the form of a payload instance, or
EntityMissingException
if any of the items were not found - Throws:
UnsupportedOperationException
- if the persisted entity type from the repository is notIdentifiable
com.broadleafcommerce.common.error.validation.BulkValidationException
- if any of the the givenreplacements
failed validation on replacementEntityMissingException
- if any of the managed instances corresponding to the givenUpdate.getId()
could not be found- See Also:
-
replaceAllAllowingPartialSuccess
Replace multiple instances of an entity at once based on the business instances containing relevant property values.Each item contained within
replacements
must exist in the backing repository and pass validation, or it will be added to the failed list in the response and not persisted. All successfully found and validated items will be persisted.See
replaceAll(List)
for an alternative that does not allow partial success.- Parameters:
replacements
- all replacements to the repository domain- Returns:
- a response containing a list of any entities which failed, and a list of the successfully replaced entity instances in the form of a payload instance
- Throws:
UnsupportedOperationException
- if the persisted entity type from the repository is notIdentifiable
- See Also:
-
create
<D,R extends org.springframework.data.repository.CrudRepository<D, P createString> & com.broadleafcommerce.common.extension.DomainTypeAware> (P businessInstance) Create an instance of an entity based on a business instance containing relevant property values. In this case, the implementation should be aware of the back repository entity type. This is generally discovered via repository implementations that use theDomainTypeAware
interface.- Parameters:
businessInstance
- The business domain instance. In general, theDomainMapperManager
is responsible for converting to a repository platform type for persistence.- Returns:
- The new entity instance in the form of a business type instance.
- Throws:
com.broadleafcommerce.common.error.validation.ValidationException
- if the given businessInstance could not be created- See Also:
-
createAll
<D,R extends org.springframework.data.repository.CrudRepository<D, List<P> createAllString> & com.broadleafcommerce.common.extension.DomainTypeAware> (@NonNull List<P> businessInstances) Create multiple instances of an entity at once based on the business instances containing relevant property values.All items contained within
businessInstances
must pass validation, else the entire batch will fail.See
createAllAllowingPartialSuccess(List)
for an alternative where partial success is allowed.- Parameters:
businessInstances
- all instances to create in the data store- Returns:
- all of the created entity instances in the form of a payload instance
- Throws:
com.broadleafcommerce.common.error.validation.BulkValidationException
- if any of the the givenbusinessInstances
failed validation- See Also:
-
createAllAllowingPartialSuccess
<D,R extends org.springframework.data.repository.CrudRepository<D, BulkPersistenceResponse<P> createAllAllowingPartialSuccessString> & com.broadleafcommerce.common.extension.DomainTypeAware> (@NonNull List<P> businessInstances) Creates multiple instances of an entity at once based on the business instances containing relevant property values.Each item contained within
businessInstances
will be validated, and if it fails validation, it will be added to the failed list in the response and not persisted. All successfully validated items will be persisted.See
createAll(List)
for an alternative that does not allow partial success.- Parameters:
businessInstances
- all instances to create in the data store- Returns:
- a response containing a list of any entities which failed, and a list of the successfully created entity instances in the form of a payload instance
- See Also:
-
delete
Perform a delete operation on the entity identified by the id.- Parameters:
id
- The id for the entity.- Throws:
EntityMissingException
- if no instance was found in the backing store corresponding to id
-