def specific_resource_subgraph(graph, specific_resource): specific_resource_graph = Graph() specific_resource_graph += graph.triples((specific_resource, None, None)) specific_resource_graph += resource_annotation_subgraph(graph, specific_resource) for selector in graph.objects(specific_resource, NS.oa.hasSelector): specific_resource_graph += graph.triples((selector, None, None)) return specific_resource_graph
def get(self, request, project_uri, canvas_uri, transcription_uri): project_uri = URIRef(project_uri) canvas_uri = URIRef(canvas_uri) if transcription_uri: transcription_uri = URIRef(transcription_uri) project_graph = get_project_graph(project_uri) return NegotiatedGraphResponse(request, resource_annotation_subgraph(project_graph, transcription_uri))
def specific_resource_subgraph(graph, specific_resource): specific_resource_graph = Graph() specific_resource_graph += graph.triples((specific_resource, None, None)) specific_resource_graph += resource_annotation_subgraph( graph, specific_resource) for selector in graph.objects(specific_resource, NS.oa.hasSelector): specific_resource_graph += graph.triples((selector, None, None)) return specific_resource_graph
def get(self, request, project_uri, canvas_uri, transcription_uri): project_uri = URIRef(project_uri) canvas_uri = URIRef(canvas_uri) if transcription_uri: transcription_uri = URIRef(transcription_uri) project_graph = get_project_graph(project_uri) return NegotiatedGraphResponse( request, resource_annotation_subgraph(project_graph, transcription_uri))
def canvas_subgraph(graph, canvas_uri, project_uri): canvas_uri = URIRef(canvas_uri) canvas_graph = Graph() canvas_graph += canvas_and_images_graph(graph, canvas_uri) canvas_graph += resource_annotation_subgraph(graph, canvas_uri) canvas_graph += anno_lists_subgraph(graph, canvas_uri, project_uri) canvas_graph += specific_resources_subgraph(graph, canvas_uri, project_uri) return canvas_graph
def read_project_text(project_uri, text_uri): # Correctly format project uri and get project graph project_identifier = uris.uri('semantic_store_projects', uri=project_uri) project_g = Graph(rdfstore(), identifier=project_identifier) # Make text uri URIRef (so Graph will understand) text_uri = URIRef(text_uri) # Create an empty graph and bind namespaces text_g = Graph() bind_namespaces(text_g) text_g += resource_annotation_subgraph(project_g, text_uri) text_g += specific_resources_subgraph(project_g, text_uri, project_uri) overwrite_text_graph_from_model(text_uri, project_uri, text_g) # Return graph about text return text_g
def read_project_text(project_uri, text_uri): # Correctly format project uri and get project graph project_identifier = uris.uri('semantic_store_projects', uri=project_uri) project_g = Graph(rdfstore(), identifier=project_identifier) # Make text uri URIRef (so Graph will understand) text_uri = URIRef(text_uri) # Create an empty graph and bind namespaces text_g = Graph() bind_namespaces(text_g) text_g += resource_annotation_subgraph(project_g, text_uri) text_g += specific_resources_subgraph(project_g, text_uri, project_uri) overwrite_text_graph_from_model(text_uri, project_uri, text_g) # Return graph about text return text_g
def read_specific_resource(project_uri, specific_resource, source): specific_resource = URIRef(specific_resource) project_identifier = uris.uri('semantic_store_projects', uri=project_uri) db_project_graph = Graph(store=rdfstore(), identifier=project_identifier) project_graph = db_project_graph return_graph = Graph() return_graph += project_graph.triples((specific_resource, None, None)) selectors = project_graph.objects(specific_resource, NS.oa.hasSelector) for selector in selectors: return_graph += project_graph.triples((selector, None, None)) if (URIRef(source), NS.rdf.type, NS.sc.Canvas) in project_graph: return_graph.add( (specific_resource, NS.ore.isDescribedBy, URIRef( uris.url("semantic_store_canvas_specific_resource", project_uri=project_uri, canvas_uri=source, specific_resource=specific_resource)))) elif (URIRef(source), NS.rdf.type, NS.dcmitype.Text) in project_graph: return_graph.add((specific_resource, NS.ore.isDescribedBy, URIRef( uris.url("semantic_store_text_specific_resource", project_uri=project_uri, text_uri=source, specific_resource=specific_resource)))) return_graph += resource_annotation_subgraph(project_graph, specific_resource) return return_graph
def read_specific_resource(project_uri, specific_resource, source): specific_resource = URIRef(specific_resource) project_identifier = uris.uri('semantic_store_projects', uri=project_uri) db_project_graph = Graph(store=rdfstore(), identifier=project_identifier) project_graph = db_project_graph return_graph = Graph() return_graph += project_graph.triples((specific_resource, None, None)) selectors = project_graph.objects(specific_resource, NS.oa.hasSelector) for selector in selectors: return_graph += project_graph.triples((selector, None, None)) if (URIRef(source), NS.rdf.type, NS.sc.Canvas) in project_graph: return_graph.add((specific_resource, NS.ore.isDescribedBy, URIRef(uris.url("semantic_store_canvas_specific_resource", project_uri=project_uri, canvas_uri=source, specific_resource=specific_resource)))) elif (URIRef(source), NS.rdf.type, NS.dcmitype.Text) in project_graph: return_graph.add((specific_resource, NS.ore.isDescribedBy, URIRef(uris.url("semantic_store_text_specific_resource", project_uri=project_uri, text_uri=source, specific_resource=specific_resource)))) return_graph += resource_annotation_subgraph(project_graph, specific_resource) return return_graph