use of org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean in project OpenClinica by OpenClinica.
the class StudyEventTransferValidator method validate.
public void validate(Object obj, Errors e) {
StudyEventTransferBean studyEventTransferBean = (StudyEventTransferBean) obj;
// Non Business Validation
if (studyEventTransferBean.getStudyUniqueId() == null || studyEventTransferBean.getStudyUniqueId().length() < 1) {
e.reject("studyEventTransferValidator.invalid_study_identifier");
return;
}
// Business Validation
Status[] included_status = new Status[] { Status.AVAILABLE, Status.PENDING };
StudyBean study = helper.verifyStudy(getStudyDAO(), studyEventTransferBean.getStudyUniqueId(), included_status, e);
if (study == null) {
return;
}
studyEventTransferBean.setStudy(study);
StudyBean site = null;
int site_id = -1;
if (studyEventTransferBean.getSiteUniqueId() != null) {
site = helper.verifySite(getStudyDAO(), studyEventTransferBean.getStudyUniqueId(), studyEventTransferBean.getSiteUniqueId(), included_status, e);
if (site == null) {
return;
}
site_id = site.getId();
studyEventTransferBean.setStudy(site);
}
boolean isRoleVerified = helper.verifyRole(studyEventTransferBean.getUser(), study.getId(), site_id, Role.MONITOR, e);
if (!isRoleVerified)
return;
// Non Business Validation
if (studyEventTransferBean.getSubjectLabel() == null) {
e.reject("studyEventTransferValidator.studySubjectId_required");
return;
}
StudySubjectBean studySubject = getStudySubjectDAO().findByLabelAndStudy(studyEventTransferBean.getSubjectLabel(), studyEventTransferBean.getStudy());
//it is not null but label null
if (studySubject == null || studySubject.getOid() == null) {
e.reject("studyEventTransferValidator.study_subject_does_not_exist", new Object[] { studyEventTransferBean.getSubjectLabel(), studyEventTransferBean.getStudy().getName() }, "StudySubject label you specified " + studyEventTransferBean.getSubjectLabel() + " does not correspond to a study " + studyEventTransferBean.getStudy().getName());
return;
}
// Non Business Validation
if (studyEventTransferBean.getEventDefinitionOID() == null || studyEventTransferBean.getEventDefinitionOID().length() < 1) {
e.reject("studyEventTransferValidator.eventDefinitionOID_required");
return;
}
if (studyEventTransferBean.getStartDateTime() == null) {
e.reject("studyEventTransferValidator.startDateTime_required");
return;
}
StudyParameterValueBean eventLocationRequiredSetting = getStudyParameterValueDAO().findByHandleAndStudy(studyEventTransferBean.getStudy().getId(), "eventLocationRequired");
// if ("true".equals(eventLocationRequiredSetting.getValue()) && (studyEventTransferBean.getLocation() == null || studyEventTransferBean.getLocation().length() < 1)) {
if (REQUIRED.equals(eventLocationRequiredSetting.getValue()) && (studyEventTransferBean.getLocation() == null || studyEventTransferBean.getLocation().length() < 1)) {
e.reject("studyEventTransferValidator.location_required");
return;
}
if (studyEventTransferBean.getEndDateTime() != null && studyEventTransferBean.getStartDateTime() != null) {
if (studyEventTransferBean.getEndDateTime().compareTo(studyEventTransferBean.getStartDateTime()) == -1) {
e.reject("studyEventTransferValidator.start_date_after_end_date", new Object[] { studyEventTransferBean.getStartDateTime(), studyEventTransferBean.getEndDateTime() }, "Start date " + studyEventTransferBean.getStartDateTime() + " after end date (" + studyEventTransferBean.getEndDateTime() + ").");
return;
}
}
int parentStudyId = study.getParentStudyId();
StudyEventDefinitionBean studyEventDefinition = getStudyEventDefinitionDAO().findByOidAndStudy(studyEventTransferBean.getEventDefinitionOID(), study.getId(), parentStudyId);
if (studyEventDefinition == null) {
e.reject("studyEventTransferValidator.invalid_eventDefinitionOID", new Object[] { studyEventTransferBean.getEventDefinitionOID() }, "EventDefinitionOID you specified " + studyEventTransferBean.getEventDefinitionOID() + " is not valid.");
return;
}
}
use of org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean in project OpenClinica by OpenClinica.
the class ExpressionService method isExpressionValid.
/**
* Given a Complete Expression check business logic validity of each
* component. Will throw OpenClinicaSystemException with correct
* explanation. This might allow immediate communication of message to user
* .
*
* @param expression
*/
public void isExpressionValid(String expression) {
int length = expression.split(ESCAPED_SEPERATOR).length;
ItemBean item = null;
ItemGroupBean itemGroup = null;
CRFBean crf = null;
boolean isEventStartDateAndStatusParamExist = (expression.endsWith(STARTDATE) || expression.endsWith(STATUS));
if (length > 0 && !isEventStartDateAndStatusParamExist) {
item = getItemFromExpression(expression);
if (item == null)
throw new OpenClinicaSystemException("OCRERR_0023");
// throw new OpenClinicaSystemException("item is Invalid");
}
if (length > 1 && !isEventStartDateAndStatusParamExist) {
String itemGroupOid = getItemGroupOidFromExpression(expression);
itemGroup = getItemGroupDao().findByOid(itemGroupOid);
ArrayList<ItemGroupBean> igBean = (ArrayList<ItemGroupBean>) getItemGroupDao().findGroupsByItemID(item.getId());
if (itemGroup == null || itemGroup.getId() != igBean.get(0).getId())
throw new OpenClinicaSystemException("OCRERR_0022");
// throw new OpenClinicaSystemException("itemGroup is Invalid");
}
if (length > 2 && !isEventStartDateAndStatusParamExist) {
crf = getCRFFromExpression(expression);
if (crf == null || crf.getId() != itemGroup.getCrfId())
throw new OpenClinicaSystemException("OCRERR_0033");
// throw new OpenClinicaSystemException("CRF is Invalid");
}
if (length > 3 && !isEventStartDateAndStatusParamExist) {
StudyEventDefinitionBean studyEventDefinition = getStudyEventDefinitionFromExpression(expression);
crf = getCRFFromExpression(expression);
if (studyEventDefinition == null || crf == null)
throw new OpenClinicaSystemException("OCRERR_0034", new String[] { expression });
// throw new
// OpenClinicaSystemException("StudyEventDefinition is Invalid");
EventDefinitionCRFBean eventDefinitionCrf = getEventDefinitionCRFDao().findByStudyEventDefinitionIdAndCRFId(this.expressionWrapper.getStudyBean(), studyEventDefinition.getId(), crf.getId());
if (eventDefinitionCrf == null || eventDefinitionCrf.getId() == 0)
throw new OpenClinicaSystemException("OCRERR_0034", new String[] { expression });
// throw new
// OpenClinicaSystemException("StudyEventDefinition is Invalid");
}
if (length == 2 && isEventStartDateAndStatusParamExist) {
StudyEventDefinitionBean studyEventDefinition = getStudyEventDefinitionFromExpressionForEventScheduling(expression);
// studyEventDefinition.getOid());
if (studyEventDefinition == null)
throw new OpenClinicaSystemException("OCRERR_0034", new String[] { expression });
}
if (length != 2 && isEventStartDateAndStatusParamExist) {
throw new OpenClinicaSystemException("OCRERR_0034", new String[] { expression });
}
}
use of org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean in project OpenClinica by OpenClinica.
the class ExpressionService method getStudyEventDefinitionFromExpression.
public StudyEventDefinitionBean getStudyEventDefinitionFromExpression(String expression, StudyBean study) {
String studyEventDefinitionKey = getStudyEventDefinitionOidFromExpression(expression);
logger.debug("Expression : {} , Study Event Definition OID {} , Study Bean {} ", new Object[] { expression, studyEventDefinitionKey, study.getId() });
if (studyEventDefinitions.get(studyEventDefinitionKey) != null) {
return studyEventDefinitions.get(studyEventDefinitionKey);
} else {
// temp fix
int studyId = study.getParentStudyId() != 0 ? study.getParentStudyId() : study.getId();
StudyEventDefinitionBean studyEventDefinition = getStudyEventDefinitionDao().findByOidAndStudy(studyEventDefinitionKey, studyId, studyId);
// findByOidAndStudy method, tbh
if (studyEventDefinition != null) {
studyEventDefinitions.put(studyEventDefinitionKey, studyEventDefinition);
return studyEventDefinition;
} else {
return null;
}
}
}
use of org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean in project OpenClinica by OpenClinica.
the class ExpressionService method getStudyEventDefinitionFromExpressionForEvents.
public StudyEventDefinitionBean getStudyEventDefinitionFromExpressionForEvents(String expression, StudyBean study) {
// TODO Auto-generated method stub
String studyEventDefinitionKey = getStudyEventDefinitionOidFromExpressionForEvents(expression);
logger.debug("Expression : {} , Study Event Definition OID {} , Study Bean {} ", new Object[] { expression, studyEventDefinitionKey, study.getId() });
if (studyEventDefinitions.get(studyEventDefinitionKey) != null) {
return studyEventDefinitions.get(studyEventDefinitionKey);
} else {
// temp fix
int studyId = study.getParentStudyId() != 0 ? study.getParentStudyId() : study.getId();
StudyEventDefinitionBean studyEventDefinition = getStudyEventDefinitionDao().findByOidAndStudy(studyEventDefinitionKey, studyId, studyId);
// findByOidAndStudy method, tbh
if (studyEventDefinition != null) {
studyEventDefinitions.put(studyEventDefinitionKey, studyEventDefinition);
return studyEventDefinition;
} else {
return null;
}
}
}
use of org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean in project OpenClinica by OpenClinica.
the class ExpressionService method getEventDefinitionCRF.
public EventDefinitionCRFBean getEventDefinitionCRF(String expression) {
if (expression.split(ESCAPED_SEPERATOR).length < 4) {
return null;
}
StudyEventDefinitionBean studyEventDefinition = getStudyEventDefinitionFromExpression(expression);
CRFBean crf = getCRFFromExpression(expression);
if (studyEventDefinition == null || crf == null)
throw new OpenClinicaSystemException("OCRERR_0020");
return getEventDefinitionCRFDao().findByStudyEventDefinitionIdAndCRFId(this.expressionWrapper.getStudyBean(), studyEventDefinition.getId(), crf.getId());
}
Aggregations