Search in sources :

Example 1 with SubjectStudyDefinitionBean

use of org.akaza.openclinica.ws.bean.SubjectStudyDefinitionBean in project OpenClinica by OpenClinica.

the class SubjectTransferValidator method validateIsSubjectExists.

public void validateIsSubjectExists(Object obj, Errors e) {
    SubjectStudyDefinitionBean subjectStudyBean = (SubjectStudyDefinitionBean) obj;
    if (subjectStudyBean.getStudyUniqueId() == null) {
        e.reject("studyEventDefinitionRequestValidator.study_does_not_exist");
        return;
    }
    Status[] included_status = new Status[] { Status.AVAILABLE };
    StudyBean study = helper.verifyStudy(getStudyDAO(), subjectStudyBean.getStudyUniqueId(), included_status, e);
    if (study == null)
        return;
    subjectStudyBean.setStudy(study);
    StudyBean site = null;
    int site_id = -1;
    if (subjectStudyBean.getSiteUniqueId() != null) {
        site = helper.verifySite(getStudyDAO(), subjectStudyBean.getStudyUniqueId(), subjectStudyBean.getSiteUniqueId(), included_status, e);
        if (site == null) {
            return;
        }
        site_id = site.getId();
        subjectStudyBean.setStudy(site);
    }
    //.verifyUser(subjectStudyBean.getUser(), getUserAccountDAO(), study.getId(), site_id,   e) ;
    boolean isRoleVerified = helper.verifyRole(subjectStudyBean.getUser(), study.getId(), site_id, e);
    if (!isRoleVerified) {
        return;
    }
    //        StudyBean study = getStudyDAO().findByUniqueIdentifier(subjectStudyBean.getStudyUniqueId());
    //        if (study == null) {
    //            e.reject("subjectTransferValidator.study_does_not_exist", new Object[] { subjectStudyBean.getStudyUniqueId() }, "Study identifier you specified "
    //                + subjectStudyBean.getStudyUniqueId() + " does not correspond to a valid study.");
    //            return;
    //        }
    //        else{        subjectStudyBean.setStudy(study);}
    //   
    //        StudyBean site = null;
    //        if (subjectStudyBean.getSiteUniqueId() != null) {
    //            site = getStudyDAO().findSiteByUniqueIdentifier(subjectStudyBean.getStudyUniqueId(), subjectStudyBean.getSiteUniqueId());
    // 	        if (site == null) {
    //	            e.reject("subjectTransferValidator.site_does_not_exist", new Object[] { subjectStudyBean.getSiteUniqueId() },
    //	                    "Site identifier you specified does not correspond to a valid site.");
    //	            return;
    //	        }
    // 	       subjectStudyBean.setStudy(site);
    //       }
    //        UserAccountBean ua = subjectStudyBean.getUser();
    //        StudyUserRoleBean role = ua.getRoleByStudy(study);
    //        if (role.getId() == 0 ) {
    //            e.reject("subjectTransferValidator.insufficient_permissions", "You do not have sufficient privileges to proceed with this operation.");
    //            return;
    //        }
    //        
    String studySubjectId = subjectStudyBean.getSubjectLabel();
    if (studySubjectId == null || studySubjectId.length() < 1) {
        e.reject("subjectTransferValidator.studySubjectId_required");
        return;
    } else if (studySubjectId.length() > 30) {
        e.reject("subjectTransferValidator.studySubjectId_invalid_length", new Object[] { studySubjectId }, "studySubjectId: " + studySubjectId + " cannot be longer than 30 characters.");
        return;
    }
    StudySubjectBean studySubject = getStudySubjectDAO().findByLabelAndStudy(subjectStudyBean.getSubjectLabel(), subjectStudyBean.getStudy());
    //it is not null but label null
    if (studySubject == null || studySubject.getOid() == null) {
        e.reject("studyEventTransferValidator.study_subject_does_not_exist", new Object[] { subjectStudyBean.getSubjectLabel(), subjectStudyBean.getStudy().getName() }, "StudySubject label you specified " + subjectStudyBean.getSubjectLabel() + " does not correspond to a study " + subjectStudyBean.getStudy().getName());
        return;
    } else {
        subjectStudyBean.setSubjectOIDId(studySubject.getOid());
    }
}
Also used : Status(org.akaza.openclinica.bean.core.Status) SubjectStudyDefinitionBean(org.akaza.openclinica.ws.bean.SubjectStudyDefinitionBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean)

Example 2 with SubjectStudyDefinitionBean

use of org.akaza.openclinica.ws.bean.SubjectStudyDefinitionBean in project OpenClinica by OpenClinica.

the class StudySubjectEndpoint method unMarshallToSubjectStudy.

