Search in sources :

Example 1 with DataTablesResponse

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

the class AnnouncementsController method getAnnouncementsAdmin.

/**
 * Get all announcements to be displayed in a DataTables for admin control centre
 *
 * @param params
 * 		{@link DataTablesParams} for the current DataTable.
 *
 * @return {@link DataTablesResponse}
 */
@RequestMapping(value = "/control/ajax/list")
@PreAuthorize("hasRole('ROLE_ADMIN')")
@ResponseBody
public DataTablesResponse getAnnouncementsAdmin(@DataTablesRequest DataTablesParams params) {
    final Page<Announcement> page = announcementService.search(AnnouncementSpecification.searchAnnouncement(params.getSearchValue()), new PageRequest(params.getCurrentPage(), params.getLength(), params.getSort()));
    final List<DataTablesResponseModel> announcements = page.getContent().stream().map(DTAnnouncementAdmin::new).collect(Collectors.toList());
    return new DataTablesResponse(params, page, announcements);
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) Announcement(ca.corefacility.bioinformatics.irida.model.announcements.Announcement) DataTablesResponseModel(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.models.DataTablesResponseModel) 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)

Example 2 with DataTablesResponse

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

the class GroupsController method getGroupUsers.

/**
 * List the members in the group.
 *
 * @param params
 *            the datatables parameters to search for.
 * @param userGroupId
 *            the group ID to get members for.
 * @return the datatables-formatted response with filtered users.
 */
@RequestMapping("/{userGroupId}/ajax/list")
@ResponseBody
public DataTablesResponse getGroupUsers(@DataTablesRequest DataTablesParams params, @PathVariable Long userGroupId) {
    final UserGroup group = userGroupService.read(userGroupId);
    final Page<UserGroupJoin> page = userGroupService.filterUsersByUsername(params.getSearchValue(), group, params.getCurrentPage(), params.getLength(), params.getSort());
    List<DataTablesResponseModel> members = page.getContent().stream().map(DTGroupMember::new).collect(Collectors.toList());
    return new DataTablesResponse(params, page, members);
}
Also used : DataTablesResponseModel(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.models.DataTablesResponseModel) UserGroupJoin(ca.corefacility.bioinformatics.irida.model.user.group.UserGroupJoin) DataTablesResponse(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesResponse) DTUserGroup(ca.corefacility.bioinformatics.irida.ria.web.models.datatables.DTUserGroup) UserGroup(ca.corefacility.bioinformatics.irida.model.user.group.UserGroup)

Example 3 with DataTablesResponse

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

the class UsersController method getAjaxUserList.

/**
 * Get a list of users based on search criteria.
 * @param params {@link DataTablesParams} for the current Users DataTables.
 * @param locale {@link Locale}
 * @return {@link DataTablesResponse} of the filtered users list.
 */
@RequestMapping(value = "/ajax/list", produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public DataTablesResponse getAjaxUserList(@DataTablesRequest DataTablesParams params, Locale locale) {
    Page<User> userPage = userService.search(UserSpecification.searchUser(params.getSearchValue()), new PageRequest(params.getCurrentPage(), params.getLength(), params.getSort()));
    List<DataTablesResponseModel> usersData = new ArrayList<>();
    for (User user : userPage) {
        // getting internationalized system role from the message source
        String roleMessageName = "systemrole." + user.getSystemRole().getName();
        String systemRole = messageSource.getMessage(roleMessageName, null, locale);
        usersData.add(new DTUser(user.getId(), user.getUsername(), user.getFirstName(), user.getLastName(), user.getEmail(), systemRole, user.getCreatedDate(), user.getModifiedDate(), user.getLastLogin()));
    }
    return new DataTablesResponse(params, userPage, usersData);
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) DTUser(ca.corefacility.bioinformatics.irida.ria.web.models.datatables.DTUser) User(ca.corefacility.bioinformatics.irida.model.user.User) DataTablesResponseModel(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.models.DataTablesResponseModel) ArrayList(java.util.ArrayList) DTUser(ca.corefacility.bioinformatics.irida.ria.web.models.datatables.DTUser) DataTablesResponse(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesResponse) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 4 with DataTablesResponse

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

the class ProjectExportController method getExportsForProject.

/**
 * Ajax method for getting the {@link NcbiExportSubmission}s for a given
 * {@link Project}
 *
 * @param projectId {@link Project} id
 * @param params    Parameters from the datatables request
 * @return DatatablesResponse of Map of submission params
 */
@RequestMapping("/ajax/projects/{projectId}/export/list")
@ResponseBody
public DataTablesResponse getExportsForProject(@DataTablesRequest DataTablesParams params, @PathVariable Long projectId) {
    Project project = projectService.read(projectId);
    List<NcbiExportSubmission> submissions = exportSubmissionService.getSubmissionsForProject(project);
    List<DataTablesResponseModel> dtExportSubmissions = submissions.stream().map(s -> new DTExportSubmission(s)).collect(Collectors.toList());
    return new DataTablesResponse(params, submissions.size(), dtExportSubmissions);
}
Also used : JsonProperty(com.fasterxml.jackson.annotation.JsonProperty) Builder(ca.corefacility.bioinformatics.irida.model.export.NcbiBioSampleFiles.Builder) java.util(java.util) DTExportSubmission(ca.corefacility.bioinformatics.irida.ria.web.models.datatables.DTExportSubmission) NcbiExportSubmission(ca.corefacility.bioinformatics.irida.model.NcbiExportSubmission) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) Controller(org.springframework.stereotype.Controller) ProjectService(ca.corefacility.bioinformatics.irida.service.ProjectService) Value(org.springframework.beans.factory.annotation.Value) Model(org.springframework.ui.Model) DataTablesResponseModel(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.models.DataTablesResponseModel) DataTablesResponse(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesResponse) Sort(org.springframework.data.domain.Sort) NcbiExportSubmissionService(ca.corefacility.bioinformatics.irida.service.export.NcbiExportSubmissionService) SequencingObjectService(ca.corefacility.bioinformatics.irida.service.SequencingObjectService) Logger(org.slf4j.Logger) ImmutableMap(com.google.common.collect.ImmutableMap) DataTablesRequest(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.config.DataTablesRequest) SequenceFilePair(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair) ca.corefacility.bioinformatics.irida.model.export(ca.corefacility.bioinformatics.irida.model.export) Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) SampleSequencingObjectJoin(ca.corefacility.bioinformatics.irida.model.sample.SampleSequencingObjectJoin) Page(org.springframework.data.domain.Page) Collectors(java.util.stream.Collectors) Project(ca.corefacility.bioinformatics.irida.model.project.Project) Principal(java.security.Principal) UserService(ca.corefacility.bioinformatics.irida.service.user.UserService) org.springframework.web.bind.annotation(org.springframework.web.bind.annotation) User(ca.corefacility.bioinformatics.irida.model.user.User) SampleService(ca.corefacility.bioinformatics.irida.service.sample.SampleService) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) DataTablesParams(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesParams) Project(ca.corefacility.bioinformatics.irida.model.project.Project) NcbiExportSubmission(ca.corefacility.bioinformatics.irida.model.NcbiExportSubmission) DTExportSubmission(ca.corefacility.bioinformatics.irida.ria.web.models.datatables.DTExportSubmission) DataTablesResponseModel(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.models.DataTablesResponseModel) DataTablesResponse(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesResponse)

