capella_rm_bridge.changeset package#
Submodules#
capella_rm_bridge.changeset.actiontypes module#
- class capella_rm_bridge.changeset.actiontypes.AttributeDefinition#
Bases:
dictAn attribute definition from the snapshot.
- static __new__(cls, _typename, _fields=None, /, **kwargs)#
- class capella_rm_bridge.changeset.actiontypes.Config#
Bases:
dictA configuration of an RM synchronization plan.
- static __new__(cls, _typename, _fields=None, /, **kwargs)#
- modules: Sequence[TrackerConfig]#
- trackers: Sequence[TrackerConfig]#
- class capella_rm_bridge.changeset.actiontypes.DataType#
Bases:
dictA data_type from the snapshot.
- static __new__(cls, _typename, _fields=None, /, **kwargs)#
- class capella_rm_bridge.changeset.actiontypes.DataTypeValue#
Bases:
dictAn enum value/option from the snapshot.
- static __new__(cls, _typename, _fields=None, /, **kwargs)#
- class capella_rm_bridge.changeset.actiontypes.EnumAttributeDefinition#
Bases:
dictAn attribute definition with type == enum from the snapshot.
- static __new__(cls, _typename, _fields=None, /, **kwargs)#
- exception capella_rm_bridge.changeset.actiontypes.InvalidAttributeDefinition#
Bases:
ExceptionRaised if an AttributeDefinition’s data-type isn’t found.
- exception capella_rm_bridge.changeset.actiontypes.InvalidFieldValue#
Bases:
ExceptionRaised if a value isn’t matching the defined type or options.
- exception capella_rm_bridge.changeset.actiontypes.InvalidSnapshotModule#
Bases:
ExceptionRaised if the module snapshot is invalid.
- exception capella_rm_bridge.changeset.actiontypes.InvalidTrackerConfig#
Bases:
ExceptionRaised when the given config is missing a non-optional key.
- exception capella_rm_bridge.changeset.actiontypes.InvalidWorkItem#
Bases:
ExceptionRaised if the work item is faulty, e.g. missing a work-item-type.
- exception capella_rm_bridge.changeset.actiontypes.InvalidWorkItemType#
Bases:
ExceptionRaised if the type isn’t matching any of the defined types.
- class capella_rm_bridge.changeset.actiontypes.MetaData#
Bases:
dictMetadata of a snapshot.
- static __new__(cls, _typename, _fields=None, /, **kwargs)#
- capella_rm_bridge.changeset.actiontypes.Primitive#
Type alias for primitive values.
alias of
Union[int,float,str,UUIDReference,Promise,list[str|UUIDReference|Promise],bool,datetime]
- class capella_rm_bridge.changeset.actiontypes.RequirementType#
Bases:
TypedDictA requirement type from the snapshot.
- attributes: Mapping[str, AttributeDefinition | EnumAttributeDefinition]#
- class capella_rm_bridge.changeset.actiontypes.Snapshot#
Bases:
dictA whole snapshot from the RM tool that may have multiple modules.
- static __new__(cls, _typename, _fields=None, /, **kwargs)#
- modules: Sequence[TrackerSnapshot]#
- class capella_rm_bridge.changeset.actiontypes.TrackerConfig#
Bases:
dictA configuration of an RM module.
- static __new__(cls, _typename, _fields=None, /, **kwargs)#
- class capella_rm_bridge.changeset.actiontypes.TrackerSnapshot#
Bases:
dictA snapshot of a whole module from the RM tool.
- static __new__(cls, _typename, _fields=None, /, **kwargs)#
capella_rm_bridge.changeset.change module#
Functionality for calulcating a ChangeSet.
- exception capella_rm_bridge.changeset.change.MissingCapellaModule#
Bases:
ExceptionA
CapellaModulewith matching UUID could not be found.
- class capella_rm_bridge.changeset.change.TrackerChange#
Bases:
objectUnites the calculators for finding actions to sync requirements.
- __init__(tracker, model, config, gather_logs=True)#
Construct a
TrackerChange.- Parameters:
tracker (Mapping[str, Any]) – Is a mapping that has
id,data_types,requirement_typesanditemsdefined. Maybe called module in different RM tools.model (MelodyModel) – An instance of
MelodyModelfor comparison with the snapshot.config (TrackerConfig) – A configuration for the module (tracker).
gather_logs (bool) –
- Raises:
InvalidTrackerConfig – If the given
configis missing any of the mandatory keys (uuid, project and/or title).MissingCapellaModule – If the model is missing a
CapellaModulefrom the UUID declared in theconfig.InvalidWorkItemType – May be raised during
TrackerChange.calculate_change()if an unknown ID of a RequirementType is used (i.e. the integrity of therequirement_typessection in the snapshot is broken).InvalidFieldValue – May be raised during
TrackerChange.calculate_change()if it is tried to set an unavailable field value (i.e. the integrity of theattributesof a work item is broken).
- Return type:
None
- attribute_definition_create_action(id, item, req_type_id)#
Return an action for creating
AttributeDefinitions.In case of an
AttributeDefinitionEnumerationrequiresidof possibly promisedEnumerationDataTypeDefinition.See also
capellambse.extensions.reqif.EnumerationDataTypeDefinition,capellambse.extensions.reqif.AttributeDefinition,capellambse.extensions.reqif.AttributeDefinitionEnumeration- Parameters:
id (str) –
item (AttributeDefinition | EnumAttributeDefinition) –
req_type_id (str) –
- Return type:
- attribute_definition_mod_action(reqtype, identifier, data)#
Return an action for an
AttributeDefinition.If a
capellambse.extensions.reqif.AttributeDefinitionorcapellambse.extensions.reqif.AttributeDefinitionEnumerationcan be found via itsidentifier, it is compared against the snapshot. If any changes are identified an action for modification is returned else None. If the definition can’t be found an action for creation is returned.- Returns:
Either a create-, mod-action or
Noneif nothing changed.- Return type:
action
- Parameters:
reqtype (RequirementType) –
identifier (str) –
data (AttributeDefinition | EnumAttributeDefinition) –
- attribute_value_create_action(id, value, req_type_id)#
Return an action for creating an
AttributeValue.Requires
idof possibly promisedAttributeDefinition/AttributeDefinitionEnumerationand checks givenvalueto be of the correct types.See also
capellambse.extension.reqif.IntegerValueAttribute,capellambse.extension.reqif.StringValueAttribute,capellambse.extension.reqif.RealValueAttribute,capellambse.extension.reqif.DateValueAttribute,capellambse.extension.reqif.BooleanValueAttribute,capellambse.extension.reqif.EnumerationValueAttribute- Parameters:
id (str) –
value (int | float | str | UUIDReference | Promise | list[str | capellambse.decl.UUIDReference | capellambse.decl.Promise] | bool | datetime | RMIdentifier) –
req_type_id (RMIdentifier) –
- Return type:
- attribute_value_mod_action(req, id, valueid, req_type_id)#
Return an action for modifying an
AttributeValue.If an
AttributeValuecan be found viadefinition.identifierit is compared against the snapshot. If any changes to itsvalue/sare identified a tuple of the name and value is returned else None. If the attribute can’t be found an action for creation is returned.- Parameters:
req (CapellaModule | Requirement | Folder) – The ReqIFElement under which the attribute value modification takes place.
id (str) – The identifier of the definition for the attribute value.
valueid (str | list[str | capellambse.decl.UUIDReference | capellambse.decl.Promise]) – The value identifier from the snapshot that is compared against the value on the found attribute if it exists. Else a new
AttributeValuewith this value is created.req_type_id (optional) – The identifier of
RequirementTypefor givenreqif it was changed. If not given orNonethe identifierreq.type.identifieris taken.
- Returns:
Either a create-action, the value to modify or
Noneif nothing changed.- Return type:
action
- calculate_change()#
Render actions for CapellaModule synchronization.
Handles synchronization of RequirementTypesFolder first and Requirements and Folders afterwards. If no RequirementTypesFolder was found an action for creation will be added to the actions. Work items are searched by the
identifier. Location changes of work items will invalidate deletions.- Return type:
None
- check_attribute_value_is_valid(id, value, req_type_id)#
Perform various integrity checks on the given attribute value.
- Raises:
capella_rm_bridge.changeset.actiontypes.InvalidFieldValue – If the types are not matching, if the used data_type definition is missing in the snapshot or the used options on an EnumerationAttributeValue are missing in the snapshot.
- Returns:
A data-class that gathers all needed data for creating the (Enumeration)AttributeValue.
- Return type:
builder
- Parameters:
id (str) –
value (int | float | str | UUIDReference | Promise | list[str | capellambse.decl.UUIDReference | capellambse.decl.Promise] | bool | datetime) –
req_type_id (RMIdentifier) –
- check_requirements_module()#
Return the starting action for the
CapellaModule.Check if a
CapellaModulecan be found and that the config is valid.
- config: TrackerConfig#
Config section for the tracker.
- data_type_create_action(data_type_id, data_type_definition)#
Return an action for creating an
EnumDataTypeDefinition.See also
capellambse.extensions.reqif.EnumerationDataTypeDefinitionDefinition for the
data_typeattribute ofAttributeDefinitionEnumerations.
- data_type_definition_mod_actions()#
Populate with ModActions for the RequirementTypesFolder.
The data type definitions and requirement type are checked via
make_datatype_definition_mod_action()andmake_reqtype_mod_action()respectively. If there are changes theactionscontainer will be populated.
- data_type_definitions: Mapping[str, DataType]#
A lookup for DataTypeDefinitions from the tracker snapshot.
- data_type_mod_action(id, ddef)#
Return an Action for creating or modifying a DataTypeDefinition.
If a
reqif.DataTypeDefinitioncan be found viaidand it differs against the snapshot an action for modification is returned. If it doesn’t differ the returnedactionisNone. If the definition can’t be found an action for creating anEnumerationDataTypeDefinition`is returned.
- invalidate_deletion(requirement)#
Try to remove
requirementfrom deletions.Remove empty dictionaries or even whole action if its only delete action was removed.
- Parameters:
requirement (Requirement | Folder) –
- Return type:
None
- model: MelodyModel#
Model instance.
- req_delete_actions(visited, attr_name='requirements')#
Return an action for deleting elements under the ReqModule.
Filter all elements from the CapellaModule attribute with name
attr_nameagainstvisited. These are the elements that are still in the model but not in the snapshot, and have to be deleted.
- req_module: CapellaModule#
The corresponding
reqif.CapellaModulefor the tracker.
- reqt_folder: CapellaTypesFolder | None#
The reqif.CapellaTypesFolder storing fields data.
- reqtype_fields_filter: Mapping[RMIdentifier, set[str]]#
A mapping for whitelisted fieldnames per RequirementType.
- requirement_type_create_action(identifier, req_type)#
Return an action for creating the
RequirementType.See also
capellambse.extensions.reqif.RequirementTypeThe
typeattribute ofRequirementsandRequirementsFolderthat enables AttributeDefinitions via thedefinitionattribute.
- Parameters:
identifier (RMIdentifier) –
req_type (RequirementType) –
- Return type:
- requirement_type_delete_actions()#
Populate actions for deleting
RequirementTypes.- Return type:
- requirement_type_mod_action(identifier, item)#
- Parameters:
identifier (RMIdentifier) –
item (RequirementType) –
- Return type:
- requirement_types: Mapping[RMIdentifier, RequirementType]#
A lookup for RequirementTypes from the tracker snapshot.
- requirement_types_folder_create_action(base)#
Return an action for creating the
CapellaTypesFolder.See also
capellambse.extensions.reqif.CapellaTypesFolderFolder for (Data-)Type- and Attribute-Definitions
- yield_data_type_definition_create_actions()#
Yield actions for creating
EnumDataTypeDefinitions.
- yield_requirement_type_create_actions()#
Yield actions for creating
RequirementTypes.
- yield_requirements_create_actions(item)#
Yield actions for creating Requirements or Folders.
The
WorkItemis identified as aRequirementsFolderif there are non-emptychildrenor a(Type, "Folder")pair in the attributes exists. Also yields creations or modifications for children.See also
capellambse.extensions.reqif.Requirement,capellambse.extensions.reqif.RequirementsFolder
- yield_requirements_mod_actions(req, item, parent=None)#
Yield an action for modifying given
req.If any modifications to simple attributes (e.g.
long_name), attributes or creations/deletions of children (in case ofreqbeing a Folder) were identified an action for modification ofreqis yielded. For modifications of children the method is called recursively and yields actions from it.- Parameters:
req (CapellaModule | Requirement | Folder) –
parent (CapellaModule | Requirement | Folder | Promise | None) –
- Return type:
- capella_rm_bridge.changeset.change.make_requirement_delete_actions(req, child_ids, key='requirements')#
Return actions for deleting elements behind
req.key.The returned list is filtered against the
identifierfrom givenchild_ids.- Parameters:
- Return type:
capella_rm_bridge.changeset.find module#
Functionality for finding ReqIF elements in a MelodyModel.
- capella_rm_bridge.changeset.find.find_by(model, value, *xtypes, attr='identifier', below=None)#
- Parameters:
model (MelodyModel) –
value (Any) –
xtypes (str) –
attr (str) –
below (GenericElement | None) –
- Return type:
ReqIFElement | None
- capella_rm_bridge.changeset.find.find_by_identifier(model, id, *xtypes, **kw)#
Try to return a model object by its
identifier.- Parameters:
model (MelodyModel) –
id (str) –
xtypes (str) –
- Return type:
ReqIFElement | None
Module contents#
A ChangeSet is a sequence of actions to be applied to a model.
The calculate_change_set()
function calculates these actions from a given snapshot of supported
Requirement Management tools and config YAML file. With the
declarative modelling feature of
capellambse a MelodyModel can be
altered with capellambse.decl.apply().
- capella_rm_bridge.changeset.calculate_change_set(model, config, snapshot, force=False, safe_mode=True, gather_logs=True)#
Return a list of actions for a given
modelandsnapshot.The returned list (
ChangeSet) stores the needed actions to synchronize themodelwith the content of thesnapshot. Thesnapshotstores a tracker or live-document which correspond to areqif.CapellaModule.- Parameters:
model (MelodyModel) – The Capella model to compare the snapshot against.
config (TrackerConfig) – A configuration of the tracker or live-document for the calculated
ChangeSet.snapshot (TrackerSnapshot) – A snapshot of a tracker or live-document from the external tool.
force (bool) – If
TrueaChangeSetwill be rendered even if an error occurred during the change-calculation loop. All related objects will be skipped.safe_mode (bool) – If
TruenoChangeSetwill be rendered iff atleast one error occurred during the change-calculation loop. IfFalseall change-actions of modules where errors occurred are dismissed.gather_logs (bool) – If
Trueall error messages are gathered in TrackerChange.errors instead of being immediately logged.
- Return type:
ChangeSet, errors
See also
capella_rm_bridge.changeset.actiontypes.TrackerConfigThe expected keys and value types of a module.
capella_rm_bridge.changeset.actiontypes.TrackerSnapshotThe expected keys and value types of a snapshot.