use of ca.corefacility.bioinformatics.irida.model.project.Project in project irida by phac-nml.
the class ProjectSettingsController method getProjectSettingsRemotePage.
/**
* Request for a {@link Project} remote settings page
*
* @param projectId
* the ID of the {@link Project} to read
* @param model
* Model for the view
* @param principal
* Logged in user
*
* @return name of the project remote settings page
*/
@RequestMapping("/remote")
@PreAuthorize("hasPermission(#projectId, 'canManageLocalProjectSettings')")
public String getProjectSettingsRemotePage(@PathVariable Long projectId, final Model model, final Principal principal) {
Project project = projectService.read(projectId);
model.addAttribute("project", project);
model.addAttribute(ProjectsController.ACTIVE_NAV, ACTIVE_NAV_SETTINGS);
model.addAttribute("page", "remote");
model.addAttribute("frequencies", ProjectSyncFrequency.values());
projectControllerUtils.getProjectTemplateDetails(model, principal, project);
return "projects/settings/pages/remote";
}
use of ca.corefacility.bioinformatics.irida.model.project.Project in project irida by phac-nml.
the class ProjectSettingsController method getProjctDeletionPage.
/**
* Request for a {@link Project} deletion page
*
* @param projectId
* the ID of the {@link Project} to read
* @param model
* Model for the view
* @param principal
* Logged in user
*
* @return name of the project deletion page
*/
@RequestMapping("/delete")
@PreAuthorize("hasPermission(#projectId, 'canManageLocalProjectSettings')")
public String getProjctDeletionPage(@PathVariable Long projectId, final Model model, final Principal principal) {
Project project = projectService.read(projectId);
model.addAttribute("project", project);
model.addAttribute(ProjectsController.ACTIVE_NAV, ACTIVE_NAV_SETTINGS);
model.addAttribute("page", "delete");
projectControllerUtils.getProjectTemplateDetails(model, principal, project);
return "projects/settings/pages/delete";
}
use of ca.corefacility.bioinformatics.irida.model.project.Project in project irida by phac-nml.
the class ProjectSettingsController method updateProjectSyncSettings.
/**
* Update the project sync settings
*
* @param projectId
* the project id to update
* @param frequency
* the sync frequency to set
* @param forceSync
* Set the project's sync status to MARKED
* @param changeUser
* update the user on a remote project to the current logged in
* user
* @param principal
* The current logged in user
* @param locale
* user's locale
*
* @return result message if successful
*/
@RequestMapping(value = "/sync", method = RequestMethod.POST)
@ResponseBody
public Map<String, String> updateProjectSyncSettings(@PathVariable Long projectId, @RequestParam(required = false) ProjectSyncFrequency frequency, @RequestParam(required = false, defaultValue = "false") boolean forceSync, @RequestParam(required = false, defaultValue = "false") boolean changeUser, Principal principal, Locale locale) {
Project read = projectService.read(projectId);
RemoteStatus remoteStatus = read.getRemoteStatus();
Map<String, Object> updates = new HashMap<>();
String message = null;
String error = null;
if (frequency != null) {
updates.put("syncFrequency", frequency);
message = messageSource.getMessage("project.settings.notifications.sync", new Object[] {}, locale);
}
if (forceSync) {
remoteStatus.setSyncStatus(SyncStatus.MARKED);
updates.put("remoteStatus", remoteStatus);
message = messageSource.getMessage("project.settings.notifications.sync", new Object[] {}, locale);
}
if (changeUser) {
// ensure the user can read the project
try {
projectRemoteService.read(remoteStatus.getURL());
User user = userService.getUserByUsername(principal.getName());
remoteStatus.setReadBy(user);
updates.put("remoteStatus", remoteStatus);
message = messageSource.getMessage("project.settings.notifications.sync.userchange", new Object[] {}, locale);
} catch (Exception ex) {
error = messageSource.getMessage("project.settings.notifications.sync.userchange.error", new Object[] {}, locale);
}
}
projectService.updateProjectSettings(read, updates);
Map<String, String> response;
if (error == null) {
response = ImmutableMap.of("result", message);
} else {
response = ImmutableMap.of("error", error);
}
return response;
}
use of ca.corefacility.bioinformatics.irida.model.project.Project in project irida by phac-nml.
the class ProjectSettingsController method getSampleMetadataTemplatesPage.
/**
* Request for a {@link Project} remote settings page
*
* @param projectId
* the ID of the {@link Project} to read
* @param model
* Model for the view
* @param principal
* Logged in user
*
* @return name of the project remote settings page
*/
@RequestMapping("/metadata-templates")
public String getSampleMetadataTemplatesPage(@PathVariable Long projectId, final Model model, final Principal principal) {
Project project = projectService.read(projectId);
model.addAttribute("project", project);
projectControllerUtils.getProjectTemplateDetails(model, principal, project);
List<ProjectMetadataTemplateJoin> templateJoins = metadataTemplateService.getMetadataTemplatesForProject(project);
List<MetadataTemplate> templates = new ArrayList<>();
for (ProjectMetadataTemplateJoin join : templateJoins) {
templates.add(join.getObject());
}
model.addAttribute("templates", templates);
model.addAttribute(ProjectsController.ACTIVE_NAV, ACTIVE_NAV_SETTINGS);
model.addAttribute("page", "metadata_templates");
return "projects/settings/pages/metadata_templates";
}
use of ca.corefacility.bioinformatics.irida.model.project.Project in project irida by phac-nml.
the class ProjectsController method getProjectMetadataPage.
/**
* Returns the name of a page to add users to a *new* project.
*
* @param model
* {@link Model}
* @param principal
* a reference to the logged in user.
* @param projectId
* the id of the project to find the metadata for.
*
* @return The name of the add users to new project page.
*/
@RequestMapping("/projects/{projectId}/metadata")
public String getProjectMetadataPage(final Model model, final Principal principal, @PathVariable long projectId) {
Project project = projectService.read(projectId);
model.addAttribute("project", project);
projectControllerUtils.getProjectTemplateDetails(model, principal, project);
model.addAttribute(ACTIVE_NAV, ACTIVE_NAV_METADATA);
return PROJECT_METADATA_PAGE;
}
Aggregations