Example 5 with DataTablesResponse

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

the class ProjectMembersController method getProjectUserMembers.

/**
 * Get a page of users on the project for display in a DataTable.
 *
 * @param params
 *            the datatables parameters for this DataTable
 * @param projectId
 *            the id of the project we're looking at
 * @return a {@link DataTablesResponseModel} of users on the project
 */
@RequestMapping(value = "/{projectId}/settings/ajax/members")
@ResponseBody
public DataTablesResponse getProjectUserMembers(@DataTablesRequest DataTablesParams params, @PathVariable final Long projectId) {
    final Project project = projectService.read(projectId);
    final Page<Join<Project, User>> usersForProject = userService.searchUsersForProject(project, params.getSearchValue(), params.getCurrentPage(), params.getLength(), params.getSort());
    List<DataTablesResponseModel> modelList = new ArrayList<>();
    for (Join<Project, User> join : usersForProject) {
        modelList.add(new DTProjectMember((ProjectUserJoin) join));
    }
    return new DataTablesResponse(params, usersForProject, modelList);
}
Also used : Project(ca.corefacility.bioinformatics.irida.model.project.Project) User(ca.corefacility.bioinformatics.irida.model.user.User) ProjectUserJoin(ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectUserJoin) DataTablesResponseModel(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.models.DataTablesResponseModel) Join(ca.corefacility.bioinformatics.irida.model.joins.Join) ProjectUserJoin(ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectUserJoin) UserGroupProjectJoin(ca.corefacility.bioinformatics.irida.model.user.group.UserGroupProjectJoin) DataTablesResponse(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesResponse) DTProjectMember(ca.corefacility.bioinformatics.irida.ria.web.models.datatables.DTProjectMember)

Aggregations

DataTablesResponse (ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesResponse)22 DataTablesResponseModel (ca.corefacility.bioinformatics.irida.ria.web.components.datatables.models.DataTablesResponseModel)16 DataTablesParams (ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesParams)13 Sort (org.springframework.data.domain.Sort)11 Project (ca.corefacility.bioinformatics.irida.model.project.Project)8 Test (org.junit.Test)8 PageRequest (org.springframework.data.domain.PageRequest)8 User (ca.corefacility.bioinformatics.irida.model.user.User)7 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)6 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)6 DataTablesRequest (ca.corefacility.bioinformatics.irida.ria.web.components.datatables.config.DataTablesRequest)4 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)4 ProjectSampleJoin (ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectSampleJoin)3 UserService (ca.corefacility.bioinformatics.irida.service.user.UserService)3 ImmutableMap (com.google.common.collect.ImmutableMap)3 Collectors (java.util.stream.Collectors)3 Autowired (org.springframework.beans.factory.annotation.Autowired)3 Page (org.springframework.data.domain.Page)3 Controller (org.springframework.stereotype.Controller)3 Model (org.springframework.ui.Model)3