Search in sources :

Example 6 with SecureUser

use of uk.ac.ebi.spot.goci.model.SecureUser in project goci by EBISPOT.

the class MappingService method validateAndMapAllAssociations.

/**
     * Perform validation and mapping of all database associations
     *
     * @param associations Collection of associations to map
     * @param performer    name of curator/job carrying out the mapping
     */
public void validateAndMapAllAssociations(Collection<Association> associations, String performer) throws EnsemblMappingException {
    // Default mapping user
    SecureUser user = secureUserRepository.findByEmail("automatic_mapping_process");
    String eRelease = this.getEnsemblRelease();
    int totalAssociationDone = 1;
    List<Long> associationsFailed = new ArrayList<Long>();
    for (Association association : associations) {
        try {
            getLog().debug("Start doMapping Association nr:" + String.valueOf(totalAssociationDone));
            doMapping(association, eRelease);
            // Update mapping event
            trackingOperationService.update(association, user, "ASSOCIATION_MAPPING");
            // Once mapping is complete, update mapping record
            getLog().debug("Update mapping record");
            mappingRecordService.updateAssociationMappingRecord(association, new Date(), performer);
            totalAssociationDone = totalAssociationDone + 1;
        } catch (EnsemblMappingException e) {
            //throw new EnsemblMappingException("Attempt to map all associations failed", e);
            associationsFailed.add(association.getId());
        }
    }
    getLog().debug("Number of associations FAILED");
    getLog().debug(String.valueOf(associationsFailed.size()));
}
Also used : Association(uk.ac.ebi.spot.goci.model.Association) EnsemblMappingException(uk.ac.ebi.spot.goci.exception.EnsemblMappingException) SecureUser(uk.ac.ebi.spot.goci.model.SecureUser)

Example 7 with SecureUser

use of uk.ac.ebi.spot.goci.model.SecureUser in project goci by EBISPOT.

the class StudyNoteController method saveNote.

@RequestMapping(value = "/studies/{studyId}/notes", method = RequestMethod.POST, params = { "saveNote" })
public String saveNote(@ModelAttribute("multiStudyNoteForm") @Valid MultiStudyNoteForm multiStudyNoteForm, BindingResult bindingResult, Model model, @PathVariable Long studyId, HttpServletRequest req) {
    // Index of value to save
    final Integer rowId = Integer.valueOf(req.getParameter("saveNote"));
    // get the study
    Study study = studyRepository.findOne(studyId);
    model.addAttribute("study", study);
    // the newly added note can only be assigned one of the availlable subject, not including system note subjects.
    Collection<NoteSubject> noteSubjects = noteSubjectService.findAvailableNoteSubjectForStudy(study);
    model.addAttribute("availableNoteSubject", noteSubjects);
    // form validation
    if (bindingResult.hasErrors()) {
        // reload system notes because they are not part of the input
        multiStudyNoteForm.setSystemNoteForms(studyNoteOperationsService.generateSystemNoteForms(study.getNotes()));
        model.addAttribute("availableNoteSubject", noteSubjects);
        model.addAttribute("multiStudyNoteForm", multiStudyNoteForm);
        return "study_notes";
    }
    // convert studynoteform to studynote domain object and save
    StudyNoteForm snf = multiStudyNoteForm.getNomalNoteForms().get(rowId.intValue());
    StudyNote noteToEdit = studyNoteOperationsService.convertToStudyNote(snf, study);
    SecureUser user = currentUserDetailsService.getUserFromRequest(req);
    ErrorNotification notification = studyOperationsService.addStudyNote(study, noteToEdit, user);
    if (!notification.hasErrors()) {
        return "redirect:/studies/" + studyId + "/notes";
    } else {
        // deal with error
        // we want to display the error to the user simply on top of the form
        getLog().warn("Request: " + req.getRequestURL() + " raised an error." + notification.errorMessage());
        model.addAttribute("errors", "Update FAIL! " + notification.errorMessage());
        multiStudyNoteForm.setSystemNoteForms(studyNoteOperationsService.generateSystemNoteForms(study.getNotes()));
        model.addAttribute("availableNoteSubject", noteSubjects);
        model.addAttribute("multiStudyNoteForm", multiStudyNoteForm);
    }
    return "study_notes";
}
Also used : Study(uk.ac.ebi.spot.goci.model.Study) StudyNoteForm(uk.ac.ebi.spot.goci.curation.model.StudyNoteForm) MultiStudyNoteForm(uk.ac.ebi.spot.goci.curation.model.MultiStudyNoteForm) NoteSubject(uk.ac.ebi.spot.goci.model.NoteSubject) StudyNote(uk.ac.ebi.spot.goci.model.StudyNote) SecureUser(uk.ac.ebi.spot.goci.model.SecureUser) ErrorNotification(uk.ac.ebi.spot.goci.curation.model.errors.ErrorNotification) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 8 with SecureUser

use of uk.ac.ebi.spot.goci.model.SecureUser in project goci by EBISPOT.

