1
+ # This file defines triggers for the opendata module
2
+ # Triggers allow the module to react automatically to changes in the ontology store
3
+ # Each trigger consists of:
4
+ # 1. A triple pattern (subject, predicate, object) where None acts as a wildcard
5
+ # 2. An event type (OntologyEvent.INSERT or OntologyEvent.DELETE)
6
+ # 3. A callback function to execute when the event occurs
7
+ #
8
+ # Example:
9
+ # from abi.services.ontology_store.OntologyStorePorts import OntologyEvent
10
+ # from rdflib import URIRef, Namespace
11
+ #
12
+ # ex = Namespace("http://example.org/")
13
+ #
14
+ # def handle_new_dataset(event_type, ontology_name, triple):
15
+ # subject, predicate, obj = triple
16
+ # # Process the new dataset here
17
+ #
18
+ # triggers = [
19
+ # ((None, URIRef(ex + "hasOpenData"), None), OntologyEvent.INSERT, handle_new_dataset),
20
+ # ]
21
+
1
22
from src import services
2
23
from lib .abi .services .ontology_store .OntologyStorePorts import OntologyEvent
3
24
from rdflib import URIRef , Literal
@@ -38,7 +59,7 @@ def register_organization_logo_update_trigger():
38
59
))
39
60
40
61
# Subscribe to the trigger
41
- services . ontology_store_service . subscribe ((None , None , URIRef ("https://www.commoncoreontologies.org/ont00000443" )), OntologyEvent .INSERT , pipeline .trigger )
62
+ return ((None , None , URIRef ("https://www.commoncoreontologies.org/ont00000443" )), OntologyEvent .INSERT , pipeline .trigger )
42
63
43
64
# Register organization size trigger
44
65
def register_organization_size_trigger ():
@@ -53,27 +74,9 @@ def register_organization_size_trigger():
53
74
))
54
75
55
76
# Subscribe to the trigger
56
- services .ontology_store_service .subscribe ((None , URIRef ("http://ontology.naas.ai/abi/number_of_employees" ), None ), OntologyEvent .INSERT , pipeline .trigger )
57
-
58
- # This file defines triggers for the opendata module
59
- # Triggers allow the module to react automatically to changes in the ontology store
60
- # Each trigger consists of:
61
- # 1. A triple pattern (subject, predicate, object) where None acts as a wildcard
62
- # 2. An event type (OntologyEvent.INSERT or OntologyEvent.DELETE)
63
- # 3. A callback function to execute when the event occurs
64
- #
65
- # Example:
66
- # from abi.services.ontology_store.OntologyStorePorts import OntologyEvent
67
- # from rdflib import URIRef, Namespace
68
- #
69
- # ex = Namespace("http://example.org/")
70
- #
71
- # def handle_new_dataset(event_type, ontology_name, triple):
72
- # subject, predicate, obj = triple
73
- # # Process the new dataset here
74
- #
75
- # triggers = [
76
- # ((None, URIRef(ex + "hasOpenData"), None), OntologyEvent.INSERT, handle_new_dataset),
77
- # ]
77
+ return ((None , URIRef ("http://ontology.naas.ai/abi/number_of_employees" ), None ), OntologyEvent .INSERT , pipeline .trigger )
78
78
79
- triggers = []
79
+ triggers = [
80
+ register_organization_logo_update_trigger (),
81
+ register_organization_size_trigger (),
82
+ ]
0 commit comments