use of ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesResponse in project irida by phac-nml.
the class AnalysesListingService method getPagedSubmissions.
/**
* Get a {@link DataTablesResponse} for {@link AnalysisSubmission}s based upon the {@link User}, and the {@link Project}
*
* @param params {@link DataTablesParams}
* @param locale {@link Locale}
* @param user {@link User}
* @param project {@link Project}
* @return {@link DataTablesResponse}
* @throws IridaWorkflowNotFoundException If the requested workflow doesn't exist
* @throws ExecutionManagerException If the submission cannot be read properly
*/
public DataTablesResponse getPagedSubmissions(DataTablesParams params, Locale locale, User user, Project project) throws IridaWorkflowNotFoundException, ExecutionManagerException {
/*
Check the DataTableParams to see if any search conditions are present
*/
Map<String, String> searchMap = params.getSearchMap();
AnalysisState state = searchMap.containsKey("analysisState") ? AnalysisState.valueOf(searchMap.get("analysisState")) : null;
String name = searchMap.getOrDefault("name", null);
/*
Workflow Ids are a special consideration.
The actual ids need to be look up based on the name passed.
*/
Set<UUID> workflowIds = null;
if (searchMap.containsKey("workflow")) {
AnalysisType workflowType = AnalysisType.fromString(searchMap.get("workflow"));
Set<IridaWorkflow> workflows = iridaWorkflowsService.getAllWorkflowsByType(workflowType);
workflowIds = workflows.stream().map(IridaWorkflow::getWorkflowIdentifier).collect(Collectors.toSet());
}
Page<AnalysisSubmission> page;
PageRequest pageRequest = new PageRequest(params.getCurrentPage(), params.getLength(), params.getSort());
if (user != null) {
// if user is set, get submissions for the user
page = analysisSubmissionService.listSubmissionsForUser(params.getSearchValue(), name, state, user, workflowIds, pageRequest);
} else if (project != null) {
// if the project is set, get submissions for the project
page = analysisSubmissionService.listSubmissionsForProject(params.getSearchValue(), name, state, workflowIds, project, pageRequest);
} else {
// if neither is set, get admin page
page = analysisSubmissionService.listAllSubmissions(params.getSearchValue(), name, state, workflowIds, pageRequest);
}
/*
IRIDA DataTables response expects and object that implements the DataTablesResponseModel interface.
*/
List<DataTablesResponseModel> data = new ArrayList<>();
for (AnalysisSubmission submission : page.getContent()) {
// Each AnalysisSubmission needs to be converted into a DTAnalysis.
data.add(createDataTablesAnalysis(submission, locale));
}
return new DataTablesResponse(params, page, data);
}
use of ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesResponse 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.DataTablesResponse 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.DataTablesResponse 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.DataTablesResponse 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);
}
Aggregations