use of ca.corefacility.bioinformatics.irida.model.NcbiExportSubmission in project irida by phac-nml.
the class ExportUploadServiceTest method testUploadSubmissionBadCredentials.
@Test(expected = UploadException.class)
public void testUploadSubmissionBadCredentials() throws UploadException, IOException {
NcbiExportSubmission submission = createFakeSubmission();
String ftpHost = "localhost";
String ftpUser = "test";
String ftpPassword = "password";
String baseDirectory = "/home/test/submit/Test";
FakeFtpServer server = new FakeFtpServer();
// finds an open port
server.setServerControlPort(0);
ExportUploadService exportUploadService = new ExportUploadService(null, null, new TestEmailController());
try {
server.start();
int ftpPort = server.getServerControlPort();
exportUploadService.setConnectionDetails(ftpHost, ftpPort, ftpUser, ftpPassword, baseDirectory);
String xml = "<xml></xml>";
exportUploadService.uploadSubmission(submission, xml);
} finally {
server.stop();
}
}
use of ca.corefacility.bioinformatics.irida.model.NcbiExportSubmission in project irida by phac-nml.
the class NcbiExportSubmissionServceTest method testCreate.
@Test
public void testCreate() {
SingleEndSequenceFile sequenceFile = new SingleEndSequenceFile(new SequenceFile());
NcbiBioSampleFiles ncbiBioSampleFiles = new NcbiBioSampleFiles("sample", Lists.newArrayList(sequenceFile), Lists.newArrayList(), null, "library_name", null, null, null, "library_construction_protocol", "namespace");
NcbiExportSubmission submission = new NcbiExportSubmission(null, null, "bioProjectId", "organization", "ncbiNamespace", new Date(), Lists.newArrayList(ncbiBioSampleFiles));
service.create(submission);
verify(repository).save(submission);
}
use of ca.corefacility.bioinformatics.irida.model.NcbiExportSubmission in project irida by phac-nml.
the class ExportUploadService method launchUpload.
/**
* Check for new {@link NcbiExportSubmission}s to be uploaded and begin
* their upload
*/
public synchronized void launchUpload() {
logger.trace("Getting new exports");
List<NcbiExportSubmission> submissionsWithState = exportSubmissionService.getSubmissionsWithState(ExportUploadState.NEW);
for (NcbiExportSubmission submission : submissionsWithState) {
try {
logger.trace("Updating submission " + submission.getId());
submission.setUploadState(ExportUploadState.UPLOADING);
submission = exportSubmissionService.update(submission);
String xmlContent = createXml(submission);
submission = uploadSubmission(submission, xmlContent);
submission.setUploadState(ExportUploadState.UPLOADED);
submission = exportSubmissionService.update(submission);
} catch (Exception e) {
logger.error("Upload failed", e);
submission.setUploadState(ExportUploadState.UPLOAD_ERROR);
submission = exportSubmissionService.update(submission);
emailController.sendNCBIUploadExceptionEmail(notificationAdminEmail, e, submission.getId());
}
}
}
use of ca.corefacility.bioinformatics.irida.model.NcbiExportSubmission in project irida by phac-nml.
the class ProjectExportController method getDetailsView.
/**
* Get the details view of a given {@link NcbiExportSubmission}
*
* @param projectId
* ID of the {@link Project} the export is for
* @param submissionId
* the {@link NcbiExportSubmission} id
* @param model
* model for the view
* @return name of the details view
*/
@RequestMapping("/projects/{projectId}/export/{submissionId}")
public String getDetailsView(@PathVariable Long projectId, @PathVariable Long submissionId, Model model) {
NcbiExportSubmission submission = exportSubmissionService.read(submissionId);
Project project = projectService.read(projectId);
model.addAttribute("submission", submission);
model.addAttribute("activeNav", "export");
model.addAttribute("project", project);
return EXPORT_DETAILS_VIEW;
}
use of ca.corefacility.bioinformatics.irida.model.NcbiExportSubmission in project irida by phac-nml.
the class ProjectExportController method submitToNcbi.
/**
* Save an NCBI submission to the database
*
* @param projectId
* the ID of the {@link Project} for the submission
* @param submission
* A {@link SubmissionBody} describing the files to upload
* @param principal
* the user submitting the upload
* @return ID of the submission if successful
* @throws InterruptedException
* if thread was not successfully put to sleep
*/
@RequestMapping(value = "/projects/{projectId}/export/ncbi", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> submitToNcbi(@PathVariable Long projectId, @RequestBody SubmissionBody submission, Principal principal) throws InterruptedException {
Project project = projectService.read(projectId);
User submitter = userService.getUserByUsername(principal.getName());
List<NcbiBioSampleFiles> bioSampleFiles = new ArrayList<>();
for (BioSampleBody sample : submission.getSamples()) {
List<SingleEndSequenceFile> singleFiles = new ArrayList<>();
sequencingObjectService.readMultiple(sample.getSingle()).forEach(f -> singleFiles.add((SingleEndSequenceFile) f));
List<SequenceFilePair> paired = new ArrayList<>();
sequencingObjectService.readMultiple(sample.getPaired()).forEach(f -> paired.add((SequenceFilePair) f));
Builder sampleBuilder = new NcbiBioSampleFiles.Builder();
sampleBuilder.bioSample(sample.getBioSample()).files(singleFiles).pairs(paired).instrumentModel(sample.getInstrumentModel()).libraryConstructionProtocol(sample.getLibraryConstructionProtocol()).libraryName(sample.getLibraryName()).librarySelection(sample.getLibrarySelection()).librarySource(sample.getLibrarySource()).libraryStrategy(sample.getLibraryStrategy()).namespace(submission.getNamespace());
NcbiBioSampleFiles build = sampleBuilder.build();
bioSampleFiles.add(build);
}
NcbiExportSubmission ncbiExportSubmission = new NcbiExportSubmission(project, submitter, submission.getBioProject(), submission.getOrganization(), submission.getNamespace(), submission.getReleaseDate(), bioSampleFiles);
ncbiExportSubmission = exportSubmissionService.create(ncbiExportSubmission);
return ImmutableMap.of("submissionId", ncbiExportSubmission.getId());
}
Aggregations