Search in sources :

Example 1 with UserControl

use of org.akaza.openclinica.web.pform.dto.UserControl in project OpenClinica by OpenClinica.

the class OpenRosaXmlGenerator method getGroupInfo.

/**
     * @param itemGroupBean
     * @param crfVersion
     * @param section
     * @param factory
     * @param bindList
     * @return
     * @throws Exception
     */
private HashMap<String, Object> getGroupInfo(ItemGroupBean itemGroupBean, CRFVersionBean crfVersion, SectionBean section, WidgetFactory factory, ArrayList<Bind> bindList) throws Exception {
    boolean expressionEvaluate = true;
    igmdao = new ItemGroupMetadataDAO(dataSource);
    List<ItemGroupMetadataBean> itemGroupMetadata = igmdao.findMetaByGroupAndSection(itemGroupBean.getId(), crfVersion.getId(), section.getId());
    HashMap<String, Object> map = new HashMap<String, Object>();
    Group group = new Group();
    Repeat repeat = new Repeat();
    group.setUsercontrol(new ArrayList<UserControl>());
    repeat.setUsercontrol(new ArrayList<UserControl>());
    Label groupHeader = new Label();
    groupHeader.setLabel(itemGroupMetadata.get(0).getHeader());
    boolean isGroupRepeating = getItemGroupMetadata(itemGroupBean, crfVersion, section).isRepeatingGroup();
    String nodeset = "/" + crfVersion.getOid() + "/" + itemGroupBean.getOid();
    // repeat.setJrNoAddRemove("true()");
    repeat.setJrCount(nodeset);
    group.setRef(nodeset);
    repeat.setNodeset(nodeset);
    String groupExpression = null;
    ExpressionExpressionEvaluate eev = getSkipPattern(null, itemGroupBean);
    groupExpression = eev.getExpression();
    expressionEvaluate = eev.isExpressionEvaluate();
    if (groupExpression != null)
        groupExpression = getFullExpressionToParse(groupExpression, crfVersion, expressionEvaluate);
    setGroupWidget(section, crfVersion, groupExpression, bindList, factory, itemGroupBean, group, repeat, isGroupRepeating, groupHeader);
    map.put("group", group);
    map.put("repeat", repeat);
    map.put("isGroupRepeating", isGroupRepeating);
    return map;
}
Also used : Group(org.akaza.openclinica.web.pform.dto.Group) HashMap(java.util.HashMap) Label(org.akaza.openclinica.web.pform.dto.Label) Repeat(org.akaza.openclinica.web.pform.dto.Repeat) ItemGroupMetadataBean(org.akaza.openclinica.bean.submit.ItemGroupMetadataBean) ItemGroupMetadataDAO(org.akaza.openclinica.dao.submit.ItemGroupMetadataDAO) UserControl(org.akaza.openclinica.web.pform.dto.UserControl)

Example 2 with UserControl

use of org.akaza.openclinica.web.pform.dto.UserControl in project OpenClinica by OpenClinica.

the class OpenRosaXmlGenerator method mapBeansToDTO.

/**
     * @param html
     * @param crf
     * @param crfVersion
     * @param crfSections
     * @return
     * @throws Exception
     */
