use of edu.stanford.bmir.protege.web.shared.obo.OBOTermSynonym in project webprotege by protegeproject.
the class TermSynonymsManager method getSynonyms.
public Collection<OBOTermSynonym> getSynonyms(OWLEntity term) {
Set<OBOTermSynonym> result = new HashSet<>();
for (OWLOntology ontology : rootOntology.getImportsClosure()) {
Set<OWLAnnotationAssertionAxiom> annotationAssertionAxioms = ontology.getAnnotationAssertionAxioms(term.getIRI());
for (OWLAnnotationAssertionAxiom ax : annotationAssertionAxioms) {
OBOTermSynonymScope synonymScope = getSynonymScope(ax);
if (synonymScope != null) {
OBOTermSynonym termSynonym = new OBOTermSynonym(xRefExtractor.getXRefs(ax), getStringValue(ax), synonymScope);
result.add(termSynonym);
}
}
}
return result;
}
use of edu.stanford.bmir.protege.web.shared.obo.OBOTermSynonym in project webprotege by protegeproject.
the class OBOTermSynonymEditorImpl method getValue.
@Override
public Optional<OBOTermSynonym> getValue() {
final String synonymName = getSynonymName();
if (synonymName.isEmpty()) {
return Optional.empty();
}
final List<OBOXRef> xrefs = xrefListField.getValue().orElse(Collections.emptyList());
return Optional.of(new OBOTermSynonym(xrefs, synonymName, getSynonymScope()));
}
use of edu.stanford.bmir.protege.web.shared.obo.OBOTermSynonym in project webprotege by protegeproject.
the class TermSynonymsManager method setSynonyms.
public void setSynonyms(@Nonnull UserId userId, @Nonnull OWLEntity term, @Nonnull Collection<OBOTermSynonym> synonyms) {
List<OWLOntologyChange> changes = new ArrayList<>();
rootOntology.getAnnotationAssertionAxioms(term.getIRI()).stream().filter(ax -> getSynonymScope(ax) != null).map(ax -> new RemoveAxiom(rootOntology, ax)).forEach(changes::add);
for (OBOTermSynonym synonym : synonyms) {
OWLAnnotationProperty synonymProperty = getSynonymAnnoationProperty(df, synonym.getScope());
OWLLiteral synonymNameLiteral = df.getOWLLiteral(synonym.getName());
Set<OWLAnnotation> synonymXRefs = synonym.getXRefs().stream().filter(x -> !x.isEmpty()).map(xRefConverter::toAnnotation).collect(Collectors.toSet());
OWLAnnotationAssertionAxiom synonymAnnotationAssertion = df.getOWLAnnotationAssertionAxiom(synonymProperty, term.getIRI(), synonymNameLiteral, synonymXRefs);
changes.add(new AddAxiom(rootOntology, synonymAnnotationAssertion));
}
if (!changes.isEmpty()) {
changeManager.applyChanges(userId, new FixedChangeListGenerator<>(changes, term, "Edited term synonyms"));
}
}
Aggregations