Search in sources :

Example 6 with BaseStudyDefinitionBean

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

the class StudyEndpoint method unMarshallRequest.

//private StudyMetadataRequestBean unMarshallRequest(Element studyEventDefinitionListAll) {
private BaseStudyDefinitionBean unMarshallRequest(Element studyEventDefinitionListAll) {
    Element studyIdentifierElement = DomUtils.getChildElementByTagName(studyEventDefinitionListAll, "identifier");
    String studyIdentifier = studyIdentifierElement == null ? null : DomUtils.getTextValue(studyIdentifierElement).trim();
    BaseStudyDefinitionBean studyMetadataRequest = new BaseStudyDefinitionBean(studyIdentifier, getUserAccount());
    return studyMetadataRequest;
}
Also used : BaseStudyDefinitionBean(org.akaza.openclinica.ws.bean.BaseStudyDefinitionBean) Element(org.w3c.dom.Element)

Example 7 with BaseStudyDefinitionBean

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

the class StudyEventDefinitionEndpoint method getStudyList.

/**
     * if NAMESPACE_URI_V1:getStudyListRequest execute this method
     * 
     * @return
     * @throws Exception
     */
@PayloadRoot(localPart = "listAllRequest", namespace = NAMESPACE_URI_V1)
public Source getStudyList(@XPathParam("//sed:studyEventDefinitionListAll") NodeList studyNodeList) throws Exception {
    ResourceBundleProvider.updateLocale(new Locale("en_US"));
    Element studyRefElement = (Element) studyNodeList.item(0);
    // StudyEventDefinitionRequestBean studyEventDefinitionRequestBean = unMarshallRequest(studyRefElement);
    BaseStudyDefinitionBean studyEventDefinitionRequestBean = unMarshallRequest(studyRefElement);
    DataBinder dataBinder = new DataBinder((studyEventDefinitionRequestBean));
    Errors errors = dataBinder.getBindingResult();
    StudyEventDefinitionRequestValidator studyEventDefinitionRequestValidator = new StudyEventDefinitionRequestValidator(dataSource);
    studyEventDefinitionRequestValidator.validate((studyEventDefinitionRequestBean), errors);
    if (!errors.hasErrors()) {
        return new DOMSource(mapConfirmation(getStudy(studyEventDefinitionRequestBean), messages.getMessage("studyEventDefinitionEndpoint.success", null, "Success", locale)));
    } else {
        return new DOMSource(mapFailConfirmation(messages.getMessage("studyEventDefinitionEndpoint.fail", null, "Fail", locale), errors));
    }
}
Also used : Locale(java.util.Locale) Errors(org.springframework.validation.Errors) StudyEventDefinitionRequestValidator(org.akaza.openclinica.ws.validator.StudyEventDefinitionRequestValidator) DOMSource(javax.xml.transform.dom.DOMSource) BaseStudyDefinitionBean(org.akaza.openclinica.ws.bean.BaseStudyDefinitionBean) Element(org.w3c.dom.Element) DataBinder(org.springframework.validation.DataBinder) PayloadRoot(org.springframework.ws.server.endpoint.annotation.PayloadRoot)

Example 8 with BaseStudyDefinitionBean

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

the class StudyMetadataRequestValidator method validate.

