def agent_relationship_type_lod(request, agent_assoc_type_name):
#import pdb; pdb.set_trace()
aats = AgentAssociationType.objects.all()
agent_assoc_type = None
for aat in aats:
if camelcase_lower(aat.label) == agent_assoc_type_name:
agent_assoc_type = aat
inverse = False
elif camelcase_lower(aat.inverse_label) == agent_assoc_type_name:
agent_assoc_type = aat
inverse = True
if not agent_assoc_type:
return HttpResponse({}, content_type='application/json')
from rdflib import Graph, Literal, BNode
from rdflib.namespace import FOAF, RDF, RDFS, OWL, SKOS
from rdflib.serializer import Serializer
from rdflib import Namespace, URIRef
path, instance_abbrv, context, store, vf_ns = get_lod_setup_items()
if inverse:
property_name = camelcase_lower(agent_assoc_type.inverse_label)
inverse_property_name = camelcase_lower(agent_assoc_type.label)
label = agent_assoc_type.inverse_label
else:
property_name = camelcase_lower(agent_assoc_type.label)
inverse_property_name = camelcase_lower(agent_assoc_type.inverse_label)
label = agent_assoc_type.label
ref = URIRef(instance_abbrv + ":agent-relationship-type-lod/" + property_name)
inv_ref = URIRef(instance_abbrv + ":agent-relationship-type-lod/" + inverse_property_name)
store.add((ref, RDF.type, RDF.Property))
store.add((ref, SKOS.prefLabel, Literal(label, lang="en")))
store.add((ref, OWL.inverseOf, inv_ref))
ser = store.serialize(format='json-ld', context=context, indent=4)
return HttpResponse(ser, content_type='application/json')
#return render_to_response("valueaccounting/agent_assoc_type.html", {
# "agent_assoc_type": agent_assoc_type,
#}, context_instance=RequestContext(request))
评论列表
文章目录