Interface CRUDService<IdentifierType extends java.io.Serializable,Type extends Timestamped<IdentifierType>>
-
- Type Parameters:
IdentifierType- Identifier for the object stored in this serviceType- The object type being stored in this service
- All Known Subinterfaces:
AnalysisService,AnalysisSubmissionService,AnnouncementService,GenomeAssemblyService,IridaClientDetailsService,MetadataTemplateService,NcbiExportSubmissionService,PasswordResetService,ProjectEventService,ProjectService,ProjectSubscriptionService,ReferenceFileService,RemoteAPIService,SampleService,SequencingObjectService,SequencingRunService,UserGroupService,UserService,WorkflowNamedParametersService
- All Known Implementing Classes:
AnalysisServiceImpl,AnalysisSubmissionServiceImpl,AnnouncementServiceImpl,CRUDServiceImpl,GenomeAssemblyServiceImpl,IridaClientDetailsServiceImpl,MetadataTemplateServiceImpl,NcbiExportSubmissionServiceImpl,PasswordResetServiceImpl,ProjectEventServiceImpl,ProjectServiceImpl,ProjectSubscriptionServiceImpl,ReferenceFileServiceImpl,RemoteAPIServiceImpl,SampleServiceImpl,SequencingObjectServiceImpl,SequencingRunServiceImpl,UserGroupServiceImpl,UserServiceImpl,WorkflowNamedParametersServiceImpl
@PreAuthorize("denyAll()") public interface CRUDService<IdentifierType extends java.io.Serializable,Type extends Timestamped<IdentifierType>>All Service interfaces should extend this interface to inherit common methods relating to creating, reading, updating and deleting objects from persistence.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description longcount()How many entities ofTypeexist in the database?Typecreate(Type object)Create a new object in the persistence store.voiddelete(IdentifierType id)Delete the object with the specified identifier from the database.java.lang.Booleanexists(IdentifierType id)Check to see if an identifier forTypeexists in the database.java.lang.Iterable<Type>findAll()List all objects ofTypein the database.org.springframework.data.history.Revisions<java.lang.Integer,Type>findRevisions(IdentifierType id)Find all of the revisions for the specified identifier.org.springframework.data.domain.Page<org.springframework.data.history.Revision<java.lang.Integer,Type>>findRevisions(IdentifierType id, org.springframework.data.domain.Pageable pageable)Returns aPageof revisions for the entity with the given id.org.springframework.data.domain.Page<Type>list(int page, int size, org.springframework.data.domain.Sort sort)List objects ofTypein the database, limited to some specific pageorg.springframework.data.domain.Page<Type>list(int page, int size, org.springframework.data.domain.Sort.Direction order)List objects ofTypein the database, limited to some specific page, ordered by calling thecompareTomethod on the class.org.springframework.data.domain.Page<Type>list(int page, int size, org.springframework.data.domain.Sort.Direction order, java.lang.String... sortProperty)List objects ofTypein the database, limited to some specific page.Typeread(IdentifierType id)Read the object type by unique identifier.java.lang.Iterable<Type>readMultiple(java.lang.Iterable<IdentifierType> idents)Read multiple objects by the given collection of identifiersorg.springframework.data.domain.Page<Type>search(org.springframework.data.jpa.domain.Specification<Type> specification, int page, int size, org.springframework.data.domain.Sort.Direction order, java.lang.String... sortProperties)Search for an entity ofTypewith a given specificationorg.springframework.data.domain.Page<Type>search(org.springframework.data.jpa.domain.Specification<Type> specification, org.springframework.data.domain.Pageable pageRequest)Search for an entity ofTypeandPageRequestTypeupdate(Type object)Update an objectTypeupdateFields(IdentifierType id, java.util.Map<java.lang.String,java.lang.Object> updatedProperties)Update properties of the given object by given fields.java.util.Collection<Type>updateMultiple(java.util.Collection<Type> objects)Update multiple objects at once
-
-
-
Method Detail
-
create
Type create(@Valid Type object) throws EntityExistsException, javax.validation.ConstraintViolationException
Create a new object in the persistence store.- Parameters:
object- The object to persist.- Returns:
- The object as it was persisted in the database. May modify the identifier of the object when returned.
- Throws:
EntityExistsException- If the object being persisted violates uniqueness constraints in the database.javax.validation.ConstraintViolationException- If the object being persisted cannot be validated by validation rules associated with the object.
-
read
Type read(IdentifierType id) throws EntityNotFoundException
Read the object type by unique identifier.- Parameters:
id- The unique identifier for this object.- Returns:
- The object corresponding to the unique identifier.
- Throws:
EntityNotFoundException- If the identifier does not exist in the database.
-
readMultiple
java.lang.Iterable<Type> readMultiple(java.lang.Iterable<IdentifierType> idents)
Read multiple objects by the given collection of identifiers- Parameters:
idents- The unique identifiers of the objects to read- Returns:
- A collection of the requested objects
-
updateFields
Type updateFields(IdentifierType id, java.util.Map<java.lang.String,java.lang.Object> updatedProperties) throws EntityExistsException, EntityNotFoundException, javax.validation.ConstraintViolationException, InvalidPropertyException
Update properties of the given object by given fields. The object must have a valid identifier prior to being passed to this method.- Parameters:
id- The identifier of the object to update.updatedProperties- the object properties that should be updated.- Returns:
- The object as it was persisted in the database. May modify the identifier of the object when returned.
- Throws:
EntityExistsException- If the object being persisted violates uniqueness constraints in the database.EntityNotFoundException- If no object with the supplied identifier exists in the database.javax.validation.ConstraintViolationException- If the object being persisted cannot be validated by validation rules associated with the object.InvalidPropertyException- If the updated properties map contains a property name that does not exist on the domain model.
-
update
Type update(Type object) throws EntityNotFoundException, javax.validation.ConstraintViolationException
Update an object- Parameters:
object- The object to update- Returns:
- The updated object
- Throws:
EntityNotFoundException- If the entity being updated is not in the databasejavax.validation.ConstraintViolationException- if the entity being updated contains constraint violations
-
updateMultiple
java.util.Collection<Type> updateMultiple(java.util.Collection<Type> objects) throws EntityNotFoundException, javax.validation.ConstraintViolationException
Update multiple objects at once- Parameters:
objects- the objects to update- Returns:
- the updated objects
- Throws:
EntityNotFoundException- if an entity being updated is not found in the databasejavax.validation.ConstraintViolationException- if an entity being updated contains constraint violations
-
delete
void delete(IdentifierType id) throws EntityNotFoundException
Delete the object with the specified identifier from the database.- Parameters:
id- The identifier of the object to delete.- Throws:
EntityNotFoundException- If no object with the specified identifier exists in the database.
-
findAll
java.lang.Iterable<Type> findAll()
List all objects ofTypein the database.- Returns:
- All objects of the specified
Typein the database.
-
list
org.springframework.data.domain.Page<Type> list(int page, int size, org.springframework.data.domain.Sort.Direction order, java.lang.String... sortProperty) throws java.lang.IllegalArgumentException
List objects ofTypein the database, limited to some specific page.- Parameters:
page- the specific page to use.size- the size of the pages used to compute the number of pages.sortProperty- the properties used to sort the collection.order- the order of the sort.- Returns:
- the list of users within the specified range.
- Throws:
java.lang.IllegalArgumentException- If theTypehas no public propertysortProperty.
-
list
org.springframework.data.domain.Page<Type> list(int page, int size, org.springframework.data.domain.Sort sort)
List objects ofTypein the database, limited to some specific page- Parameters:
page- the specific page to usesize- the size of the pagessort- ASortobject for ordering the results- Returns:
- a list of objects in the given range
-
list
org.springframework.data.domain.Page<Type> list(int page, int size, org.springframework.data.domain.Sort.Direction order)
List objects ofTypein the database, limited to some specific page, ordered by calling thecompareTomethod on the class.- Parameters:
page- the specific page to use.size- the size of the pages used to compute the number of pages.order- the order of the sort.- Returns:
- the list of users within the specified range.
-
exists
java.lang.Boolean exists(IdentifierType id)
Check to see if an identifier forTypeexists in the database.- Parameters:
id- The identifier to check for.- Returns:
trueif the identifier exists,falseotherwise.
-
count
long count()
How many entities ofTypeexist in the database?- Returns:
- the number of entities in the database.
-
search
org.springframework.data.domain.Page<Type> search(org.springframework.data.jpa.domain.Specification<Type> specification, int page, int size, org.springframework.data.domain.Sort.Direction order, java.lang.String... sortProperties)
Search for an entity ofTypewith a given specification- Parameters:
specification- The search specificationpage- The page numbersize- the size of the pageorder- the order of the page sortsortProperties- The properties to sort on- Returns:
- a Page of Type
-
search
org.springframework.data.domain.Page<Type> search(org.springframework.data.jpa.domain.Specification<Type> specification, org.springframework.data.domain.Pageable pageRequest)
Search for an entity ofTypeandPageRequest- Parameters:
specification- The searchSpecificationpageRequest- ThePageRequest- Returns:
- a
PageofType
-
findRevisions
org.springframework.data.history.Revisions<java.lang.Integer,Type> findRevisions(IdentifierType id)
Find all of the revisions for the specified identifier.- Parameters:
id- the identifier to find revisions for.- Returns:
- the collection of revisions for the identifier.
-
findRevisions
org.springframework.data.domain.Page<org.springframework.data.history.Revision<java.lang.Integer,Type>> findRevisions(IdentifierType id, org.springframework.data.domain.Pageable pageable)
Returns aPageof revisions for the entity with the given id.- Parameters:
id- the identifier to find revisions for.pageable- the page specification.- Returns:
- the page of revisions for the specified resource.
-
-