/**
   * Gets the names of the contexts that use this data element. The names of the contexts are are
   * comma separated.
   */
  public String getUsingContexts() throws Exception {
    NCIBC4JUtil bc4jUtil = new NCIBC4JUtil();
    String usingContext = "";
    StringBuffer sbuf = new StringBuffer("");

    try {
      oracle.jbo.ViewObject desView =
          getViewObject().getApplicationModule().findViewObject("DesignationsView");

      /*ViewObjectImpl desView1 = (DesignationsViewImpl)
      bc4jUtil.cloneViewObject(desView);*/
      desView.setWhereClause("AC_IDSEQ='" + getDeIdseq() + "' and DETL_NAME = 'USED_BY'");
      desView.executeQuery();

      DesignationsViewRowImpl desRow;
      String desContext;
      boolean multipleUsedBys = false;

      while (desView.hasNext()) {
        desRow = (DesignationsViewRowImpl) desView.next();
        desContext = (String) desRow.getContextsRow().getAttribute("Name");

        if (!multipleUsedBys) {
          sbuf.append(desContext);
          multipleUsedBys = true;
        } else {
          sbuf.append(" , " + desContext);
        }
      }
    } catch (Exception e) {
      throw e;
    }

    return sbuf.toString();
  }
  public Context getContext() {
    try {
      oracle.jbo.ViewObject vdView =
          getViewObject().getApplicationModule().findViewObject("ContextsView");

      vdView.setWhereClause("CONTE_IDSEQ='" + getConteIdseq() + "'");

      Row row = vdView.first();

      Context conte = (Context) new BC4JContextTransferObject((ContextsViewRowImpl) row);

      return conte;
    } // end try
    catch (Exception e) {
      log.error("Error in DataElementsViewRowImpl.getContext(): ", e);

      return null;
    }
  }
  public ValueDomain getValueDomain() {
    try {
      oracle.jbo.ViewObject vdView =
          getViewObject().getApplicationModule().findViewObject("ValueDomainsView");

      vdView.setWhereClause("VD_IDSEQ='" + getVdIdseq() + "'");

      Row row = vdView.first();

      ValueDomain vd =
          (ValueDomain) new BC4JValueDomainTransferObject((ValueDomainsViewRowImpl) row);

      return vd;
    } // end try
    catch (Exception e) {
      log.error("Error in DataElementsViewRowImpl.getValueDomain(): ", e);

      return null;
    }
  }
  public DataElementConcept getDataElementConcept() {
    try {
      oracle.jbo.ViewObject decView =
          getViewObject().getApplicationModule().findViewObject("DataElementConceptsView");

      decView.setWhereClause("DEC_IDSEQ='" + getDecIdseq() + "'");

      Row row = decView.first();

      DataElementConcept dec =
          (DataElementConcept)
              new BC4JDataElementConceptTransferObject((DataElementConceptsViewRowImpl) row);

      return dec;
    } // end try
    catch (Exception e) {
      log.error("Error in getDataElementConcept(): ", e);

      return null;
    }
  }
  public List getDesignations() {
    List designations = new ArrayList(9);
    NCIBC4JUtil bc4jUtil = new NCIBC4JUtil();

    try {
      oracle.jbo.ViewObject desView =
          getViewObject().getApplicationModule().findViewObject("DesignationsView");

      /*ViewObjectImpl desView1 = (DesignationsViewImpl)
      bc4jUtil.cloneViewObject(desView);*/
      desView.setWhereClause("AC_IDSEQ='" + getDeIdseq() + "'");
      desView.executeQuery();

      while (desView.hasNext()) {
        designations.add(
            new BC4JDesignationTransferObject((DesignationsViewRowImpl) desView.next()));
      }
    } catch (Exception e) {
      log.error("Error in getDesignations(): ", e);
    }

    return designations;
  }
  public String getRegistrationStatus() {
    String rgStatus = null;

    try {
      oracle.jbo.ViewObject rView =
          getViewObject().getApplicationModule().findViewObject("AcRegistrationsView");

      rView.setWhereClause("AC_IDSEQ='" + getDeIdseq() + "'");

      Row row = rView.first();

      if (row != null) {
        rgStatus = (String) row.getAttribute("RegistrationStatus");
      }

      // String longCDEName = row
    } // end try
    catch (Exception e) {
      log.error("Error in getRegistrationStatus(): ", e);
    }

    return rgStatus;
  }
  public String getCDEId() {
    Number cdeId = null;

    try {
      oracle.jbo.ViewObject cdeIdView =
          getViewObject().getApplicationModule().findViewObject("DeCdeIdView");

      cdeIdView.setWhereClause("AC_IDSEQ='" + getDeIdseq() + "'");

      Row row = cdeIdView.first();

      if (row != null) {
        cdeId = (Number) row.getAttribute("MinCdeId");
      }

      return cdeId.toString();
    } // end try
    catch (Exception e) {
      log.error("Error in getCDEId(): ", e);

      return null;
    }
  }
  public String getLongCDEName() {
    String longCDEName = null;

    try {
      oracle.jbo.ViewObject rdView =
          getViewObject().getApplicationModule().findViewObject("ReferenceDocumentsView");

      rdView.setWhereClause(
          "AC_IDSEQ='" + getDeIdseq() + "' AND DCTL_NAME = 'Preferred Question Text'");

      Row row = rdView.first();

      if (row != null) {
        longCDEName = (String) row.getAttribute("DocText");
      }

      // String longCDEName = row
    } // end try
    catch (Exception e) {
      log.error("Error in getLongCDEName(): ", e);
    }

    return longCDEName;
  }