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

31 statements  

« prev     ^ index     » next       coverage.py v7.6.12, created at 2025-11-01 22:02 +0000

1#!/usr/bin/python 

2# -*- coding: utf-8 -*- 

3# Copyright (c) 2016, Silvio Peroni <essepuntato@gmail.com> 

4# Copyright (c) 2023, Arcangelo Massari <arcangelo.massari@unibo.it> 

5# 

6# Permission to use, copy, modify, and/or distribute this software for any purpose 

7# with or without fee is hereby granted, provided that the above copyright notice 

8# and this permission notice appear in all copies. 

9# 

10# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 

11# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 

12# FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, 

13# OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 

14# DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS 

15# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 

16# SOFTWARE. 

17from __future__ import annotations 

18 

19from typing import TYPE_CHECKING 

20 

21from rdflib import Namespace, URIRef 

22 

23if TYPE_CHECKING: 23 ↛ 24line 23 didn't jump to line 24 because the condition on line 23 was never true

24 from rdflib_ocdm.prov.provenance import OCDMProvenance 

25 

26from rdflib_ocdm.abstract_entity import AbstractEntity 

27 

28if TYPE_CHECKING: 28 ↛ 29line 28 didn't jump to line 29 because the condition on line 28 was never true

29 from typing import ClassVar, Dict 

30 

31 

32class ProvEntity(AbstractEntity): 

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

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

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

36 that created or modified the entity metadata. 

37 """ 

38 

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

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

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

42 

43 iri_entity: ClassVar[URIRef] = PROV.Entity 

44 iri_generated_at_time: ClassVar[URIRef] = PROV.generatedAtTime 

45 iri_invalidated_at_time: ClassVar[URIRef] = PROV.invalidatedAtTime 

46 iri_specialization_of: ClassVar[URIRef] = PROV.specializationOf 

47 iri_was_derived_from: ClassVar[URIRef] = PROV.wasDerivedFrom 

48 iri_had_primary_source: ClassVar[URIRef] = PROV.hadPrimarySource 

49 iri_was_attributed_to: ClassVar[URIRef] = PROV.wasAttributedTo 

50 iri_description: ClassVar[URIRef] = DCTERMS.description 

51 iri_has_update_query: ClassVar[URIRef] = OCO.hasUpdateQuery 

52 

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

54 'se': iri_entity 

55 } 

56 

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

58 super(ProvEntity, self).__init__() 

59 self.prov_subject = prov_subject 

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

61 self.g: OCDMProvenance = g 

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

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

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

65 g.all_entities.add(self.res)