Class ReportRunner

java.lang.Object
neqsim.mcp.runners.ReportRunner

public final class ReportRunner extends Object
Report generator that transforms simulation results into structured engineering reports.

Produces rich Markdown reports with tables, SVG-compatible data (for chart rendering by AI agents), and structured JSON data arrays suitable for plotting. Reports cover process summaries, PVT studies, parametric sweeps, flow assurance analyses, and field development evaluations.

Version:
1.0
Author:
Even Solbraa
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final com.google.gson.Gson
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    Private constructor — all methods are static.
  • Method Summary

    Modifier and Type
    Method
    Description
    private static void
    appendJsonAsTable(StringBuilder md, com.google.gson.JsonObject obj, String keyHeader, String valueHeader)
    Appends a flat JSON object as a Markdown table.
    private static com.google.gson.JsonObject
    computeSummary(com.google.gson.JsonObject data)
    Computes summary statistics from the data.
    private static String
    errorJson(String code, String message)
    Creates an error JSON string.
    private static com.google.gson.JsonArray
    extractChartData(com.google.gson.JsonObject data, String reportType)
    Extracts chart-ready data arrays from simulation results.
    private static void
    extractFlatValues(com.google.gson.JsonObject obj, String prefix, com.google.gson.JsonArray rows)
    Recursively extracts flat numeric values from JSON into table rows.
    private static com.google.gson.JsonArray
    extractTables(com.google.gson.JsonObject data, String reportType)
    Extracts structured tables from simulation data.
    private static void
    findPlottableArrays(com.google.gson.JsonObject obj, String prefix, com.google.gson.JsonArray charts)
    Recursively finds arrays of numbers that could be plotted.
    private static String
    generateMarkdown(String reportType, String title, String author, com.google.gson.JsonObject data)
    Generates a Markdown report.
    private static String
    Infers a unit from a field name suffix.
    static String
    run(String json)
    Generates a structured engineering report from simulation results.

    Methods inherited from class Object

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

    • GSON

      private static final com.google.gson.Gson GSON
  • Constructor Details

    • ReportRunner

      private ReportRunner()
      Private constructor — all methods are static.
  • Method Details

    • run

      public static String run(String json)
      Generates a structured engineering report from simulation results.

      Input JSON format:

      {
        "reportType": "process_summary" | "pvt_study" | "parametric_sweep" |
                       "flow_assurance" | "equipment_design" | "custom",
        "title": "HP Compression System Design",
        "author": "NeqSim MCP",
        "data": { ... results from previous simulation ... },
        "includeValidation": true,
        "includeChartData": true
      }
      
      Parameters:
      json - the report request JSON
      Returns:
      JSON containing markdown report, tables, chart data, and metadata
    • generateMarkdown

      private static String generateMarkdown(String reportType, String title, String author, com.google.gson.JsonObject data)
      Generates a Markdown report.
      Parameters:
      reportType - the report type
      title - the report title
      author - the author
      data - the simulation data
      Returns:
      Markdown string
    • appendJsonAsTable

      private static void appendJsonAsTable(StringBuilder md, com.google.gson.JsonObject obj, String keyHeader, String valueHeader)
      Appends a flat JSON object as a Markdown table.
      Parameters:
      md - the StringBuilder
      obj - the JSON object
      keyHeader - the key column header
      valueHeader - the value column header
    • extractTables

      private static com.google.gson.JsonArray extractTables(com.google.gson.JsonObject data, String reportType)
      Extracts structured tables from simulation data.
      Parameters:
      data - the simulation data
      reportType - the report type
      Returns:
      JSON array of table objects
    • extractFlatValues

      private static void extractFlatValues(com.google.gson.JsonObject obj, String prefix, com.google.gson.JsonArray rows)
      Recursively extracts flat numeric values from JSON into table rows.
      Parameters:
      obj - the JSON object
      prefix - the key prefix
      rows - the rows array to populate
    • inferUnit

      private static String inferUnit(String key)
      Infers a unit from a field name suffix.
      Parameters:
      key - the field name
      Returns:
      the inferred unit or empty string
    • extractChartData

      private static com.google.gson.JsonArray extractChartData(com.google.gson.JsonObject data, String reportType)
      Extracts chart-ready data arrays from simulation results.
      Parameters:
      data - the simulation data
      reportType - the report type
      Returns:
      JSON array of chart data objects
    • findPlottableArrays

      private static void findPlottableArrays(com.google.gson.JsonObject obj, String prefix, com.google.gson.JsonArray charts)
      Recursively finds arrays of numbers that could be plotted.
      Parameters:
      obj - the JSON object
      prefix - the key prefix
      charts - the charts array to populate
    • computeSummary

      private static com.google.gson.JsonObject computeSummary(com.google.gson.JsonObject data)
      Computes summary statistics from the data.
      Parameters:
      data - the simulation data
      Returns:
      summary JSON object
    • errorJson

      private static String errorJson(String code, String message)
      Creates an error JSON string.
      Parameters:
      code - the error code
      message - the error message
      Returns:
      error JSON