Coverage for heritrace / uri_generator / uri_generator.py: 100%
1 statements
« prev ^ index » next coverage.py v7.13.4, created at 2026-03-21 12:56 +0000
« prev ^ index » next coverage.py v7.13.4, created at 2026-03-21 12:56 +0000
1# SPDX-FileCopyrightText: 2024-2025 Arcangelo Massari <arcangelo.massari@unibo.it>
2#
3# SPDX-License-Identifier: ISC
5from abc import ABC, abstractmethod
8class URIGenerator(ABC): # pragma: no cover
9 """
10 Abstract base class for URI generators.
11 """
13 @abstractmethod
14 def generate_uri(self, entity_type: str | None = None, context_data: dict = None) -> str:
15 """
16 Generate a new URI for an entity of the given type.
18 :param entity_type: The type of entity to generate a URI for
19 :type entity_type: str
20 :param context_data: Additional context data for special URI generation.
21 Expected structure:
22 {
23 "entity_type": "http://purl.org/spar/cito/Citation",
24 "properties": {
25 "http://purl.org/spar/cito/hasCitingEntity": [
26 {
27 "is_existing_entity": True,
28 "entity_uri": "https://w3id.org/oc/meta/br/061503302037"
29 }
30 ],
31 "http://purl.org/spar/cito/hasCitedEntity": [
32 {
33 "is_existing_entity": True,
34 "entity_uri": "https://w3id.org/oc/meta/br/061503302004"
35 }
36 ]
37 }
38 }
39 :type context_data: dict
40 :return: The generated URI
41 :rtype: str
42 """
43 pass
45 @abstractmethod
46 def initialize_counters(self, sparql) -> None:
47 """
48 Initialize counters for entity types supported by this URI generator.
50 :param sparql: SPARQLWrapper instance to execute queries on the dataset
51 :return: None
52 """
53 pass