Search in sources :

Example 1 with BaseStudyDefinitionBean

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

the class StudyEventDefinitionEndpoint method unMarshallRequest.

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

Example 2 with BaseStudyDefinitionBean

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

the class CRFDataImportValidator method validate.

public void validate(Object obj, Errors e) {
    //CRFDataImportBean crfDataImportBean = (CRFDataImportBean) obj;
    BaseStudyDefinitionBean crfDataImportBean = (BaseStudyDefinitionBean) obj;
    if (crfDataImportBean.getStudyUniqueId() == null) {
        e.reject("studyEventDefinitionRequestValidator.study_does_not_exist");
        return;
    }
    Status[] included_status = new Status[] { Status.AVAILABLE, Status.PENDING };
    StudyBean study = helper.verifyStudyByOID(getStudyDAO(), crfDataImportBean.getStudyUniqueId(), included_status, e);
    if (study == null)
        return;
    boolean isRoleVerified = helper.verifyRole(crfDataImportBean.getUser(), study.getId(), -1, Role.MONITOR, e);
    if (!isRoleVerified)
        return;
    //        StudyBean study = getStudyDAO().findByOid(crfDataImportBean.getStudyUniqueId());
    //        if (study == null) {
    //        	  e.reject("subjectTransferValidator.study_does_not_exist", new Object[] { crfDataImportBean.getStudyUniqueId() }, "Study identifier you specified "
    //                      + crfDataImportBean.getStudyUniqueId() + " does not correspond to a valid study.");
    //              return;  
    //        }
    //      //validate study status
    //        if ( !( study.getStatus().isAvailable() ||  study.getStatus().isPending() )) {
    //            e.reject("subjectTransferValidator.study_status_wrong", new Object[] { crfDataImportBean.getStudyUniqueId() }, "Study "
    //            		+ crfDataImportBean.getStudyUniqueId() +" has wrong status.");
    //            return;
    //        }
    //       //not monitor
    //        StudyUserRoleBean role = crfDataImportBean.getUser().getRoleByStudy(study);
    //        if (role.getId() == 0 || role.getRole().equals(Role.MONITOR) || role.getStatus() != Status.AVAILABLE) {
    //        	 e.reject("studyEventDefinitionRequestValidator.insufficient_permissions",
    //             "You do not have sufficient privileges to proceed with this operation.");
    //        	 return;
    //        }
    //      
    crfDataImportBean.setStudy(study);
}
Also used : Status(org.akaza.openclinica.bean.core.Status) BaseStudyDefinitionBean(org.akaza.openclinica.ws.bean.BaseStudyDefinitionBean) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean)

Example 3 with BaseStudyDefinitionBean

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

the class StudyEventDefinitionRequestValidator method validate.

