Search in sources :

Example 1 with DTAnnouncementUser

use of ca.corefacility.bioinformatics.irida.ria.web.models.datatables.DTAnnouncementUser in project irida by phac-nml.

the class AnnouncementsController method getUserAnnouncementInfoTable.

/**
 * Get user read status for current announcement
 * @param announcementID {@link Long} identifier for the {@link Announcement}
 * @param params {@link DataTablesParams} parameters for current DataTable
 * @return {@link DataTablesResponse} containing the list of users.
 */
@RequestMapping(value = "/{announcementID}/details/ajax/list", method = RequestMethod.GET)
@PreAuthorize("hasRole('ROLE_ADMIN')")
@ResponseBody
public DataTablesResponse getUserAnnouncementInfoTable(@PathVariable Long announcementID, @DataTablesRequest final DataTablesParams params) {
    final Announcement currentAnnouncement = announcementService.read(announcementID);
    final Page<User> page = userService.search(UserSpecification.searchUser(params.getSearchValue()), new PageRequest(params.getCurrentPage(), params.getLength(), params.getSort()));
    final List<DataTablesResponseModel> announcementUsers = page.getContent().stream().map(user -> new DTAnnouncementUser(user, userHasRead(user, currentAnnouncement))).collect(Collectors.toList());
    return new DataTablesResponse(params, page, announcementUsers);
}
Also used : PathVariable(org.springframework.web.bind.annotation.PathVariable) RequestParam(org.springframework.web.bind.annotation.RequestParam) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) Controller(org.springframework.stereotype.Controller) Announcement(ca.corefacility.bioinformatics.irida.model.announcements.Announcement) Model(org.springframework.ui.Model) DataTablesResponseModel(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.models.DataTablesResponseModel) AnnouncementSpecification(ca.corefacility.bioinformatics.irida.repositories.specification.AnnouncementSpecification) DataTablesResponse(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesResponse) Logger(org.slf4j.Logger) DTAnnouncementUser(ca.corefacility.bioinformatics.irida.ria.web.models.datatables.DTAnnouncementUser) DataTablesRequest(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.config.DataTablesRequest) PageRequest(org.springframework.data.domain.PageRequest) RequestMethod(org.springframework.web.bind.annotation.RequestMethod) IOException(java.io.IOException) DTAnnouncementAdmin(ca.corefacility.bioinformatics.irida.ria.web.models.datatables.DTAnnouncementAdmin) Page(org.springframework.data.domain.Page) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) Collectors(java.util.stream.Collectors) UserSpecification(ca.corefacility.bioinformatics.irida.repositories.specification.UserSpecification) List(java.util.List) Principal(java.security.Principal) UserService(ca.corefacility.bioinformatics.irida.service.user.UserService) Optional(java.util.Optional) AnnouncementUserJoin(ca.corefacility.bioinformatics.irida.model.announcements.AnnouncementUserJoin) User(ca.corefacility.bioinformatics.irida.model.user.User) AnnouncementService(ca.corefacility.bioinformatics.irida.service.AnnouncementService) Collections(java.util.Collections) DataTablesParams(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesParams) PageRequest(org.springframework.data.domain.PageRequest) DTAnnouncementUser(ca.corefacility.bioinformatics.irida.ria.web.models.datatables.DTAnnouncementUser) User(ca.corefacility.bioinformatics.irida.model.user.User) Announcement(ca.corefacility.bioinformatics.irida.model.announcements.Announcement) DataTablesResponseModel(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.models.DataTablesResponseModel) DTAnnouncementUser(ca.corefacility.bioinformatics.irida.ria.web.models.datatables.DTAnnouncementUser) DataTablesResponse(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesResponse) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

Announcement (ca.corefacility.bioinformatics.irida.model.announcements.Announcement)1 AnnouncementUserJoin (ca.corefacility.bioinformatics.irida.model.announcements.AnnouncementUserJoin)1 User (ca.corefacility.bioinformatics.irida.model.user.User)1 AnnouncementSpecification (ca.corefacility.bioinformatics.irida.repositories.specification.AnnouncementSpecification)1 UserSpecification (ca.corefacility.bioinformatics.irida.repositories.specification.UserSpecification)1 DataTablesParams (ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesParams)1 DataTablesResponse (ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesResponse)1 DataTablesRequest (ca.corefacility.bioinformatics.irida.ria.web.components.datatables.config.DataTablesRequest)1 DataTablesResponseModel (ca.corefacility.bioinformatics.irida.ria.web.components.datatables.models.DataTablesResponseModel)1 DTAnnouncementAdmin (ca.corefacility.bioinformatics.irida.ria.web.models.datatables.DTAnnouncementAdmin)1 DTAnnouncementUser (ca.corefacility.bioinformatics.irida.ria.web.models.datatables.DTAnnouncementUser)1 AnnouncementService (ca.corefacility.bioinformatics.irida.service.AnnouncementService)1 UserService (ca.corefacility.bioinformatics.irida.service.user.UserService)1 IOException (java.io.IOException)1 Principal (java.security.Principal)1 Collections (java.util.Collections)1 List (java.util.List)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 Logger (org.slf4j.Logger)1