Search in sources :

Example 1 with Project

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);
}
Also used : MetadataTemplate(ca.corefacility.bioinformatics.irida.model.sample.MetadataTemplate) AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) ProjectMetadataTemplateJoin(ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectMetadataTemplateJoin) Project(ca.corefacility.bioinformatics.irida.model.project.Project) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 2 with Project

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

Example 3 with Project

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);
}
Also used : JsonProperty(com.fasterxml.jackson.annotation.JsonProperty) Builder(ca.corefacility.bioinformatics.irida.model.export.NcbiBioSampleFiles.Builder) java.util(java.util) DTExportSubmission(ca.corefacility.bioinformatics.irida.ria.web.models.datatables.DTExportSubmission) NcbiExportSubmission(ca.corefacility.bioinformatics.irida.model.NcbiExportSubmission) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) Controller(org.springframework.stereotype.Controller) ProjectService(ca.corefacility.bioinformatics.irida.service.ProjectService) Value(org.springframework.beans.factory.annotation.Value) Model(org.springframework.ui.Model) DataTablesResponseModel(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.models.DataTablesResponseModel) DataTablesResponse(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesResponse) Sort(org.springframework.data.domain.Sort) NcbiExportSubmissionService(ca.corefacility.bioinformatics.irida.service.export.NcbiExportSubmissionService) SequencingObjectService(ca.corefacility.bioinformatics.irida.service.SequencingObjectService) Logger(org.slf4j.Logger) ImmutableMap(com.google.common.collect.ImmutableMap) DataTablesRequest(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.config.DataTablesRequest) SequenceFilePair(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair) ca.corefacility.bioinformatics.irida.model.export(ca.corefacility.bioinformatics.irida.model.export) Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) SampleSequencingObjectJoin(ca.corefacility.bioinformatics.irida.model.sample.SampleSequencingObjectJoin) Page(org.springframework.data.domain.Page) Collectors(java.util.stream.Collectors) Project(ca.corefacility.bioinformatics.irida.model.project.Project) Principal(java.security.Principal) UserService(ca.corefacility.bioinformatics.irida.service.user.UserService) org.springframework.web.bind.annotation(org.springframework.web.bind.annotation) User(ca.corefacility.bioinformatics.irida.model.user.User) SampleService(ca.corefacility.bioinformatics.irida.service.sample.SampleService) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) DataTablesParams(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesParams) Project(ca.corefacility.bioinformatics.irida.model.project.Project) NcbiExportSubmission(ca.corefacility.bioinformatics.irida.model.NcbiExportSubmission) DTExportSubmission(ca.corefacility.bioinformatics.irida.ria.web.models.datatables.DTExportSubmission) DataTablesResponseModel(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.models.DataTablesResponseModel) DataTablesResponse(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesResponse)

Example 4 with Project

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;
}
Also used : Project(ca.corefacility.bioinformatics.irida.model.project.Project)

Example 5 with Project

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));
    }
}
Also used : Project(ca.corefacility.bioinformatics.irida.model.project.Project) User(ca.corefacility.bioinformatics.irida.model.user.User) ProjectWithoutOwnerException(ca.corefacility.bioinformatics.irida.exceptions.ProjectWithoutOwnerException) ProjectRole(ca.corefacility.bioinformatics.irida.model.enums.ProjectRole)

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