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 Summary
FieldsModifier and TypeFieldDescriptionprivate static final Stringprivate Connectionprivate static final LoggerPre-collected lines to be added at the beginning of the report.private static final StringPrefix for messages to be included in the final report.private com.scivicslab.pojoactor.workflow.IIActorSystem -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate com.scivicslab.pojoactor.core.ActionResultAdd a line to the report.private com.scivicslab.pojoactor.core.ActionResultaddWorkflowInfo(String args) Add workflow metadata (file, name, description) to the report.private StringbuildTransitionSummary(long sessionId) Build transition summary.com.scivicslab.pojoactor.core.ActionResultcallByActionName(String actionName, String args) private com.scivicslab.pojoactor.core.ActionResultgenerateReport(String sessionIdStr) Generate workflow execution report.private StringgetFinalStatus(long sessionId) Get final session status.getReportMessages(long sessionId) Get messages with % prefix from logs.private StringRetrieves session ID from nodeGroup actor.private StringgetSessionInfo(long sessionId) Get session information.private StringRetrieves workflow file path from nodeGroup actor.private StringgetWorkflowPathFromSession(long sessionId) Retrieves workflow file path from session in database.private voidreportToMultiplexer(String data) Report result to outputMultiplexer.private longresolveSessionId(String sessionIdStr) Resolve session ID from argument or auto-retrieve from nodeGroup.voidsetActorSystem(com.scivicslab.pojoactor.workflow.IIActorSystem system) voidsetConnection(Connection connection) Sets the database connection for log queries.private com.scivicslab.pojoactor.core.ActionResulttransitionSummary(String sessionIdStr) Show transition success/failure summary.
-
Field Details
-
CLASS_NAME
-
logger
-
REPORT_PREFIX
Prefix for messages to be included in the final report.- See Also:
-
connection
-
system
-
preLines
-
-
Constructor Details
-
WorkflowReporter
public WorkflowReporter()
-
-
Method Details
-
setConnection
Sets the database connection for log queries.- Parameters:
connection- the JDBC connection to the H2 log database
-
setActorSystem
- Specified by:
setActorSystemin interfacecom.scivicslab.pojoactor.workflow.ActorSystemAware
-
callByActionName
- Specified by:
callByActionNamein interfacecom.scivicslab.pojoactor.core.CallableByActionName
-
addLine
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
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
Retrieves workflow file path from session in database.- Throws:
SQLException
-
getWorkflowPathFromNodeGroup
Retrieves workflow file path from nodeGroup actor. -
generateReport
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
Get session information.- Throws:
SQLException
-
getReportMessages
Get messages with % prefix from logs.- Throws:
SQLException
-
buildTransitionSummary
Build transition summary.- Throws:
SQLException
-
getFinalStatus
Get final session status.- Throws:
SQLException
-
transitionSummary
Show transition success/failure summary. -
resolveSessionId
Resolve session ID from argument or auto-retrieve from nodeGroup.- Throws:
NumberFormatException
-
getSessionIdFromNodeGroup
Retrieves session ID from nodeGroup actor. -
reportToMultiplexer
Report result to outputMultiplexer.
-