Search in sources :

Example 1 with MappingDetails

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

the class AssociationController method validateUnapproved.

/**
     -     * Run mapping pipeline on all SNPs in a study
     -     *
     -     * @param studyId            Study ID in database
     -     * @param redirectAttributes attributes for a redirect scenario
     -     */
@RequestMapping(value = "/studies/{studyId}/associations/validate_unapproved", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET)
public String validateUnapproved(@PathVariable Long studyId, RedirectAttributes redirectAttributes, Model model, HttpServletRequest request) throws //                                         @RequestParam(required = false) Long associationId)
EnsemblMappingException {
    Study study = studyRepository.findOne(studyId);
    // For the study get all associations
    Collection<Association> studyAssociations = associationRepository.findByStudyId(studyId);
    for (Association associationToValidate : studyAssociations) {
        if (!associationToValidate.getSnpApproved()) {
            String measurementType = associationOperationsService.determineIfAssociationIsOrType(associationToValidate);
            List<AssociationValidationView> criticalErrors = new ArrayList<>();
            if (associationToValidate.getSnpInteraction()) {
                criticalErrors = associationOperationsService.checkSnpAssociationInteractionFormErrors((SnpAssociationInteractionForm) associationOperationsService.generateForm(associationToValidate), measurementType);
            } else {
                criticalErrors = associationOperationsService.checkSnpAssociationFormErrors((SnpAssociationStandardMultiForm) associationOperationsService.generateForm(associationToValidate), measurementType);
            }
            //if an association has critical errors, go straight to that association
            if (!criticalErrors.isEmpty()) {
                model.addAttribute("study", study);
                model.addAttribute("measurementType", measurementType);
                // Get mapping details
                model.addAttribute("mappingDetails", associationOperationsService.createMappingDetails(associationToValidate));
                // Return any association errors
                model.addAttribute("errors", criticalErrors);
                model.addAttribute("criticalErrorsFound", true);
                if (associationToValidate.getSnpInteraction()) {
                    model.addAttribute("form", associationOperationsService.generateForm(associationToValidate));
                    return "redirect:/associations/" + associationToValidate.getId();
                // return "edit_snp_interaction_association";
                } else {
                    model.addAttribute("form", associationOperationsService.generateForm(associationToValidate));
                    // Determine view
                    if (associationToValidate.getMultiSnpHaplotype()) {
                        return "redirect:/associations/" + associationToValidate.getId();
                    // return "edit_multi_snp_association";
                    } else {
                        //                             return "edit_standard_snp_association";
                        return "redirect:/associations/" + associationToValidate.getId();
                    }
                }
            } else //     if there are no criticial errors, save the validation and go to the next association
            {
                // Save and validate form
                String eRelease = ensemblRestTemplateService.getRelease();
                Collection<AssociationValidationView> errors = associationOperationsService.validateAndSaveAssociation(study, associationToValidate, currentUserDetailsService.getUserFromRequest(request), eRelease);
                // Determine if we have any errors rather than warnings
                long errorCount = errors.stream().filter(validationError -> !validationError.getWarning()).count();
                //if there are errors rather than warnings, go straight to the page to edit
                if (errorCount > 0) {
                    model.addAttribute("study", study);
                    model.addAttribute("measurementType", measurementType);
                    // Get mapping details for association we're editing
                    model.addAttribute("mappingDetails", associationOperationsService.createMappingDetails(associationToValidate));
                    model.addAttribute("errors", errors);
                    model.addAttribute("criticalErrorsFound", true);
                    if (associationToValidate.getSnpInteraction()) {
                        model.addAttribute("form", associationOperationsService.generateForm(associationToValidate));
                        //                              return "edit_snp_interaction_association";
                        return "redirect:/associations/" + associationToValidate.getId();
                    } else {
                        model.addAttribute("form", associationOperationsService.generateForm(associationToValidate));
                        // Determine view
                        if (associationToValidate.getMultiSnpHaplotype()) {
                            //                                  return "edit_multi_snp_association";
                            return "redirect:/associations/" + associationToValidate.getId();
                        } else {
                            //                                  return "edit_standard_snp_association";
                            return "redirect:/associations/" + associationToValidate.getId();
                        }
                    }
                }
            }
        }
    }
    String message = "Mapping complete, please check for any errors displayed in the 'Errors' column";
    redirectAttributes.addFlashAttribute("mappingComplete", message);
    return "redirect:/studies/" + studyId + "/associations";
}
Also used : FileUploadException(uk.ac.ebi.spot.goci.curation.exception.FileUploadException) java.util(java.util) SnpAssociationTableView(uk.ac.ebi.spot.goci.curation.model.SnpAssociationTableView) LoggerFactory(org.slf4j.LoggerFactory) SnpAssociationInteractionForm(uk.ac.ebi.spot.goci.curation.model.SnpAssociationInteractionForm) Autowired(org.springframework.beans.factory.annotation.Autowired) SimpleDateFormat(java.text.SimpleDateFormat) BindingResult(org.springframework.validation.BindingResult) Controller(org.springframework.stereotype.Controller) SnpAssociationStandardMultiForm(uk.ac.ebi.spot.goci.curation.model.SnpAssociationStandardMultiForm) EfoTraitRepository(uk.ac.ebi.spot.goci.repository.EfoTraitRepository) Value(org.springframework.beans.factory.annotation.Value) Valid(javax.validation.Valid) Model(org.springframework.ui.Model) uk.ac.ebi.spot.goci.curation.service(uk.ac.ebi.spot.goci.curation.service) HttpServletRequest(javax.servlet.http.HttpServletRequest) uk.ac.ebi.spot.goci.model(uk.ac.ebi.spot.goci.model) Qualifier(org.springframework.beans.factory.annotation.Qualifier) StudyRepository(uk.ac.ebi.spot.goci.repository.StudyRepository) Sort(org.springframework.data.domain.Sort) EnsemblRestTemplateService(uk.ac.ebi.spot.goci.service.EnsemblRestTemplateService) DateFormat(java.text.DateFormat) RedirectAttributes(org.springframework.web.servlet.mvc.support.RedirectAttributes) DataIntegrityException(uk.ac.ebi.spot.goci.curation.exception.DataIntegrityException) Logger(org.slf4j.Logger) AssociationRepository(uk.ac.ebi.spot.goci.repository.AssociationRepository) MediaType(org.springframework.http.MediaType) HttpServletResponse(javax.servlet.http.HttpServletResponse) SnpAssociationForm(uk.ac.ebi.spot.goci.curation.model.SnpAssociationForm) EnsemblMappingException(uk.ac.ebi.spot.goci.exception.EnsemblMappingException) SheetProcessingException(uk.ac.ebi.spot.goci.exception.SheetProcessingException) IOException(java.io.IOException) SnpFormColumn(uk.ac.ebi.spot.goci.curation.model.SnpFormColumn) AssociationUploadErrorView(uk.ac.ebi.spot.goci.curation.model.AssociationUploadErrorView) FileNotFoundException(java.io.FileNotFoundException) MapCatalogService(uk.ac.ebi.spot.goci.service.MapCatalogService) GetRequest(com.mashape.unirest.request.GetRequest) SnpFormRow(uk.ac.ebi.spot.goci.curation.model.SnpFormRow) WebDataBinder(org.springframework.web.bind.WebDataBinder) org.springframework.web.bind.annotation(org.springframework.web.bind.annotation) LastViewedAssociation(uk.ac.ebi.spot.goci.curation.model.LastViewedAssociation) MultipartFile(org.springframework.web.multipart.MultipartFile) AssociationValidationView(uk.ac.ebi.spot.goci.curation.model.AssociationValidationView) MappingDetails(uk.ac.ebi.spot.goci.curation.model.MappingDetails) LastViewedAssociation(uk.ac.ebi.spot.goci.curation.model.LastViewedAssociation) SnpAssociationStandardMultiForm(uk.ac.ebi.spot.goci.curation.model.SnpAssociationStandardMultiForm) AssociationValidationView(uk.ac.ebi.spot.goci.curation.model.AssociationValidationView) SnpAssociationInteractionForm(uk.ac.ebi.spot.goci.curation.model.SnpAssociationInteractionForm)

