Skip to content

Commit

Permalink
fixing Data Dictionary issue
Browse files Browse the repository at this point in the history
  • Loading branch information
danydvd committed Mar 14, 2018
1 parent 3afb650 commit ba77e8f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2,166 deletions.
22 changes: 13 additions & 9 deletions data_dictionary/scripts/lib/modifyDD.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,26 @@
sparqlData.setReturnFormat(JSON)
with open ('modifyDD.txt' , 'w+') as out:
for subgraph in ['community', 'collection', 'generic', 'thesis', 'oai_pmh', 'oai_etdms', 'instances']:
out.write("PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> prefix ual: <http://terms.library.ualberta.ca/> prefix ualid: <http://terms.library.ualberta.ca/id>" + "\n")
#out.write("PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> prefix ual: <http://terms.library.ualberta.ca/> prefix ualid: <http://terms.library.ualberta.ca/id>" + "\n")
sparqlData.setQuery("prefix ual: <http://terms.library.ualberta.ca/> select * where {graph ual:%s {?s ?p ?o} }" %(subgraph))
r = sparqlData.query().convert()['results']['bindings']
for triple in r:
subject = triple['s']['value'].lower()
predicate = triple['p']['value']
objectt = triple['o']['value']
sparql = "http://206.167.181.124:7200/repositories/testdd"
print (objectt)
sparql = "http://206.167.181.124:7200/repositories/test/statements"
sparql = SPARQLWrapper(sparql)
#sparql.setMethod('POST')
sparql.setMethod('POST')
if triple['o']['type'] == "uri":
query = "INSERT DATA {GRAPH ual:%s {<%s> <%s> <%s>} } " % (subgraph, subject, predicate, objectt)
print ("uri")
query = "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> prefix ual: <http://terms.library.ualberta.ca/> prefix ualid: <http://terms.library.ualberta.ca/id> INSERT DATA {GRAPH ual:%s {<%s> <%s> <%s>} } " % (subgraph, subject, predicate, objectt)
if triple['o']['type'] == "literal":
#print (subject, " is a literal")
query = 'INSERT DATA {GRAPH ual:%s {<%s> <%s> "%s"} } ; ' % (subgraph, subject, predicate, objectt)
out.write(query + "\n")
query = "INSERT DATA {GRAPH ual:%s {<%s> <http://terms.library.ualberta.ca/dataDictionaryLabel> <%s>} } ; " % (subgraph, subject, triple['s']['value'])
out.write(query + "\n")
print (subject, " is a literal")
query = 'PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> prefix ual: <http://terms.library.ualberta.ca/> prefix ualid: <http://terms.library.ualberta.ca/id> INSERT DATA {GRAPH ual:%s {<%s> <%s> "%s"} } ; ' % (subgraph, subject, predicate, objectt)
#out.write(query + "\n")
sparql.setQuery(query)
sparql.query()
#query = "INSERT DATA {GRAPH ual:%s {<%s> <http://terms.library.ualberta.ca/dataDictionaryLabel> <%s>} } ; " % (subgraph, subject, triple['s']['value'])
#out.write(query + "\n")

Loading

0 comments on commit ba77e8f

Please sign in to comment.