/**
  * This method reset the values of all filter criteria in UI
  *
  * @return EMPTY_STRING - empty string
  */
 public String resetValue() {
   try {
     metricIdUI.setValue(EMPTY_STRING);
     metricNameUI.setValue(EMPTY_STRING);
     statusChoiceUI.setValue(0);
     delineatedPrivilegesChoiceUI.setValue(0);
     initialize();
     if (checkForResetCount) {
       nextLinkUI.setDisabled(false);
     }
     OPPE_LOG.debug("METRICS.RESET_VALUES_DEBUG");
   } catch (Exception exception) {
     OPPE_LOG.error("DATABASE_RETRIEVE_ERROR", exception);
     showGenericError();
   }
   return EMPTY_STRING;
 }
  /**
   * This method is action listener for select privileges drop down
   *
   * @param valueChangeEvent - object of ValueChangeEvent
   */
  public void selectPrivilegesListener(ValueChangeEvent valueChangeEvent) {
    try {
      String newValue = String.valueOf(valueChangeEvent.getNewValue());
      if (categoryIdList.contains(newValue) && newValue != CAPMETRIC_LIST_DROPDOWN_SELECT) {
        RichSelectOneChoice privilegeSelectOneChoice =
            (RichSelectOneChoice) findComponentInRoot(DEL_PRIV_UICOMP);
        FacesMessage message = new FacesMessage();
        message.setDetail(getValue("#{CommonResourceText['CATEGORY_NOT_CHOOSEN']}"));
        message.setSeverity(FacesMessage.SEVERITY_ERROR);

        // Reset resource area to default value
        FacesContext.getCurrentInstance()
            .addMessage(
                privilegeSelectOneChoice.getClientId(FacesContext.getCurrentInstance()), message);
        privilegeSelectOneChoice.setValue(0);
        privilegeSelectOneChoice.setValid(false);
        AdfFacesContext.getCurrentInstance().addPartialTarget(privilegeSelectOneChoice);
      }
      OPPE_LOG.debug("METRICS.VALUE_CHANE_EVENT_DEBUG");
    } catch (Exception exception) {
      OPPE_LOG.error("DATABASE_RETRIEVE_ERROR", exception);
      showGenericError();
    }
  }
 /**
  * This method returns the record on the basis of search criteria.
  *
  * @return EmptyString - empty string
  */
 public String metricSearch() {
   try {
     alertHeaderUI.setVisible(false);
     checkMetricSearch = true;
     if (!(statusChoiceUI.getValue() == null
         && metricIdUI.getValue() == null
         && metricNameUI.getValue() == null
         && delPrivValue == null
         && goClick)) {
       OppeMetricsDTO oppeMetricsDto = new OppeMetricsDTO();
       rangeBegin = PAGINATION_RANGE_BEGIN_VALUE;
       rangeEnd = rangeBegin + FETCH_SIZE - 1;
       oppeMetricsDto = setFilterCriteria(oppeMetricsDto);
       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();
       }
       totalRecord = true;
       if (totalCount == 0) {
         rangeBegin = 0L;
         totalRecord = false;
       }
       if (totalCount <= FETCH_SIZE) {
         getNextLinkUI().setDisabled(true);
         rangeEnd = totalCount;
       } else {
         getNextLinkUI().setDisabled(false);
       }
       getPreviousLinkUI().setDisabled(true);
       OPPE_LOG.debug("METRICS.METRIC_SEARCH_DEBUG");
     } else {
       alertHeaderUI.setVisible(true);
       goClick = false;
     }
     checkMetricSearch = false;
   } catch (Exception exeception) {
     OPPE_LOG.error("DATABASE_RETRIEVE_ERROR", exeception);
     showGenericError();
   }
   return EMPTY_STRING;
 }
  /**
   * 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;
  }