Example 2 with MappingDetails

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

the class AssociationController method viewAssociation.

/* Existing association information */
// View association information
@RequestMapping(value = "/associations/{associationId}", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET)
public String viewAssociation(Model model, @PathVariable Long associationId) {
    // Return association with that ID
    Association associationToView = associationRepository.findOne(associationId);
    // Get mapping details
    MappingDetails mappingDetails = associationOperationsService.createMappingDetails(associationToView);
    model.addAttribute("mappingDetails", mappingDetails);
    // Return any association errors
    model.addAttribute("errors", associationValidationReportService.generateAssociationWarningsListView(associationId));
    // Establish study
    Long studyId = associationToView.getStudy().getId();
    // Also passes back study object to view so we can create links back to main study page
    model.addAttribute("study", studyRepository.findOne(studyId));
    // Determine if association is an OR or BETA type
    String measurementType = associationOperationsService.determineIfAssociationIsOrType(associationToView);
    model.addAttribute("measurementType", measurementType);
    // Determine form to return
    SnpAssociationForm form = associationOperationsService.generateForm(associationToView);
    model.addAttribute("form", form);
    // Determine page to return
    if (associationToView.getSnpInteraction() != null && associationToView.getSnpInteraction()) {
        return "edit_snp_interaction_association";
    } else if (associationToView.getMultiSnpHaplotype() != null && associationToView.getMultiSnpHaplotype()) {
        return "edit_multi_snp_association";
    } else {
        return "edit_standard_snp_association";
    }
}
Also used : LastViewedAssociation(uk.ac.ebi.spot.goci.curation.model.LastViewedAssociation) SnpAssociationForm(uk.ac.ebi.spot.goci.curation.model.SnpAssociationForm) MappingDetails(uk.ac.ebi.spot.goci.curation.model.MappingDetails) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with MappingDetails

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

