Search in sources :

Example 6 with AssociationValidationView

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

the class AssociationController method addSnpInteraction.

@RequestMapping(value = "/studies/{studyId}/associations/add_interaction", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.POST)
public String addSnpInteraction(@ModelAttribute("form") @Valid SnpAssociationInteractionForm snpAssociationInteractionForm, BindingResult bindingResult, @PathVariable Long studyId, Model model, @RequestParam(required = true) String measurementType, HttpServletRequest request) throws EnsemblMappingException {
    Study study = studyRepository.findOne(studyId);
    model.addAttribute("study", study);
    model.addAttribute("measurementType", measurementType);
    // Binding vs Validator issue. File: messages.properties
    if (bindingResult.hasErrors()) {
        model.addAttribute("form", snpAssociationInteractionForm);
        return "add_snp_interaction_association";
    }
    // Check for errors in form that would prevent saving an association
    List<AssociationValidationView> colErrors = associationOperationsService.checkSnpAssociationInteractionFormErrors(snpAssociationInteractionForm, measurementType);
    if (!colErrors.isEmpty()) {
        model.addAttribute("errors", colErrors);
        model.addAttribute("form", snpAssociationInteractionForm);
        model.addAttribute("criticalErrorsFound", true);
        return "add_snp_interaction_association";
    } else {
        // Create an association object from details in returned form
        Association newAssociation = snpInteractionAssociationService.createAssociation(snpAssociationInteractionForm);
        // Save and validate form
        Collection<AssociationValidationView> errors = null;
        String eRelease = ensemblRestTemplateService.getRelease();
        try {
            errors = associationOperationsService.saveAssociationCreatedFromForm(study, newAssociation, currentUserDetailsService.getUserFromRequest(request), eRelease);
        } catch (EnsemblMappingException e) {
            return "ensembl_mapping_failure";
        }
        // Determine if we have any errors rather than warnings
        long errorCount = errors.stream().filter(validationError -> !validationError.getWarning()).count();
        if (errorCount > 0) {
            model.addAttribute("errors", errors);
            model.addAttribute("form", snpAssociationInteractionForm);
            model.addAttribute("criticalErrorsFound", true);
            return "add_snp_interaction_association";
        } else {
            return "redirect:/associations/" + newAssociation.getId();
        }
    }
}
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) AssociationValidationView(uk.ac.ebi.spot.goci.curation.model.AssociationValidationView) EnsemblMappingException(uk.ac.ebi.spot.goci.exception.EnsemblMappingException)

Example 7 with AssociationValidationView

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

the class AssociationValidationReportService method generateAssociationWarningsListView.

/**
     * Retrieve validation warnings for an association and return this is a structure accessible by view
     *
     * @param associationId ID of association to get warning for
     */
public List<AssociationValidationView> generateAssociationWarningsListView(Long associationId) {
    List<AssociationValidationView> associationValidationViews = new ArrayList<>();
    associationValidationReportRepository.findByAssociationId(associationId).forEach(associationValidationReport -> {
        associationValidationViews.add(new AssociationValidationView(associationValidationReport.getValidatedField(), associationValidationReport.getWarning(), true));
    });
    return associationValidationViews;
}
Also used : AssociationValidationView(uk.ac.ebi.spot.goci.curation.model.AssociationValidationView) ArrayList(java.util.ArrayList)

Example 8 with AssociationValidationView

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

the class AssociationOperationsService method processAssociationValidationErrors.

/**
     * Retrieve validation warnings for an association and return this is a structure accessible by view
     *
     * @param errors List of validation errors to process
     */
private List<AssociationValidationView> processAssociationValidationErrors(Collection<ValidationError> errors) {
    List<AssociationValidationView> associationValidationViews = new ArrayList<>();
    errors.forEach(validationError -> {
        associationValidationViews.add(new AssociationValidationView(validationError.getField(), validationError.getError(), validationError.getWarning()));
    });
    return associationValidationViews;
}
Also used : AssociationValidationView(uk.ac.ebi.spot.goci.curation.model.AssociationValidationView)

Aggregations

AssociationValidationView (uk.ac.ebi.spot.goci.curation.model.AssociationValidationView)8 java.util (java.util)6 Autowired (org.springframework.beans.factory.annotation.Autowired)6 Qualifier (org.springframework.beans.factory.annotation.Qualifier)6 LastViewedAssociation (uk.ac.ebi.spot.goci.curation.model.LastViewedAssociation)6 MappingDetails (uk.ac.ebi.spot.goci.curation.model.MappingDetails)6 SnpAssociationForm (uk.ac.ebi.spot.goci.curation.model.SnpAssociationForm)6 SnpAssociationInteractionForm (uk.ac.ebi.spot.goci.curation.model.SnpAssociationInteractionForm)6 SnpAssociationStandardMultiForm (uk.ac.ebi.spot.goci.curation.model.SnpAssociationStandardMultiForm)6 SnpFormColumn (uk.ac.ebi.spot.goci.curation.model.SnpFormColumn)6 SnpFormRow (uk.ac.ebi.spot.goci.curation.model.SnpFormRow)6 EnsemblMappingException (uk.ac.ebi.spot.goci.exception.EnsemblMappingException)6 uk.ac.ebi.spot.goci.model (uk.ac.ebi.spot.goci.model)6 AssociationRepository (uk.ac.ebi.spot.goci.repository.AssociationRepository)6 GetRequest (com.mashape.unirest.request.GetRequest)5 FileNotFoundException (java.io.FileNotFoundException)5 IOException (java.io.IOException)5 DateFormat (java.text.DateFormat)5 SimpleDateFormat (java.text.SimpleDateFormat)5 HttpServletRequest (javax.servlet.http.HttpServletRequest)5