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;
}
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);
}
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;
// }
}
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));
}
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));
}
}
Aggregations