/** @param metadata The metadata to set. */
  public void setMetadata(ItemFormMetadataBean metadata) {
    this.metadata = metadata;

    ResponseSetBean rsb = metadata.getResponseSet();
    // BWP 09/18/07 >> rsb cannot be null here because I added this line to
    // ItemFormMetadataBean's
    // constructor: responseSet=new ResponseSetBean();
    // logger.info("rsb = " + rsb);

    org.akaza.openclinica.bean.core.ResponseType rt = rsb.getResponseType();

    if (rt.equals(org.akaza.openclinica.bean.core.ResponseType.CHECKBOX)
        || rt.equals(org.akaza.openclinica.bean.core.ResponseType.RADIO)
        || rt.equals(org.akaza.openclinica.bean.core.ResponseType.SELECT)
        || rt.equals(org.akaza.openclinica.bean.core.ResponseType.SELECTMULTI)) {

      ArrayList nullValues = eventDefinitionCRF.getNullValuesList();
      for (int i = 0; i < nullValues.size(); i++) {
        NullValue nv = (NullValue) nullValues.get(i);
        ResponseOptionBean ro = new ResponseOptionBean();

        ro.setValue(nv.getName());
        ro.setText(nv.getDescription());
        rsb.addOption(ro);
      }
    }
    metadata.setResponseSet(rsb);
  }
  public void loadDBValue() {
    ResponseSetBean rsb = metadata.getResponseSet();
    org.akaza.openclinica.bean.core.ResponseType rt = rsb.getResponseType();
    String dbValue = data.getValue();
    // System.out.println("setting dbValue: " + dbValue);
    if (rt.equals(org.akaza.openclinica.bean.core.ResponseType.CHECKBOX)
        || rt.equals(org.akaza.openclinica.bean.core.ResponseType.SELECTMULTI)) {
      String dbValues[] = dbValue.split(",");

      if (dbValues != null) {
        for (String element : dbValues) {
          if (element != null) {
            rsb.setSelected(element.trim(), true);
          }
        }
      }
    } else if (rt.equals(org.akaza.openclinica.bean.core.ResponseType.TEXT)
        || rt.equals(
            org.akaza.openclinica.bean.core.ResponseType
                .TEXTAREA) // || rt.equals(org.akaza.openclinica.bean.core.ResponseType.CODING)
        || rt.equals(org.akaza.openclinica.bean.core.ResponseType.CALCULATION)
        || rt.equals(org.akaza.openclinica.bean.core.ResponseType.GROUP_CALCULATION)) {
      rsb.setValue(dbValue);
    } else if (rt.equals(org.akaza.openclinica.bean.core.ResponseType.FILE)) {
      // Here assume dbValue from database should be a valid file pathname
      if (dbValue.length() > 0) {
        dbData.setValue(dbValue);
        File f = new File(dbValue);
        String filename = f.getName();
        if (f.isFile()) {
          rsb.setValue(filename);
        } else {
          // File does not exist,
          rsb.setValue("fileNotFound#" + filename);
        }
      } else {
        rsb.setValue(dbValue);
      }
    } else {
      if (dbValue != null) {
        dbValue = dbValue.trim();
      }
      rsb.setSelected(dbValue, true);
    }

    metadata.setResponseSet(rsb);
  }
  public void loadFormValue(String value) {
    ResponseSetBean rsb = metadata.getResponseSet();
    org.akaza.openclinica.bean.core.ResponseType rt = rsb.getResponseType();

    if (rt.equals(org.akaza.openclinica.bean.core.ResponseType.TEXT)
        || rt.equals(
            org.akaza.openclinica.bean.core.ResponseType
                .TEXTAREA) // || rt.equals(org.akaza.openclinica.bean.core.ResponseType.CODING)
        || rt.equals(org.akaza.openclinica.bean.core.ResponseType.CALCULATION)
        || rt.equals(org.akaza.openclinica.bean.core.ResponseType.GROUP_CALCULATION)
        || rt.equals(org.akaza.openclinica.bean.core.ResponseType.FILE)) {
      rsb.setValue(value);
    } else {
      if (value != null) {
        rsb.setSelected(value.trim(), true);
      }
    }
    // logger.info("loadFormValue, line 241, DisplayItemBean
    // "+rsb.getResponseType().getName());
    metadata.setResponseSet(rsb);
    // System.out.println("data value:" + data.getId() + " " + value);
    data.setValue(value); // comment set by tbh, 112007
  }