Exemplo n.º 1
0
 public Object getEntityFromHashMap(HashMap hm) {
   ItemDataBean eb = new ItemDataBean();
   this.setEntityAuditInformation(eb, hm);
   eb.setId(((Integer) hm.get("item_data_id")).intValue());
   eb.setEventCRFId(((Integer) hm.get("event_crf_id")).intValue());
   eb.setItemId(((Integer) hm.get("item_id")).intValue());
   eb.setValue((String) hm.get("value"));
   eb.setStatus(Status.get(((Integer) hm.get("status_id")).intValue()));
   return eb;
 }
  private ItemDataBean copyItemDataBean(ItemDataBean src) {
    ItemDataBean result = new ItemDataBean();
    result.setEventCRFId(src.getEventCRFId());
    result.setItemId(src.getItemId());
    result.setValue(src.getValue());
    result.setOrdinal(src.getOrdinal());
    result.setSelected(src.isSelected());
    result.setAuditLog(src.isAuditLog());
    result.setCreatedDate(src.getCreatedDate());
    result.setUpdatedDate(src.getUpdatedDate());
    result.setOwner(src.getOwner());
    result.setOwnerId(src.getOwnerId());
    result.setUpdater(src.getUpdater());
    result.setUpdaterId(src.getUpdaterId());
    result.setStatus(src.getStatus());

    return result;
  }
Exemplo n.º 3
0
  public ArrayList<ItemBean> findAllWithItemDataByCRFVersionId(int crfVersionId, int eventCRFId) {
    this.unsetTypeExpected();

    this.setTypeExpected(1, TypeNames.STRING); // (item)name
    this.setTypeExpected(2, TypeNames.INT); // ordinal
    this.setTypeExpected(3, TypeNames.STRING); // oc_oid
    this.setTypeExpected(4, TypeNames.INT); // item_data_id
    this.setTypeExpected(5, TypeNames.INT); // item_id
    this.setTypeExpected(6, TypeNames.STRING); // (item)value

    ArrayList<ItemBean> answer = new ArrayList<ItemBean>();

    HashMap variables = new HashMap();
    variables.put(new Integer(1), new Integer(crfVersionId));
    variables.put(new Integer(2), new Integer(eventCRFId));

    String sql = digester.getQuery("findAllWithItemDataByCRFVersionId");

    ArrayList rows = super.select(sql, variables);
    Iterator it = rows.iterator();
    int cur_item_id = 0;
    ItemBean item_bean = null;
    ItemDataBean item_data_bean = null;
    while (it.hasNext()) {
      HashMap row = (HashMap) it.next();
      Integer id = (Integer) row.get("item_id");
      if (cur_item_id != id.intValue()) {
        item_bean = new ItemBean();
        answer.add(item_bean);
        cur_item_id = id.intValue();
        item_bean.setId(cur_item_id);
        item_bean.setName((String) row.get("name"));
        item_bean.setOid((String) row.get("oc_oid"));
      }
      item_data_bean = new ItemDataBean();
      item_data_bean.setValue((String) row.get("value"));
      item_data_bean.setOrdinal(((Integer) row.get("ordinal")).intValue());
      item_data_bean.setId(((Integer) row.get("item_data_id")).intValue());
      item_data_bean.setItemId(cur_item_id);
      item_bean.addItemDataElement(item_data_bean);
    }

    return answer;
  }
  protected boolean writeToDB(
      ItemBean ib,
      ItemFormMetadataBean ifm,
      ItemDataBean idb,
      String exp,
      String value,
      StringBuffer err) {
    ItemDataDAO iddao = new ItemDataDAO(sm.getDataSource());
    NumberFormat nf = NumberFormat.getInstance();

    if (idb == null) {
      idb = new ItemDataBean();
    }

    ItemDataType idt = ib.getDataType();
    if (value == null || value.length() == 0) {
      if (idb.isActive() && !"".equals(idb.getValue())) {
        idb.setValue("<erased>");
      } else {
        idb.setValue("");
      }
      err.append("Result is empty in" + " " + exp + "; ");
    } else {
      idb.setValue(this.getMathContextValue(value, ifm, idt, err));
    }

    idb.setStatus(Status.UNAVAILABLE);
    // idb.setNeedsRecalc(false);
    if (!idb.isActive()) {
      // will this need to change for double data entry?
      idb.setCreatedDate(new Date());
      idb.setOwner(ub);
      idb.setItemId(ib.getId());
      idb.setEventCRFId(ecb.getId());

      idb = (ItemDataBean) iddao.create(idb);
    } else {
      idb = (ItemDataBean) iddao.update(idb);
    }

    return idb.isActive();
  }