use of ca.corefacility.bioinformatics.irida.web.assembler.resource.ResourceCollection in project irida by phac-nml.
the class RESTSampleSequenceFilesController method getSampleSequenceFiles.
/**
* Get the {@link SequenceFile} entities associated with a specific
* {@link Sample}.
*
* @param sampleId
* the identifier for the {@link Sample}.
* @return the {@link SequenceFile} entities associated with the
* {@link Sample}.
*/
@RequestMapping(value = "/api/samples/{sampleId}/sequenceFiles", method = RequestMethod.GET)
public ModelMap getSampleSequenceFiles(@PathVariable Long sampleId) {
ModelMap modelMap = new ModelMap();
logger.debug("Reading seq files for sample " + sampleId);
Sample sample = sampleService.read(sampleId);
Collection<SampleSequencingObjectJoin> sequencingObjectsForSample = sequencingObjectService.getSequencingObjectsForSample(sample);
ResourceCollection<SequenceFile> resources = new ResourceCollection<>();
/*
* Note: This is a kind of antiquated seeing we should be referencing
* sequencing objects instead. At the very least the link we're pointing
* to here should be going through the sequencing object
*/
for (SampleSequencingObjectJoin r : sequencingObjectsForSample) {
for (SequenceFile sf : r.getObject().getFiles()) {
String fileLabel = objectLabels.get(r.getObject().getClass());
sf.add(linkTo(methodOn(RESTSampleSequenceFilesController.class).readSequenceFileForSequencingObject(sampleId, fileLabel, r.getObject().getId(), sf.getId())).withSelfRel());
resources.add(sf);
}
}
// add a link to this collection
resources.add(linkTo(methodOn(RESTSampleSequenceFilesController.class).getSampleSequenceFiles(sampleId)).withSelfRel());
// add a link back to the sample
resources.add(linkTo(methodOn(RESTProjectSamplesController.class).getSample(sampleId)).withRel(RESTSampleSequenceFilesController.REL_SAMPLE));
resources.add(linkTo(methodOn(RESTSampleSequenceFilesController.class).listSequencingObjectsOfTypeForSample(sample.getId(), RESTSampleSequenceFilesController.objectLabels.get(SequenceFilePair.class))).withRel(RESTSampleSequenceFilesController.REL_SAMPLE_SEQUENCE_FILE_PAIRS));
resources.add(linkTo(methodOn(RESTSampleSequenceFilesController.class).listSequencingObjectsOfTypeForSample(sample.getId(), RESTSampleSequenceFilesController.objectLabels.get(SingleEndSequenceFile.class))).withRel(RESTSampleSequenceFilesController.REL_SAMPLE_SEQUENCE_FILE_UNPAIRED));
modelMap.addAttribute(RESTGenericController.RESOURCE_NAME, resources);
return modelMap;
}
use of ca.corefacility.bioinformatics.irida.web.assembler.resource.ResourceCollection in project irida by phac-nml.
the class RESTAnalysisSubmissionController method getAnalysisInputUnpairedFiles.
/**
* get the {@link SequenceFile}s not in {@link SequenceFilePair}s used for
* the {@link AnalysisSubmission}
*
* @param identifier
* the {@link AnalysisSubmission} id
* @return list of {@link SequenceFile}s
*/
@RequestMapping("/{identifier}/sequenceFiles/unpaired")
public ModelMap getAnalysisInputUnpairedFiles(@PathVariable Long identifier) {
ModelMap map = new ModelMap();
AnalysisSubmission analysisSubmission = analysisSubmissionService.read(identifier);
Set<SingleEndSequenceFile> inputFilesSingleEnd = sequencingObjectService.getSequencingObjectsOfTypeForAnalysisSubmission(analysisSubmission, SingleEndSequenceFile.class);
ResourceCollection<SequencingObject> resources = new ResourceCollection<>(inputFilesSingleEnd.size());
for (SingleEndSequenceFile file : inputFilesSingleEnd) {
SampleSequencingObjectJoin join = sampleService.getSampleForSequencingObject(file);
if (join != null) {
SequencingObject sequencingObject = join.getObject();
RESTSampleSequenceFilesController.addSequencingObjectLinks(sequencingObject, join.getSubject().getId());
resources.add(sequencingObject);
}
}
resources.add(linkTo(methodOn(RESTAnalysisSubmissionController.class).getAnalysisInputUnpairedFiles(identifier)).withSelfRel());
map.addAttribute(RESTGenericController.RESOURCE_NAME, resources);
return map;
}
use of ca.corefacility.bioinformatics.irida.web.assembler.resource.ResourceCollection in project irida by phac-nml.
the class RESTGenericController method listAllResources.
/**
* Get all resources in the application.
*
* @return a model containing all resources of the specified type in the
* application.
*/
@RequestMapping(method = RequestMethod.GET)
public ModelMap listAllResources() {
Iterable<Type> entities = crudService.findAll();
ResourceCollection<Type> resources = new ResourceCollection<>();
for (Type entity : entities) {
entity.add(constructCustomResourceLinks(entity));
entity.add(linkTo(getClass()).slash(entity.getId()).withSelfRel());
resources.add(entity);
}
resources.add(linkTo(getClass()).withSelfRel());
ModelMap model = new ModelMap();
// get custom links for the collection
Collection<Link> constructCollectionResourceLinks = constructCollectionResourceLinks(resources);
resources.add(constructCollectionResourceLinks);
model.addAttribute(RESTGenericController.RESOURCE_NAME, resources);
return model;
}
use of ca.corefacility.bioinformatics.irida.web.assembler.resource.ResourceCollection in project irida by phac-nml.
the class RESTProjectAnalysisController method getProjectAnalyses.
/**
* Get the list of {@link AnalysisSubmission}s associated with this
* {@link Project}.
*
* @param projectId
* the identifier of the {@link Project} to get the
* {@link AnalysisSubmission}s for.
* @return the list of {@link AnalysisSubmission}s associated with this
* {@link Project}.
*/
@RequestMapping(value = "/api/projects/{projectId}/analyses", method = RequestMethod.GET)
public ModelMap getProjectAnalyses(@PathVariable Long projectId) {
logger.debug("Loading analyses for project [" + projectId + "]");
ModelMap modelMap = new ModelMap();
Project p = projectService.read(projectId);
Collection<AnalysisSubmission> analysisSubmissions = analysisSubmissionService.getAnalysisSubmissionsSharedToProject(p);
ResourceCollection<AnalysisSubmission> analysisResources = new ResourceCollection<>(analysisSubmissions.size());
for (AnalysisSubmission submission : analysisSubmissions) {
submission.add(linkTo(methodOn(RESTAnalysisSubmissionController.class, Long.class).getResource(submission.getId())).withSelfRel());
analysisResources.add(submission);
}
analysisResources.add(linkTo(methodOn(RESTProjectsController.class, Long.class).getResource(projectId)).withRel(PROJECT_REL));
analysisResources.add(linkTo(methodOn(RESTProjectAnalysisController.class, Long.class).getProjectAnalyses(projectId)).withSelfRel());
modelMap.addAttribute(ANALYSIS_RESOURCES, analysisResources);
return modelMap;
}
use of ca.corefacility.bioinformatics.irida.web.assembler.resource.ResourceCollection in project irida by phac-nml.
the class RESTProjectAnalysisController method getProjectAnalysesByType.
/**
* Get the list of {@link AnalysisSubmission}s for this {@link Project} by
* type of analysis.
*
* @param projectId
* The {@link Project} to search.
* @param type
* The analysis type to search for.
* @return A list of {@link AnalysisSubmission}s for the given
* {@link Project} by the given type.
* @throws IridaWorkflowNotFoundException
* If the {@link AnalysisSubmission} is linked to a workflow not
* found in IRIDA.
*/
@RequestMapping(value = "/api/projects/{projectId}/analyses/{type}", method = RequestMethod.GET)
public ModelMap getProjectAnalysesByType(@PathVariable Long projectId, @PathVariable String type) throws IridaWorkflowNotFoundException {
logger.debug("Loading analyses for project [" + projectId + "] by type [" + type + "]");
if (!RESTAnalysisSubmissionController.ANALYSIS_TYPES.containsKey(type)) {
throw new EntityNotFoundException("Analysis type [" + type + "] not found");
}
AnalysisType analysisType = RESTAnalysisSubmissionController.ANALYSIS_TYPES.get(type);
ModelMap modelMap = new ModelMap();
Project p = projectService.read(projectId);
Collection<AnalysisSubmission> analysisSubmissions = analysisSubmissionService.getAnalysisSubmissionsSharedToProject(p);
ResourceCollection<AnalysisSubmission> analysisResources = new ResourceCollection<>(analysisSubmissions.size());
for (AnalysisSubmission submission : analysisSubmissions) {
IridaWorkflow iridaWorkflow = iridaWorkflowsService.getIridaWorkflow(submission.getWorkflowId());
AnalysisType submissionAnalysisType = iridaWorkflow.getWorkflowDescription().getAnalysisType();
if (analysisType.equals(submissionAnalysisType)) {
submission.add(linkTo(methodOn(RESTAnalysisSubmissionController.class, Long.class).getResource(submission.getId())).withSelfRel());
analysisResources.add(submission);
}
}
analysisResources.add(linkTo(methodOn(RESTProjectsController.class, Long.class).getResource(projectId)).withRel(PROJECT_REL));
analysisResources.add(linkTo(methodOn(RESTProjectAnalysisController.class, Long.class).getProjectAnalysesByType(projectId, type)).withSelfRel());
modelMap.addAttribute(ANALYSIS_RESOURCES, analysisResources);
return modelMap;
}
Aggregations