Search in sources :

Example 1 with StudyEventTransferValidator

use of org.akaza.openclinica.ws.validator.StudyEventTransferValidator 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

ParseException (java.text.ParseException)1 Locale (java.util.Locale)1 DOMSource (javax.xml.transform.dom.DOMSource)1 OpenClinicaSystemException (org.akaza.openclinica.exception.OpenClinicaSystemException)1 StudyEventTransferBean (org.akaza.openclinica.ws.bean.StudyEventTransferBean)1 StudyEventTransferValidator (org.akaza.openclinica.ws.validator.StudyEventTransferValidator)1 DataBinder (org.springframework.validation.DataBinder)1 Errors (org.springframework.validation.Errors)1 Element (org.w3c.dom.Element)1