Search in sources :

Example 6 with Project

use of ca.corefacility.bioinformatics.irida.model.project.Project in project irida by phac-nml.

the class ProjectMembersController method getProjectUserMembers.

/**
 * Get a page of users on the project for display in a DataTable.
 *
 * @param params
 *            the datatables parameters for this DataTable
 * @param projectId
 *            the id of the project we're looking at
 * @return a {@link DataTablesResponseModel} of users on the project
 */
@RequestMapping(value = "/{projectId}/settings/ajax/members")
@ResponseBody
public DataTablesResponse getProjectUserMembers(@DataTablesRequest DataTablesParams params, @PathVariable final Long projectId) {
    final Project project = projectService.read(projectId);
    final Page<Join<Project, User>> usersForProject = userService.searchUsersForProject(project, params.getSearchValue(), params.getCurrentPage(), params.getLength(), params.getSort());
    List<DataTablesResponseModel> modelList = new ArrayList<>();
    for (Join<Project, User> join : usersForProject) {
        modelList.add(new DTProjectMember((ProjectUserJoin) join));
    }
    return new DataTablesResponse(params, usersForProject, modelList);
}
Also used : Project(ca.corefacility.bioinformatics.irida.model.project.Project) User(ca.corefacility.bioinformatics.irida.model.user.User) ProjectUserJoin(ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectUserJoin) DataTablesResponseModel(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.models.DataTablesResponseModel) Join(ca.corefacility.bioinformatics.irida.model.joins.Join) ProjectUserJoin(ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectUserJoin) UserGroupProjectJoin(ca.corefacility.bioinformatics.irida.model.user.group.UserGroupProjectJoin) DataTablesResponse(ca.corefacility.bioinformatics.irida.ria.web.components.datatables.DataTablesResponse) DTProjectMember(ca.corefacility.bioinformatics.irida.ria.web.models.datatables.DTProjectMember)

Example 7 with Project

use of ca.corefacility.bioinformatics.irida.model.project.Project in project irida by phac-nml.

the class ProjectMembersController method addProjectMember.

/**
 * Add a member to a project
 *
 * @param projectId
 *            The ID of the project
 * @param memberId
 *            The ID of the user
 * @param projectRole
 *            The role for the user on the project
 * @param locale
 *            the reported locale of the browser
 * @return map for showing success message.
 */
@RequestMapping(value = "/{projectId}/settings/members", method = RequestMethod.POST)
@ResponseBody
public Map<String, String> addProjectMember(@PathVariable Long projectId, @RequestParam Long memberId, @RequestParam String projectRole, Locale locale) {
    logger.trace("Adding user " + memberId + " to project " + projectId);
    Project project = projectService.read(projectId);
    User user = userService.read(memberId);
    ProjectRole role = ProjectRole.fromString(projectRole);
    projectService.addUserToProject(project, user, role);
    return ImmutableMap.of("result", messageSource.getMessage("project.members.add.success", new Object[] { user.getLabel(), project.getLabel() }, locale));
}
Also used : Project(ca.corefacility.bioinformatics.irida.model.project.Project) User(ca.corefacility.bioinformatics.irida.model.user.User) ProjectRole(ca.corefacility.bioinformatics.irida.model.enums.ProjectRole)

Example 8 with Project

use of ca.corefacility.bioinformatics.irida.model.project.Project in project irida by phac-nml.

the class ProjectMembersController method addProjectGroupMember.

/**
 * Add a group to a project
 *
 * @param projectId
 *            The ID of the project
 * @param memberId
 *            The ID of the user
 * @param projectRole
 *            The role for the user on the project
 * @param locale
 *            the reported locale of the browser
 * @return map for showing success message.
 */
@RequestMapping(value = "/{projectId}/settings/groups", method = RequestMethod.POST)
@ResponseBody
public Map<String, String> addProjectGroupMember(@PathVariable Long projectId, @RequestParam Long memberId, @RequestParam String projectRole, Locale locale) {
    logger.trace("Adding user " + memberId + " to project " + projectId);
    final Project project = projectService.read(projectId);
    final UserGroup userGroup = userGroupService.read(memberId);
    final ProjectRole role = ProjectRole.fromString(projectRole);
    projectService.addUserGroupToProject(project, userGroup, role);
    return ImmutableMap.of("result", messageSource.getMessage("project.members.add.success", new Object[] { userGroup.getLabel(), project.getLabel() }, locale));
}
Also used : Project(ca.corefacility.bioinformatics.irida.model.project.Project) ProjectRole(ca.corefacility.bioinformatics.irida.model.enums.ProjectRole) UserGroup(ca.corefacility.bioinformatics.irida.model.user.group.UserGroup)

Example 9 with Project

use of ca.corefacility.bioinformatics.irida.model.project.Project in project irida by phac-nml.

the class ProjectMembersController method removeUserGroup.

/**
 * Remove a user group from a project
 *
 * @param projectId The project to remove from
 * @param userId    The user to remove
 * @param locale    Locale of the logged in user
 * @return Success or error message
 */
@RequestMapping(path = "{projectId}/settings/groups/{userId}", method = RequestMethod.DELETE)
@ResponseBody
public Map<String, String> removeUserGroup(@PathVariable final Long projectId, @PathVariable final Long userId, final Locale locale) {
    final Project project = projectService.read(projectId);
    final UserGroup userGroup = userGroupService.read(userId);
    try {
        projectService.removeUserGroupFromProject(project, userGroup);
        return ImmutableMap.of("success", messageSource.getMessage("project.members.edit.remove.success", new Object[] { userGroup.getLabel() }, locale));
    } catch (final ProjectWithoutOwnerException e) {
        return ImmutableMap.of("failure", messageSource.getMessage("project.members.edit.remove.nomanager", new Object[] { userGroup.getLabel() }, locale));
    }
}
Also used : Project(ca.corefacility.bioinformatics.irida.model.project.Project) ProjectWithoutOwnerException(ca.corefacility.bioinformatics.irida.exceptions.ProjectWithoutOwnerException) UserGroup(ca.corefacility.bioinformatics.irida.model.user.group.UserGroup)

Example 10 with Project

use of ca.corefacility.bioinformatics.irida.model.project.Project in project irida by phac-nml.

the class ProjectMembersController method getProjectUsersPage.

/**
 * Gets the name of the template for the project members page. Populates the
 * template with standard info.
 *
 * @param model
 *            {@link Model}
 * @param principal
 *            {@link Principal}
 * @param projectId
 *            Id for the project to show the users for
 * @return The name of the project members page.
 */
@RequestMapping("/{projectId}/settings/members")
public String getProjectUsersPage(final Model model, final Principal principal, @PathVariable Long projectId) {
    Project project = projectService.read(projectId);
    model.addAttribute("project", project);
    projectUtils.getProjectTemplateDetails(model, principal, project);
    model.addAttribute("projectRoles", projectRoles);
    model.addAttribute(ProjectsController.ACTIVE_NAV, ProjectSettingsController.ACTIVE_NAV_SETTINGS);
    model.addAttribute("page", "members");
    return "projects/settings/pages/members";
}
Also used : Project(ca.corefacility.bioinformatics.irida.model.project.Project)

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