Print one activity and walk its `turnParent` chain via `previous`.
(repo: &Repository, input: &ProvActivityInput, graph: &ProvenanceGraph)
| 291 | |
| 292 | /// Print one activity and walk its `turnParent` chain via `previous`. |
| 293 | fn print_activity_chain(repo: &Repository, input: &ProvActivityInput, graph: &ProvenanceGraph) { |
| 294 | // The projected (unsigned) value is the source of truth for the shape. |
| 295 | let value = project(input); |
| 296 | let activity = value |
| 297 | .get("@graph") |
| 298 | .and_then(|g| g.as_array()) |
| 299 | .and_then(|nodes| { |
| 300 | nodes |
| 301 | .iter() |
| 302 | .find(|n| n.get("@type").and_then(|t| t.as_str()) == Some("prov:Activity")) |
| 303 | }); |
| 304 | |
| 305 | let indent = " "; |
| 306 | if let Some(act) = activity { |
| 307 | println!( |
| 308 | "{indent}{} {}", |
| 309 | emphasis("activity"), |
| 310 | info(act.get("@id").and_then(|v| v.as_str()).unwrap_or("?")) |
| 311 | ); |
| 312 | if let Some(gen) = act.get("generated").and_then(|v| v.as_array()) { |
| 313 | for g in gen { |
| 314 | println!( |
| 315 | "{indent} {} {}", |
| 316 | hint("generated"), |
| 317 | info(g.as_str().unwrap_or("?")) |
| 318 | ); |
| 319 | } |
| 320 | } |
| 321 | println!( |
| 322 | "{indent} {} {}", |
| 323 | hint("agent"), |
| 324 | info( |
| 325 | act.get("associatedWith") |
| 326 | .and_then(|v| v.as_str()) |
| 327 | .unwrap_or("?") |
| 328 | ) |
| 329 | ); |
| 330 | println!( |
| 331 | "{indent} {} {} ({})", |
| 332 | hint("agent label"), |
| 333 | info(&input.agent_display_name), |
| 334 | input.agent_vendor.as_deref().unwrap_or("no vendor") |
| 335 | ); |
| 336 | println!( |
| 337 | "{indent} {} {}", |
| 338 | hint("person"), |
| 339 | info( |
| 340 | act.get("actedOnBehalfOf") |
| 341 | .and_then(|v| v.as_str()) |
| 342 | .unwrap_or("?") |
| 343 | ) |
| 344 | ); |
| 345 | if let Some(parent) = act.get("turnParent").and_then(|v| v.as_str()) { |
| 346 | println!("{indent} {} {}", hint("turnParent"), info(parent)); |
| 347 | } else { |
| 348 | println!("{indent} {}", hint("turnParent: (root turn)")); |
| 349 | } |
| 350 | } |
no test coverage detected