the class AssociationController method addColEditMode.

// Add single column to table
@RequestMapping(value = "/associations/{associationId}", params = { "addCol" })
public String addColEditMode(SnpAssociationInteractionForm snpAssociationInteractionForm, Model model, @PathVariable Long associationId) {
    snpAssociationInteractionForm.getSnpFormColumns().add(new SnpFormColumn());
    // Pass back updated form
    model.addAttribute("form", snpAssociationInteractionForm);
    // Also passes back study object to view so we can create links back to main study page
    Association currentAssociation = associationRepository.findOne(associationId);
    Study associationStudy = currentAssociation.getStudy();
    Long studyId = associationStudy.getId();
    model.addAttribute("study", studyRepository.findOne(studyId));
    // Determine if association is an OR or BETA type
    String measurementType = associationOperationsService.determineIfAssociationIsOrType(currentAssociation);
    model.addAttribute("measurementType", measurementType);
    // Get mapping details
    MappingDetails mappingDetails = associationOperationsService.createMappingDetails(currentAssociation);
    model.addAttribute("mappingDetails", mappingDetails);
    // Return any association errors
    model.addAttribute("errors", associationValidationReportService.generateAssociationWarningsListView(associationId));
    return "edit_snp_interaction_association";
}
Also used : LastViewedAssociation(uk.ac.ebi.spot.goci.curation.model.LastViewedAssociation) MappingDetails(uk.ac.ebi.spot.goci.curation.model.MappingDetails) SnpFormColumn(uk.ac.ebi.spot.goci.curation.model.SnpFormColumn) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with MappingDetails

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

the class AssociationController method performValidation.

