Esempio n. 1
0
  public Object getEntityFromHashMap(HashMap hm) {
    ItemBean eb = new ItemBean();
    // below inserted to find out a class cast exception, tbh
    Date dateCreated = (Date) hm.get("date_created");
    Date dateUpdated = (Date) hm.get("date_updated");
    Integer statusId = (Integer) hm.get("status_id");
    Integer ownerId = (Integer) hm.get("owner_id");
    Integer updateId = (Integer) hm.get("update_id");

    eb.setCreatedDate(dateCreated);
    eb.setUpdatedDate(dateUpdated);
    eb.setStatus(Status.get(statusId.intValue()));
    eb.setOwnerId(ownerId.intValue());
    eb.setUpdaterId(updateId.intValue());
    // something to trip over
    // something else to trip over
    // eb = (ItemBean)this.getEntityAuditInformation(hm);
    eb.setName((String) hm.get("name"));
    eb.setId(((Integer) hm.get("item_id")).intValue());
    eb.setDescription((String) hm.get("description"));
    eb.setUnits((String) hm.get("units"));
    eb.setPhiStatus(((Boolean) hm.get("phi_status")).booleanValue());
    eb.setItemDataTypeId(((Integer) hm.get("item_data_type_id")).intValue());
    eb.setItemReferenceTypeId(((Integer) hm.get("item_reference_type_id")).intValue());
    // logger.info("item name|date type id" + eb.getName() + "|" +
    // eb.getItemDataTypeId());
    eb.setDataType(ItemDataType.get(eb.getItemDataTypeId()));
    eb.setOid((String) hm.get("oc_oid"));
    // the rest should be all set
    return eb;
  }
Esempio n. 2
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;
  }