Skip to content

Commit

Permalink
OntTerm.asPreferred added, InterLexRemote always return isAbout iri
Browse files Browse the repository at this point in the history
also set _query_result during OntTerm init so that it is always
present regardless of how the term was constructed
  • Loading branch information
tgbugs committed Sep 12, 2019
1 parent 3bd810d commit 7cb93ce
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 3 additions & 0 deletions ontquery/plugins/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,9 @@ def isAbout(g):
qrd['curie'] = i.curie
qrd['iri'] = i.iri
toskip += 'curie', 'iri'
else:
qrd['predicates']['TEMP:preferredId'] = i # FIXME this should probably be in the record itself ...

if curie:
qrd['curie'] = curie
toskip += 'curie',
Expand Down
13 changes: 12 additions & 1 deletion ontquery/terms.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,6 @@ def _make_iri(cls, prefix, suffix):
def quoted(self):
return quote(self.iri, safe=tuple())

@property
def asTerm(self):
inst_class = self._instrumented_class()
return inst_class(self)
Expand Down Expand Up @@ -600,6 +599,7 @@ def __real_init__(self, validated, results_gen, noId):

setattr(self, keyword, value) # TODO value lists...
self.validated = True
self._query_result = result

if i is None:
self._source = None
Expand Down Expand Up @@ -649,6 +649,17 @@ def debug(self):
if self._graph:
print(self._graph.serialize(format='nifttl').decode())

def asPreferred(self):
""" Return the term attached to its preferred id """
if 'TEMP:preferredId' in self.predicates:
return self.predicates['TEMP:preferredId'].asTerm()
elif self.deprecated:
rb = self('replacedBy:', as_term=True)
if rb:
return rb[0]
else:
return self

def asId(self):
uninst_class = self._uninstrumented_class()
return uninst_class(self)
Expand Down

0 comments on commit 7cb93ce

Please sign in to comment.