|
8 | 8 | render_template, request, url_for) |
9 | 9 | from flask_babel import gettext |
10 | 10 | from flask_login import current_user, login_required |
11 | | -from rdflib import RDF, XSD, ConjunctiveGraph, Graph, Literal, URIRef |
| 11 | +from rdflib import RDF, XSD, Dataset, Graph, Literal, URIRef |
12 | 12 | from SPARQLWrapper import JSON |
13 | 13 | from time_agnostic_library.agnostic_entity import AgnosticEntity |
14 | 14 |
|
@@ -186,13 +186,19 @@ def about(subject): |
186 | 186 | abort(404) |
187 | 187 |
|
188 | 188 | if data_graph: |
189 | | - triples = list(data_graph.triples((None, None, None))) |
190 | | - subject_classes = [o for s, p, o in data_graph.triples((URIRef(subject), RDF.type, None))] |
| 189 | + # For Dataset (quadstore), we need to use quads() instead of triples() |
| 190 | + if isinstance(data_graph, Dataset): |
| 191 | + # Convert quads to triples by extracting only s, p, o |
| 192 | + triples = [(s, p, o) for s, p, o, g in data_graph.quads((None, None, None))] |
| 193 | + subject_classes = [o for s, p, o, g in data_graph.quads((URIRef(subject), RDF.type, None))] |
| 194 | + subject_triples = [(s, p, o) for s, p, o, g in data_graph.quads((URIRef(subject), None, None))] |
| 195 | + else: |
| 196 | + triples = list(data_graph.triples((None, None, None))) |
| 197 | + subject_classes = [o for s, p, o in data_graph.triples((URIRef(subject), RDF.type, None))] |
| 198 | + subject_triples = list(data_graph.triples((URIRef(subject), None, None))) |
191 | 199 |
|
192 | 200 | highest_priority_class = get_highest_priority_class(subject_classes) |
193 | | - entity_shape = determine_shape_for_entity_triples( |
194 | | - list(data_graph.triples((URIRef(subject), None, None))) |
195 | | - ) |
| 201 | + entity_shape = determine_shape_for_entity_triples(subject_triples) |
196 | 202 |
|
197 | 203 | ( |
198 | 204 | can_be_added, |
@@ -432,7 +438,7 @@ def create_nested_entity( |
432 | 438 | editor: Editor, entity_uri, entity_data, graph_uri=None |
433 | 439 | ): |
434 | 440 | form_fields = get_form_fields() |
435 | | - |
| 441 | + |
436 | 442 | editor.create( |
437 | 443 | entity_uri, |
438 | 444 | URIRef("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), |
@@ -1388,7 +1394,7 @@ def restore_version(entity_uri, timestamp): |
1388 | 1394 |
|
1389 | 1395 |
|
1390 | 1396 | def compute_graph_differences( |
1391 | | - current_graph: Graph | ConjunctiveGraph, historical_graph: Graph | ConjunctiveGraph |
| 1397 | + current_graph: Graph | Dataset, historical_graph: Graph | Dataset |
1392 | 1398 | ): |
1393 | 1399 | if get_dataset_is_quadstore(): |
1394 | 1400 | current_data = set(current_graph.quads()) |
|
0 commit comments