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