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);
}
}
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;
}
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;
}
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;
}
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;
}
Aggregations