use of ca.corefacility.bioinformatics.irida.model.workflow.analysis.Analysis in project irida by phac-nml.
the class AnalysisController method getSharedProjectsForAnalysis.
/**
* Get the status of projects that can be shared with the given analysis
*
* @param submissionId
* the {@link AnalysisSubmission} id
* @return a list of {@link AnalysisController.SharedProjectResponse}
*/
@RequestMapping(value = "/ajax/{submissionId}/share", method = RequestMethod.GET)
@ResponseBody
public List<SharedProjectResponse> getSharedProjectsForAnalysis(@PathVariable Long submissionId) {
AnalysisSubmission submission = analysisSubmissionService.read(submissionId);
// Input files
// - Paired
Set<SequenceFilePair> inputFilePairs = sequencingObjectService.getSequencingObjectsOfTypeForAnalysisSubmission(submission, SequenceFilePair.class);
// get projects already shared with submission
Set<Project> projectsShared = projectService.getProjectsForAnalysisSubmission(submission).stream().map(ProjectAnalysisSubmissionJoin::getSubject).collect(Collectors.toSet());
// get available projects
Set<Project> projectsInAnalysis = projectService.getProjectsForSequencingObjects(inputFilePairs);
List<SharedProjectResponse> projectResponses = projectsShared.stream().map(p -> new SharedProjectResponse(p, true)).collect(Collectors.toList());
// Create response for shared projects
projectResponses.addAll(projectsInAnalysis.stream().filter(p -> !projectsShared.contains(p)).map(p -> new SharedProjectResponse(p, false)).collect(Collectors.toList()));
projectResponses.sort(new Comparator<SharedProjectResponse>() {
@Override
public int compare(SharedProjectResponse p1, SharedProjectResponse p2) {
return p1.getProject().getName().compareTo(p2.getProject().getName());
}
});
return projectResponses;
}
Aggregations