/**
   * This method gives the list for Delineated Privilege DropDown in UI
   *
   * @return List - SelectItem (for Delineated Privilege DropDown)
   */
  public List<SelectItem> getSelectList() {

    try {
      Long institutionId =
          Long.valueOf(getValueFromSessionParam(PARAMETER_INSTITUTION_ID).toString());
      if (selectList == null || selectList.isEmpty()) {
        selectList = new ArrayList<SelectItem>();
        LinkedHashMap<String, String> categoryPrivilegesMap =
            (LinkedHashMap<String, String>)
                executeBinding(GET_PRIVILEGE_TYPES, INSTITUTION_ID, institutionId);
        if (categoryPrivilegesMap == null) {
          showGenericError();
        }
        Iterator<Map.Entry<String, String>> entries = categoryPrivilegesMap.entrySet().iterator();
        Map.Entry<String, String> entry;
        while (entries.hasNext()) {
          entry = entries.next();
          selectList.add(new SelectItem(entry.getKey(), entry.getValue()));
          if (entry.getValue().contains(HYPHENS)) {
            categoryIdList.add(entry.getKey());
          }
        }
      }
      OPPE_LOG.debug("METRICS.GET_PRIVILEGES_LIST_DEBUG");
    } catch (Exception exception) {
      OPPE_LOG.error("DATABASE_RETRIEVE_ERROR", exception);
      showGenericError();
    }
    return selectList;
  }
  /**
   * This method sets the filter criteria in OppeMetricsDTO
   *
   * @param oppeMetricsDto - instance of OppeMetricsDTO
   * @return oppeMetricsDto - instance of OppeMetricsDTO
   */
  private OppeMetricsDTO setFilterCriteria(OppeMetricsDTO oppeMetricsDto) {
    if (checkMetricSearch && statusChoiceUI != null && metricIdUI != null && metricNameUI != null) {
      statusChoiceUI.setValue(
          statusChoiceUI.getValue() != null
                  && (statusChoiceUI.getValue().toString().length() == 0
                      || statusChoiceUI.getValue().toString().equals(SELECT_ALL))
              ? null
              : statusChoiceUI.getValue());
      setdelPrivValue(
          getdelPrivValue() != null
                  && (getdelPrivValue().toString().length() == 0
                      || getdelPrivValue().equals(SELECT_ALL))
              ? null
              : getdelPrivValue());
      metricIdUI.setValue(
          metricIdUI.getValue() != null && metricIdUI.getValue().toString().trim().length() == 0
              ? null
              : metricIdUI.getValue());
      metricNameUI.setValue(
          metricNameUI.getValue() != null && metricNameUI.getValue().toString().trim().length() == 0
              ? null
              : metricNameUI.getValue());
      if (statusChoiceUI.getValue() != null) {
        oppeMetricsDto.setStatusId(Long.valueOf(statusChoiceUI.getValue().toString()));
      }
      if (delPrivValue != null) {
        oppeMetricsDto.setDelineatedPrivilegeId(Long.valueOf(delPrivValue));
      }
      if (metricIdUI.getValue() != null) {
        oppeMetricsDto.setMetricId(
            PERCENT + metricIdUI.getValue().toString().toUpperCase() + PERCENT);
      }
      if (metricNameUI.getValue() != null) {
        oppeMetricsDto.setMetricsName(
            PERCENT + metricNameUI.getValue().toString().toUpperCase() + PERCENT);
      }
    }

    oppeMetricsDto.setRangeBegin(rangeBegin);
    oppeMetricsDto.setRangeEnd(rangeEnd);
    oppeMetricsDto.setSortBy(getSortOrder());
    oppeMetricsDto.setEvaluationType(getEvaluationTypeId());
    oppeMetricsDto.setInstitutionId(
        Long.valueOf(getValueFromSessionParam(PARAMETER_INSTITUTION_ID).toString()));
    OPPE_LOG.debug("METRICS.SET_FILTER_CRITERIA_DEBUG");
    return oppeMetricsDto;
  }
  /**
   * This method render the previousUI set of records
   *
   * @return EmptyString - empty string
   */
  public String onPreviousClick() {
    try {

      rangeBegin = Long.valueOf(rangeBeginUI.getValue().toString()) - FETCH_SIZE;
      rangeEnd = rangeBegin + FETCH_SIZE - 1;
      totalRowCount = Long.valueOf(totalCountUI.getValue().toString().trim());
      if (rangeBegin <= 1) {
        previousLinkUI.setDisabled(true);
      }
      nextLinkUI.setDisabled(false);
      OppeMetricsDTO oppeMetricsDto = new OppeMetricsDTO();
      oppeMetricsDto = setFilterCriteria(oppeMetricsDto);
      Map parameterMap = new HashMap();
      parameterMap.put(OPPEMETRIC_DTO, oppeMetricsDto);
      parameterMap.put(IS_METRIC_SEARCH, false);
      executeBinding(GET_OPPE_METRICDATA, parameterMap);
      OPPE_LOG.debug("METRICS.PREVIOUS_CLICK_DEBUG");
    } catch (Exception exception) {
      OPPE_LOG.error("DATABASE_RETRIEVE_ERROR", exception);
      showGenericError();
    }
    return EMPTY_STRING;
  }
 /** This method initializes some variables before page load. */
 public void initialize() {
   try {
     checkMetricSearch = true;
     rangeBegin = PAGINATION_RANGE_BEGIN_VALUE;
     rangeEnd = rangeBegin + FETCH_SIZE - 1;
     sortOrder = OPPEMETRIC_DEFAULT_SORT;
     evaluationTypeId = (Long) getValueFromSessionParam(EVALUATION_TYPE_ID);
     categoryIdList = new ArrayList<String>();
     OppeMetricsDTO oppeMetricsDto = new OppeMetricsDTO();
     oppeMetricsDto.setEvaluationType(evaluationTypeId);
     oppeMetricsDto.setRangeBegin(rangeBegin);
     oppeMetricsDto.setRangeEnd(rangeEnd);
     oppeMetricsDto.setInstitutionId(
         Long.valueOf(getValueFromSessionParam(PARAMETER_INSTITUTION_ID).toString()));
     oppeMetricsDto.setSortBy(OPPEMETRIC_DEFAULT_SORT);
     Map parameterMap = new HashMap();
     parameterMap.put(OPPEMETRIC_DTO, oppeMetricsDto);
     parameterMap.put(IS_METRIC_SEARCH, true);
     executeBinding(GET_OPPE_METRICDATA, parameterMap);
     Long totalCount = (Long) executeBinding(GET_OPPE_METRIC_COUNT);
     if (totalCount == null) {
       showGenericError();
     } else {
       totalMetricsCount = totalCount;
       isLinkEnabled = false;
       if (totalCount <= FETCH_SIZE) {
         rangeEnd = totalCount;
         isLinkEnabled = true;
       } else {
         checkForResetCount = true;
       }
       if (totalCount == 0) {
         rangeBegin = 0L;
       }
     }
     totalRecord = true;
     goClick = false;
     checkMetricSearch = false;
     OPPE_LOG.debug("METRICS.INITIALIZE_DEBUG");
   } catch (Exception exception) {
     OPPE_LOG.error("DATABASE_RETRIEVE_ERROR", exception);
     showGenericError();
   }
 }