Skip to content

Commit

Permalink
Merge pull request #41 from tetherless-world/org-update
Browse files Browse the repository at this point in the history
Changes to grab new organization
  • Loading branch information
Patrick West committed Feb 2, 2016
2 parents f18af0a + 5aa68aa commit 4801716
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 56 deletions.
18 changes: 8 additions & 10 deletions html/people.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,18 @@ <h5><small>
{{#if network_id}}<div><strong>network ID: </strong><small>{{network_id}}</small></div>{{/if}}

{{#if dcoCommunities}}
<div><strong>Communities:</strong> {{#expand dcoCommunities}}{{commrole}} - <a href="{{community.uri}}" target="_blank">{{community.name}}</a>{{/expand}}</div>
<div><strong>Communities:</strong></div>
<div>{{#list dcoCommunities}}{{commrole}} - <a href="{{community.uri}}" target="_blank">{{community.name}}</a>{{/list}}</div>
{{/if}}

{{#if teams}}
<div><strong>Teams:</strong> {{#expand teams}}{{teamrole}} - <a href="{{team.uri}}" target="_blank">{{team.name}}</a>{{/expand}}</div>
<div><strong>Teams:</strong></div>
<div>{{#list teams}}{{teamrole}} - <a href="{{team.uri}}" target="_blank">{{team.name}}</a>{{/list}}</div>
{{/if}}

{{#if organization}}
<div><strong>Organizations:</strong> {{#expand organization}}<a href="{{uri}}" target="_blank">{{name}}</a>{{/expand}}</div>
{{/if}}

{{#if affiliations}}
<div><strong>Affiliations:</strong></div>
<div>{{#list affiliations}}{{position}} - <a href="{{org.uri}}">{{org.name}}</a>{{/list}}</div>
{{#if organizations}}
<div><strong>Organizations:</strong></div>
<div>{{#list organizations}}{{orgrole}} - <a href="{{organization.uri}}" target="_blank">{{organization.name}}</a>{{/list}}</div>
{{/if}}

{{#if researchArea}}
Expand Down Expand Up @@ -139,7 +137,7 @@ <h5><small>
facets: [
{'field': 'dcoCommunities.community.name.exact', 'display': 'Community'},
{'field': 'teams.team.name.exact', 'display': 'Team'},
{'field': 'organization.name.exact', 'display': 'Organization'},
{'field': 'organizations.organization.name.exact', 'display': 'Organization'},
{'field': 'researchArea.name.exact', 'display': 'Research Area'},
{'field': 'homeCountry.name.exact', 'display': 'Country'},
{'field': 'isDcoMember', 'display': 'Show only DCO-members'}
Expand Down
49 changes: 19 additions & 30 deletions ingest/ingest-people.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,24 @@ def get_research_areas(person):


def get_organizations(person):
return Maybe.of(person).stream() \
.flatmap(lambda p: p.objects(DCO.inOrganization)) \
.filter(has_label) \
.map(lambda r: {"uri": str(r.identifier), "name": str(r.label())}).list()
orgs = []

orgroles = Maybe.of(person).stream() \
.flatmap(lambda per: per.objects(VIVO.relatedBy)) \
.filter(lambda related: has_type(related, VIVO.Position)).list()

for orgrole in orgroles:
org = Maybe.of(orgrole).stream() \
.flatmap(lambda r: r.objects(VIVO.relates)) \
.filter(lambda o: has_type(o, FOAF.Organization)) \
.filter(has_label) \
.map(lambda o: {"uri": str(o.identifier), "name": str(o.label())}) \
.one().value

if org:
orgs.append({"orgrole": str(orgrole.label()), "organization": org})

return orgs


def get_teams(person):
Expand Down Expand Up @@ -249,27 +263,6 @@ def get_home_country(person):
.map(lambda r: {"uri": str(r.identifier), "name": str(r.label())}).one().value


def get_affiliations(person):
affiliations = []

positions = Maybe.of(person).stream() \
.flatmap(lambda per: per.objects(VIVO.relatedBy)) \
.filter(lambda related: has_type(related, VIVO.Position)).list()

for position in positions:
organization = Maybe.of(position).stream() \
.flatmap(lambda r: r.objects(VIVO.relates)) \
.filter(lambda o: has_type(o, FOAF.Organization)) \
.filter(has_label) \
.map(lambda o: {"uri": str(o.identifier), "name": str(o.label())}) \
.one().value

if organization:
affiliations.append({"position": str(position.label()), "org": organization})

return affiliations


def get_thumbnail(person):
return Maybe.of(person).stream() \
.flatmap(lambda p: p.objects(VITRO_PUB.mainImage)) \
Expand Down Expand Up @@ -329,7 +322,7 @@ def create_person_doc(person, endpoint):

organizations = get_organizations(per)
if organizations:
doc.update({"organization": organizations})
doc.update({"organizations": organizations})

teams = get_teams(per)
if teams:
Expand All @@ -343,10 +336,6 @@ def create_person_doc(person, endpoint):
if thumbnail:
doc.update({"thumbnail": thumbnail})

affiliations = get_affiliations(per)
if affiliations:
doc.update({"affiliations": affiliations})

return doc


Expand Down
28 changes: 18 additions & 10 deletions ingest/mappings/person.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,24 +95,32 @@
}
}
},
"organization": {
"organizations": {
"properties": {
"name": {
"type": "multi_field",
"fields": {
"organization": {
"properties": {
"name": {
"type": "string",
"index": "analyzed"
"type": "multi_field",
"fields": {
"name": {
"type": "string",
"index": "analyzed"
},
"exact": {
"type": "string",
"index": "not_analyzed"
}
}
},
"exact": {
"uri": {
"type": "string",
"index": "not_analyzed"
"index": "no"
}
}
},
"uri": {
"orgrole": {
"type": "string",
"index": "no"
"index": "analyzed"
}
}
},
Expand Down
14 changes: 8 additions & 6 deletions ingest/queries/describePerson.rq
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ PREFIX bibo: <http://purl.org/ontology/bibo/>
PREFIX obo: <http://purl.obolibrary.org/obo/>
PREFIX vcard: <http://www.w3.org/2006/vcard/ns#>

DESCRIBE ?person ?dcoid ?mostSpecificType ?org ?commrole ?dco_community ?teamrole ?team ?main_image ?thumb_image ?thumbnail ?research_area ?vcard ?email ?name ?position ?affiliation ?homeCountry
DESCRIBE ?person ?dcoid ?mostSpecificType ?orgrole ?org ?commrole ?dco_community ?teamrole ?team ?main_image ?thumb_image ?thumbnail ?research_area ?vcard ?email ?name ?homeCountry
WHERE {
?person a foaf:Person .
?person vitro:mostSpecificType ?mostSpecificType .
Expand All @@ -22,11 +22,13 @@ WHERE {
OPTIONAL { ?vcard vcard:hasEmail ?email }
OPTIONAL { ?vcard vcard:hasName ?name }
}
OPTIONAL { ?person vivo:relatedBy ?position .
?position a vivo:Position .
?position vivo:relates ?affiliation .
?affiliation a foaf:Organization }
OPTIONAL { ?person dco:inOrganization ?org }
OPTIONAL { ?person vivo:relatedBy ?orgrole .
?orgrole a vivo:Position .
OPTIONAL { ?orgrole vivo:dateTimeInterval ?interval .
?interval vivo:end ?end . }
FILTER( ! BOUND(?end))
?orgrole vivo:relates ?org .
?org a foaf:Organization }
OPTIONAL { ?person obo:RO_0000053 ?commrole .
?commrole a vivo:MemberRole .
OPTIONAL { ?commrole vivo:dateTimeInterval ?interval .
Expand Down

0 comments on commit 4801716

Please sign in to comment.