public void validate(Object obj, Errors e) {
    BaseStudyDefinitionBean studyMetadataRequest = (BaseStudyDefinitionBean) obj;
    if (studyMetadataRequest.getStudyUniqueId() == null) {
        //&& studyMetadataRequest.getSiteUniqueId() == null) {
        e.reject("studyEventDefinitionRequestValidator.study_does_not_exist");
        return;
    }
    StudyBean study = helper.verifyStudy(getStudyDAO(), studyMetadataRequest.getStudyUniqueId(), null, e);
    if (study == null)
        return;
    int site_id = -1;
    StudyBean site;
    if (studyMetadataRequest.getSiteUniqueId() != null) {
        site = helper.verifySite(getStudyDAO(), studyMetadataRequest.getStudyUniqueId(), studyMetadataRequest.getSiteUniqueId(), null, e);
        if (site != null) {
            site_id = site.getId();
        }
    }
    helper.verifyUser(studyMetadataRequest.getUser(), getUserAccountDAO(), study.getId(), site_id, e);
//        
//        StudyUserRoleBean studySur = getUserAccountDAO().findRoleByUserNameAndStudyId(studyMetadataRequest.getUser().getName(), study.getId());
//	      if (studySur.getStatus() != Status.AVAILABLE) {
//	          e.reject("studyEventDefinitionRequestValidator.insufficient_permissions",
//	                  "You do not have sufficient privileges to proceed with this operation.");
//	          return;
//	      }
//        if (studyMetadataRequest.getStudyUniqueId() != null && studyMetadataRequest.getSiteUniqueId() == null) {
//            StudyBean study = getStudyDAO().findByUniqueIdentifier(studyMetadataRequest.getStudyUniqueId());
//            if (study == null) {
//            	  e.reject("subjectTransferValidator.study_does_not_exist", new Object[] { studyMetadataRequest.getStudyUniqueId() }, "Study identifier you specified "
//                          + studyMetadataRequest.getStudyUniqueId() + " does not correspond to a valid study.");
//                  return;  
//            }
//       
//            StudyUserRoleBean studySur = getUserAccountDAO().findRoleByUserNameAndStudyId(studyMetadataRequest.getUser().getName(), study.getId());
//            if (studySur.getStatus() != Status.AVAILABLE) {
//                e.reject("studyEventDefinitionRequestValidator.insufficient_permissions",
//                        "You do not have sufficient privileges to proceed with this operation.");
//                return;
//            }
//        }
//        if (studyMetadataRequest.getStudyUniqueId() != null && studyMetadataRequest.getSiteUniqueId() != null) {
//            StudyBean study = getStudyDAO().findByUniqueIdentifier(studyMetadataRequest.getStudyUniqueId());
//            StudyBean site = getStudyDAO().findByUniqueIdentifier(studyMetadataRequest.getSiteUniqueId());
//            if (study == null || site == null || site.getParentStudyId() != study.getId()) {
//                e.reject("studyEventDefinitionRequestValidator.invalid_study_identifier_site_identifier");
//                return;
//            }
//            StudyUserRoleBean siteSur = getUserAccountDAO().findRoleByUserNameAndStudyId(studyMetadataRequest.getUser().getName(), site.getId());
//            if (siteSur.getStatus() != Status.AVAILABLE) {
//                e.reject("studyEventDefinitionRequestValidator.insufficient_permissions",
//                        "You do not have sufficient privileges to proceed with this operation.");
//                return;
//            }
//        }
}
Also used : BaseStudyDefinitionBean(org.akaza.openclinica.ws.bean.BaseStudyDefinitionBean) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean)

Aggregations

BaseStudyDefinitionBean (org.akaza.openclinica.ws.bean.BaseStudyDefinitionBean)8 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)4 Element (org.w3c.dom.Element)4 Locale (java.util.Locale)3 DOMSource (javax.xml.transform.dom.DOMSource)3 DataBinder (org.springframework.validation.DataBinder)3 Errors (org.springframework.validation.Errors)3 PayloadRoot (org.springframework.ws.server.endpoint.annotation.PayloadRoot)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Status (org.akaza.openclinica.bean.core.Status)1 UserAccountBean (org.akaza.openclinica.bean.login.UserAccountBean)1 DisplayItemBeanWrapper (org.akaza.openclinica.bean.submit.DisplayItemBeanWrapper)1 ODMContainer (org.akaza.openclinica.bean.submit.crfdata.ODMContainer)1 SubjectDataBean (org.akaza.openclinica.bean.submit.crfdata.SubjectDataBean)1 ImportDataRuleRunnerContainer (org.akaza.openclinica.logic.rulerunner.ImportDataRuleRunnerContainer)1 DataImportService (org.akaza.openclinica.web.crfdata.DataImportService)1 ImportCRFInfoContainer (org.akaza.openclinica.web.crfdata.ImportCRFInfoContainer)1 CRFDataImportValidator (org.akaza.openclinica.ws.validator.CRFDataImportValidator)1 StudyEventDefinitionRequestValidator (org.akaza.openclinica.ws.validator.StudyEventDefinitionRequestValidator)1