private ModelOutput fromRiskConfidence(RiskConfidence riskConfidence) {
    ModelOutput modelOutput = new ModelOutput();
    modelOutput.setId(String.valueOf(riskConfidence.getId()));
    modelOutput.setCreatedDate(riskConfidence.getDateCreated());
    modelOutput.setModelRunId(riskConfidence.getGroupId());

    Map<String, Object> output = new HashMap<String, Object>();
    output.put("ALTERNATIVE_ID", riskConfidence.getAlternativeId());
    output.put("COURSE_ID", riskConfidence.getCourseId());
    output.put("MODEL_RISK_CONFIDENCE", riskConfidence.getModelRiskConfidence());

    modelOutput.setOutput(output);
    return modelOutput;
  }
  @Override
  public Page<ModelOutput> findByCourseId(String courseId, boolean onlyLastRun, Pageable pageable) {

    Page<ModelOutput> page = null;
    if (onlyLastRun) {
      RiskConfidence riskConfidence =
          riskConfidenceRepository.findTopByCourseIdOrderByDateCreatedDesc(courseId);
      if (riskConfidence != null) {
        page =
            convert(
                riskConfidenceRepository.findByGroupIdAndCourseId(
                    riskConfidence.getGroupId(), courseId, pageable),
                pageable);
      }
    } else {
      page = convert(riskConfidenceRepository.findByCourseId(courseId, pageable), pageable);
    }

    return page;
  }