@Async
private void performValidation(Model model, HttpSession session, Study study, SecureUser user) {
    Future<Boolean> future = executorService.submit(() -> {
        Collection<Association> studyAssociations = associationService.findAllByStudyId(study.getId());
        for (Association associationToValidate : studyAssociations) {
            if (!associationToValidate.getSnpApproved()) {
                String measurementType = associationOperationsService.determineIfAssociationIsOrType(associationToValidate);
                List<AssociationValidationView> criticalErrors = new ArrayList<>();
                if (associationToValidate.getSnpInteraction()) {
                    criticalErrors = associationOperationsService.checkSnpAssociationInteractionFormErrorsForView((SnpAssociationInteractionForm) associationOperationsService.generateForm(associationToValidate), measurementType);
                } else {
                    criticalErrors = associationOperationsService.checkSnpAssociationFormErrors((SnpAssociationStandardMultiForm) associationOperationsService.generateForm(associationToValidate), measurementType);
                }
                // if an association has critical errors, go straight to that association
                if (!criticalErrors.isEmpty()) {
                    session.setAttribute("measurementType", measurementType);
                    // Get mapping details
                    session.setAttribute("mappingDetails", associationOperationsService.createMappingDetails(associationToValidate));
                    // Return any association errors
                    session.setAttribute("errors", criticalErrors);
                    session.setAttribute("criticalErrorsFound", true);
                    session.setAttribute("associationId", associationToValidate.getId());
                    break;
                } else // if there are no criticial errors, save the validation and go to the next association
                {
                    // Save and validate form
                    String eRelease = ensemblRestTemplateService.getRelease();
                    Collection<AssociationValidationView> errors = associationOperationsService.validateAndSaveAssociation(study, associationToValidate, user, eRelease);
                    // Determine if we have any errors rather than warnings
                    long errorCount = errors.stream().filter(validationError -> !validationError.getWarning()).count();
                    // if there are errors rather than warnings, go straight to the page to edit
                    if (errorCount > 0) {
                        session.setAttribute("study", study);
                        session.setAttribute("measurementType", measurementType);
                        // Get mapping details for association we're editing
                        session.setAttribute("mappingDetails", associationOperationsService.createMappingDetails(associationToValidate));
                        session.setAttribute("errors", errors);
                        session.setAttribute("criticalErrorsFound", true);
                        session.setAttribute("associationId", associationToValidate.getId());
                        break;
                    }
                }
            }
        }
        session.setAttribute("done", true);
        return true;
    });
    session.setAttribute("future", future);
}
Also used : PathVariable(org.springframework.web.bind.annotation.PathVariable) RequestParam(org.springframework.web.bind.annotation.RequestParam) CheckMappingService(uk.ac.ebi.spot.goci.curation.service.CheckMappingService) LoggerFactory(org.slf4j.LoggerFactory) SnpAssociationInteractionForm(uk.ac.ebi.spot.goci.curation.model.SnpAssociationInteractionForm) Autowired(org.springframework.beans.factory.annotation.Autowired) Valid(javax.validation.Valid) AssociationOperationsService(uk.ac.ebi.spot.goci.curation.service.AssociationOperationsService) PreDestroy(javax.annotation.PreDestroy) Model(org.springframework.ui.Model) Future(java.util.concurrent.Future) AssociationDeletionService(uk.ac.ebi.spot.goci.curation.service.AssociationDeletionService) uk.ac.ebi.spot.goci.model(uk.ac.ebi.spot.goci.model) StudyRepository(uk.ac.ebi.spot.goci.repository.StudyRepository) Pageable(org.springframework.data.domain.Pageable) Sort(org.springframework.data.domain.Sort) EnsemblRestTemplateService(uk.ac.ebi.spot.goci.service.EnsemblRestTemplateService) DateFormat(java.text.DateFormat) RedirectAttributes(org.springframework.web.servlet.mvc.support.RedirectAttributes) HttpSession(javax.servlet.http.HttpSession) MediaType(org.springframework.http.MediaType) EventsViewService(uk.ac.ebi.spot.goci.curation.service.EventsViewService) PageRequest(org.springframework.data.domain.PageRequest) RequestMethod(org.springframework.web.bind.annotation.RequestMethod) Page(org.springframework.data.domain.Page) SnpFormColumn(uk.ac.ebi.spot.goci.curation.model.SnpFormColumn) AssociationUploadErrorView(uk.ac.ebi.spot.goci.curation.model.AssociationUploadErrorView) FileNotFoundException(java.io.FileNotFoundException) Executors(java.util.concurrent.Executors) SingleSnpMultiSnpAssociationService(uk.ac.ebi.spot.goci.curation.service.SingleSnpMultiSnpAssociationService) SnpAssociationTableViewService(uk.ac.ebi.spot.goci.curation.service.SnpAssociationTableViewService) LastViewedAssociation(uk.ac.ebi.spot.goci.curation.model.LastViewedAssociation) SnpInteractionAssociationService(uk.ac.ebi.spot.goci.curation.service.SnpInteractionAssociationService) InitBinder(org.springframework.web.bind.annotation.InitBinder) CurrentUserDetailsService(uk.ac.ebi.spot.goci.curation.service.CurrentUserDetailsService) FileUploadException(uk.ac.ebi.spot.goci.curation.exception.FileUploadException) Async(org.springframework.scheduling.annotation.Async) java.util(java.util) SnpAssociationTableView(uk.ac.ebi.spot.goci.curation.model.SnpAssociationTableView) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) SimpleDateFormat(java.text.SimpleDateFormat) BindingResult(org.springframework.validation.BindingResult) Callable(java.util.concurrent.Callable) Controller(org.springframework.stereotype.Controller) SnpAssociationStandardMultiForm(uk.ac.ebi.spot.goci.curation.model.SnpAssociationStandardMultiForm) EfoTraitRepository(uk.ac.ebi.spot.goci.repository.EfoTraitRepository) AssociationService(uk.ac.ebi.spot.goci.service.AssociationService) Value(org.springframework.beans.factory.annotation.Value) AssociationValidationReportService(uk.ac.ebi.spot.goci.curation.service.AssociationValidationReportService) HttpServletRequest(javax.servlet.http.HttpServletRequest) ModelAttribute(org.springframework.web.bind.annotation.ModelAttribute) Qualifier(org.springframework.beans.factory.annotation.Qualifier) ExceptionHandler(org.springframework.web.bind.annotation.ExceptionHandler) ExecutorService(java.util.concurrent.ExecutorService) DataIntegrityException(uk.ac.ebi.spot.goci.curation.exception.DataIntegrityException) Logger(org.slf4j.Logger) AssociationUploadService(uk.ac.ebi.spot.goci.curation.service.AssociationUploadService) AssociationRepository(uk.ac.ebi.spot.goci.repository.AssociationRepository) HttpServletResponse(javax.servlet.http.HttpServletResponse) SnpAssociationForm(uk.ac.ebi.spot.goci.curation.model.SnpAssociationForm) EnsemblMappingException(uk.ac.ebi.spot.goci.exception.EnsemblMappingException) SheetProcessingException(uk.ac.ebi.spot.goci.exception.SheetProcessingException) IOException(java.io.IOException) CheckEfoTermAssignmentService(uk.ac.ebi.spot.goci.curation.service.CheckEfoTermAssignmentService) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) StudyAssociationBatchDeletionEventService(uk.ac.ebi.spot.goci.curation.service.StudyAssociationBatchDeletionEventService) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) MapCatalogService(uk.ac.ebi.spot.goci.service.MapCatalogService) SnpFormRow(uk.ac.ebi.spot.goci.curation.model.SnpFormRow) WebDataBinder(org.springframework.web.bind.WebDataBinder) MultipartFile(org.springframework.web.multipart.MultipartFile) AssociationDownloadService(uk.ac.ebi.spot.goci.curation.service.AssociationDownloadService) AssociationValidationView(uk.ac.ebi.spot.goci.curation.model.AssociationValidationView) MappingDetails(uk.ac.ebi.spot.goci.curation.model.MappingDetails) AssociationValidationView(uk.ac.ebi.spot.goci.curation.model.AssociationValidationView) SnpAssociationInteractionForm(uk.ac.ebi.spot.goci.curation.model.SnpAssociationInteractionForm) LastViewedAssociation(uk.ac.ebi.spot.goci.curation.model.LastViewedAssociation) SnpAssociationStandardMultiForm(uk.ac.ebi.spot.goci.curation.model.SnpAssociationStandardMultiForm) Async(org.springframework.scheduling.annotation.Async)

