diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..423fdbb --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +data.n3 diff --git a/notizenrdf b/notizenrdf new file mode 100644 index 0000000..0da053b --- /dev/null +++ b/notizenrdf @@ -0,0 +1,50 @@ + rdf:type + rdf:type + rdf:type + rdf:type + rdf:type + rdf:type + "55903128900" + vivo:mostSpecificType + vivo:relatedBy + vivo:relatedBy + vivo:relatedBy + + + rdf:type + rdf:type + rdf:type + rdf:type + rdf:type + rdf:type + rdf:type + vivo:mostSpecificType + + + rdf:type + rdf:type + rdf:type + rdf:type + rdf:type + rdf:type + rdf:type + rdf:type + rdf:type + rdf:type + rdf:type + vivo:mostSpecificType + + +#Die Person + rdf:type + "Krömker, Volker "^^ + #hasContactInfo + +#Die VCard + rdf:type + + #contactInformationFor + +#(einer) der Titel + rdf:type + "Prof. Dr. med.-vet."^^ \ No newline at end of file diff --git a/triplify.py b/triplify.py index 716cc8c..9276256 100644 --- a/triplify.py +++ b/triplify.py @@ -306,7 +306,7 @@ def processPersons(session, additionalIdSeq): #use memberships to determine person type for i, membership in enumerate(sqlP.memberships): - if membership.active != 'Y': + if membership.active == False: continue #SKIP INACTIVE MEMBERSHIPS! processMembership(membership, additionalIdSeq) diff --git a/vivordftest.py b/vivordftest.py new file mode 100644 index 0000000..3c11017 --- /dev/null +++ b/vivordftest.py @@ -0,0 +1,96 @@ +import csv +from pprint import pprint +import urllib + +from rdflib import Namespace +from rdfalchemy import rdfSingle +from rdfalchemy.rdfSubject import rdfSubject + +from rdflib import Literal, BNode, Namespace, URIRef +from rdflib import RDF, RDFS, Graph, OWL +from rdflib.namespace import XSD + + +foaf = Namespace('http://xmlns.com/foaf/0.1/') +core = Namespace('http://vivoweb.org/ontology/core#') +vitro = Namespace('http://vitro.mannlib.cornell.edu/ns/vitro/0.7') +local = Namespace('http://localhost/core/ontology/core-local#') + +#Namespace for the vivo app +vivo_app_url = 'http://localhost/vivo/' +app = Namespace(vivo_app_url) + + +class Thing(rdfSubject): + rdf_type = OWL.Thing + label = rdfSingle(RDFS.label) + +class Person(Thing): + rdf_type = foaf.Person + +class FacultyMember(Person): + rdf_type = core.FacultyMember + firstname = rdfSingle(foaf.firstName) + middlename = rdfSingle(core.middleName) + lastname = rdfSingle(foaf.lastName) + work_email = rdfSingle(core.workEmail) + phone = rdfSingle(core.workPhone) + fax = rdfSingle(core.workFax) + research_overview = rdfSingle(core.researchOverview) + preferred_title = rdfSingle(core.preferredTitle) + moniker = rdfSingle(vitro.moniker) + people_id = rdfSingle(local.peopleID) + + + +def get_graph(): + """ + Helper for getting a graph and binding namespaces. + """ + g = rdfSubject.db + #Bind the namespaces + g.bind('foaf', foaf) + g.bind('core', core) + g.bind('vitro', vitro) + g.bind('local', local) + return g + +g = get_graph() + +#Open the sample VIVO people file. +csv_url = 'http://iweb.dl.sourceforge.net/project/vivo/Data%20Ingest/people.csv' +people_file = urllib.urlopen(csv_url) +for count, row in enumerate(csv.DictReader(people_file)): + #Create a URI for the person. + person_uri = URIRef("%sfaculty%s" % (app, count + 1)) + fac = FacultyMember(person_uri) + fac.label = row.get('name').strip() + fac.people_id = row.get('person_ID') + fac.moniker = row.get('title') + fac.firstname = row.get('first') + middle_name = row.get('middle') + if middle_name is not None and middle_name != "": + fac.middlename = row.get('middle') + fac.lastname = row.get('last') + fac.work_email = row.get('email') + fac.phone = row.get('phone') + fac.fax = row.get('fax') + +print g.serialize(format='n3') +g.close() +""" +#Load the n3 file as a rdfSubject db. +people_n3 = 'http://iweb.dl.sourceforge.net/project/vivo/Data%20Ingest/people.n3' +rdfSubject.db.load(people_n3, format='n3') +#Get all of the assistant professors in the graph. +asst_professors = FacultyMember.filter_by(moniker="Assistant Professor") +print '\n' + '=' * 20 +print "Assistant Professors" +print '=' * 20 + '\n' +for fac in asst_professors: + #Print full name, email, and url to vivo profile. + print "%s\t%s\t%s" % (fac.label, fac.work_email, fac.resUri.toPython()) + +#Use get_by to retrieve a single faculty member +faculty = FacultyMember.get_by(hr_id='3958') +print faculty.label""" \ No newline at end of file