use of uk.ac.ebi.spot.goci.model.SecureUser in project goci by EBISPOT.
the class StudyNoteController method viewStudyNotes.
@RequestMapping(value = "/studies/{studyId}/notes", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET)
public String viewStudyNotes(Model model, @PathVariable Long studyId, HttpServletRequest request) {
// get the study
Study study = studyRepository.findOne(studyId);
model.addAttribute("study", study);
SecureUser user = currentUserDetailsService.getUserFromRequest(request);
// an form object mapped from the studyNote object, it contains a list of notes
MultiStudyNoteForm msnf = studyNoteOperationsService.generateMultiStudyNoteForm(study.getNotes(), study, user);
model.addAttribute("multiStudyNoteForm", msnf);
return "study_notes";
}
use of uk.ac.ebi.spot.goci.model.SecureUser in project goci by EBISPOT.
the class StudyNoteController method enableEditNote.
// This will enable save/remove button for a study note and disable all other action for other notes
@RequestMapping(value = "/studies/{studyId}/notes", method = RequestMethod.POST, params = { "editNote" })
public String enableEditNote(Model model, @PathVariable Long studyId, HttpServletRequest req) {
// Index of value to remove
final Integer rowId = Integer.valueOf(req.getParameter("editNote"));
// get the study
Study study = studyRepository.findOne(studyId);
model.addAttribute("study", study);
// get All note subjects for dropdown
// remove subjects including 'Imported from previous system' 'SystemNote'
Collection<NoteSubject> noteSubjects = noteSubjectService.findAvailableNoteSubjectForStudy(study);
model.addAttribute("availableNoteSubject", noteSubjects);
SecureUser user = currentUserDetailsService.getUserFromRequest(req);
// an form object mapped from the studyNote object, it contains a list of notes
MultiStudyNoteForm msnf = studyNoteOperationsService.generateMultiStudyNoteForm(study.getNotes(), study, user);
// enable the edit for the note and disable all edit for other notes
msnf.startEdit(rowId);
model.addAttribute("multiStudyNoteForm", msnf);
return "study_notes";
}
use of uk.ac.ebi.spot.goci.model.SecureUser 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.SecureUser in project goci by EBISPOT.
the class SubmissionController method updateSubmission.
@CrossOrigin
@RequestMapping(value = "/update/{submissionID}", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.PUT)
public ResponseEntity<Submission> updateSubmission(@PathVariable String submissionID, @ModelAttribute Submission submission, Model model, HttpServletRequest request) {
SecureUser currentUser = currentUserDetailsService.getUserFromRequest(request);
submission = submissionService.updateSubmission(submission, currentUser);
ResponseEntity<Submission> response = new ResponseEntity<>(submission, HttpStatus.OK);
return response;
}
use of uk.ac.ebi.spot.goci.model.SecureUser in project goci by EBISPOT.
the class AssociationUploadService method upload.
@Transactional(readOnly = false)
public List<AssociationUploadErrorView> upload(MultipartFile file, Study study, SecureUser user) throws IOException, EnsemblMappingException {
int s = study.getEvents().size();
if (s > 0) {
getLog().trace("Study " + study.getId().toString() + " has " + s + " events");
}
// File errors will contain any validation errors and be returned to controller if any are found
List<AssociationUploadErrorView> fileErrors = new ArrayList<>();
String originalFilename = file.getOriginalFilename();
getLog().info("Uploading file: ".concat(originalFilename));
// Upload file
try {
uploadFile(file, study.getId());
// Send file, including path, to SNP batch loader process
File uploadedFile = studyFileService.getFileFromFileName(study.getId(), originalFilename);
ValidationSummary validationSummary = associationFileUploadService.processAndValidateAssociationFile(uploadedFile, "full");
if (validationSummary != null) {
// Check if we have any row errors
long rowErrorCount = validationSummary.getRowValidationSummaries().parallelStream().filter(rowValidationSummary -> !rowValidationSummary.getErrors().isEmpty()).count();
// Errors found
if (rowErrorCount > 0) {
studyFileService.deleteFile(study.getId(), originalFilename);
getLog().error("Row errors found in file: " + originalFilename);
validationSummary.getRowValidationSummaries().forEach(rowValidationSummary -> fileErrors.addAll(processRowError(rowValidationSummary)));
} else {
// Determine if we have any errors rather than warnings
// Errors prevent saving association
List<ValidationError> allAssociationsErrors = new ArrayList<>();
validationSummary.getAssociationSummaries().forEach(associationSummary -> allAssociationsErrors.addAll(associationSummary.getErrors()));
long associationErrorCount = allAssociationsErrors.parallelStream().filter(validationError -> !validationError.getWarning()).count();
if (associationErrorCount > 0) {
studyFileService.deleteFile(study.getId(), originalFilename);
getLog().error("Association errors found in file: " + originalFilename);
validationSummary.getAssociationSummaries().forEach(associationSummary -> fileErrors.addAll(processAssociationError(associationSummary)));
} else {
Integer numberOfAssociations = validationSummary.getAssociationSummaries().size();
String description = numberOfAssociations.toString().concat(" associations created from upload of '").concat(originalFilename).concat("'");
createBatchUploadEvent(study, description, user);
saveAssociations(validationSummary.getAssociationSummaries(), study, user);
}
}
}
return fileErrors;
} catch (IOException e) {
throw new IOException(e);
}
}
Aggregations