private Integer mapBeansToDTO(Html html, CRFBean crf, CRFVersionBean crfVersion, ArrayList<SectionBean> crfSections) throws Exception {
    boolean expressionEvaluate = true;
    int sectionCount = 0;
    ItemFormMetadataBean itemFormMetadataBean = null;
    Body body = html.getBody();
    ArrayList<Group> allSections = new ArrayList<Group>();
    ArrayList<Bind> bindList = new ArrayList<Bind>();
    WidgetFactory factory = new WidgetFactory(crfVersion);
    html.getHead().setTitle(crf.getName());
    for (SectionBean section : crfSections) {
        ArrayList<Group> groups = new ArrayList<Group>();
        Group singleSection = new Group();
        singleSection.setUsercontrol(new ArrayList<UserControl>());
        String ref = "/" + crfVersion.getOid() + "/" + "SECTION_" + section.getLabel().replaceAll("\\W", "_");
        singleSection.setRef(ref);
        String sectionExpression = null;
        igdao = new ItemGroupDAO(dataSource);
        ArrayList<ItemGroupBean> groupBeans = (ArrayList<ItemGroupBean>) igdao.findGroupBySectionId(section.getId());
        int count = 0;
        if (groupBeans.size() > 0) {
            for (ItemGroupBean groupBean : groupBeans) {
                ExpressionExpressionEvaluate eev = getSkipPattern(null, groupBean);
                String expr = eev.getExpression();
                expressionEvaluate = eev.isExpressionEvaluate();
                if (expr != null) {
                    if (sectionExpression != null) {
                        sectionExpression = sectionExpression + " and " + expr;
                        count++;
                    } else {
                        sectionExpression = expr;
                        count++;
                    }
                }
            }
            if (sectionExpression != null && groupBeans.size() == count) {
                sectionExpression = getFullExpressionToParse(sectionExpression, crfVersion, expressionEvaluate);
            } else {
                sectionExpression = null;
            }
            setSectionWidget(section, crfVersion, sectionExpression, bindList, factory, singleSection);
            HashMap<String, Object> groupMap = null;
            boolean isGroupRepeating = false;
            Group group = null;
            Repeat repeat = null;
            idao = new ItemDAO(dataSource);
            ArrayList<ItemBean> items = (ArrayList<ItemBean>) idao.findAllBySectionIdOrderedByItemFormMetadataOrdinal(section.getId());
            Integer itemGroupId = 0;
            for (ItemBean item : items) {
                ItemGroupBean itemGroupBean = getItemGroupBeanByItemId(item.getId());
                if (itemGroupId != itemGroupBean.getId()) {
                    groupMap = getGroupInfo(itemGroupBean, crfVersion, section, factory, bindList);
                    isGroupRepeating = (Boolean) groupMap.get("isGroupRepeating");
                    group = (Group) groupMap.get("group");
                    repeat = (Repeat) groupMap.get("repeat");
                }
                itemFormMetadataBean = getItemFormMetadata(item, crfVersion);
                int responseTypeId = itemFormMetadataBean.getResponseSet().getResponseTypeId();
                boolean isItemRequired = itemFormMetadataBean.isRequired();
                String responseLayout = itemFormMetadataBean.getResponseLayout();
                String itemExpression = null;
                ExpressionExpressionEvaluate eev = getSkipPattern(item, itemGroupBean);
                itemExpression = eev.getExpression();
                expressionEvaluate = eev.isExpressionEvaluate();
                if (itemExpression != null)
                    itemExpression = getFullExpressionToParse(itemExpression, crfVersion, expressionEvaluate);
                // Add the Item Header
                setHeaderWidget(item, itemFormMetadataBean, itemGroupBean, bindList, factory, isGroupRepeating, repeat, group, itemExpression);
                // Add the Item SubHeader
                setSubHeaderWidget(item, itemFormMetadataBean, itemGroupBean, bindList, factory, isGroupRepeating, repeat, group, itemExpression);
                // Add the Item itself
                setItemWidget(item, responseTypeId, itemFormMetadataBean, itemGroupBean, bindList, factory, isGroupRepeating, repeat, group, isItemRequired, responseLayout, itemExpression);
                if (itemGroupId != itemGroupBean.getId()) {
                    groups.add(group);
                    itemGroupId = itemGroupBean.getId();
                }
            }
            // end of item loop
            singleSection.setGroup(groups);
            allSections.add(singleSection);
        }
        // end of groups per section if exist
        sectionCount = allSections.size();
    }
    // end of section loop
    body.setGroup(allSections);
    html.getHead().getModel().setBind(bindList);
    return sectionCount;
}
Also used : Group(org.akaza.openclinica.web.pform.dto.Group) Bind(org.akaza.openclinica.web.pform.dto.Bind) ItemBean(org.akaza.openclinica.bean.submit.ItemBean) ItemDAO(org.akaza.openclinica.dao.submit.ItemDAO) ArrayList(java.util.ArrayList) ItemGroupDAO(org.akaza.openclinica.dao.submit.ItemGroupDAO) Repeat(org.akaza.openclinica.web.pform.dto.Repeat) UserControl(org.akaza.openclinica.web.pform.dto.UserControl) Body(org.akaza.openclinica.web.pform.dto.Body) SectionBean(org.akaza.openclinica.bean.submit.SectionBean) WidgetFactory(org.akaza.openclinica.web.pform.widget.WidgetFactory) ItemGroupBean(org.akaza.openclinica.bean.submit.ItemGroupBean) ItemFormMetadataBean(org.akaza.openclinica.bean.submit.ItemFormMetadataBean)

Aggregations

Group (org.akaza.openclinica.web.pform.dto.Group)2 Repeat (org.akaza.openclinica.web.pform.dto.Repeat)2 UserControl (org.akaza.openclinica.web.pform.dto.UserControl)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 ItemBean (org.akaza.openclinica.bean.submit.ItemBean)1 ItemFormMetadataBean (org.akaza.openclinica.bean.submit.ItemFormMetadataBean)1 ItemGroupBean (org.akaza.openclinica.bean.submit.ItemGroupBean)1 ItemGroupMetadataBean (org.akaza.openclinica.bean.submit.ItemGroupMetadataBean)1 SectionBean (org.akaza.openclinica.bean.submit.SectionBean)1 ItemDAO (org.akaza.openclinica.dao.submit.ItemDAO)1 ItemGroupDAO (org.akaza.openclinica.dao.submit.ItemGroupDAO)1 ItemGroupMetadataDAO (org.akaza.openclinica.dao.submit.ItemGroupMetadataDAO)1 Bind (org.akaza.openclinica.web.pform.dto.Bind)1 Body (org.akaza.openclinica.web.pform.dto.Body)1 Label (org.akaza.openclinica.web.pform.dto.Label)1 WidgetFactory (org.akaza.openclinica.web.pform.widget.WidgetFactory)1