Search in sources :

Example 26 with SectionBean

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

the class OpenRosaXmlGenerator method buildForm.

/**
     * @param formId
     * @return
     * @throws Exception
     */
public String buildForm(String formId) throws Exception {
    try {
        CRFVersionDAO versionDAO = new CRFVersionDAO(dataSource);
        FormLayoutDAO fldao = new FormLayoutDAO<>(dataSource);
        FormLayoutBean formLayout = fldao.findByOid(formId);
        CRFDAO crfDAO = new CRFDAO(dataSource);
        CRFBean crf = (CRFBean) crfDAO.findByPK(formLayout.getCrfId());
        CRFVersionMetadataUtil metadataUtil = new CRFVersionMetadataUtil(dataSource);
        ArrayList<SectionBean> crfSections = metadataUtil.retrieveFormMetadata(formLayout);
        ArrayList<CRFVersionBean> crfVersions = versionDAO.findAllByCRFId(crf.getId());
        CRFVersionBean crfVersion = crfVersions.get(0);
        StringWriter writer = new StringWriter();
        IOUtils.copy(getClass().getResourceAsStream("/properties/xform_template.xml"), writer, "UTF-8");
        String xform = writer.toString();
        Html html = buildJavaXForm(xform);
        int sectionCount = mapBeansToDTO(html, crf, crfVersion, crfSections);
        if (sectionCount > 1)
            setFormPaging(html);
        String xformMinusInstance = buildStringXForm(html);
        String preInstance = xformMinusInstance.substring(0, xformMinusInstance.indexOf("<instance>"));
        String instance = buildInstance(html.getHead().getModel(), formLayout, crfVersion, crfSections);
        String nodeset = xformMinusInstance.substring(xformMinusInstance.indexOf("</instance>") + "</instance>".length());
        // add nodeset for instanceId
        String postInstance = "<bind calculate=\"concat('uuid:', uuid())\" nodeset=\"/" + formLayout.getOid() + "/meta/instanceID\" readonly=\"true()\" type=\"string\"/>" + nodeset;
        logger.debug(preInstance + "<instance>\n" + instance + "\n</instance>" + postInstance);
        System.out.println(preInstance + "<instance>\n" + instance + "\n</instance>" + postInstance);
        return preInstance + "<instance>\n" + instance + "\n</instance>" + postInstance;
    } catch (Exception e) {
        log.error(e.getMessage());
        log.error(ExceptionUtils.getStackTrace(e));
        throw new Exception(e);
    }
}
Also used : CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) FormLayoutBean(org.akaza.openclinica.bean.submit.FormLayoutBean) Html(org.akaza.openclinica.web.pform.dto.Html) OpenClinicaException(org.akaza.openclinica.exception.OpenClinicaException) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) SectionBean(org.akaza.openclinica.bean.submit.SectionBean) StringWriter(java.io.StringWriter) FormLayoutDAO(org.akaza.openclinica.dao.submit.FormLayoutDAO) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) CRFVersionMetadataUtil(org.akaza.openclinica.control.managestudy.CRFVersionMetadataUtil)

Example 27 with SectionBean

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

the class SectionDAO method update.

public EntityBean update(EntityBean eb) {
    SectionBean sb = (SectionBean) eb;
    HashMap variables = new HashMap();
    variables.put(new Integer(1), new Integer(sb.getCRFVersionId()));
    variables.put(new Integer(2), new Integer(sb.getStatus().getId()));
    variables.put(new Integer(3), sb.getLabel());
    variables.put(new Integer(4), sb.getTitle());
    variables.put(new Integer(5), sb.getInstructions());
    variables.put(new Integer(6), sb.getSubtitle());
    variables.put(new Integer(7), sb.getPageNumberLabel());
    variables.put(new Integer(8), new Integer(sb.getOrdinal()));
    variables.put(new Integer(9), new Integer(sb.getUpdaterId()));
    variables.put(new Integer(10), new Integer(sb.getBorders()));
    variables.put(new Integer(11), new Integer(sb.getId()));
    this.execute(digester.getQuery("update"), variables);
    return eb;
}
Also used : SectionBean(org.akaza.openclinica.bean.submit.SectionBean) HashMap(java.util.HashMap)

