Search in sources :

Example 76 with StudyEventDefinitionBean

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;
    }
}
Also used : Status(org.akaza.openclinica.bean.core.Status) StudyParameterValueBean(org.akaza.openclinica.bean.service.StudyParameterValueBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) StudyEventTransferBean(org.akaza.openclinica.ws.bean.StudyEventTransferBean) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)

Example 77 with StudyEventDefinitionBean

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 });
    }
}
Also used : ItemBean(org.akaza.openclinica.bean.submit.ItemBean) ArrayList(java.util.ArrayList) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) ItemGroupBean(org.akaza.openclinica.bean.submit.ItemGroupBean) OpenClinicaSystemException(org.akaza.openclinica.exception.OpenClinicaSystemException) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean)

Example 78 with StudyEventDefinitionBean

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;
        }
    }
}
Also used : StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)

Example 79 with StudyEventDefinitionBean

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;
        }
    }
}
Also used : StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)

Example 80 with StudyEventDefinitionBean

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());
}
Also used : StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) OpenClinicaSystemException(org.akaza.openclinica.exception.OpenClinicaSystemException) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean)

Aggregations

StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)155 ArrayList (java.util.ArrayList)109 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)85 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)65 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)61 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)61 CRFBean (org.akaza.openclinica.bean.admin.CRFBean)56 EventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)55 HashMap (java.util.HashMap)51 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)51 EventDefinitionCRFDAO (org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO)50 CRFDAO (org.akaza.openclinica.dao.admin.CRFDAO)49 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)49 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)48 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)45 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)45 StudySubjectDAO (org.akaza.openclinica.dao.managestudy.StudySubjectDAO)42 CRFVersionDAO (org.akaza.openclinica.dao.submit.CRFVersionDAO)39 Date (java.util.Date)37 CRFVersionBean (org.akaza.openclinica.bean.submit.CRFVersionBean)37