public void validate(Object obj, Errors e) {
    BaseStudyDefinitionBean studyEventDefinitionRequestBean = (BaseStudyDefinitionBean) obj;
    if (studyEventDefinitionRequestBean.getStudyUniqueId() == null && studyEventDefinitionRequestBean.getSiteUniqueId() == null) {
        e.reject("studyEventDefinitionRequestValidator.invalid_study_identifier");
        return;
    }
    StudyBean study;
    int study_id = -1;
    if (studyEventDefinitionRequestBean.getStudyUniqueId() != null) {
        study = helper.verifyStudy(getStudyDAO(), studyEventDefinitionRequestBean.getStudyUniqueId(), null, e);
        if (study == null) {
            return;
        }
        study_id = study.getId();
    }
    StudyBean site;
    int site_id = -1;
    if (studyEventDefinitionRequestBean.getSiteUniqueId() != null) {
        site = helper.verifySite(getStudyDAO(), studyEventDefinitionRequestBean.getStudyUniqueId(), studyEventDefinitionRequestBean.getSiteUniqueId(), null, e);
        if (site == null) {
            return;
        }
        site_id = site.getId();
    }
    boolean isRoleVerified = helper.verifyRole(studyEventDefinitionRequestBean.getUser(), study_id, site_id, e);
//        //verify study ID
//        if (studyEventDefinitionRequestBean.getStudyUniqueId() != null ) {
//            StudyBean study = getStudyDAO().findByUniqueIdentifier(studyEventDefinitionRequestBean.getStudyUniqueId());
//            if (study == null) {
//                e.reject("studyEventDefinitionRequestValidator.invalid_study_identifier");
//                return;
//            }
//            studyEventDefinitionRequestBean.setStudy(study);
//        }
//        if ( studyEventDefinitionRequestBean.getSiteUniqueId() != null) {
//        	StudyBean site = getStudyDAO().findSiteByUniqueIdentifier(studyEventDefinitionRequestBean.getStudyUniqueId(), studyEventDefinitionRequestBean.getSiteUniqueId());
// 	        
//		    if ( site == null ) {
//                e.reject("studyEventDefinitionRequestValidator.invalid_study_identifier_site_identifier");
//                return;
//            }
//		    studyEventDefinitionRequestBean.setStudy(site);
//        }
//        StudyUserRoleBean siteSur = getUserAccountDAO().findRoleByUserNameAndStudyId(studyEventDefinitionRequestBean.getUser().getName(), studyEventDefinitionRequestBean.getStudy().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)

Example 4 with BaseStudyDefinitionBean

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

the class DataEndpoint method importDataInTransaction.

protected Source importDataInTransaction(Element odmElement) throws Exception {
    ResourceBundleProvider.updateLocale(new Locale("en_US"));
    // logger.debug("rootElement=" + odmElement);
    LOG.debug("rootElement=" + odmElement);
    // String xml = null;
    UserAccountBean userBean = null;
    try {
        if (odmElement == null) {
            return new DOMSource(mapFailConfirmation(null, "Your XML is not well-formed."));
        }
        // xml = node2String(odmElement);
        // xml = xml.replaceAll("<ODM>", this.ODM_HEADER_NAMESPACE);
        ODMContainer odmContainer = unmarshallToODMContainer(odmElement);
        // Element clinicalDataNode = (Element) odmElement.getElementsByTagName("ClinicalData").item(0);
        // String studyUniqueID = clinicalDataNode.getAttribute("StudyOID");
        String studyUniqueID = odmContainer.getCrfDataPostImportContainer().getStudyOID();
        userBean = getUserAccount();
        // CRFDataImportBean crfDataImportBean = new CRFDataImportBean(studyUniqueID, userBean);
        BaseStudyDefinitionBean crfDataImportBean = new BaseStudyDefinitionBean(studyUniqueID, userBean);
        DataBinder dataBinder = new DataBinder(crfDataImportBean);
        Errors errors = dataBinder.getBindingResult();
        CRFDataImportValidator crfDataImportValidator = new CRFDataImportValidator(dataSource);
        crfDataImportValidator.validate(crfDataImportBean, errors);
        if (!errors.hasErrors()) {
            StudyBean studyBean = crfDataImportBean.getStudy();
            List<DisplayItemBeanWrapper> displayItemBeanWrappers = new ArrayList<DisplayItemBeanWrapper>();
            HashMap<Integer, String> importedCRFStatuses = new HashMap<Integer, String>();
            List<String> errorMessagesFromValidation = dataImportService.validateMetaData(odmContainer, dataSource, coreResources, studyBean, userBean, displayItemBeanWrappers, importedCRFStatuses);
            if (errorMessagesFromValidation.size() > 0) {
                String err_msg = convertToErrorString(errorMessagesFromValidation);
                return new DOMSource(mapFailConfirmation(null, err_msg));
            }
            ImportCRFInfoContainer importCrfInfo = new ImportCRFInfoContainer(odmContainer, dataSource);
            errorMessagesFromValidation = dataImportService.validateData(odmContainer, dataSource, coreResources, studyBean, userBean, displayItemBeanWrappers, importedCRFStatuses);
            if (errorMessagesFromValidation.size() > 0) {
                String err_msg = convertToErrorString(errorMessagesFromValidation);
                return new DOMSource(mapFailConfirmation(null, err_msg));
            }
            // setup ruleSets to run if applicable
            ArrayList<SubjectDataBean> subjectDataBeans = odmContainer.getCrfDataPostImportContainer().getSubjectData();
            List<ImportDataRuleRunnerContainer> containers = dataImportService.runRulesSetup(dataSource, studyBean, userBean, subjectDataBeans, ruleSetService);
            List<String> auditMsgs = new DataImportService().submitData(odmContainer, dataSource, studyBean, userBean, displayItemBeanWrappers, importedCRFStatuses);
            // run rules if applicable
            List<String> ruleActionMsgs = dataImportService.runRules(studyBean, userBean, containers, ruleSetService, ExecutionMode.SAVE);
            List<String> skippedCRFMsgs = getSkippedCRFMessages(importCrfInfo);
            return new DOMSource(mapConfirmation(auditMsgs, ruleActionMsgs, skippedCRFMsgs, importCrfInfo));
        } else {
            return new DOMSource(mapFailConfirmation(errors, null));
        }
    // //
    } catch (Exception e) {
        // return new DOMSource(mapFailConfirmation(null,"Your XML is not well-formed. "+ npe.getMessage()));
        LOG.error("Error processing data import request", e);
        throw new Exception(e);
    }
// return new DOMSource(mapConfirmation(xml, studyBean, userBean));
}
Also used : Locale(java.util.Locale) DOMSource(javax.xml.transform.dom.DOMSource) HashMap(java.util.HashMap) CRFDataImportValidator(org.akaza.openclinica.ws.validator.CRFDataImportValidator) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) ArrayList(java.util.ArrayList) ImportDataRuleRunnerContainer(org.akaza.openclinica.logic.rulerunner.ImportDataRuleRunnerContainer) Errors(org.springframework.validation.Errors) ODMContainer(org.akaza.openclinica.bean.submit.crfdata.ODMContainer) BaseStudyDefinitionBean(org.akaza.openclinica.ws.bean.BaseStudyDefinitionBean) ImportCRFInfoContainer(org.akaza.openclinica.web.crfdata.ImportCRFInfoContainer) SubjectDataBean(org.akaza.openclinica.bean.submit.crfdata.SubjectDataBean) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) DataImportService(org.akaza.openclinica.web.crfdata.DataImportService) DataBinder(org.springframework.validation.DataBinder) DisplayItemBeanWrapper(org.akaza.openclinica.bean.submit.DisplayItemBeanWrapper)

Example 5 with BaseStudyDefinitionBean

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

the class StudyEndpoint method getStudyMetadata.

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

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