the class StudyNoteController method addNoteToTable.

@RequestMapping(value = "/studies/{studyId}/notes", method = RequestMethod.POST, params = { "addNote" })
public String addNoteToTable(Model model, @PathVariable Long studyId, HttpServletRequest request) {
    // get the study
    Study study = studyRepository.findOne(studyId);
    model.addAttribute("study", study);
    // disabled the check because we want to add note to the table
    // if(study.getHousekeeping().getIsPublished()){
    // return "redirect:/studies/" + studyId + "/notes";
    // }
    // the newly added note can only be assigned one of the availlable subject, not including system note subjects.
    Collection<NoteSubject> noteSubjects = noteSubjectService.findAvailableNoteSubjectForStudy(study);
    model.addAttribute("availableNoteSubject", noteSubjects);
    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);
    // create a default study note with default setting
    StudyNote emptyNote = studyNoteOperationsService.createEmptyStudyNote(study, user);
    StudyNoteForm emptyNoteForm = studyNoteOperationsService.convertToStudyNoteForm(emptyNote);
    // attach the empty form
    msnf.getNomalNoteForms().add(0, emptyNoteForm);
    // Index of value to add
    // final Integer rowId = msnf.getNomalNoteForms().size()-1;
    // enable the edit for the new note and disable all edit for other notes
    msnf.startEdit(0);
    // reload system notes because they are not part of the input
    msnf.setSystemNoteForms(studyNoteOperationsService.generateSystemNoteForms(study.getNotes()));
    model.addAttribute("multiStudyNoteForm", msnf);
    return "study_notes";
}
Also used : Study(uk.ac.ebi.spot.goci.model.Study) StudyNoteForm(uk.ac.ebi.spot.goci.curation.model.StudyNoteForm) MultiStudyNoteForm(uk.ac.ebi.spot.goci.curation.model.MultiStudyNoteForm) NoteSubject(uk.ac.ebi.spot.goci.model.NoteSubject) MultiStudyNoteForm(uk.ac.ebi.spot.goci.curation.model.MultiStudyNoteForm) SecureUser(uk.ac.ebi.spot.goci.model.SecureUser) StudyNote(uk.ac.ebi.spot.goci.model.StudyNote) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 9 with SecureUser

use of uk.ac.ebi.spot.goci.model.SecureUser in project goci by EBISPOT.

the class StudyNoteController method duplicateNoteAcrossPublication.

@RequestMapping(value = "/studies/{studyId}/notes", method = RequestMethod.POST, params = { "duplicateNote" })
public String duplicateNoteAcrossPublication(Model model, @PathVariable Long studyId, HttpServletRequest req) {
    final Long noteId = Long.valueOf(req.getParameter("duplicateNote"));
    SecureUser user = currentUserDetailsService.getUserFromRequest(req);
    Study study = studyRepository.findOne(studyId);
    ErrorNotification notification = studyOperationsService.duplicateStudyNoteToSiblingStudies(study, noteId, user);
    if (notification.hasErrors()) {
        // we want to display the error to the user simply on top of the form
        getLog().warn("Request: " + req.getRequestURL() + " raised an error." + notification.errorMessage());
        model.addAttribute("errors", "Duplicate FAIL! " + notification.errorMessage());
    // redirectAttributes.addFlashAttribute("errors", "Duplicate FAIL! " + notification.errorMessage());
    // req.setAttribute("errors", "Duplicate FAIL! " + notification.errorMessage());
    }
    return "redirect:/studies/" + studyId + "/notes";
}
Also used : Study(uk.ac.ebi.spot.goci.model.Study) SecureUser(uk.ac.ebi.spot.goci.model.SecureUser) ErrorNotification(uk.ac.ebi.spot.goci.curation.model.errors.ErrorNotification) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

SecureUser (uk.ac.ebi.spot.goci.model.SecureUser)9 Study (uk.ac.ebi.spot.goci.model.Study)6 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)5 MultiStudyNoteForm (uk.ac.ebi.spot.goci.curation.model.MultiStudyNoteForm)4 NoteSubject (uk.ac.ebi.spot.goci.model.NoteSubject)3 ArrayList (java.util.ArrayList)2 StudyNoteForm (uk.ac.ebi.spot.goci.curation.model.StudyNoteForm)2 ErrorNotification (uk.ac.ebi.spot.goci.curation.model.errors.ErrorNotification)2 EnsemblMappingException (uk.ac.ebi.spot.goci.exception.EnsemblMappingException)2 Association (uk.ac.ebi.spot.goci.model.Association)2 StudyNote (uk.ac.ebi.spot.goci.model.StudyNote)2 DepositionSubmission (uk.ac.ebi.spot.goci.model.deposition.DepositionSubmission)2 Submission (uk.ac.ebi.spot.goci.model.deposition.Submission)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 File (java.io.File)1 IOException (java.io.IOException)1 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 Collection (java.util.Collection)1 Iterator (java.util.Iterator)1