use of ca.corefacility.bioinformatics.irida.model.joins.impl.RelatedProjectJoin in project irida by phac-nml.
the class ProjectServiceImplTest method testRemoveRelatedProject2ProjectArgs.
@Test
public void testRemoveRelatedProject2ProjectArgs() {
Project x = new Project("projectx");
Project y = new Project("projecty");
RelatedProjectJoin join = new RelatedProjectJoin(x, y);
when(relatedProjectRepository.getRelatedProjectJoin(x, y)).thenReturn(join);
projectService.removeRelatedProject(x, y);
verify(relatedProjectRepository).getRelatedProjectJoin(x, y);
verify(relatedProjectRepository).delete(join);
}
use of ca.corefacility.bioinformatics.irida.model.joins.impl.RelatedProjectJoin in project irida by phac-nml.
the class ProjectServiceImplTest method testAddRelatedProject.
@Test
public void testAddRelatedProject() {
Project p1 = new Project("project 1");
Project p2 = new Project("project 2");
RelatedProjectJoin rp = new RelatedProjectJoin(p1, p2);
when(relatedProjectRepository.save(any(RelatedProjectJoin.class))).thenReturn(rp);
RelatedProjectJoin returned = projectService.addRelatedProject(p1, p2);
assertNotNull(returned);
assertEquals(rp, returned);
verify(relatedProjectRepository).save(any(RelatedProjectJoin.class));
}
use of ca.corefacility.bioinformatics.irida.model.joins.impl.RelatedProjectJoin in project irida by phac-nml.
the class ProjectServiceImplTest method testGetRelatedProjects.
@Test
public void testGetRelatedProjects() {
Project p1 = new Project("project 1");
Project p2 = new Project("project 2");
Project p3 = new Project("project 3");
List<RelatedProjectJoin> relatedProjectList = Lists.newArrayList(new RelatedProjectJoin(p1, p2), new RelatedProjectJoin(p1, p3));
when(relatedProjectRepository.getRelatedProjectsForProject(p1)).thenReturn(relatedProjectList);
List<RelatedProjectJoin> relatedProjects = projectService.getRelatedProjects(p1);
assertFalse(relatedProjects.isEmpty());
for (RelatedProjectJoin rp : relatedProjects) {
assertEquals(p1, rp.getSubject());
}
verify(relatedProjectRepository).getRelatedProjectsForProject(p1);
}
use of ca.corefacility.bioinformatics.irida.model.joins.impl.RelatedProjectJoin in project irida by phac-nml.
the class ProjectServiceImpl method removeRelatedProject.
/**
* {@inheritDoc}
*/
@Override
@Transactional
@PreAuthorize("hasRole('ROLE_ADMIN') or hasPermission(#subject,'isProjectOwner')")
public void removeRelatedProject(Project subject, Project relatedProject) {
RelatedProjectJoin relatedProjectJoin = relatedProjectRepository.getRelatedProjectJoin(subject, relatedProject);
removeRelatedProject(relatedProjectJoin);
}
use of ca.corefacility.bioinformatics.irida.model.joins.impl.RelatedProjectJoin in project irida by phac-nml.
the class ProjectSamplesController method getProjectSamplesPage.
/**
* Get the samples for a given project
*
* @param model
* A model for the sample list view
* @param principal
* The user reading the project
* @param projectId
* The ID of the project
* @param httpSession
* The user's session
*
* @return Name of the project samples list view
*/
@RequestMapping(value = { "/projects/{projectId}", "/projects/{projectId}/samples" })
public String getProjectSamplesPage(final Model model, final Principal principal, @PathVariable long projectId, HttpSession httpSession) {
Project project = projectService.read(projectId);
model.addAttribute("project", project);
// Set up the template information
projectControllerUtils.getProjectTemplateDetails(model, principal, project);
// Exporting functionality
boolean haveGalaxyCallbackURL = (httpSession.getAttribute(ProjectsController.GALAXY_CALLBACK_VARIABLE_NAME) != null);
model.addAttribute("linkerAvailable", LINKER_AVAILABLE);
model.addAttribute("galaxyCallback", haveGalaxyCallbackURL);
// Add the associated projects
List<RelatedProjectJoin> associatedJoin = projectService.getRelatedProjects(project);
List<Project> associated = associatedJoin.stream().map(RelatedProjectJoin::getObject).collect(Collectors.toList());
model.addAttribute("associatedProjects", associated);
model.addAttribute(ACTIVE_NAV, ACTIVE_NAV_SAMPLES);
return PROJECT_SAMPLES_PAGE;
}
Aggregations