casework / CASE-Mapping-Python

Apache License 2.0
0 stars 3 forks source link

Role class must derive from UcoObject #72

Closed fabrizio-turchi closed 1 month ago

fabrizio-turchi commented 1 month ago

The Role class is a subclass of Facet and it's not possible to create a Relation between an Identity (IdentityAbstraction subclass of UcoObject) and a Role , because the ObservableRelationship class expects an UcoObject as source and target properties.

ajnelson-nist commented 1 month ago

Thank you for reporting. I'll post a fix.

ajnelson-nist commented 1 month ago

Fixed in #73 . Thanks again!

fabrizio-turchi commented 1 month ago

The code you pushed doesn't seems to solve the issue. If I put the following code in the example.py:

role_created_time = datetime.strptime("2024-09-24T21:38:19", "%Y-%m-%dT%H:%M:%S")
role_df_expert = uco.role.Role(
    description="Digital Forensic Mobile Expert",
    name="Digital Forensic Incident Response",
    created_time=role_created_time
)
bundle.append_to_uco_object(role_df_expert)
has_role_relation = uco.observable.ObservableRelationship(
    source=object_identity,
    target=role_df_expert,
    kind_of_relationship="Has_Role",
    directional=True,
)
bundle.append_to_uco_object(has_role_relation)

It raises the TypeError: The target of an ObservableRelationship must be an Observable.

Moreover I realised that the relation "Has_Role" is not included in the list.

ajnelson-nist commented 1 month ago

Roles are not natively ObservableObjects. If you instantiate a uco.core.Relationship instead of uco.observableObservableRelationship, you should be fine.

Has_Role is known to be omitted, but that vocabulary is only suggestive. You can use any string you wish.

fabrizio-turchi commented 1 month ago

Thanks Alex!