Search in sources :

Example 66 with ItemGroupBean

use of org.akaza.openclinica.bean.submit.ItemGroupBean in project OpenClinica by OpenClinica.

the class ItemGroupDAO method getEntityFromHashMap.

public Object getEntityFromHashMap(HashMap hm) {
    ItemGroupBean formGroupBean = new ItemGroupBean();
    super.setEntityAuditInformation(formGroupBean, hm);
    formGroupBean.setId((Integer) hm.get("item_group_id"));
    formGroupBean.setName((String) hm.get("name"));
    formGroupBean.setCrfId((Integer) hm.get("crf_id"));
    formGroupBean.setOid((String) hm.get("oc_oid"));
    formGroupBean.setLayoutGroupPath((String) hm.get("layout_group_path"));
    return formGroupBean;
}
Also used : ItemGroupBean(org.akaza.openclinica.bean.submit.ItemGroupBean)

Example 67 with ItemGroupBean

use of org.akaza.openclinica.bean.submit.ItemGroupBean in project OpenClinica by OpenClinica.

the class ItemGroupDAO method findTopOneGroupBySectionId.

public ItemGroupBean findTopOneGroupBySectionId(int sectionId) {
    ItemGroupBean formGroupBean = new ItemGroupBean();
    this.setTypesExpected();
    HashMap<Integer, Integer> variables = new HashMap<Integer, Integer>();
    variables.put(1, sectionId);
    String sql = digester.getQuery("findTopOneGroupBySectionId");
    ArrayList listofMap = this.select(sql, variables);
    for (Object map : listofMap) {
        formGroupBean = (ItemGroupBean) this.getEntityFromHashMap((HashMap) map);
    }
    return formGroupBean;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ItemGroupBean(org.akaza.openclinica.bean.submit.ItemGroupBean)

Example 68 with ItemGroupBean

use of org.akaza.openclinica.bean.submit.ItemGroupBean in project OpenClinica by OpenClinica.

the class ExpressionService method getItemGroupExpression.

public ItemGroupBean getItemGroupExpression(String expression) {
    if (expression.split(ESCAPED_SEPERATOR).length < 2) {
        return null;
    }
    String itemGroupKey = getItemGroupOidFromExpression(expression);
    logger.debug("Expression : {} , ItemGroup OID : {} " + expression, itemGroupKey);
    if (itemGroups.get(itemGroupKey) != null) {
        return itemGroups.get(itemGroupKey);
    } else {
        ItemGroupBean itemGroup = getItemGroupDao().findByOid(itemGroupKey);
        if (itemGroup != null) {
            itemGroups.put(itemGroupKey, itemGroup);
            return itemGroup;
        } else {
            return null;
        }
    }
}
Also used : ItemGroupBean(org.akaza.openclinica.bean.submit.ItemGroupBean)

Example 69 with ItemGroupBean

use of org.akaza.openclinica.bean.submit.ItemGroupBean 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 70 with ItemGroupBean

use of org.akaza.openclinica.bean.submit.ItemGroupBean in project OpenClinica by OpenClinica.

the class ExpressionService method checkValidityOfItemOrItemGroupOidInCrf.

public String checkValidityOfItemOrItemGroupOidInCrf(String oid, RuleSetBean ruleSet) {
    oid = oid.trim();
    String[] theOid = oid.split(ESCAPED_SEPERATOR);
    if (theOid.length == 2) {
        ItemGroupBean itemGroup = getItemGroupDao().findByOid(theOid[0]);
        Boolean isItemGroupBePartOfCrfOrNull = ruleSet.getCrfId() != null ? itemGroup.getCrfId().equals(ruleSet.getCrfId()) : true;
        if (itemGroup != null && isItemGroupBePartOfCrfOrNull) {
            if (ruleSet.getCrfId() != null && itemGroup.getCrfId().equals(ruleSet.getCrfId())) {
                return "OK";
            }
            if (ruleSet.getCrfId() != null && !itemGroup.getCrfId().equals(ruleSet.getCrfId())) {
                return oid;
            }
            ItemBean item = getItemDao().findItemByGroupIdandItemOid(itemGroup.getId(), theOid[1]);
            if (item != null) {
                return "OK";
            }
        }
    }
    if (theOid.length == 1) {
        ItemGroupBean itemGroup = getItemGroupDao().findByOid(oid);
        if (itemGroup != null) {
            if (ruleSet.getCrfId() != null && itemGroup.getCrfId().equals(ruleSet.getCrfId())) {
                return "OK";
            }
            if (ruleSet.getCrfId() != null && !itemGroup.getCrfId().equals(ruleSet.getCrfId())) {
                return oid;
            }
            return "OK";
        }
        // ItemBean item =
        // getItemDao().findItemByGroupIdandItemOid(getItemGroupExpression(ruleSet.getTarget().getValue()).getId(),
        // oid);
        ArrayList<ItemBean> items = (ArrayList<ItemBean>) getItemDao().findByOid(oid);
        if (items == null || items.size() != 0) {
            return "OK";
        }
    }
    return oid;
}
Also used : ItemBean(org.akaza.openclinica.bean.submit.ItemBean) ArrayList(java.util.ArrayList) ItemGroupBean(org.akaza.openclinica.bean.submit.ItemGroupBean)

Aggregations

ItemGroupBean (org.akaza.openclinica.bean.submit.ItemGroupBean)71 ArrayList (java.util.ArrayList)45 HashMap (java.util.HashMap)34 ItemBean (org.akaza.openclinica.bean.submit.ItemBean)26 DisplayItemGroupBean (org.akaza.openclinica.bean.submit.DisplayItemGroupBean)25 ItemGroupDAO (org.akaza.openclinica.dao.submit.ItemGroupDAO)23 SectionBean (org.akaza.openclinica.bean.submit.SectionBean)20 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)18 DisplayItemBean (org.akaza.openclinica.bean.submit.DisplayItemBean)17 ItemFormMetadataBean (org.akaza.openclinica.bean.submit.ItemFormMetadataBean)16 ItemGroupMetadataBean (org.akaza.openclinica.bean.submit.ItemGroupMetadataBean)16 CRFVersionBean (org.akaza.openclinica.bean.submit.CRFVersionBean)15 DisplaySectionBean (org.akaza.openclinica.bean.submit.DisplaySectionBean)14 ItemDAO (org.akaza.openclinica.dao.submit.ItemDAO)14 CRFBean (org.akaza.openclinica.bean.admin.CRFBean)13 EventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)12 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)12 CRFVersionDAO (org.akaza.openclinica.dao.submit.CRFVersionDAO)11 SectionDAO (org.akaza.openclinica.dao.submit.SectionDAO)11 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)10