use of ca.corefacility.bioinformatics.irida.model.project.Project in project irida by phac-nml.
the class AnalysisController method getMetadataTemplatesForAnalysis.
/**
* Get a list of all {@link MetadataTemplate}s for the {@link AnalysisSubmission}
*
* @param submissionId id of the {@link AnalysisSubmission}
* @return a map of {@link MetadataTemplate}s
*/
@RequestMapping("/ajax/{submissionId}/metadata-templates")
@ResponseBody
public Map<String, Object> getMetadataTemplatesForAnalysis(@PathVariable Long submissionId) {
AnalysisSubmission submission = analysisSubmissionService.read(submissionId);
List<Project> projectsUsedInAnalysisSubmission = projectService.getProjectsUsedInAnalysisSubmission(submission);
Set<Long> projectIds = new HashSet<>();
Set<Map<String, Object>> templates = new HashSet<>();
for (Project project : projectsUsedInAnalysisSubmission) {
if (!projectIds.contains(project.getId())) {
projectIds.add(project.getId());
// Get the templates for the project
List<ProjectMetadataTemplateJoin> templateList = metadataTemplateService.getMetadataTemplatesForProject(project);
for (ProjectMetadataTemplateJoin projectMetadataTemplateJoin : templateList) {
MetadataTemplate metadataTemplate = projectMetadataTemplateJoin.getObject();
Map<String, Object> templateMap = ImmutableMap.of("label", metadataTemplate.getLabel(), "id", metadataTemplate.getId());
templates.add(templateMap);
}
}
}
return ImmutableMap.of("templates", templates);
}
use of ca.corefacility.bioinformatics.irida.model.project.Project in project irida by phac-nml.
the class ProjectEventsController method addSubscription.
/**
* Update the subscription status on a {@link Project} for a {@link User}
*
* @param userId
* The {@link User} id to update
* @param projectId
* the {@link Project} to subscribe to
* @param subscribe
* boolean whether to be subscribed to the project or not
* @param locale
* locale of the request
* @return Map success message if the subscription status was updated
*/
@RequestMapping(value = "/projects/{projectId}/subscribe/{userId}", method = RequestMethod.POST)
public Map<String, String> addSubscription(@PathVariable Long userId, @PathVariable Long projectId, @RequestParam boolean subscribe, Locale locale) {
User user = userService.read(userId);
Project project = projectService.read(projectId);
userService.updateEmailSubscription(user, project, subscribe);
String message;
if (subscribe) {
message = messageSource.getMessage("user.projects.subscriptions.added", new Object[] { project.getLabel() }, locale);
} else {
message = messageSource.getMessage("user.projects.subscriptions.removed", new Object[] { project.getLabel() }, locale);
}
return ImmutableMap.of("success", "true", "message", message);
}
use of ca.corefacility.bioinformatics.irida.model.project.Project 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);
}
use of ca.corefacility.bioinformatics.irida.model.project.Project in project irida by phac-nml.
the class ProjectExportController method getExportsPage.
/**
* Get the project export list view
*
* @param projectId which {@link Project} to get exports for
* @param model model for the view
* @param principal The currently logged in user
* @return name of the exports list view
*/
@RequestMapping("/projects/{projectId}/export")
public String getExportsPage(@PathVariable Long projectId, Model model, Principal principal) {
Project project = projectService.read(projectId);
// Set up the template information
projectControllerUtils.getProjectTemplateDetails(model, principal, project);
model.addAttribute("project", project);
model.addAttribute("activeNav", "export");
return EXPORT_LIST_VIEW;
}
use of ca.corefacility.bioinformatics.irida.model.project.Project in project irida by phac-nml.
the class ProjectMembersController method updateUserRole.
/**
* Update a user's role on a project
*
* @param projectId The ID of the project
* @param userId The ID of the user
* @param projectRole The role to set
* @param locale Locale of the logged in user
* @return Success or error message
*/
@RequestMapping(path = "{projectId}/settings/members/editrole/{userId}", method = RequestMethod.POST)
@ResponseBody
public Map<String, String> updateUserRole(@PathVariable final Long projectId, @PathVariable final Long userId, @RequestParam final String projectRole, final Locale locale) {
final Project project = projectService.read(projectId);
final User user = userService.read(userId);
final ProjectRole role = ProjectRole.fromString(projectRole);
final String roleName = messageSource.getMessage("projectRole." + projectRole, new Object[] {}, locale);
try {
projectService.updateUserProjectRole(project, user, role);
return ImmutableMap.of("success", messageSource.getMessage("project.members.edit.role.success", new Object[] { user.getLabel(), roleName }, locale));
} catch (final ProjectWithoutOwnerException e) {
return ImmutableMap.of("failure", messageSource.getMessage("project.members.edit.role.failure.nomanager", new Object[] { user.getLabel(), roleName }, locale));
}
}
Aggregations