def add_create_date(short_ids): add = Graph() logging.info("Adding create date for new faculty.") for short in short_ids: #Don't add a create data if this short id is invalid. if common.valid_short_id(short) is True: uri = make_uri(short) add.add((uri, BLOCAL.fisCreated, TODAY)) return add
def graph_faculty_data(fac_info): """ New FIS data for a single row in the feed. """ #Add graph ag = rdflib.Graph() shortId = fac_info.get('shortId') #Validate the shortId - skip invalid ids. valid = common.valid_short_id(shortId) if valid is not True: logging.warning("Invalid shortId {}.".format(shortId)) return uri = make_uri(shortId) ag.add((uri, RDF.type, VIVO.FacultyMember)) ag.add((uri, RDF.type, BLOCAL.BrownThing)) ag.add((uri, RDFS.label, Literal(fac_info['label']))) ag.add((uri, FOAF.firstName, Literal(fac_info['first']))) ag.add((uri, FOAF.lastName, Literal(fac_info['last']))) ag.add((uri, VIVO.preferredTitle, Literal(fac_info['title']))) ag.add((uri, BLOCAL.shortId, Literal(shortId))) #Required data properties - not requireing middle name or email now. optional_properties = ['middle', 'email', 'workdayID'] for k, v in fac_info.items(): if (v is None) and (k not in optional_properties): logging.error("Required data missing {} for {}.".format(k, shortId)) raise Exception("Required data missing in FIS file at fac_info {0}.".format(shortId)) #Add optional data properties. #Email is now optional if fac_info['email'] is None: logging.warning("Missing email for {}.".format(uri)) else: ag.add((uri, VIVO.primaryEmail, Literal(fac_info['email']))) #Middle name is optional. middle = fac_info.get('middle') if middle is not None: ag.add((uri, VIVO.middleName, Literal(middle))) #FIS sync date. ag.add((uri, BLOCAL.fisUpdated, TODAY)) #if new is True: # ag.add((uri, BLOCAL.fisCreated, TODAY)) return ag