Example 28 with SectionBean

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

the class SectionDAO method findByPK.

public EntityBean findByPK(int ID) {
    SectionBean eb = new SectionBean();
    this.setTypesExpected();
    HashMap variables = new HashMap();
    variables.put(new Integer(1), new Integer(ID));
    String sql = digester.getQuery("findByPK");
    ArrayList alist = this.selectByCache(sql, variables);
    Iterator it = alist.iterator();
    if (it.hasNext()) {
        eb = (SectionBean) this.getEntityFromHashMap((HashMap) it.next());
    }
    return eb;
}
Also used : SectionBean(org.akaza.openclinica.bean.submit.SectionBean) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator)

Example 29 with SectionBean

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

the class SectionDAO method create.

public EntityBean create(EntityBean eb) {
    SectionBean sb = (SectionBean) eb;
    HashMap variables = new HashMap();
    variables.put(new Integer(1), new Integer(sb.getCRFVersionId()));
    variables.put(new Integer(2), new Integer(sb.getStatus().getId()));
    variables.put(new Integer(3), sb.getLabel());
    variables.put(new Integer(4), sb.getTitle());
    variables.put(new Integer(5), sb.getInstructions());
    variables.put(new Integer(6), sb.getSubtitle());
    variables.put(new Integer(7), sb.getPageNumberLabel());
    variables.put(new Integer(8), new Integer(sb.getOrdinal()));
    variables.put(new Integer(9), new Integer(sb.getParentId()));
    variables.put(new Integer(10), new Integer(sb.getOwnerId()));
    variables.put(new Integer(11), new Integer(sb.getBorders()));
    this.execute(digester.getQuery("create"), variables);
    return eb;
}
Also used : SectionBean(org.akaza.openclinica.bean.submit.SectionBean) HashMap(java.util.HashMap)

Example 30 with SectionBean

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

the class SectionDAO method findAll.

public Collection findAll() {
    this.setTypesExpected();
    ArrayList alist = this.select(digester.getQuery("findAll"));
    ArrayList al = new ArrayList();
    Iterator it = alist.iterator();
    while (it.hasNext()) {
        SectionBean eb = (SectionBean) this.getEntityFromHashMap((HashMap) it.next());
        al.add(eb);
    }
    return al;
}
Also used : SectionBean(org.akaza.openclinica.bean.submit.SectionBean) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator)

Aggregations

SectionBean (org.akaza.openclinica.bean.submit.SectionBean)63 ArrayList (java.util.ArrayList)49 SectionDAO (org.akaza.openclinica.dao.submit.SectionDAO)35 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)33 HashMap (java.util.HashMap)28 DisplaySectionBean (org.akaza.openclinica.bean.submit.DisplaySectionBean)28 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)22 CRFVersionBean (org.akaza.openclinica.bean.submit.CRFVersionBean)20 ItemGroupBean (org.akaza.openclinica.bean.submit.ItemGroupBean)20 DisplayItemGroupBean (org.akaza.openclinica.bean.submit.DisplayItemGroupBean)19 EventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)17 CRFVersionDAO (org.akaza.openclinica.dao.submit.CRFVersionDAO)17 CRFBean (org.akaza.openclinica.bean.admin.CRFBean)16 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)15 DisplayItemBean (org.akaza.openclinica.bean.submit.DisplayItemBean)15 ItemBean (org.akaza.openclinica.bean.submit.ItemBean)15 ItemDataBean (org.akaza.openclinica.bean.submit.ItemDataBean)15 ItemFormMetadataBean (org.akaza.openclinica.bean.submit.ItemFormMetadataBean)14 CRFDAO (org.akaza.openclinica.dao.admin.CRFDAO)14 ItemDAO (org.akaza.openclinica.dao.submit.ItemDAO)14