Search in sources :

Example 6 with EnsemblMappingException

use of uk.ac.ebi.spot.goci.exception.EnsemblMappingException in project goci by EBISPOT.

the class AssociationController method addStandardSnps.

// Add new standard association/snp information to a study
@RequestMapping(value = "/studies/{studyId}/associations/add_standard", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.POST)
public String addStandardSnps(@ModelAttribute("form") @Valid SnpAssociationStandardMultiForm snpAssociationStandardMultiForm, 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", snpAssociationStandardMultiForm);
        return "add_standard_snp_association";
    }
    // Check for errors in form that would prevent saving an association
    List<AssociationValidationView> rowErrors = associationOperationsService.checkSnpAssociationFormErrors(snpAssociationStandardMultiForm, measurementType);
    if (!rowErrors.isEmpty()) {
        model.addAttribute("errors", rowErrors);
        model.addAttribute("form", snpAssociationStandardMultiForm);
        model.addAttribute("criticalErrorsFound", true);
        return "add_standard_snp_association";
    } else {
        // Create an association object from details in returned form
        Association newAssociation = singleSnpMultiSnpAssociationService.createAssociation(snpAssociationStandardMultiForm);
        // Save and validate form
        String eRelease = ensemblRestTemplateService.getRelease();
        Collection<AssociationValidationView> errors = null;
        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", snpAssociationStandardMultiForm);
            model.addAttribute("criticalErrorsFound", true);
            return "add_standard_snp_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 EnsemblMappingException

use of uk.ac.ebi.spot.goci.exception.EnsemblMappingException in project goci by EBISPOT.

the class MapCatalogService method mapCatalogContentsByAssociations.

// This method should be refactor with mapCatalogContentsNight
public void mapCatalogContentsByAssociations(String performer, Collection<Association> associations) throws EnsemblMappingException {
    Collection<Association> associationsToMap = associationService.findAssociationAssociationData(associations);
    getLog().info("Mapping all associations in database, total number: " + associationsToMap.size());
    try {
        mappingService.validateAndMapAllAssociations(associationsToMap, performer);
    } catch (EnsemblMappingException e) {
        throw new EnsemblMappingException("Attempt to map all associations failed", e);
    }
}
Also used : Association(uk.ac.ebi.spot.goci.model.Association) EnsemblMappingException(uk.ac.ebi.spot.goci.exception.EnsemblMappingException)

Example 8 with EnsemblMappingException

use of uk.ac.ebi.spot.goci.exception.EnsemblMappingException in project goci by EBISPOT.

the class MapCatalogService method mapCatalogContents.

/**
     * Get all associations in database and map
     *
     * @param performer name of curator/job carrying out the mapping
     */
public void mapCatalogContents(String performer) throws EnsemblMappingException {
    // Get all old association reports so we can compare with new ones, do this before we remap
    Collection<AssociationReport> oldAssociationReports = associationReportRepository.findAll();
    // Get all associations via service
    Collection<Association> associations = associationService.findAllAssociations();
    getLog().info("Mapping all associations in database, total number: " + associations.size());
    try {
        mappingService.validateAndMapAllAssociations(associations, performer);
    } catch (EnsemblMappingException e) {
        throw new EnsemblMappingException("Attempt to map all associations failed", e);
    }
    mappingErrorComparisonService.compareOldVersusNewErrors(oldAssociationReports, false, 0, 0);
}
Also used : Association(uk.ac.ebi.spot.goci.model.Association) AssociationReport(uk.ac.ebi.spot.goci.model.AssociationReport) EnsemblMappingException(uk.ac.ebi.spot.goci.exception.EnsemblMappingException)

Example 9 with EnsemblMappingException

use of uk.ac.ebi.spot.goci.exception.EnsemblMappingException in project goci by EBISPOT.

the class MapCatalogService method mapCatalogContentsNight.

public void mapCatalogContentsNight(String performer) throws EnsemblMappingException {
    Collection<Association> associations = associationService.findAssociationToMap();
    getLog().info("Mapping all associations in database, total number: " + associations.size());
    try {
        mappingService.validateAndMapAllAssociations(associations, performer);
    } catch (EnsemblMappingException e) {
        throw new EnsemblMappingException("Attempt to map all associations failed", e);
    }
}
Also used : Association(uk.ac.ebi.spot.goci.model.Association) EnsemblMappingException(uk.ac.ebi.spot.goci.exception.EnsemblMappingException)

Example 10 with EnsemblMappingException

use of uk.ac.ebi.spot.goci.exception.EnsemblMappingException 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)

Aggregations

EnsemblMappingException (uk.ac.ebi.spot.goci.exception.EnsemblMappingException)13 Autowired (org.springframework.beans.factory.annotation.Autowired)7 Qualifier (org.springframework.beans.factory.annotation.Qualifier)7 IOException (java.io.IOException)6 java.util (java.util)6 Logger (org.slf4j.Logger)6 LoggerFactory (org.slf4j.LoggerFactory)6 MultipartFile (org.springframework.web.multipart.MultipartFile)6 AssociationUploadErrorView (uk.ac.ebi.spot.goci.curation.model.AssociationUploadErrorView)6 AssociationValidationView (uk.ac.ebi.spot.goci.curation.model.AssociationValidationView)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 uk.ac.ebi.spot.goci.model (uk.ac.ebi.spot.goci.model)6 GetRequest (com.mashape.unirest.request.GetRequest)5 FileNotFoundException (java.io.FileNotFoundException)5