use of edu.stanford.bmir.protege.web.shared.obo.OBOXRef in project webprotege by protegeproject.
the class XRefConverter method toOBOXRef.
/**
* Convert the specified value and description to an OBO XRef
* @param value The value.
* @param description The description
* @return The corresponding OBOXRef
*/
@Nonnull
public OBOXRef toOBOXRef(@Nonnull String value, @Nonnull String description) {
// Need to peel apart the ID
if (value.startsWith(Obo2OWLConstants.DEFAULT_IRI_PREFIX)) {
String localValue = value.substring(Obo2OWLConstants.DEFAULT_IRI_PREFIX.length());
Matcher matcher = SEPARATOR_PATTERN.matcher(localValue);
if (matcher.matches()) {
String dbname = unescapeSpaces(matcher.group(1));
String dbid = matcher.group(3);
return new OBOXRef(dbname, dbid, description);
} else {
return new OBOXRef("", value, description);
}
} else {
final int nameIdSeparatorIndex = value.indexOf(':');
if (nameIdSeparatorIndex != -1) {
return new OBOXRef(value.substring(0, nameIdSeparatorIndex), value.substring(nameIdSeparatorIndex + 1), description);
}
return new OBOXRef("", value, description);
}
}
use of edu.stanford.bmir.protege.web.shared.obo.OBOXRef in project webprotege by protegeproject.
the class XRefEditorImpl method getValue.
@Override
public Optional<OBOXRef> getValue() {
String databaseName = getDatabaseName();
if (databaseName.isEmpty()) {
return Optional.empty();
}
String databaseId = getDatabaseId();
if (databaseId.isEmpty()) {
return Optional.empty();
}
String description = getDescription();
return Optional.of(new OBOXRef(databaseName, databaseId, description));
}
use of edu.stanford.bmir.protege.web.shared.obo.OBOXRef in project webprotege by protegeproject.
the class TermDefinitionManager method setTermDefinition.
public void setTermDefinition(@Nonnull UserId userId, @Nonnull OWLEntity term, @Nonnull OBOTermDefinition definition) {
List<OBOXRef> xRefs = definition.getXRefs();
Set<OWLAnnotation> xrefAnnotations = xRefs.stream().filter(x -> !x.isEmpty()).map(xRefConverter::toAnnotation).collect(Collectors.toSet());
IRI subject = term.getIRI();
final IRI defIRI = getIRI(OBOFormatConstants.OboFormatTag.TAG_DEF);
OWLAnnotationProperty defAnnotationProperty = df.getOWLAnnotationProperty(defIRI);
OWLLiteral defLiteral = df.getOWLLiteral(definition.getDefinition());
OWLAnnotationAssertionAxiom definitionAssertion = df.getOWLAnnotationAssertionAxiom(defAnnotationProperty, subject, defLiteral, xrefAnnotations);
List<OWLOntologyChange> changes = new ArrayList<>();
for (OWLAnnotationAssertionAxiom existingAx : rootOntology.getAnnotationAssertionAxioms(subject)) {
if (existingAx.getProperty().getIRI().equals(defIRI)) {
changes.add(new RemoveAxiom(rootOntology, existingAx));
Set<OWLAnnotation> nonXRefAnnotations = getAxiomAnnotationsExcludingXRefs(existingAx);
OWLAxiom fullyAnnotatedDefinitionAssertion = definitionAssertion.getAnnotatedAxiom(nonXRefAnnotations);
changes.add(new AddAxiom(rootOntology, fullyAnnotatedDefinitionAssertion));
}
}
if (changes.isEmpty()) {
// New
changes.add(new AddAxiom(rootOntology, definitionAssertion));
}
changeManager.applyChanges(userId, new FixedChangeListGenerator<>(changes, term, "Edited the term definition for " + renderingManager.getRendering(term).getBrowserText()));
}
use of edu.stanford.bmir.protege.web.shared.obo.OBOXRef 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()));
}
Aggregations