Example 5 with MappingDetails

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

the class AssociationController method editAssociation.

// Edit existing association
// We tried to remap if the snp or genes changed.
// TODO : implement something for SNP:SNP iteration. Actually we remap.
@RequestMapping(value = "/associations/{associationId}", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.POST)
public // TODO COULD REFACTOR TO JUST USE SUPERCLASS AS METHOD PARAMETER
String editAssociation(@ModelAttribute SnpAssociationStandardMultiForm snpAssociationStandardMultiForm, @ModelAttribute SnpAssociationInteractionForm snpAssociationInteractionForm, @PathVariable Long associationId, @RequestParam(value = "associationtype", required = true) String associationType, Model model, HttpServletRequest request, RedirectAttributes redirectAttributes) throws EnsemblMappingException {
    // Establish study and association we are editing
    Collection<String> previousAuthorReportedGenes = new HashSet<>();
    Collection<String> authorReportedGenes = new HashSet<>();
    Collection<String> previousSnps = new HashSet<>();
    Collection<String> snps = new HashSet<>();
    String isToRemapping = "yes";
    Association associationToEdit = associationRepository.findOne(associationId);
    Long studyId = associationToEdit.getStudy().getId();
    Study study = studyRepository.findOne(studyId);
    model.addAttribute("study", study);
    AssociationReport oldAssociationReport = associationToEdit.getAssociationReport();
    previousAuthorReportedGenes = associationOperationsService.getGenesIds(associationToEdit.getLoci());
    previousSnps = associationOperationsService.getSpnsName(associationToEdit.getSnps());
    // Determine if association is an OR or BETA type
    String measurementType = associationOperationsService.determineIfAssociationIsOrType(associationToEdit);
    model.addAttribute("measurementType", measurementType);
    // Validate returned form depending on association type
    List<AssociationValidationView> criticalErrors = new ArrayList<>();
    if (associationType.equalsIgnoreCase("interaction")) {
        criticalErrors = associationOperationsService.checkSnpAssociationInteractionFormErrorsForView(snpAssociationInteractionForm, measurementType);
    } else {
        criticalErrors = associationOperationsService.checkSnpAssociationFormErrors(snpAssociationStandardMultiForm, measurementType);
    }
    // If errors found then return the edit form with all information entered by curator preserved
    if (!criticalErrors.isEmpty()) {
        // Get mapping details
        model.addAttribute("mappingDetails", associationOperationsService.createMappingDetails(associationToEdit));
        // Return any association errors
        model.addAttribute("errors", criticalErrors);
        model.addAttribute("criticalErrorsFound", true);
        if (associationType.equalsIgnoreCase("interaction")) {
            model.addAttribute("form", snpAssociationInteractionForm);
            return "edit_snp_interaction_association";
        } else {
            model.addAttribute("form", snpAssociationStandardMultiForm);
            // Determine view
            if (associationToEdit.getMultiSnpHaplotype()) {
                return "edit_multi_snp_association";
            } else {
                return "edit_standard_snp_association";
            }
        }
    } else {
        // Create association
        Association editedAssociation;
        // Request parameter determines how to process form and also which form to process
        if (associationType.equalsIgnoreCase("interaction")) {
            editedAssociation = snpInteractionAssociationService.createAssociation(snpAssociationInteractionForm);
        } else {
            editedAssociation = singleSnpMultiSnpAssociationService.createAssociation(snpAssociationStandardMultiForm);
            // New snps to compare with the previousSnps.
            Collection<SnpFormRow> newSnpsList = snpAssociationStandardMultiForm.getSnpFormRows();
            if (newSnpsList != null && !newSnpsList.isEmpty()) {
                for (SnpFormRow snp : newSnpsList) {
                    snps.add(snp.getSnp());
                }
            }
        }
        authorReportedGenes = associationOperationsService.getGenesIds(editedAssociation.getLoci());
        if (oldAssociationReport != null) {
            if ((previousAuthorReportedGenes.size() == authorReportedGenes.size()) && (snps.size() == snps.size())) {
                // check the values
                if ((authorReportedGenes.equals(previousAuthorReportedGenes)) && (snps.equals(previousSnps))) {
                    editedAssociation.setLastMappingDate(associationToEdit.getLastMappingDate());
                    editedAssociation.setLastMappingPerformedBy(associationToEdit.getLastMappingPerformedBy());
                    editedAssociation.setAssociationReport(oldAssociationReport);
                    isToRemapping = "no";
                }
            }
        }
        if ((oldAssociationReport != null) && (isToRemapping.compareTo("yes") == 0)) {
            associationOperationsService.deleteAssocationReport(associationToEdit.getAssociationReport().getId());
        }
        // Save and validate form
        String eRelease = ensemblRestTemplateService.getRelease();
        Collection<AssociationValidationView> errors = associationOperationsService.saveEditedAssociationFromForm(study, editedAssociation, associationId, currentUserDetailsService.getUserFromRequest(request), eRelease);
        // Determine if we have any errors rather than warnings
        long errorCount = errors.stream().filter(validationError -> !validationError.getWarning()).count();
        if (errorCount > 0) {
            // Get mapping details for association we're editing
            model.addAttribute("mappingDetails", associationOperationsService.createMappingDetails(associationToEdit));
            model.addAttribute("errors", errors);
            model.addAttribute("criticalErrorsFound", true);
            if (associationType.equalsIgnoreCase("interaction")) {
                model.addAttribute("form", snpAssociationInteractionForm);
                return "edit_snp_interaction_association";
            } else {
                model.addAttribute("form", snpAssociationStandardMultiForm);
                // Determine view
                if (associationToEdit.getMultiSnpHaplotype()) {
                    return "edit_multi_snp_association";
                } else {
                    return "edit_standard_snp_association";
                }
            }
        } else {
            redirectAttributes.addFlashAttribute("isToRemapping", isToRemapping);
            return "redirect:/associations/" + associationId;
        }
    }
}
Also used : PathVariable(org.springframework.web.bind.annotation.PathVariable) RequestParam(org.springframework.web.bind.annotation.RequestParam) CheckMappingService(uk.ac.ebi.spot.goci.curation.service.CheckMappingService) LoggerFactory(org.slf4j.LoggerFactory) SnpAssociationInteractionForm(uk.ac.ebi.spot.goci.curation.model.SnpAssociationInteractionForm) Autowired(org.springframework.beans.factory.annotation.Autowired) Valid(javax.validation.Valid) AssociationOperationsService(uk.ac.ebi.spot.goci.curation.service.AssociationOperationsService) PreDestroy(javax.annotation.PreDestroy) Model(org.springframework.ui.Model) Future(java.util.concurrent.Future) AssociationDeletionService(uk.ac.ebi.spot.goci.curation.service.AssociationDeletionService) uk.ac.ebi.spot.goci.model(uk.ac.ebi.spot.goci.model) StudyRepository(uk.ac.ebi.spot.goci.repository.StudyRepository) Pageable(org.springframework.data.domain.Pageable) Sort(org.springframework.data.domain.Sort) EnsemblRestTemplateService(uk.ac.ebi.spot.goci.service.EnsemblRestTemplateService) DateFormat(java.text.DateFormat) RedirectAttributes(org.springframework.web.servlet.mvc.support.RedirectAttributes) HttpSession(javax.servlet.http.HttpSession) MediaType(org.springframework.http.MediaType) EventsViewService(uk.ac.ebi.spot.goci.curation.service.EventsViewService) PageRequest(org.springframework.data.domain.PageRequest) RequestMethod(org.springframework.web.bind.annotation.RequestMethod) Page(org.springframework.data.domain.Page) SnpFormColumn(uk.ac.ebi.spot.goci.curation.model.SnpFormColumn) AssociationUploadErrorView(uk.ac.ebi.spot.goci.curation.model.AssociationUploadErrorView) FileNotFoundException(java.io.FileNotFoundException) Executors(java.util.concurrent.Executors) SingleSnpMultiSnpAssociationService(uk.ac.ebi.spot.goci.curation.service.SingleSnpMultiSnpAssociationService) SnpAssociationTableViewService(uk.ac.ebi.spot.goci.curation.service.SnpAssociationTableViewService) LastViewedAssociation(uk.ac.ebi.spot.goci.curation.model.LastViewedAssociation) SnpInteractionAssociationService(uk.ac.ebi.spot.goci.curation.service.SnpInteractionAssociationService) InitBinder(org.springframework.web.bind.annotation.InitBinder) CurrentUserDetailsService(uk.ac.ebi.spot.goci.curation.service.CurrentUserDetailsService) FileUploadException(uk.ac.ebi.spot.goci.curation.exception.FileUploadException) Async(org.springframework.scheduling.annotation.Async) java.util(java.util) SnpAssociationTableView(uk.ac.ebi.spot.goci.curation.model.SnpAssociationTableView) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) SimpleDateFormat(java.text.SimpleDateFormat) BindingResult(org.springframework.validation.BindingResult) Callable(java.util.concurrent.Callable) Controller(org.springframework.stereotype.Controller) SnpAssociationStandardMultiForm(uk.ac.ebi.spot.goci.curation.model.SnpAssociationStandardMultiForm) EfoTraitRepository(uk.ac.ebi.spot.goci.repository.EfoTraitRepository) AssociationService(uk.ac.ebi.spot.goci.service.AssociationService) Value(org.springframework.beans.factory.annotation.Value) AssociationValidationReportService(uk.ac.ebi.spot.goci.curation.service.AssociationValidationReportService) HttpServletRequest(javax.servlet.http.HttpServletRequest) ModelAttribute(org.springframework.web.bind.annotation.ModelAttribute) Qualifier(org.springframework.beans.factory.annotation.Qualifier) ExceptionHandler(org.springframework.web.bind.annotation.ExceptionHandler) ExecutorService(java.util.concurrent.ExecutorService) DataIntegrityException(uk.ac.ebi.spot.goci.curation.exception.DataIntegrityException) Logger(org.slf4j.Logger) AssociationUploadService(uk.ac.ebi.spot.goci.curation.service.AssociationUploadService) AssociationRepository(uk.ac.ebi.spot.goci.repository.AssociationRepository) HttpServletResponse(javax.servlet.http.HttpServletResponse) SnpAssociationForm(uk.ac.ebi.spot.goci.curation.model.SnpAssociationForm) EnsemblMappingException(uk.ac.ebi.spot.goci.exception.EnsemblMappingException) SheetProcessingException(uk.ac.ebi.spot.goci.exception.SheetProcessingException) IOException(java.io.IOException) CheckEfoTermAssignmentService(uk.ac.ebi.spot.goci.curation.service.CheckEfoTermAssignmentService) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) StudyAssociationBatchDeletionEventService(uk.ac.ebi.spot.goci.curation.service.StudyAssociationBatchDeletionEventService) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) MapCatalogService(uk.ac.ebi.spot.goci.service.MapCatalogService) SnpFormRow(uk.ac.ebi.spot.goci.curation.model.SnpFormRow) WebDataBinder(org.springframework.web.bind.WebDataBinder) MultipartFile(org.springframework.web.multipart.MultipartFile) AssociationDownloadService(uk.ac.ebi.spot.goci.curation.service.AssociationDownloadService) AssociationValidationView(uk.ac.ebi.spot.goci.curation.model.AssociationValidationView) MappingDetails(uk.ac.ebi.spot.goci.curation.model.MappingDetails) AssociationValidationView(uk.ac.ebi.spot.goci.curation.model.AssociationValidationView) LastViewedAssociation(uk.ac.ebi.spot.goci.curation.model.LastViewedAssociation) SnpFormRow(uk.ac.ebi.spot.goci.curation.model.SnpFormRow) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

MappingDetails (uk.ac.ebi.spot.goci.curation.model.MappingDetails)16 LastViewedAssociation (uk.ac.ebi.spot.goci.curation.model.LastViewedAssociation)9 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)7 Timestamp (java.sql.Timestamp)5 SimpleDateFormat (java.text.SimpleDateFormat)4 Test (org.junit.Test)4 AssociationValidationView (uk.ac.ebi.spot.goci.curation.model.AssociationValidationView)4 SnpAssociationForm (uk.ac.ebi.spot.goci.curation.model.SnpAssociationForm)4 SnpAssociationInteractionForm (uk.ac.ebi.spot.goci.curation.model.SnpAssociationInteractionForm)4 SnpFormColumn (uk.ac.ebi.spot.goci.curation.model.SnpFormColumn)4 SnpFormRow (uk.ac.ebi.spot.goci.curation.model.SnpFormRow)4 FileNotFoundException (java.io.FileNotFoundException)3 IOException (java.io.IOException)3 DateFormat (java.text.DateFormat)3 java.util (java.util)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)3 HttpServletResponse (javax.servlet.http.HttpServletResponse)3 Valid (javax.validation.Valid)3 Logger (org.slf4j.Logger)3 LoggerFactory (org.slf4j.LoggerFactory)3