public void processRequest() throws Exception {
    FormProcessor fp = new FormProcessor(request);
    int itemId = fp.getInt(ITEM_ID);
    ItemDAO idao = new ItemDAO(sm.getDataSource());
    ItemFormMetadataDAO ifmdao = new ItemFormMetadataDAO(sm.getDataSource());
    CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
    CRFDAO cdao = new CRFDAO(sm.getDataSource());

    if (itemId == 0) {
      addPageMessage("Please choose an item first.");
      forwardPage(Page.ITEM_DETAIL);
      return;
    }
    ItemBean item = (ItemBean) idao.findByPK(itemId);
    ArrayList versions = idao.findAllVersionsByItemId(item.getId());
    ArrayList versionItems = new ArrayList();
    // finds each item metadata for each version
    for (int i = 0; i < versions.size(); i++) {
      Integer versionId = (Integer) versions.get(i);
      CRFVersionBean version = (CRFVersionBean) cvdao.findByPK(versionId.intValue());
      if (versionId != null && versionId.intValue() > 0) {
        ItemFormMetadataBean imfBean =
            ifmdao.findByItemIdAndCRFVersionId(item.getId(), versionId.intValue());
        imfBean.setCrfVersionName(version.getName());
        CRFBean crf = (CRFBean) cdao.findByPK(version.getCrfId());
        imfBean.setCrfName(crf.getName());
        versionItems.add(imfBean);
      }
    }
    request.setAttribute(VERSION_ITEMS, versionItems);
    request.setAttribute(ITEM_BEAN, item);
    forwardPage(Page.ITEM_DETAIL);
  }
Beispiel #2
0
 public ArrayList findAllActiveByCRF(CRFBean crf) {
   HashMap variables = new HashMap();
   this.setTypesExpected();
   this.setTypeExpected(14, TypeNames.INT); // crf_version_id
   this.setTypeExpected(15, TypeNames.STRING); // version name
   variables.put(new Integer(1), new Integer(crf.getId()));
   String sql = digester.getQuery("findAllActiveByCRF");
   ArrayList alist = this.select(sql, variables);
   ArrayList al = new ArrayList();
   Iterator it = alist.iterator();
   while (it.hasNext()) {
     HashMap hm = (HashMap) it.next();
     ItemBean eb = (ItemBean) this.getEntityFromHashMap(hm);
     Integer versionId = (Integer) hm.get("crf_version_id");
     String versionName = (String) hm.get("cvname");
     ItemFormMetadataBean imf = new ItemFormMetadataBean();
     imf.setCrfVersionName(versionName);
     // logger.info("versionName" + imf.getCrfVersionName());
     imf.setCrfVersionId(versionId.intValue());
     eb.setItemMeta(imf);
     al.add(eb);
   }
   return al;
 }