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();
}
}
}
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);
}
}
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);
}
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);
}
}
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()));
}
Aggregations