Coverage for rdflib_ocdm / prov / prov_entity.py: 100%

27 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-03-21 12:35 +0000

1#!/usr/bin/python 

2 

3# SPDX-FileCopyrightText: 2016 Silvio Peroni <essepuntato@gmail.com> 

4# SPDX-FileCopyrightText: 2023-2025 Arcangelo Massari <arcangelo.massari@unibo.it> 

5# 

6# SPDX-License-Identifier: ISC 

7from __future__ import annotations 

8 

9from typing import TYPE_CHECKING 

10 

11from rdflib import Namespace, URIRef 

12 

13if TYPE_CHECKING: 

14 from rdflib_ocdm.prov.provenance import OCDMProvenance 

15 

16from rdflib_ocdm.abstract_entity import AbstractEntity 

17 

18if TYPE_CHECKING: 

19 from typing import ClassVar, Dict 

20 

21 

22class ProvEntity(AbstractEntity): 

23 """Snapshot of entity metadata: a particular snapshot recording the 

24 metadata associated with an individual entity at a particular date and time,  

25 including the agent, such as a person, organisation or automated process  

26 that created or modified the entity metadata. 

27 """ 

28 

29 DCTERMS: ClassVar[Namespace] = Namespace("http://purl.org/dc/terms/") 

30 OCO: ClassVar[Namespace] = Namespace("https://w3id.org/oc/ontology/") 

31 PROV: ClassVar[Namespace] = Namespace("http://www.w3.org/ns/prov#") 

32 

33 iri_entity: ClassVar[URIRef] = PROV.Entity 

34 iri_generated_at_time: ClassVar[URIRef] = PROV.generatedAtTime 

35 iri_invalidated_at_time: ClassVar[URIRef] = PROV.invalidatedAtTime 

36 iri_specialization_of: ClassVar[URIRef] = PROV.specializationOf 

37 iri_was_derived_from: ClassVar[URIRef] = PROV.wasDerivedFrom 

38 iri_had_primary_source: ClassVar[URIRef] = PROV.hadPrimarySource 

39 iri_was_attributed_to: ClassVar[URIRef] = PROV.wasAttributedTo 

40 iri_description: ClassVar[URIRef] = DCTERMS.description 

41 iri_has_update_query: ClassVar[URIRef] = OCO.hasUpdateQuery 

42 

43 short_name_to_type_iri: ClassVar[Dict[str, URIRef]] = { 

44 'se': iri_entity 

45 } 

46 

47 def __init__(self, prov_subject: str, g: OCDMProvenance, count: str) -> None: 

48 super(ProvEntity, self).__init__() 

49 self.prov_subject = prov_subject 

50 self.res = URIRef(prov_subject + '/prov/se/' + count) 

51 self.g: OCDMProvenance = g 

52 self._create_type(ProvEntity.iri_entity, prov_subject + '/prov/') 

53 if str(self.res) not in g.res_to_entity: 

54 g.res_to_entity[str(self.res)] = self 

55 g.all_entities.add(self.res)