use of ca.corefacility.bioinformatics.irida.ria.web.components.datatables.models.DataTablesResponseModel in project irida by phac-nml.
the class ProjectMembersController method getProjectGroupMembers.
/**
* Get a page of groups on the project for display in a DataTable.
*
* @param params
* the datatables criteria for filtering/sorting groups
* @param projectId
* the id of the project we're looking at
* @return a {@link DataTablesResponseModel} of groups on the project
*/
@RequestMapping(value = "/{projectId}/settings/ajax/groups")
@ResponseBody
public DataTablesResponse getProjectGroupMembers(@DataTablesRequest DataTablesParams params, @PathVariable final Long projectId) {
final Project project = projectService.read(projectId);
final Page<UserGroupProjectJoin> userGroupsForProject = userGroupService.getUserGroupsForProject(params.getSearchValue(), project, params.getCurrentPage(), params.getLength(), params.getSort());
List<DataTablesResponseModel> responseModels = new ArrayList<>();
for (UserGroupProjectJoin userGroupProjectJoin : userGroupsForProject) {
responseModels.add(new DTProjectGroup(userGroupProjectJoin));
}
return new DataTablesResponse(params, userGroupsForProject, responseModels);
}
use of ca.corefacility.bioinformatics.irida.ria.web.components.datatables.models.DataTablesResponseModel in project irida by phac-nml.
the class ProjectSamplesController method getProjectSamples.
/**
* Generate the {@link Sample}s for the {@link Project} table based on the filter criteria.
*
* @param projectId identifier for the current {@link Project}
* @param params for the current DataTable.
* @param sampleNames List of {@link Sample} names to filter by.
* @param associated List of associated {@link Project} identifiers currently displayed in the table.
* @param filter for specific {@link Sample} attributes.
* @param locale for the current user.
* @return {@link DTProjectSamples} that meet the requirements
*/
@RequestMapping(value = "/projects/{projectId}/ajax/samples", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST)
@ResponseBody
public DataTablesResponse getProjectSamples(@PathVariable Long projectId, @DataTablesRequest DataTablesParams params, @RequestParam(required = false, name = "sampleNames[]", defaultValue = "") List<String> sampleNames, @RequestParam(required = false, name = "associated[]", defaultValue = "") List<Long> associated, UISampleFilter filter, Locale locale) {
List<Project> projects = new ArrayList<>();
// Check to see if any associated projects need to be added to the query.
if (!associated.isEmpty()) {
projects = (List<Project>) projectService.readMultiple(associated);
}
// This project is always in the query.
projects.add(projectService.read(projectId));
final Page<ProjectSampleJoin> page = sampleService.getFilteredSamplesForProjects(projects, sampleNames, filter.getName(), params.getSearchValue(), filter.getOrganism(), filter.getStartDate(), filter.getEndDate(), params.getCurrentPage(), params.getLength(), params.getSort());
// Create DataTables representation of the page.
List<DataTablesResponseModel> models = new ArrayList<>();
for (ProjectSampleJoin psj : page.getContent()) {
models.add(buildProjectSampleDataTablesModel(psj, locale));
}
return new DataTablesResponse(params, page, models);
}
use of ca.corefacility.bioinformatics.irida.ria.web.components.datatables.models.DataTablesResponseModel 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);
}
use of ca.corefacility.bioinformatics.irida.ria.web.components.datatables.models.DataTablesResponseModel in project irida by phac-nml.
the class GroupsController method getGroups.
/**
* Search/filter/page with datatables for {@link UserGroup}.
* @param params {@link DataTablesParams} for the current DataTable
* @param principal Currently logged in user
* @return {@link DataTablesResponse} for the current table base on the parameters.
*/
@RequestMapping("/ajax/list")
@ResponseBody
public DataTablesResponse getGroups(@DataTablesRequest final DataTablesParams params, final Principal principal) {
Page<UserGroup> groups = userGroupService.search(UserGroupSpecification.searchUserGroup(params.getSearchValue()), new PageRequest(params.getCurrentPage(), params.getLength(), params.getSort()));
User currentUser = userService.getUserByUsername(principal.getName());
List<DataTablesResponseModel> groupsWithOwnership = groups.getContent().stream().map(ug -> new DTUserGroup(ug, isGroupOwner(currentUser, ug), currentUser.getSystemRole().equals(Role.ROLE_ADMIN))).collect(Collectors.toList());
return new DataTablesResponse(params, groups, groupsWithOwnership);
}
use of ca.corefacility.bioinformatics.irida.ria.web.components.datatables.models.DataTablesResponseModel in project irida by phac-nml.
the class ClientsController method getAjaxClientsList.
/**
* Get a {@link DataTablesResponse} for the Clients page.
*
* @param params
* {@link DataTablesParams} for the current DataTable.
*
* @return {@link DataTablesResponse}
*/
@RequestMapping(value = "/ajax/list", produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public DataTablesResponse getAjaxClientsList(@DataTablesRequest DataTablesParams params) {
Specification<IridaClientDetails> specification = IridaClientDetailsSpecification.searchClient(params.getSearchValue());
Page<IridaClientDetails> page = clientDetailsService.search(specification, new PageRequest(params.getCurrentPage(), params.getLength(), params.getSort()));
List<DataTablesResponseModel> models = new ArrayList<>();
for (IridaClientDetails client : page.getContent()) {
models.add(new DTClient(client, clientDetailsService.countActiveTokensForClient(client)));
}
return new DataTablesResponse(params, page, models);
}
Aggregations