Iterating Relationships

Iterating Relationships
 1ot = impact.gui.output_toolbox
 2db = impact.active_database
 3
 4ot.clear()
 5
 6document_id = "781f9860-8966-4d2d-844c-fc5e9b94b979"
 7
 8# Find the document
 9document = db.find_document_by_id(document_id)
10
11if document is not None:
12
13    # Display relationships
14    ot.add("Document " + document.name + " Relationships Count: " + str(document.series_relationships.count))
15
16    for rel in document.series_relationships:
17
18        # each relationship can be between a specific document version or the latest document version
19        # and another object
20        if rel.document_latest_version:
21            ot.add("Latest version " + str(rel.relationship_as_string) + " Relationship to " + str(rel.object_id_as_string))
22        else:
23            ot.add("version " + str(rel.document.version.version_as_string) + " " + str(rel.relationship_as_string) + " Relationship to " + str(rel.object_id_as_string))
24
25else:
26    ot.add("Unable to find the document with ID '" + str(document_id) + "'")