def triples_contributors(self, contributor, contributor_order_index, creator=False): try: dsid = self.dsid # FIXME json reload needs to deal with this except BaseException as e: # FIXME ... loge.exception(e) return cid = contributor['id'] if isinstance(cid, idlib.Stream) and hasattr( cid, 'asUri'): # FIXME nasty branch s = cid.asUri(rdflib.URIRef) elif isinstance(cid, BlackfynnId): s = rdflib.URIRef(cid.uri_api) elif isinstance(cid, dict): if isinstance(cid['id'], idlib.Stream): # FIXME nasty branch s = cid['id'].asUri(rdflib.URIRef) else: raise NotImplementedError(f'{type(cid["id"])}: {cid["id"]}') else: s = rdflib.URIRef(cid) # FIXME json reload needs to deal with this if 'data_remote_user_id' in contributor: userid = rdflib.URIRef( contributor['data_remote_user_id'].uri_api) # FIXME yield s, TEMP.hasDataRemoteUserId, userid if 'blackfynn_user_id' in contributor: userid = rdflib.URIRef( contributor['blackfynn_user_id'].uri_api) # FIXME yield s, TEMP.hasBlackfynnUserId, userid yield s, rdf.type, owl.NamedIndividual yield s, rdf.type, sparc.Person yield s, TEMP.contributorTo, dsid # TODO other way around too? hasContributor converter = conv.ContributorConverter(contributor) yield from converter.triples_gen(s) if creator: yield s, TEMP.creatorOf, dsid # dataset <-> contributor object dcs = rdflib.BNode() yield dcs, rdf.type, owl.NamedIndividual yield dcs, rdf.type, sparc.DatasetContribution yield dcs, TEMP.aboutDataset, dsid # FIXME forDataset? yield dcs, TEMP.aboutContributor, s yield dcs, TEMP.contributorOrderIndex, rdflib.Literal( contributor_order_index) dconverter = conv.DatasetContributorConverter(contributor) for _s, p, o in dconverter.triples_gen(dcs): if p == sparc.isContactPerson and o._value == True: yield dsid, TEMP.hasContactPerson, s yield _s, p, o
def triples_contributors(self, contributor, creator=False): try: dsid = self.dsid # FIXME json reload needs to deal with this except BaseException as e: # FIXME ... log.error(e) return s = rdflib.URIRef(contributor['id']) # FIXME json reload needs to deal with this if 'blackfynn_user_id' in contributor: userid = rdflib.URIRef(contributor['blackfynn_user_id']) yield s, TEMP.hasBlackfynnUserId, userid yield s, a, owl.NamedIndividual yield s, a, sparc.Researcher yield s, TEMP.contributorTo, dsid converter = conv.ContributorConverter(contributor) yield from converter.triples_gen(s) if creator: yield s, TEMP.creatorOf, dsid
def triples_contributors(self, contributor, creator=False): try: dsid = self.dsid # FIXME json reload needs to deal with this except BaseException as e: # FIXME ... loge.exception(e) return cid = contributor['id'] if isinstance(cid, idlib.Stream): # FIXME nasty branch s = cid.asType(rdflib.URIRef) else: s = rdflib.URIRef(cid) # FIXME json reload needs to deal with this if 'blackfynn_user_id' in contributor: userid = rdflib.URIRef(contributor['blackfynn_user_id']) yield s, TEMP.hasBlackfynnUserId, userid yield s, rdf.type, owl.NamedIndividual yield s, rdf.type, sparc.Researcher yield s, TEMP.contributorTo, dsid # TODO other way around too? hasContributor converter = conv.ContributorConverter(contributor) yield from converter.triples_gen(s) if creator: yield s, TEMP.creatorOf, dsid # dataset <-> contributor object dcs = rdflib.BNode() yield dcs, rdf.type, owl.NamedIndividual yield dcs, rdf.type, TEMP.DatasetContributor yield dcs, TEMP.aboutDataset, dsid # FIXME forDataset? yield dcs, TEMP.aboutContributor, s dconverter = conv.DatasetContributorConverter(contributor) for _s, p, o in dconverter.triples_gen(dcs): if p == sparc.isContactPerson and o._value == True: yield dsid, TEMP.hasContactPerson, s yield _s, p, o