Class WorkflowReporter

java.lang.Object
com.scivicslab.actoriac.WorkflowReporter
All Implemented Interfaces:
com.scivicslab.pojoactor.core.CallableByActionName, com.scivicslab.pojoactor.workflow.ActorSystemAware

public class WorkflowReporter extends Object implements com.scivicslab.pojoactor.core.CallableByActionName, com.scivicslab.pojoactor.workflow.ActorSystemAware
Workflow execution reporter for actor-IaC.

Aggregates workflow execution results and generates final reports. Messages starting with '%' prefix are collected and displayed in the final report, enabling simple check/status reporting from workflows.

Usage in workflows:

- actor: this
  method: executeCommand
  arguments:
    - |
      if command -v node > /dev/null; then
        echo "%[OK] Node.js: $(node --version)"
      else
        echo "%[ERROR] Node.js: not found"
      fi

Actions:

  • report - Generate workflow execution report. Args: sessionId (optional)
  • transition-summary - Show transition success/failure summary. Args: sessionId

Report Output Example:

=== Workflow Execution Report ===
Session #42 | Workflow: DocumentDeployWorkflow | Status: COMPLETED

--- Check Results ---
[OK] Node.js: v18.0.0
[OK] yarn: 1.22.19
[ERROR] Maven: not found

--- Transitions ---
[✓] check-doclist
[✓] detect-changes
[✗] build-docs: yarn not found

=== Result: FAILED ===
Since:
2.12.2
Author:
devteam@scivicslab.com
  • Field Details

  • Constructor Details

  • Method Details

    • setConnection

      public void setConnection(Connection connection)
      Sets the database connection for log queries.
      Parameters:
      connection - the JDBC connection to the H2 log database
    • setActorSystem

      public void setActorSystem(com.scivicslab.pojoactor.workflow.IIActorSystem system)
      Specified by:
      setActorSystem in interface com.scivicslab.pojoactor.workflow.ActorSystemAware
    • callByActionName

      public com.scivicslab.pojoactor.core.ActionResult callByActionName(String actionName, String args)
      Specified by:
      callByActionName in interface com.scivicslab.pojoactor.core.CallableByActionName
    • addLine

      private com.scivicslab.pojoactor.core.ActionResult addLine(String args)
      Add a line to the report.

      Lines added via this method will appear at the beginning of the "Check Results" section in the report. This is useful for adding workflow description or other contextual information.

      The argument is passed as a JSON array from the workflow engine, so this method extracts the first element.

      Parameters:
      args - the JSON array containing the line to add
      Returns:
      ActionResult indicating success
    • addWorkflowInfo

      private com.scivicslab.pojoactor.core.ActionResult addWorkflowInfo(String args)
      Add workflow metadata (file, name, description) to the report.

      This action reads the workflow YAML file and extracts the name and description fields, adding them to the report header. The workflow file path is obtained from nodeGroup.

      Parameters:
      args - unused (workflow path is obtained from nodeGroup)
      Returns:
      ActionResult indicating success or failure
    • getWorkflowPathFromSession

      private String getWorkflowPathFromSession(long sessionId) throws SQLException
      Retrieves workflow file path from session in database.
      Throws:
      SQLException
    • getWorkflowPathFromNodeGroup

      Retrieves workflow file path from nodeGroup actor.
    • generateReport

      private com.scivicslab.pojoactor.core.ActionResult generateReport(String sessionIdStr)
      Generate workflow execution report.

      Collects messages starting with '%' prefix and generates a summary report.

      Parameters:
      sessionIdStr - session ID to report on, or empty for auto-retrieval
    • getSessionInfo

      private String getSessionInfo(long sessionId) throws SQLException
      Get session information.
      Throws:
      SQLException
    • getReportMessages

      private List<String> getReportMessages(long sessionId) throws SQLException
      Get messages with % prefix from logs.
      Throws:
      SQLException
    • buildTransitionSummary

      private String buildTransitionSummary(long sessionId) throws SQLException
      Build transition summary.
      Throws:
      SQLException
    • getFinalStatus

      private String getFinalStatus(long sessionId) throws SQLException
      Get final session status.
      Throws:
      SQLException
    • transitionSummary

      private com.scivicslab.pojoactor.core.ActionResult transitionSummary(String sessionIdStr)
      Show transition success/failure summary.
    • resolveSessionId

      private long resolveSessionId(String sessionIdStr) throws NumberFormatException
      Resolve session ID from argument or auto-retrieve from nodeGroup.
      Throws:
      NumberFormatException
    • getSessionIdFromNodeGroup

      Retrieves session ID from nodeGroup actor.
    • reportToMultiplexer

      private void reportToMultiplexer(String data)
      Report result to outputMultiplexer.