Print one activity and its prior-turn chain — the routed render: the activity block projects from the wire-carried input, and the chain renders the handler's pre-walked activity URNs.
(input: &ProvActivityInput, priors: &[String], truncated: bool)
| 396 | /// activity block projects from the wire-carried input, and the chain |
| 397 | /// renders the handler's pre-walked activity URNs. |
| 398 | fn print_activity_chain(input: &ProvActivityInput, priors: &[String], truncated: bool) { |
| 399 | // The projected (unsigned) value is the source of truth for the shape. |
| 400 | let value = project(input); |
| 401 | let activity = value |
| 402 | .get("@graph") |
| 403 | .and_then(|g| g.as_array()) |
| 404 | .and_then(|nodes| { |
| 405 | nodes |
| 406 | .iter() |
| 407 | .find(|n| n.get("@type").and_then(|t| t.as_str()) == Some("prov:Activity")) |
| 408 | }); |
| 409 | |
| 410 | let indent = " "; |
| 411 | if let Some(act) = activity { |
| 412 | println!( |
| 413 | "{indent}{} {}", |
| 414 | emphasis("activity"), |
| 415 | info(act.get("@id").and_then(|v| v.as_str()).unwrap_or("?")) |
| 416 | ); |
| 417 | if let Some(gen) = act.get("generated").and_then(|v| v.as_array()) { |
| 418 | for g in gen { |
| 419 | println!( |
| 420 | "{indent} {} {}", |
| 421 | hint("generated"), |
| 422 | info(g.as_str().unwrap_or("?")) |
| 423 | ); |
| 424 | } |
| 425 | } |
| 426 | println!( |
| 427 | "{indent} {} {}", |
| 428 | hint("agent"), |
| 429 | info( |
| 430 | act.get("associatedWith") |
| 431 | .and_then(|v| v.as_str()) |
| 432 | .unwrap_or("?") |
| 433 | ) |
| 434 | ); |
| 435 | println!( |
| 436 | "{indent} {} {} ({})", |
| 437 | hint("agent label"), |
| 438 | info(&input.agent_display_name), |
| 439 | input.agent_vendor.as_deref().unwrap_or("no vendor") |
| 440 | ); |
| 441 | println!( |
| 442 | "{indent} {} {}", |
| 443 | hint("person"), |
| 444 | info( |
| 445 | act.get("actedOnBehalfOf") |
| 446 | .and_then(|v| v.as_str()) |
| 447 | .unwrap_or("?") |
| 448 | ) |
| 449 | ); |
| 450 | if let Some(parent) = act.get("turnParent").and_then(|v| v.as_str()) { |
| 451 | println!("{indent} {} {}", hint("turnParent"), info(parent)); |
| 452 | } else { |
| 453 | println!("{indent} {}", hint("turnParent: (root turn)")); |
| 454 | } |
| 455 | } |