Skip to content

Commit d7a32b8

Browse files
committed
feat: use new method
1 parent c367d4a commit d7a32b8

File tree

1 file changed

+27
-24
lines changed

1 file changed

+27
-24
lines changed

src/core/modules/opendata/triggers.py

+27-24
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
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+
122
from src import services
223
from lib.abi.services.ontology_store.OntologyStorePorts import OntologyEvent
324
from rdflib import URIRef, Literal
@@ -38,7 +59,7 @@ def register_organization_logo_update_trigger():
3859
))
3960

4061
# 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)
4263

4364
# Register organization size trigger
4465
def register_organization_size_trigger():
@@ -53,27 +74,9 @@ def register_organization_size_trigger():
5374
))
5475

5576
# 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)
7878

79-
triggers = []
79+
triggers = [
80+
register_organization_logo_update_trigger(),
81+
register_organization_size_trigger(),
82+
]

0 commit comments

Comments
 (0)