Search in sources :

Example 1 with ListAllByStudyResponse

use of org.openclinica.ws.studysubject.v1.ListAllByStudyResponse in project OpenClinica by OpenClinica.

the class StudySubjectEndpoint method listStudySubjectsInStudy.

/**
 * Use this method to list all study subjects. Scheduled event data will also be show if available.
 *
 * @param requestElement
 * @return ListAllByStudyResponse
 * @throws Exception
 */
@PayloadRoot(localPart = "listAllByStudyRequest", namespace = NAMESPACE_URI_V1)
public ListAllByStudyResponse listStudySubjectsInStudy(JAXBElement<ListStudySubjectsInStudyType> requestElement) throws Exception {
    try {
        ResourceBundleProvider.updateLocale(new Locale("en_US"));
        ListStudySubjectsInStudyType listStudySubjectsInStudyType = requestElement.getValue();
        StudyBean study = null;
        try {
            study = validateRequestAndReturnStudy(listStudySubjectsInStudyType.getStudyRef());
        } catch (OpenClinicaSystemException e) {
            e.printStackTrace();
            ListAllByStudyResponse response = new ListAllByStudyResponse();
            response.setResult(messages.getMessage("studySubjectEndpoint.fail", null, "Fail", locale));
            response.getError().add(messages.getMessage(e.getErrorCode(), null, e.getErrorCode(), locale));
            return response;
        }
        return mapListStudySubjectsInStudyResponse(study, messages.getMessage("studySubjectEndpoint.success", null, "Success", locale), listStudySubjectsInStudyType.getStudyRef());
    } catch (Exception eee) {
        eee.printStackTrace();
        throw eee;
    }
}
Also used : Locale(java.util.Locale) ListStudySubjectsInStudyType(org.openclinica.ws.beans.ListStudySubjectsInStudyType) ListAllByStudyResponse(org.openclinica.ws.studysubject.v1.ListAllByStudyResponse) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) OpenClinicaSystemException(org.akaza.openclinica.exception.OpenClinicaSystemException) ParseException(java.text.ParseException) OpenClinicaSystemException(org.akaza.openclinica.exception.OpenClinicaSystemException) PayloadRoot(org.springframework.ws.server.endpoint.annotation.PayloadRoot)

Example 2 with ListAllByStudyResponse

use of org.openclinica.ws.studysubject.v1.ListAllByStudyResponse in project OpenClinica by OpenClinica.

the class StudySubjectEndpoint method mapListStudySubjectsInStudyResponse.

/**
 * Build the response for listStudySubjectsInStudy method
 *
 * @param study
 * @param message
 * @param studyRef
 * @return ListAllByStudyResponse
 * @throws Exception
 */
private ListAllByStudyResponse mapListStudySubjectsInStudyResponse(StudyBean study, String message, StudyRefType studyRef) throws Exception {
    ListAllByStudyResponse response = new ListAllByStudyResponse();
    response.setResult(message);
    StudySubjectsType studySubjectsType = new StudySubjectsType();
    response.setStudySubjects(studySubjectsType);
    List<StudySubjectBean> studySubjects = this.subjectService.getStudySubject(study);
    for (StudySubjectBean studySubjectBean : studySubjects) {
        StudySubjectWithEventsType studySubjectType = new StudySubjectWithEventsType();
        SubjectType subjectType = new SubjectType();
        studySubjectType.setLabel(studySubjectBean.getLabel());
        studySubjectType.setSecondaryLabel(studySubjectBean.getSecondaryLabel());
        studySubjectType.setOid(studySubjectBean.getOid());
        if (studySubjectBean.getEnrollmentDate() != null) {
            studySubjectType.setEnrollmentDate(getXMLGregorianCalendarDate(studySubjectBean.getEnrollmentDate()));
        }
        SubjectBean subjectBean = (SubjectBean) getSubjectDao().findByPK(studySubjectBean.getSubjectId());
        subjectType.setUniqueIdentifier(subjectBean.getUniqueIdentifier());
        String genderStr = String.valueOf(subjectBean.getGender());
        if (!"".equals(genderStr.trim())) {
            subjectType.setGender(GenderType.fromValue(genderStr));
        }
        if (subjectBean.getDateOfBirth() != null) {
            subjectType.setDateOfBirth(getXMLGregorianCalendarDate(subjectBean.getDateOfBirth()));
        }
        studySubjectType.setSubject(subjectType);
        // studySubjectType.setStudyRef(studyRef);
        logger.debug(studySubjectBean.getLabel());
        studySubjectType.setEvents(getEvents(studySubjectBean));
        studySubjectsType.getStudySubject().add(studySubjectType);
    }
    return response;
}
Also used : SubjectBean(org.akaza.openclinica.bean.submit.SubjectBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) SubjectType(org.openclinica.ws.beans.SubjectType) ListAllByStudyResponse(org.openclinica.ws.studysubject.v1.ListAllByStudyResponse) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) StudySubjectWithEventsType(org.openclinica.ws.beans.StudySubjectWithEventsType) StudySubjectsType(org.openclinica.ws.beans.StudySubjectsType)

Aggregations

ListAllByStudyResponse (org.openclinica.ws.studysubject.v1.ListAllByStudyResponse)2 ParseException (java.text.ParseException)1 Locale (java.util.Locale)1 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)1 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)1 SubjectBean (org.akaza.openclinica.bean.submit.SubjectBean)1 OpenClinicaSystemException (org.akaza.openclinica.exception.OpenClinicaSystemException)1 ListStudySubjectsInStudyType (org.openclinica.ws.beans.ListStudySubjectsInStudyType)1 StudySubjectWithEventsType (org.openclinica.ws.beans.StudySubjectWithEventsType)1 StudySubjectsType (org.openclinica.ws.beans.StudySubjectsType)1 SubjectType (org.openclinica.ws.beans.SubjectType)1 PayloadRoot (org.springframework.ws.server.endpoint.annotation.PayloadRoot)1