Class AnnouncementServiceImpl
- java.lang.Object
-
- ca.corefacility.bioinformatics.irida.service.impl.CRUDServiceImpl<java.lang.Long,Announcement>
-
- ca.corefacility.bioinformatics.irida.service.impl.AnnouncementServiceImpl
-
- All Implemented Interfaces:
AnnouncementService
,CRUDService<java.lang.Long,Announcement>
@Service public class AnnouncementServiceImpl extends CRUDServiceImpl<java.lang.Long,Announcement> implements AnnouncementService
Service for managing @{link Announcements}
-
-
Field Summary
-
Fields inherited from class ca.corefacility.bioinformatics.irida.service.impl.CRUDServiceImpl
CREATED_DATE_SORT_PROPERTY, repository, validator, valueType
-
-
Constructor Summary
Constructors Constructor Description AnnouncementServiceImpl(AnnouncementRepository announcementRepository, AnnouncementUserJoinRepository announcementUserJoinRepository, UserRepository userRepository, javax.validation.Validator validator)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Map<Announcement,java.lang.Long>
countReadsForAllAnnouncements()
Get a map where the keys areAnnouncement
s and the values areInteger
s representing the number ofUser
s who have read that announcement.java.lang.Long
countReadsForOneAnnouncement(Announcement announcement)
Get a count of the number ofUser
s who have readAnnouncement
Announcement
create(Announcement announcement)
Create a new object in the persistence store.void
delete(java.lang.Long id)
Delete the object with the specified identifier from the database.java.util.List<Announcement>
getAllAnnouncements()
Get a list of all of theAnnouncement
s that currently existjava.util.List<Announcement>
getAnnouncementsCreatedByUser(User user)
Get a list ofAnnouncement
s created by specific adminUser
java.util.List<AnnouncementUserReadDetails>
getAnnouncementsForUser(User user)
Get a list ofAnnouncement
s that have been read and unread byUser
java.util.List<AnnouncementUserJoin>
getReadAnnouncementsForUser(User user)
Get a list ofAnnouncement
s that have been read byUser
java.util.List<AnnouncementUserJoin>
getReadUsersForAnnouncement(Announcement announcement)
Get all of theJoin
s describing users that have comfirmed they've read a particularAnnouncement
java.util.List<Announcement>
getUnreadAnnouncementsForUser(User user)
Get a list ofAnnouncement
s that have not been read byUser
java.util.List<User>
getUnreadUsersForAnnouncement(Announcement announcement)
Get a list of all of theUser
s that have not confirmed they've read theAnnouncement
AnnouncementUserJoin
markAnnouncementAsReadByUser(Announcement announcement, User user)
Mark anAnnouncement
object as read by aUser
void
markAnnouncementAsUnreadByUser(Announcement announcement, User user)
Mark anAnnouncement
as unread by aUser
Announcement
read(java.lang.Long id)
Read the object type by unique identifier.org.springframework.data.domain.Page<Announcement>
search(org.springframework.data.jpa.domain.Specification<Announcement> specification, org.springframework.data.domain.Pageable request)
Search for an entity ofType
andPageRequest
Announcement
update(Announcement announcement)
Update an object-
Methods inherited from class ca.corefacility.bioinformatics.irida.service.impl.CRUDServiceImpl
count, exists, findAll, findRevisions, findRevisions, list, list, list, readMultiple, search, updateFields, updateMultiple
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface ca.corefacility.bioinformatics.irida.service.CRUDService
count, exists, findAll, findRevisions, findRevisions, list, list, list, readMultiple, search, updateFields, updateMultiple
-
-
-
-
Constructor Detail
-
AnnouncementServiceImpl
@Autowired public AnnouncementServiceImpl(AnnouncementRepository announcementRepository, AnnouncementUserJoinRepository announcementUserJoinRepository, UserRepository userRepository, javax.validation.Validator validator)
-
-
Method Detail
-
create
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") public Announcement create(Announcement announcement)
Create a new object in the persistence store.- Specified by:
create
in interfaceCRUDService<java.lang.Long,Announcement>
- Overrides:
create
in classCRUDServiceImpl<java.lang.Long,Announcement>
- Parameters:
announcement
- The object to persist.- Returns:
- The object as it was persisted in the database. May modify the identifier of the object when returned.
-
delete
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") public void delete(java.lang.Long id)
Delete the object with the specified identifier from the database.- Specified by:
delete
in interfaceCRUDService<java.lang.Long,Announcement>
- Overrides:
delete
in classCRUDServiceImpl<java.lang.Long,Announcement>
- Parameters:
id
- The identifier of the object to delete.
-
update
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") public Announcement update(Announcement announcement)
Update an object- Specified by:
update
in interfaceCRUDService<java.lang.Long,Announcement>
- Overrides:
update
in classCRUDServiceImpl<java.lang.Long,Announcement>
- Parameters:
announcement
- The object to update- Returns:
- The updated object
-
read
@PreAuthorize("hasAnyRole(\'ROLE_USER\')") public Announcement read(java.lang.Long id)
Read the object type by unique identifier.- Specified by:
read
in interfaceCRUDService<java.lang.Long,Announcement>
- Overrides:
read
in classCRUDServiceImpl<java.lang.Long,Announcement>
- Parameters:
id
- The unique identifier for this object.- Returns:
- The object corresponding to the unique identifier.
-
search
@PreAuthorize("hasAnyRole(\'ROLE_USER\')") public org.springframework.data.domain.Page<Announcement> search(org.springframework.data.jpa.domain.Specification<Announcement> specification, org.springframework.data.domain.Pageable request)
Search for an entity ofType
andPageRequest
- Specified by:
search
in interfaceCRUDService<java.lang.Long,Announcement>
- Overrides:
search
in classCRUDServiceImpl<java.lang.Long,Announcement>
- Parameters:
specification
- The searchSpecification
request
- ThePageRequest
- Returns:
- a
Page
ofType
-
markAnnouncementAsReadByUser
@PreAuthorize("hasAnyRole(\'ROLE_USER\')") public AnnouncementUserJoin markAnnouncementAsReadByUser(Announcement announcement, User user) throws EntityExistsException
Mark anAnnouncement
object as read by aUser
- Specified by:
markAnnouncementAsReadByUser
in interfaceAnnouncementService
- Parameters:
announcement
- The announcement to markuser
- the user who's read the announcement- Returns:
- An
AnnouncementUserJoin
object representing the relationship between the announcement and the user - Throws:
EntityExistsException
-
markAnnouncementAsUnreadByUser
@PreAuthorize("hasAnyRole(\'ROLE_USER\')") public void markAnnouncementAsUnreadByUser(Announcement announcement, User user) throws EntityNotFoundException
Mark anAnnouncement
as unread by aUser
- Specified by:
markAnnouncementAsUnreadByUser
in interfaceAnnouncementService
- Parameters:
announcement
- the announcement to markuser
- the user to mark the announcement for- Throws:
EntityNotFoundException
-
getReadUsersForAnnouncement
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") public java.util.List<AnnouncementUserJoin> getReadUsersForAnnouncement(Announcement announcement) throws EntityNotFoundException
Get all of theJoin
s describing users that have comfirmed they've read a particularAnnouncement
- Specified by:
getReadUsersForAnnouncement
in interfaceAnnouncementService
- Parameters:
announcement
- TheAnnouncement
for which we want to load users that have read it- Returns:
- List of
User
s that have read the announcement - Throws:
EntityNotFoundException
-
getUnreadUsersForAnnouncement
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") public java.util.List<User> getUnreadUsersForAnnouncement(Announcement announcement) throws EntityNotFoundException
Get a list of all of theUser
s that have not confirmed they've read theAnnouncement
- Specified by:
getUnreadUsersForAnnouncement
in interfaceAnnouncementService
- Parameters:
announcement
- The- Returns:
- List of
User
s that haven't confirmed they've read the announcement - Throws:
EntityNotFoundException
-
getAnnouncementsForUser
@PreAuthorize("hasPermission(#user, \'canUpdateUser\')") public java.util.List<AnnouncementUserReadDetails> getAnnouncementsForUser(User user)
Get a list ofAnnouncement
s that have been read and unread byUser
- Specified by:
getAnnouncementsForUser
in interfaceAnnouncementService
- Parameters:
user
-User
for whom we want to get unread announcements- Returns:
- list of
AnnouncementUserReadDetails
objects representing announcements read and unread by a user
-
getReadAnnouncementsForUser
@PreAuthorize("hasPermission(#user, \'canUpdateUser\')") public java.util.List<AnnouncementUserJoin> getReadAnnouncementsForUser(User user)
Get a list ofAnnouncement
s that have been read byUser
- Specified by:
getReadAnnouncementsForUser
in interfaceAnnouncementService
- Parameters:
user
-User
for whom we want to get unread announcements- Returns:
- list of
Join
objects representing announcements marked as read by a user
-
getUnreadAnnouncementsForUser
@PreAuthorize("hasPermission(#user, \'canUpdateUser\')") public java.util.List<Announcement> getUnreadAnnouncementsForUser(User user)
Get a list ofAnnouncement
s that have not been read byUser
- Specified by:
getUnreadAnnouncementsForUser
in interfaceAnnouncementService
- Parameters:
user
-User
for whom we want to get unread announcements- Returns:
- List of
Announcement
s that have not been read by the user
-
getAllAnnouncements
@PreAuthorize("hasAnyRole(\'ROLE_USER\')") public java.util.List<Announcement> getAllAnnouncements()
Get a list of all of theAnnouncement
s that currently exist- Specified by:
getAllAnnouncements
in interfaceAnnouncementService
- Returns:
- List of
Announcement
s
-
getAnnouncementsCreatedByUser
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") public java.util.List<Announcement> getAnnouncementsCreatedByUser(User user)
Get a list ofAnnouncement
s created by specific adminUser
- Specified by:
getAnnouncementsCreatedByUser
in interfaceAnnouncementService
- Parameters:
user
- The adminUser
who created the announcements- Returns:
- List of announcements created by the admin, empty list if
User
is not an admin
-
countReadsForOneAnnouncement
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") public java.lang.Long countReadsForOneAnnouncement(Announcement announcement)
Get a count of the number ofUser
s who have readAnnouncement
- Specified by:
countReadsForOneAnnouncement
in interfaceAnnouncementService
- Parameters:
announcement
-Announcement
for which we want the number of users who have read it- Returns:
- number of users who have read
Announcement
-
countReadsForAllAnnouncements
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") public java.util.Map<Announcement,java.lang.Long> countReadsForAllAnnouncements()
Get a map where the keys areAnnouncement
s and the values areInteger
s representing the number ofUser
s who have read that announcement.- Specified by:
countReadsForAllAnnouncements
in interfaceAnnouncementService
- Returns:
- A Map of announcements and counts of users who have read that announcement
-
-