/** * Expands a string representation of an IRI into an IRI. OBO Library Identifiers are handled as are built in * OWL IRIs. This means that IAO:0000115 is expanded to http://purl.obolibrary.org/obo/IAO_0000115 for example, * and rdfs:label is expanded into its full IRI for example. * @param iri The string representation of the IRI. * @return The expanded IRI. If the string representation is null then the empty value is returned. */ public static Optional<IRI> expand(@Nullable String iri) { if(iri == null) { return Optional.empty(); } if(OboUtilities.isOboId(iri)) { return Optional.of(OboUtilities.getOboLibraryIriFromOboId(iri)); } IRI builtInIri = builtInVocabulary.get(iri); if(builtInIri != null) { return Optional.of(builtInIri); } else { return Optional.of(IRI.create(iri)); } } }
public OWLEntityCreationSet<T> getOWLEntityCreationSet(EntityCreationMode preview) throws RuntimeException { try { if (isEntityIRI()) { IRI iri = getRawIRI(); return getCreationSetForIri(iri); } else if(isOboId()) { IRI iri = OboUtilities.getOboLibraryIriFromOboId(getEntityName()); if(owlEditorKit.getOWLModelManager().getActiveOntology().containsEntityInSignature(iri, Imports.INCLUDED)) { throw new OWLEntityCreationException("Entity already exists: " + iri); } return getCreationSetForIri(iri); } else { switch (preview) { case CREATE: return owlEditorKit.getModelManager().getOWLEntityFactory().createOWLEntity(type, getEntityName(), getBaseIRI()); case PREVIEW: return owlEditorKit.getModelManager().getOWLEntityFactory().preview(type, getEntityName(), getBaseIRI()); default: throw new IllegalStateException("Programmer error - report this (with stack trace) to the Protege 4 mailing list"); } } } catch (OWLEntityCreationException e) { throw new RuntimeException(e); } }