use of org.springframework.web.bind.annotation.ModelAttribute in project BroadleafCommerce by BroadleafCommerce.
the class RegisterCustomerController method initCustomerRegistrationForm.
@ModelAttribute("registerCustomerForm")
public RegisterCustomerForm initCustomerRegistrationForm() {
RegisterCustomerForm customerRegistrationForm = new RegisterCustomerForm();
Customer customer = customerService.createNewCustomer();
customerRegistrationForm.setCustomer(customer);
return customerRegistrationForm;
}
use of org.springframework.web.bind.annotation.ModelAttribute in project goci by EBISPOT.
the class AncestryController method populateCountryMap.
@ModelAttribute("countryMap")
public Map<String, Set<Country>> populateCountryMap(Model model) {
Map<String, Set<Country>> countryMap = new TreeMap<>();
List<Country> countries = countryRepository.findAll();
for (Country country : countries) {
Set<Country> countrySet = countryMap.get(country.getMajorArea());
if (countrySet == null) {
countrySet = new TreeSet<Country>(Comparator.comparing(Country::getCountryName));
countryMap.put(country.getMajorArea(), countrySet);
}
countrySet.add(country);
}
return countryMap;
}
use of org.springframework.web.bind.annotation.ModelAttribute 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.checkSnpAssociationInteractionFormErrorsForView(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
String eRelease = ensemblRestTemplateService.getRelease();
Collection<AssociationValidationView> errors = associationOperationsService.saveAssociationCreatedFromForm(study, newAssociation, 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) {
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 org.springframework.web.bind.annotation.ModelAttribute 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 = associationOperationsService.saveAssociationCreatedFromForm(study, newAssociation, 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) {
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 org.springframework.web.bind.annotation.ModelAttribute in project pivotal-cla by pivotalsoftware.
the class UserControllerAdvice method importedSignature.
@ModelAttribute("importedSignature")
boolean importedSignature(@AuthenticationPrincipal User currentUser, ImportedSignaturesSessionAttr importedSignaturesSessionAttr, @ModelAttribute ClaRequest claRequest) throws Exception {
if (!importedSignaturesSessionAttr.getValue()) {
return false;
}
ClaPullRequestStatusRequest updatePullRequest = claRequest.createUpdatePullRequestStatus(currentUser.getGitHubLogin());
if (updatePullRequest != null) {
claService.savePullRequestStatus(updatePullRequest);
}
importedSignaturesSessionAttr.setValue(false);
return true;
}
Aggregations