Search in sources :

Example 26 with Project

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";
}
Also used : Project(ca.corefacility.bioinformatics.irida.model.project.Project) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 27 with Project

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";
}
Also used : Project(ca.corefacility.bioinformatics.irida.model.project.Project) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 28 with Project

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;
}
Also used : Project(ca.corefacility.bioinformatics.irida.model.project.Project) User(ca.corefacility.bioinformatics.irida.model.user.User) HashMap(java.util.HashMap) RemoteStatus(ca.corefacility.bioinformatics.irida.model.remote.RemoteStatus) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 29 with Project

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";
}
Also used : Project(ca.corefacility.bioinformatics.irida.model.project.Project) MetadataTemplate(ca.corefacility.bioinformatics.irida.model.sample.MetadataTemplate) ArrayList(java.util.ArrayList) ProjectMetadataTemplateJoin(ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectMetadataTemplateJoin) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 30 with Project

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;
}
Also used : DTProject(ca.corefacility.bioinformatics.irida.ria.web.models.datatables.DTProject) Project(ca.corefacility.bioinformatics.irida.model.project.Project) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

Project (ca.corefacility.bioinformatics.irida.model.project.Project)331 Test (org.junit.Test)190 Sample (ca.corefacility.bioinformatics.irida.model.sample.Sample)120 User (ca.corefacility.bioinformatics.irida.model.user.User)88 WithMockUser (org.springframework.security.test.context.support.WithMockUser)80 ProjectSampleJoin (ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectSampleJoin)71 Join (ca.corefacility.bioinformatics.irida.model.joins.Join)62 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)51 RelatedProjectJoin (ca.corefacility.bioinformatics.irida.model.joins.impl.RelatedProjectJoin)37 ArrayList (java.util.ArrayList)34 ProjectUserJoin (ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectUserJoin)30 SampleSequencingObjectJoin (ca.corefacility.bioinformatics.irida.model.sample.SampleSequencingObjectJoin)30 AnalysisSubmission (ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission)27 ProjectRole (ca.corefacility.bioinformatics.irida.model.enums.ProjectRole)25 ReferenceFile (ca.corefacility.bioinformatics.irida.model.project.ReferenceFile)23 ProjectEvent (ca.corefacility.bioinformatics.irida.model.event.ProjectEvent)22 ProjectAnalysisSubmissionJoin (ca.corefacility.bioinformatics.irida.model.workflow.submission.ProjectAnalysisSubmissionJoin)22 List (java.util.List)22 UserRoleSetProjectEvent (ca.corefacility.bioinformatics.irida.model.event.UserRoleSetProjectEvent)21 ImmutableMap (com.google.common.collect.ImmutableMap)21