use of uk.ac.ebi.spot.goci.model.deposition.SubmissionImportProgress in project goci by EBISPOT.
the class SubmissionController method importSubmission.
@CrossOrigin
@RequestMapping(value = "/{submissionID}", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.POST)
public String importSubmission(@PathVariable String submissionID, Model model, HttpServletRequest request, RedirectAttributes redirectAttributes) {
List<String> statusMessages = new ArrayList<>();
List<String> errorMessages = new ArrayList<>();
try {
Map<String, Submission> submissionList = submissionService.getSubmissions();
DepositionSubmission depositionSubmission = submissionService.getSubmission(submissionID);
SecureUser currentUser = currentUserDetailsService.getUserFromRequest(request);
boolean importInProgress = submissionImportProgressService.importInProgress(depositionSubmission.getSubmissionId());
if (importInProgress) {
statusMessages = Arrays.asList(new String[] { "Import is already in progress. Please wait." });
} else {
SubmissionImportProgress submissionImportProgress = submissionImportProgressService.createNewImport(currentUser.getEmail(), depositionSubmission.getSubmissionId());
depositionSubmissionImportService.importSubmission(depositionSubmission, currentUser, submissionImportProgress.getId());
statusMessages = Arrays.asList(new String[] { "Import task has been submitted. You will receive an email when it's done." });
}
model.addAttribute("submissions", submissionList.values());
} catch (Exception e) {
e.printStackTrace();
StringWriter stringWriter = new StringWriter();
e.printStackTrace(new PrintWriter(stringWriter));
errorMessages.add(stringWriter.getBuffer().toString());
}
redirectAttributes.addFlashAttribute("errors", String.join("<br>", errorMessages));
redirectAttributes.addFlashAttribute("changesSaved", String.join("<br>", statusMessages));
return "redirect:/submissions/" + submissionID;
}
use of uk.ac.ebi.spot.goci.model.deposition.SubmissionImportProgress in project goci by EBISPOT.
the class SubmissionImportProgressService method getSubmissions.
public List<String> getSubmissions() {
List<SubmissionImportProgress> submissionImportProgresses = submissionImportProgressRepository.findAll();
List<String> ids = new ArrayList<>();
for (SubmissionImportProgress submissionImportProgress : submissionImportProgresses) {
ids.add(submissionImportProgress.getSubmissionId());
}
return ids;
}
use of uk.ac.ebi.spot.goci.model.deposition.SubmissionImportProgress in project goci by EBISPOT.
the class SubmissionImportProgressService method createNewImport.
public SubmissionImportProgress createNewImport(String userEmail, String submissionId) {
log.info("Creating new import for [{}]: {}", submissionId, userEmail);
SubmissionImportProgress submissionImportProgress = new SubmissionImportProgress(null, Calendar.getInstance().getTime(), submissionId, userEmail);
submissionImportProgress = submissionImportProgressRepository.save(submissionImportProgress);
log.info("Import progress created: {}", submissionImportProgress.getId());
return submissionImportProgress;
}
Aggregations