/**
     * Process createStudySubject request by creating SubjectStudyDefinitionBean from received payload.
     * 
     * @param subjectElement
     * @return SubjectTransferBean
     * @throws ParseException
     */
private SubjectStudyDefinitionBean unMarshallToSubjectStudy(Element subjectStudyElement) throws ParseException {
    Element studySubjectIdElement = DomUtils.getChildElementByTagName(subjectStudyElement, "label");
    Element study = DomUtils.getChildElementByTagName(subjectStudyElement, "studyRef");
    Element studyIdentifierElement = DomUtils.getChildElementByTagName(study, "identifier");
    Element site = DomUtils.getChildElementByTagName(study, "siteRef");
    Element siteIdentifierElement = site == null ? null : DomUtils.getChildElementByTagName(site, "identifier");
    String studySubjectIdValue = DomUtils.getTextValue(studySubjectIdElement).trim();
    String studyIdentifier = studyIdentifierElement == null ? null : DomUtils.getTextValue(studyIdentifierElement).trim();
    String siteIdentifier = siteIdentifierElement == null ? null : DomUtils.getTextValue(siteIdentifierElement).trim();
    SubjectStudyDefinitionBean subjectTransferBean = new SubjectStudyDefinitionBean(studyIdentifier, siteIdentifier, getUserAccount(), studySubjectIdValue);
    return subjectTransferBean;
}
Also used : SubjectStudyDefinitionBean(org.akaza.openclinica.ws.bean.SubjectStudyDefinitionBean) JAXBElement(javax.xml.bind.JAXBElement) Element(org.w3c.dom.Element)

Example 3 with SubjectStudyDefinitionBean

use of org.akaza.openclinica.ws.bean.SubjectStudyDefinitionBean in project OpenClinica by OpenClinica.

the class StudySubjectEndpoint method isStudySubject.

/**
       * Use this method to find if studysubject exists by study/site/subject lable.
     * 
     * @param requestElement
     * @return studySubjectOID
     * @throws Exception
  */
@PayloadRoot(localPart = "isStudySubjectRequest", namespace = NAMESPACE_URI_V1)
public Source isStudySubject(@XPathParam("//studySubject:studySubject") NodeList subject) throws Exception {
    ResourceBundleProvider.updateLocale(locale);
    Element subjectElement = (Element) subject.item(0);
    // Element studyElement = (Element) study.item(0);
    //,studyElement);
    SubjectStudyDefinitionBean subjectStudyBean = unMarshallToSubjectStudy(subjectElement);
    DataBinder dataBinder = new DataBinder((subjectStudyBean));
    Errors errors = dataBinder.getBindingResult();
    SubjectTransferValidator subjectTransferValidator = new SubjectTransferValidator(dataSource);
    subjectTransferValidator.validateIsSubjectExists((subjectStudyBean), errors);
    if (subjectStudyBean.getSubjectOIDId() == null) {
        //case for core misfunction
        errors.reject("studySubjectEndpoint.fail");
    }
    if (!errors.hasErrors()) {
        return new DOMSource(mapConfirmation(messages.getMessage("studySubjectEndpoint.success", null, "Success", locale), subjectStudyBean.getSubjectOIDId(), errors, "subjectOID"));
    } else {
        return new DOMSource(mapConfirmation(messages.getMessage("studySubjectEndpoint.fail", null, "Fail", locale), null, errors));
    }
}
Also used : SubjectTransferValidator(org.akaza.openclinica.ws.validator.SubjectTransferValidator) Errors(org.springframework.validation.Errors) DOMSource(javax.xml.transform.dom.DOMSource) SubjectStudyDefinitionBean(org.akaza.openclinica.ws.bean.SubjectStudyDefinitionBean) JAXBElement(javax.xml.bind.JAXBElement) Element(org.w3c.dom.Element) DataBinder(org.springframework.validation.DataBinder) PayloadRoot(org.springframework.ws.server.endpoint.annotation.PayloadRoot)

Aggregations

SubjectStudyDefinitionBean (org.akaza.openclinica.ws.bean.SubjectStudyDefinitionBean)3 JAXBElement (javax.xml.bind.JAXBElement)2 Element (org.w3c.dom.Element)2 DOMSource (javax.xml.transform.dom.DOMSource)1 Status (org.akaza.openclinica.bean.core.Status)1 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)1 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)1 SubjectTransferValidator (org.akaza.openclinica.ws.validator.SubjectTransferValidator)1 DataBinder (org.springframework.validation.DataBinder)1 Errors (org.springframework.validation.Errors)1 PayloadRoot (org.springframework.ws.server.endpoint.annotation.PayloadRoot)1