Search in sources :

Example 36 with DataBinder

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));
    }
}
Also used : Locale(java.util.Locale) Errors(org.springframework.validation.Errors) DOMSource(javax.xml.transform.dom.DOMSource) Element(org.w3c.dom.Element) StudyEventTransferBean(org.akaza.openclinica.ws.bean.StudyEventTransferBean) DataBinder(org.springframework.validation.DataBinder) OpenClinicaSystemException(org.akaza.openclinica.exception.OpenClinicaSystemException) ParseException(java.text.ParseException) OpenClinicaSystemException(org.akaza.openclinica.exception.OpenClinicaSystemException) StudyEventTransferValidator(org.akaza.openclinica.ws.validator.StudyEventTransferValidator)

Aggregations

DataBinder (org.springframework.validation.DataBinder)36 Test (org.junit.Test)15 Errors (org.springframework.validation.Errors)14 Locale (java.util.Locale)8 MutablePropertyValues (org.springframework.beans.MutablePropertyValues)7 ArrayList (java.util.ArrayList)6 DOMSource (javax.xml.transform.dom.DOMSource)6 OpenClinicaSystemException (org.akaza.openclinica.exception.OpenClinicaSystemException)5 Element (org.w3c.dom.Element)5 HashMap (java.util.HashMap)4 FileItem (org.apache.commons.fileupload.FileItem)4 DiskFileItemFactory (org.apache.commons.fileupload.disk.DiskFileItemFactory)4 ServletFileUpload (org.apache.commons.fileupload.servlet.ServletFileUpload)4 MapPropertySource (org.springframework.core.env.MapPropertySource)4 PayloadRoot (org.springframework.ws.server.endpoint.annotation.PayloadRoot)4 File (java.io.File)3 LinkedHashMap (java.util.LinkedHashMap)3 FileProperties (org.akaza.openclinica.bean.rule.FileProperties)3 Study (org.akaza.openclinica.domain.datamap.Study)3 PFormCache (org.akaza.openclinica.web.pform.PFormCache)3