Relationship

A Relationship expresses a directed semantic link between two Element objects (e.g. composition, association, triggering). The module also contains helper functions to validate relationship rules against the Archimate 3 metamodel.

Module contents

Relationship module - extracted from the legacy monolith.

class pyArchimate.relationship.Relationship(rel_type='', source=None, target=None, uuid=None, name=None, access_type=None, influence_strength=None, desc=None, is_directed=None, profile=None, parent=None)[source]

Bases: object

Class to manage the relationship between two elements of the model

Parameters:
  • rel_type (str) – Archimate relationship type

  • source ([str|Element]) – element source either an element identifier, or an element object

  • target ([str|Element]) – element target either an element identifier, or an element object

  • uuid (str) – identifier of the relationship

  • name (str) – optional name of the relationship

  • access_type (str) – optional parameter for access relationship (‘Read’, ‘ReadWrite’, ‘Write’, ‘Access’)

  • influence_strength (str) – optional influence strength for Influence relationships. Canonical field preserved across export/import cycles. Values: numeric (0-10), ‘+’, ‘++’, ‘-’, ‘–‘. Supports round-trip fidelity with both .archimate and OpenGroup formats. On import, automatically maps legacy ‘modifier’ field to influenceStrength.

  • desc (str) – description/documentation text of the relationship. Stored as <documentation> element in .archimate format. Preserved during round-trip export/import cycles with support for Unicode characters, special XML characters, and arbitrary length text.

  • is_directed (bool) – boolean flag for association relationship

  • profile (str) – relationship profile identifier

  • parent (Model) – parent Model object

property access_type

Get the access type of an Access relationship

Returns:

type

Return type:

str

delete()[source]

Method to delete this relationship from the model structure Also take care to remove visual conns from the views

property influence_strength

Get the influence strength of an Influence relationship

Returns:

influence strength

Return type:

str

property is_directed

Get the direction of an Association relationship

Returns:

direction flag

Return type:

boolean

property profile_id

Gets the profile ID if the current profile is valid and exists in the associated model’s profiles. Returns None if either there is no current profile or it does not exist in the model’s profiles.

Returns:

The ID of the current profile if it exists, otherwise None.

Return type:

int or None

property profile_name

Retrieve the name of the profile associated with the current object. This is done by checking if the profile attribute exists and matches a profile in the model’s profiles. If no matching profile is found or the profile attribute is None, the method returns None.

Returns:

The name of the associated profile if it exists, otherwise None.

Return type:

str or None

prop(key, value=None)[source]

Method to set a property given by its key if a value is provided or to return of value of a property if the value is None

Parameters:
  • key (str)

  • value (str)

Returns:

value of the property defined by the key or None

Return type:

str

property props

Return the properties of this relationship

Returns:

properties

Return type:

dict

remove_folder()[source]

Method to remove this element from the given folder path

remove_prop(key)[source]

Methode to remove a property by key

Parameters:

key (str)

reset_profile() None[source]

Clear the profile assignment.

set_profile(profile_name)[source]

Sets or updates the profile for the current instance based on the provided profile name. If the profile name exists in the model’s profile collection, it is set as the current profile. Otherwise, a new profile is created and added to the model, and its unique identifier is set for the current profile.

Parameters:

profile_name (str) – The name of the profile to set. If it does not exist, a new profile is created with this name.

Raises:

ValueError – If the profile name is invalid or cannot be processed.

property source

Get the source object

Returns:

Source object

Return type:

[Element | None]

property target: Element | None

Get the target object

Returns:

Element object

Return type:

Element

property type

Get the Archimate type of the relationship

Returns:

Archimate type

Return type:

str

property uuid

Get this relationship identifier

Returns:

Identifier

Return type:

str