Class ReportRecommendationUtil

java.lang.Object
com.ssgllc.fish.service.util.published.ReportRecommendationUtil

@Component public class ReportRecommendationUtil extends Object
Building blocks for a Compass report recommendation context script: the reports the current user can run, what their inputs are, and links that open them.

Called as the reportRecommendationUtil bean. Every lookup applies the access rules of the Reports pages, so a script cannot reach a report the user could not open. Criteria maps take the same keys as bpmUtil.searchEntity; they narrow a result and never widen access.

Groovy example:
def me = com.ssgllc.fish.service.util.registered.ExpressionUtil.getCurrentUserUuidStr()
def custom = reportRecommendationUtil.getCustomReports([:])
def shared = custom.findAll { it.userId != me }
def standard = reportRecommendationUtil.getStandardReports(["name.contains": "case"])
standard.each { report ->
  def description = reportRecommendationUtil.describeReport(report)
  if (description == null) { return } // unreadable or unparseable: leave it out
  context.append(reportRecommendationUtil.runReportUrl(report.name)).append("\n")
  description.params.each { context.append(it.describe()).append("\n") }
}

  • Constructor Summary

    Constructors
    Constructor
    Description
    ReportRecommendationUtil(com.ssgllc.fish.service.CustomReportPersonalizedService customReportPersonalizedService, com.ssgllc.fish.service.ReportService reportService, com.ssgllc.fish.service.cache.ValueSets valueSets, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    com.ssgllc.fish.service.report.vo.ReportDescription
    describeReport(com.ssgllc.fish.service.dto.gen.ReportDefinitionDTO report)
    A report's inputs, with the URL query keys (input names) that prefill them, and its output columns.
    com.ssgllc.fish.service.report.vo.ReportDescription
    describeReport(com.ssgllc.fish.service.dto.gen.ReportDefinitionDTO report, int maxAllowedValues)
    As describeReport(ReportDefinitionDTO), listing the allowed values of a value set only when it holds at most maxAllowedValues active concepts.
    List<com.ssgllc.fish.service.dto.gen.CustomReportDTO>
    The custom (personalized) reports the current user owns or that are shared with them, sorted by name, with the parent report expanded and scrubbed.
    List<com.ssgllc.fish.service.dto.gen.CustomReportDTO>
    getCustomReports(Map<String,Object> criteria, int limit)
    As getCustomReports(Map), returning at most limit reports.
    getSavedValues(com.ssgllc.fish.service.dto.gen.CustomReportDTO customReport, com.ssgllc.fish.service.report.vo.ReportDescription description)
    The value-set, date and yes/no values a custom report was saved with, keyed by input name (the SQL param name, or the field id on an input form).
    List<com.ssgllc.fish.service.dto.gen.ReportDefinitionDTO>
    The standard reports the current user can read, sorted by name, with definition internals scrubbed: the Standard tab's listing.
    List<com.ssgllc.fish.service.dto.gen.ReportDefinitionDTO>
    getStandardReports(Map<String,Object> criteria, int limit)
    As getStandardReports(Map), returning at most limit reports.
    An absolute link that runs a custom report with its saved values.
    runReportUrl(String reportName)
    An absolute link that opens a standard report.
    runReportUrl(String reportName, Map<String,?> params)
    An absolute link that opens a standard report with inputs prefilled, keyed by input name.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ReportRecommendationUtil

      public ReportRecommendationUtil(com.ssgllc.fish.service.CustomReportPersonalizedService customReportPersonalizedService, com.ssgllc.fish.service.ReportService reportService, com.ssgllc.fish.service.cache.ValueSets valueSets, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
  • Method Details

    • getStandardReports

      public List<com.ssgllc.fish.service.dto.gen.ReportDefinitionDTO> getStandardReports(Map<String,Object> criteria)
      The standard reports the current user can read, sorted by name, with definition internals scrubbed: the Standard tab's listing. Only published reports unless the criteria name a published filter of their own. An id filter is replaced by the reports the user's roles grant, as on that tab.
      Parameters:
      criteria - ReportDefinition criteria, keyed as for bpmUtil.searchEntity; null for none.
      Returns:
      The matching reports.

      Groovy example:
      return reportRecommendationUtil.getStandardReports(["name.contains": "case"])
    • getStandardReports

      public List<com.ssgllc.fish.service.dto.gen.ReportDefinitionDTO> getStandardReports(Map<String,Object> criteria, int limit)
      As getStandardReports(Map), returning at most limit reports.

      Groovy example:
      return reportRecommendationUtil.getStandardReports(["explanation.specified": true], 50)
    • getCustomReports

      public List<com.ssgllc.fish.service.dto.gen.CustomReportDTO> getCustomReports(Map<String,Object> criteria)
      The custom (personalized) reports the current user owns or that are shared with them, sorted by name, with the parent report expanded and scrubbed. A report whose userId is not the current user's reached them through sharing. Split the list by owner rather than filtering on userId here: with sharing disabled the owner filter is forced to the current user, so a "not mine" query returns the caller's own reports.
      Parameters:
      criteria - CustomReport criteria, keyed as for bpmUtil.searchEntity; null for none.
      Returns:
      The matching reports.

      Groovy example:
      def me = com.ssgllc.fish.service.util.registered.ExpressionUtil.getCurrentUserUuidStr()
      def shared = reportRecommendationUtil.getCustomReports([:]).findAll { it.userId != me }
    • getCustomReports

      public List<com.ssgllc.fish.service.dto.gen.CustomReportDTO> getCustomReports(Map<String,Object> criteria, int limit)
      As getCustomReports(Map), returning at most limit reports.
    • describeReport

      public com.ssgllc.fish.service.report.vo.ReportDescription describeReport(com.ssgllc.fish.service.dto.gen.ReportDefinitionDTO report)
      A report's inputs, with the URL query keys (input names) that prefill them, and its output columns. Inputs come from the input form when the report has one, otherwise from the params declared in its SQL. For a custom report, pass its parent report. The report is looked up by id, so inside one transaction this reuses the report the listing loaded.
      Parameters:
      report - A report from getStandardReports(Map), or a custom report's parent report.
      Returns:
      The description; null when the current user cannot read the report or its definition cannot be parsed, so the caller should leave the report out.

      Groovy example:
      return reportRecommendationUtil.describeReport(customReport.parentReport)?.params*.describe()
    • describeReport

      public com.ssgllc.fish.service.report.vo.ReportDescription describeReport(com.ssgllc.fish.service.dto.gen.ReportDefinitionDTO report, int maxAllowedValues)
      As describeReport(ReportDefinitionDTO), listing the allowed values of a value set only when it holds at most maxAllowedValues active concepts.
    • getSavedValues

      public Map<String,Object> getSavedValues(com.ssgllc.fish.service.dto.gen.CustomReportDTO customReport, com.ssgllc.fish.service.report.vo.ReportDescription description)
      The value-set, date and yes/no values a custom report was saved with, keyed by input name (the SQL param name, or the field id on an input form). A value-set value is written as CODE (Display) instead of the concept id the form saved, so a model can read it; several concepts are joined with ", ", and a concept id the value set no longer holds is returned as it was saved. A date or yes/no value is returned as stored, so a relative date keeps its encoding.

      Text, numbers and entity values are left out: they can hold whatever the report's owner typed, which on a shared report is another user's data and should not reach a model.

      Parameters:
      customReport - The custom report.
      description - Its parent report's description from describeReport(ReportDefinitionDTO), which gives each input's type and value set. Null gives an empty map.

      Groovy example:
      return reportRecommendationUtil.getSavedValues(customReport, reportRecommendationUtil.describeReport(customReport.parentReport))
    • runReportUrl

      public String runReportUrl(String reportName)
      An absolute link that opens a standard report.

      Groovy example:
      return reportRecommendationUtil.runReportUrl(report.name)
    • runReportUrl

      public String runReportUrl(String reportName, Map<String,?> params)
      An absolute link that opens a standard report with inputs prefilled, keyed by input name. A collection value is joined with commas, which is how a multi-value field takes several concept ids; null values are left out.

      Groovy example:
      return reportRecommendationUtil.runReportUrl(report.name, ["COUNTY": countyConceptId, "START_DATE": "2026-01-01"])
    • runPersonalizedReportUrl

      public String runPersonalizedReportUrl(String customReportId)
      An absolute link that runs a custom report with its saved values.

      Groovy example:
      return reportRecommendationUtil.runPersonalizedReportUrl(customReport.id)