/** * @return the root of the default object insert in the ontology without namespace. * @since 2.5.1 */ default public IRI getRootIri() { return IRI.create(getOntology().getOntologyID().getOntologyIRI().get().getNamespace()); }
private static byte[] bytesOfOntologyId(final OWLOntologyID ontologyID) { if (ontologyID.getVersionIRI().isPresent()) return (ontologyID.getOntologyIRI().get() + " " + ontologyID.getVersionIRI().get()).getBytes(); else return ontologyID.getOntologyIRI().get().toString().getBytes(); }
/** * Gets a builtin vocabulary value for a given IRI. * * @param iri The IRI * @return The builtin vocabulary having the specified IRI, or {@code null} if there is no * builtin vocabulary with the specified IRI */ @Nullable public static SWRLBuiltInsVocabulary getBuiltIn(IRI iri) { return Stream.of(values()).filter(v -> v.iri.equals(iri)).findAny().orElse(null); }
private static String getDefaultOntologyTagValue(IRI baseIRI) { URI baseURI = baseIRI.toURI(); String baseURIPath = baseURI.getPath(); if (baseURIPath == null) { return baseIRI.toString(); } int lastSlashIndex = baseURIPath.lastIndexOf("/"); if (lastSlashIndex == -1 || lastSlashIndex + 1 == baseURIPath.length()) { return baseURIPath; } return baseURIPath.substring(lastSlashIndex + 1); }
protected IRI getIRI(String s) { try { final Optional<IRI> defaultDocURI = ontology.getOntologyID().getDefaultDocumentIRI(); return IRI.create(new URI(defaultDocURI.get().getScheme(), defaultDocURI.get().toURI().getSchemeSpecificPart(), s)); } catch (Exception e) { LoggerFactory.getLogger(AbstractOWLObjectHierarchyCreator.class) .error("An error occurred whilst creating an IRI: {}", e); } return null; }
private static boolean willRedirectTotheWrongPlace(OntologyCatalogManager catalogManager, IRI importLocation, URI physicalLocation) { if (catalogManager.getRedirect(importLocation.toURI()) == null) { return !importLocation.equals(IRI.create(physicalLocation)); } else { return !physicalLocation.equals(catalogManager.getRedirect(importLocation.toURI())); } }
/** * @param iri the iri to check * @return true if the input iri matches the default document iri */ public boolean matchDocument(IRI iri) { return iri.equals(getDefaultDocumentIRI().orElse(null)); }
private void initializeImportedOntology(OWLOntology i) { //get name, get URI, add to the config Ontology ont = new Ontology(); ont.setNamespaceURI(i.getOntologyID().getOntologyIRI().get().toString()); ont.setName(i.getOntologyID().getOntologyIRI().get().getShortForm().replace("<", "<").replace(">", ">")); //added replacements so they will be shown in html mainOntologyMetadata.getImportedOntologies().add(ont); }
/** * @return originating ontology */ public OWLOntology getOriginatingOntology() { return ontologyManager.ontologies() .filter(o -> o.annotations().anyMatch(a -> a.getProperty().getIRI().equals(iri))) .findFirst().orElse(null); }
@Override protected void beginDocument() { pending.clear(); // Namespaces writeNamespaces(); write("@base "); write("<"); if (!ontology.isAnonymous()) { write(ontology.getOntologyID().getOntologyIRI().get().toString()); } else { write(Namespaces.OWL.toString()); } write("> .\n\n"); // Ontology URI }
/** * Constructs an ontology input source using the specified file. * * @param file The file from which a concrete representation of an ontology will be obtained. * @param format ontology format. Can be null. * @param mime mime type */ public FileDocumentSource(File file, @Nullable OWLDocumentFormat format, @Nullable String mime) { super(IRI.create(file), format, mime); this.file = checkNotNull(file, "file cannot be null"); }
private static Optional<IRI> opt(@Nullable IRI i) { if (i == null || NodeID.isAnonymousNodeIRI(i)) { return emptyOptional(); } if (!i.isAbsolute()) { LOGGER.error( "Ontology IRIs must be absolute; IRI {} is relative and will be made absolute by prefixing urn:absolute: to it", i); return optional(IRI.create("urn:absolute:" + i)); } return optional(i); }
private void setActiveSelected() { deprecationProfiles.forEach(profile -> { profile.getActivatedBy().ifPresent(activatedByIri -> { Optional<IRI> ontologyIRI = getOWLModelManager().getActiveOntology().getOntologyID().getOntologyIRI(); if(ontologyIRI.isPresent()) { if(ontologyIRI.get().equals(activatedByIri)) { profilesCombo.setSelectedItem(profile); setDescription(); } } }); }); setDescription(); }
public Set<OWLObjectProperty> getObjectPropertiesWithDomain(OWLClass domain) { Set<OWLObjectProperty> properties = new TreeSet<>(); String query = "SELECT ?p WHERE {?p <http://www.w3.org/2000/01/rdf-schema#domain> <" + domain.toStringID() + ">.}"; ResultSet rs = executeSelectQuery(query); QuerySolution qs; while(rs.hasNext()){ qs = rs.next(); properties.add(df.getOWLObjectProperty(IRI.create(qs.getResource("p").getURI()))); } return properties; }
@Override public Set<OWLIndividual> getRelatedIndividualsImpl(OWLIndividual individual, OWLObjectProperty objectProperty) { Set<OWLIndividual> individuals = new HashSet<>(); String query = String.format("SELECT ?ind WHERE {<%s> <%s> ?ind, FILTER(isIRI(?ind))}", individual.toStringID(), objectProperty.toStringID()); ResultSet rs = executeSelectQuery(query); while(rs.hasNext()){ QuerySolution qs = rs.next(); individuals.add(df.getOWLNamedIndividual(IRI.create(qs.getResource("ind").getURI()))); } return individuals; }
public void addImport(IOntology ontology) { if (!this.ontology.getImports().contains(((Ontology) ontology).ontology)) { OWLDataFactory factory = this.ontology.getOWLOntologyManager() .getOWLDataFactory(); OWLImportsDeclaration imp = factory.getOWLImportsDeclaration(IRI .create(((Ontology) ontology).ontology.getOntologyID() .getOntologyIRI().toString())); this.ontology.getOWLOntologyManager() .applyChange(new AddImport(this.ontology, imp)); this.imported.add(ontology.getConceptSpace()); } }