use of org.springframework.validation.DataBinder in project OpenClinica by OpenClinica.
the class EventEndpoint method scheduleEventInTransaction.
protected Source scheduleEventInTransaction(NodeList event) throws Exception {
ResourceBundleProvider.updateLocale(new Locale("en_US"));
Element eventElement = (Element) event.item(0);
StudyEventTransferBean studyEventTransferBean = unMarshallToEventTransfer(eventElement);
DataBinder dataBinder = new DataBinder((studyEventTransferBean));
Errors errors = dataBinder.getBindingResult();
StudyEventTransferValidator studyEventTransferValidator = new StudyEventTransferValidator(dataSource);
studyEventTransferValidator.validate((studyEventTransferBean), errors);
if (!errors.hasErrors()) {
try {
HashMap<String, String> h = getEventService().scheduleEvent(studyEventTransferBean.getUser(), studyEventTransferBean.getStartDateTime(), studyEventTransferBean.getEndDateTime(), studyEventTransferBean.getLocation(), studyEventTransferBean.getStudyUniqueId(), studyEventTransferBean.getSiteUniqueId(), studyEventTransferBean.getEventDefinitionOID(), studyEventTransferBean.getSubjectLabel());
return new DOMSource(mapSuccessConfirmation(h));
} catch (OpenClinicaSystemException ose) {
errors.reject("eventEndpoint.cannot_schedule", "Cannot schedule an event for this Subject.");
return new DOMSource(mapFailConfirmation(errors));
} catch (Exception e) {
logger.error(e.getMessage());
logger.error(ExceptionUtils.getStackTrace(e));
throw e;
}
} else {
return new DOMSource(mapFailConfirmation(errors));
}
}
Aggregations